Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Morb0 committed Jan 23, 2022
2 parents cda6bb2 + 49c8ce0 commit d9bc64e
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 64 deletions.
59 changes: 40 additions & 19 deletions Content.Server/Fluids/Components/BucketComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
Expand Down Expand Up @@ -70,11 +71,7 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
return false;
}

if (mopComponent.CurrentVolume == mopComponent.MaxVolume)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("bucket-component-mop-is-full-message"));
return false;
}


_currentlyUsing.Add(eventArgs.Using);

Expand All @@ -92,25 +89,49 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
CurrentVolume <= 0 || !Owner.InRangeUnobstructed(mopComponent.Owner))
return false;

// Top up mops solution given it needs it to annihilate puddles I guess

var transferAmount = FixedPoint2.Min(mopComponent.MaxVolume - mopComponent.CurrentVolume, CurrentVolume);
if (transferAmount == 0)
//Checks if the mop is empty
if(mopComponent.CurrentVolume == 0)
{
return false;
}
// Transfers up to half the mop's available capacity to the mop
// Takes the lower of the mop's available volume and the bucket's current volume.
var transferAmount = FixedPoint2.Min(0.5*mopComponent.AvailableVolume, CurrentVolume);
if (transferAmount == 0)
{
return false;
}

var mopContents = mopComponent.MopSolution;
var mopContents = mopComponent.MopSolution;

if (mopContents == null)
{
return false;
}
if (mopContents == null)
{
return false;
}

// Transfer solution from the bucket to the mop
// Owner is the bucket being interacted with. contents is the Solution contained by said bucket.
var solution = solutionsSys.SplitSolution(Owner, contents, transferAmount);
if (!solutionsSys.TryAddSolution(mopComponent.Owner, mopComponent.MopSolution, solution))
{
return false; //if the attempt fails
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("bucket-component-mop-is-now-wet-message"));

var solution = solutionsSys.SplitSolution(Owner, contents, transferAmount);
if (!solutionsSys.TryAddSolution(mopComponent.Owner, mopContents, solution))
}
else //if mop is not empty
{
return false;
//Transfer the mop solution to the bucket

if (mopComponent.MopSolution == null)
return false;

var solutionFromMop = solutionsSys.SplitSolution(mopComponent.Owner, mopComponent.MopSolution, mopComponent.CurrentVolume);
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution);
if (!solutionsSys.TryAddSolution(Owner, solution, solutionFromMop))
{
return false; //if the attempt fails
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("bucket-component-mop-is-now-dry-message"));

}

SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner);
Expand Down
50 changes: 25 additions & 25 deletions Content.Server/Fluids/Components/MopComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MopComponent : Component, IAfterInteract
/// </summary>
public bool Mopping { get; private set; }

// MopSolution Object stores whatever solution the mop has absorbed.
public Solution? MopSolution
{
get
Expand All @@ -43,6 +44,7 @@ public Solution? MopSolution
}
}

// MaxVolume is the Maximum volume the mop can absorb (however, this is defined in janitor.yml)
public FixedPoint2 MaxVolume
{
get => MopSolution?.MaxVolume ?? FixedPoint2.Zero;
Expand All @@ -56,8 +58,12 @@ public FixedPoint2 MaxVolume
}
}

// CurrentVolume is the volume the mop has absorbed.
public FixedPoint2 CurrentVolume => MopSolution?.CurrentVolume ?? FixedPoint2.Zero;

// AvailableVolume is the remaining volume capacity of the mop.
public FixedPoint2 AvailableVolume => MopSolution?.AvailableVolume ?? FixedPoint2.Zero;

// Currently there's a separate amount for pickup and dropoff so
// Picking up a puddle requires multiple clicks
// Dumping in a bucket requires 1 click
Expand Down Expand Up @@ -99,11 +105,6 @@ async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
return false;
}

if (CurrentVolume <= 0)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("mop-component-mop-is-dry-message"));
return false;
}

