Mop & Bucket Behaviour Change (#6193)

This commit is contained in:
Willhelm53
2022-01-22 23:27:22 -06:00
committed by GitHub
parent e179f4983f
commit 02cbadb766
5 changed files with 72 additions and 49 deletions

View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
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;
@@ -70,11 +71,7 @@ namespace Content.Server.Fluids.Components
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);
@@ -92,25 +89,49 @@ namespace Content.Server.Fluids.Components
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;
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 mopContents = mopComponent.MopSolution;
if (mopContents == null)
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"));
var solution = solutionsSys.SplitSolution(Owner, contents, transferAmount);
if (!solutionsSys.TryAddSolution(mopComponent.Owner, mopContents, solution))
{
return false;
}
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner);