Mopping Puddle Dilution and Wet Floor Sparkles (#6273)

This commit is contained in:
Willhelm53
2022-02-04 20:26:11 -06:00
committed by GitHub
parent 3d3a3c857b
commit 4d3a381962
10 changed files with 87 additions and 20 deletions

View File

@@ -27,7 +27,7 @@ namespace Content.Server.Fluids.Components
[Dependency] private readonly IEntityManager _entities = default!;
public const string SolutionName = "mop";
/// <summary>
/// Used to prevent do_after spam if we're currently mopping.
/// </summary>
@@ -71,10 +71,16 @@ namespace Content.Server.Fluids.Components
public FixedPoint2 PickupAmount { get; } = FixedPoint2.New(10);
/// <summary>
/// After cleaning a floor tile, leave this much reagent as a puddle. I.e., leave behind a wet floor.
/// When using the mop on an empty floor tile, leave this much reagent as a new puddle.
/// </summary>
[DataField("residueAmount")]
public FixedPoint2 ResidueAmount { get; } = FixedPoint2.New(5);
public FixedPoint2 ResidueAmount { get; } = FixedPoint2.New(10); // Should be higher than MopLowerLimit
/// <summary>
/// To leave behind a wet floor, the mop will be unable to take from puddles with a volume less than this amount.
/// </summary>
[DataField("mopLowerLimit")]
public FixedPoint2 MopLowerLimit { get; } = FixedPoint2.New(5);
[DataField("pickup_sound")]
private SoundSpecifier _pickupSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
@@ -117,6 +123,14 @@ namespace Content.Server.Fluids.Components
!solutionSystem.TryGetSolution((puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
return false;
// if the puddle is too small for the mop to effectively take any more solution
if (puddleSolution.TotalVolume <= MopLowerLimit)
{
// Transfers solution from the mop to the puddle
solutionSystem.TryAddSolution(target, puddleSolution, solutionSystem.SplitSolution(Owner, contents, FixedPoint2.Min(ResidueAmount,CurrentVolume)));
return true;
}
// if the mop is full
if(AvailableVolume <= 0)
{
@@ -141,28 +155,28 @@ namespace Content.Server.Fluids.Components
puddleComponent.Deleted)
return false;
// The volume the mop will take from the puddle
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, AvailableVolume);
else
{
transferAmount = FixedPoint2.Min(PickupAmount, puddleSolution.TotalVolume, AvailableVolume);
// is the puddle cleaned?
bool isCleaned = (puddleSolution.TotalVolume - transferAmount <= 0);
if ((puddleSolution.TotalVolume - transferAmount) < MopLowerLimit) // If the transferAmount would bring the puddle below the MopLowerLimit
transferAmount = puddleSolution.TotalVolume - MopLowerLimit; // Then the transferAmount should bring the puddle down to the MopLowerLimit exactly
}
// Transfers solution from the puddle to the mop
solutionSystem.TryAddSolution(Owner, contents, solutionSystem.SplitSolution(target, puddleSolution, transferAmount));
if (isCleaned)
{
// deletes the puddle
_entities.DeleteEntity(puddleComponent.Owner);
}
SoundSystem.Play(Filter.Pvs(Owner), _pickupSound.GetSound(), Owner);
// if the mop became full after that puddle, let the player know.
if(AvailableVolume <= 0)
Owner.PopupMessage(eventArgs.User, Loc.GetString("mop-component-mop-is-now-full-message"));
return true;
}
}