if (eventArgs.Target is not {Valid: true} target)
{
Expand All @@ -117,8 +118,15 @@ async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
!solutionSystem.TryGetSolution((puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
return false;

// So if the puddle has 20 units we mop in 2 seconds. Don't just store CurrentVolume given it can change so need to re-calc it anyway.
var doAfterArgs = new DoAfterEventArgs(eventArgs.User, _mopSpeed * puddleSolution.CurrentVolume.Float() / 10.0f,
// if the mop is full
if(AvailableVolume <= 0)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("mop-component-mop-is-full-message"));
return false;
}

// Mopping duration (aka delay) should scale with PickupAmount and not puddle volume, because we are picking up a constant volume of solution with each click.
var doAfterArgs = new DoAfterEventArgs(eventArgs.User, _mopSpeed * PickupAmount.Float() / 10.0f,
target: target)
{
BreakOnUserMove = true,
Expand All @@ -138,30 +146,22 @@ async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
FixedPoint2 transferAmount;
// does the puddle actually have reagents? it might not if its a weird cosmetic entity.
if (puddleSolution.TotalVolume == 0)
transferAmount = FixedPoint2.Min(PickupAmount, CurrentVolume);
transferAmount = FixedPoint2.Min(PickupAmount, AvailableVolume);
else
transferAmount = FixedPoint2.Min(PickupAmount, puddleSolution.TotalVolume, CurrentVolume);
transferAmount = FixedPoint2.Min(PickupAmount, puddleSolution.TotalVolume, AvailableVolume);


// is the puddle cleaned?
if (puddleSolution.TotalVolume - transferAmount <= 0)
{
_entities.DeleteEntity(puddleComponent.Owner);
bool isCleaned = (puddleSolution.TotalVolume - transferAmount <= 0);

// After cleaning the puddle, make a new puddle with solution from the mop as a "wet floor". Then evaporate it slowly.
// we do this WITHOUT adding to the existing puddle. Otherwise we have might have water puddles with the vomit sprite.
var splitSolution = solutionSystem.SplitSolution(Owner, contents, transferAmount)
.SplitSolution(ResidueAmount);
spillableSystem.SpillAt(splitSolution, eventArgs.ClickLocation, "PuddleSmear", combine: false);
}
else
{
// remove solution from the puddle
solutionSystem.SplitSolution(target, puddleSolution, transferAmount);
// Transfers solution from the puddle to the mop
solutionSystem.TryAddSolution(Owner, contents, solutionSystem.SplitSolution(target, puddleSolution, transferAmount));

// and from the mop
solutionSystem.SplitSolution(Owner, contents, transferAmount);
if (isCleaned)
{
// deletes the puddle
_entities.DeleteEntity(puddleComponent.Owner);
}

SoundSystem.Play(Filter.Pvs(Owner), _pickupSound.GetSound(), Owner);

return true;
Expand Down
27 changes: 16 additions & 11 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
Entries:
- author: moony
changes:
- {message: 'Added a warning dialog to the observe button, no more misclicks.',
type: Add}
id: 417
time: '2021-10-08T14:22:58.0000000+00:00'
- author: metalgearsloth
changes:
- {message: Shuttle rotation is now enabled., type: Add}
id: 418
time: '2021-10-08T23:55:11.0000000+00:00'
- author: Zumorica
changes:
- {message: Added grilles., type: Add}
Expand Down Expand Up @@ -2919,3 +2908,19 @@ Entries:
- {message: Added to codebase new xeno artifacts with random effects., type: Add}
id: 918
time: '2022-01-22T12:55:11.0000000+00:00'
- author: Lamrr
changes:
- {message: Shotgun shells ('shots') are now available in boxes., type: Add}
id: 919
time: '2022-01-22T20:47:55.0000000+00:00'
- author: Willhelm53
changes:
- {message: Added ability for mop buckets to receive fluid from mops, type: Add}
- {message: Popup messages informing when the mop becomes full (from puddles or
mop bucket) or empty (from mop bucket), type: Add}
- {message: The mop now transfers solution from the puddle to the mop instead of
consuming water to destroy puddles, type: Fix}
- {message: 'The mop bucket now receives fluid from a wet mop, or gives fluid to
a dry mop', type: Tweak}
id: 920
time: '2022-01-23T05:27:22.0000000+00:00'
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bucket-component-bucket-is-empty-message = Bucket is empty
bucket-component-mop-is-full-message = Bucket is full
bucket-component-mop-is-now-wet-message = Mop is now wet
bucket-component-mop-is-now-dry-message = Mop is now dry
3 changes: 2 additions & 1 deletion Resources/Locale/en-US/fluids/components/mop-component.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mop-component-mop-is-dry-message = Mop needs to be wet!
mop-component-mop-is-dry-message = Mop needs to be wet!
mop-component-mop-is-full-message = Mop is full!
32 changes: 32 additions & 0 deletions Resources/Prototypes/Catalog/Fills/Boxes/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,35 @@
layers:
- state: box_security
- state: ziptie

- type: entity
name: box of beanbag shots
parent: BoxCardboard
id: BoxBeanbag
description: A box full of beanbag shots, designed for riot shotguns.
components:
- type: StorageFill
contents:
- id: ShellShotgunBeanbag
amount: 6
- type: Sprite
layers:
- state: box_beanbag
- type: Storage
capacity: 30

- type: entity
name: box of lethal shots
parent: BoxCardboard
id: BoxLethalshot
description: A box full of lethal shots, designed for riot shotguns.
components:
- type: StorageFill
contents:
- id: ShellShotgunBase
amount: 6
- type: Sprite
layers:
- state: box_lethalshot
- type: Storage
capacity: 30
4 changes: 2 additions & 2 deletions Resources/Prototypes/Catalog/Fills/Crates/armory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
contents:
- id: ShotgunGladstone
amount: 2
- id: ShellShotgun
amount: 18
- id: BoxLethalshot
amount: 3
4 changes: 2 additions & 2 deletions Resources/Prototypes/Catalog/Fills/Crates/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
amount: 2
- id: ShotgunGladstone
amount: 2
- id: ShellShotgunBeanbag
amount: 12
- id: BoxBeanbag
amount: 2
# - ShieldRiot
# - SecGasmask

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- type: SolutionContainerManager
solutions:
mop:
maxVol: 10
maxVol: 50

- type: entity
name: mop bucket
Expand All @@ -38,7 +38,7 @@
maxVol: 500
reagents:
- ReagentId: Water
Quantity: 500
Quantity: 250 # half-full at roundstart to leave room for puddles
- type: Physics
bodyType: Dynamic
- type: Fixtures
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion Resources/Textures/Objects/Storage/boxes.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/17dc39d12005f3279a90212b5c61a781c08693a5",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/cc65477c04f7403ca8a457bd5bae69a01abadbf0",
"size": {
"x": 32,
"y": 32
Expand Down Expand Up @@ -113,6 +113,12 @@
"name": "hug-inhand-right",
"directions": 4
},
{
"name": "box_lethalshot"
},
{
"name": "box_beanbag"
},
{
"name": "ziptie"
}
Expand Down

0 comments on commit d9bc64e

Please sign in to comment.