&&absorbedSolutionisnotnull)// needs a solution to place on the tile
{
TileReftile=mapGrid.GetTileRef(clickLocation);
// Drop some of the absorbed liquid onto the ground
varreleaseAmount=FixedPoint2.Min(absorbent.ResidueAmount,absorbedSolution.CurrentVolume);// The release amount specified on the absorbent component, or the amount currently absorbed (whichever is less).
varreleasedSolution=_solutionSystem.SplitSolution(absorbent.Owner,absorbedSolution,releaseAmount);// Remove releaseAmount of solution from the absorbent component
_spillableSystem.SpillAt(tile,releasedSolution,puddlePrototypeId);// And spill it onto the tile.
}
}
// Handles logic for our different types of valid target.
// Checks for conditions that would prevent a doAfter from starting.
SoundSystem.Play(sfx.GetSound(),Filter.Pvs(user),used);// Give instant feedback for diluting puddle, so that it's clear that the player is adding to the puddle (as opposed to other behaviours, which have a doAfter).
// TODO: consider onelining this with the above, using additional args on Min()?
if((puddleSolution.TotalVolume-transferAmount)<component.MopLowerLimit)// If the transferAmount would bring the puddle below the MopLowerLimit
{
transferAmount=puddleSolution.TotalVolume-component.MopLowerLimit;// Then the transferAmount should bring the puddle down to the MopLowerLimit exactly
}
donor=target;// the puddle Uid
donorSolutionName=puddle.SolutionName;
acceptor=used;// the mop/tool Uid
acceptorSolutionName="absorbed";// by definition on AbsorbentComponent
// Set delay/popup/sound if nondefault. Popup and sound will only play on a successful doAfter.
delay=(component.PickupAmount.Float()/10.0f)*component.MopSpeed;// Delay should scale with PickupAmount, which represents the maximum we can pick up per click.
elseif((TryComp<RefillableSolutionComponent>(target,outvarrefillable))// We can put solution from the tool into the target
&&(currentVolume>0))// And the tool is wet
{
// These return conditions will abort BEFORE the do_after is called:
if(!_solutionSystem.TryGetRefillableSolution(target,outvarrefillableSolution))// refillable Solution is null
{
return;
}
elseif(refillableSolution.AvailableVolume<=0)// target container is full (liquid destination)
{
msg="mopping-system-target-container-full";
user.PopupMessage(user,Loc.GetString(msg,("target",target)));// play message now because we are aborting.
return;
}
elseif(refillableSolution.MaxVolume<=FixedPoint2.New(20))// target container is too small (e.g. syringe)
{
msg="mopping-system-target-container-too-small";
user.PopupMessage(user,Loc.GetString(msg,("target",target)));// play message now because we are aborting.
return;
}
else
{
// Determine transferAmount
if(_tagSystem.HasTag(used,"Mop")// if the tool used is a literal mop (and not a sponge, rag, etc.)
&&!_tagSystem.HasTag(target,"Wringer"))// and if the target does not have a wringer for properly drying the mop
{
delay=5.0f;// Should take much longer if you don't have a wringer
if((currentVolume/(currentVolume+availableVolume))>0.25)// mop is more than one-quarter full
{
transferAmount=FixedPoint2.Min(refillableSolution.AvailableVolume,currentVolume*0.6);// squeeze up to 60% of the solution from the mop.
msg="mopping-system-hand-squeeze-little-wet";
if((currentVolume/(currentVolume+availableVolume))>0.5)// if the mop is more than half full
msg="mopping-system-hand-squeeze-still-wet";// overwrites the above
}
else// mop is less than one-quarter full
{
transferAmount=FixedPoint2.Min(refillableSolution.AvailableVolume,currentVolume);// squeeze remainder of solution from the mop.
msg="mopping-system-hand-squeeze-dry";
}
}
else
{
transferAmount=FixedPoint2.Min(refillableSolution.AvailableVolume,currentVolume);//Transfer all liquid from the tool to the container, but only if it will fit.
msg="mopping-system-refillable-success";
delay=1.0f;
}
donor=used;// the mop/tool Uid
donorSolutionName="absorbed";// by definition on AbsorbentComponent
acceptor=target;// the refillable container's Uid
acceptorSolutionName=refillable.Solution;
// Set delay/popup/sound if nondefault. Popup and sound will only play on a successful doAfter.
elseif(drainableSolution.CurrentVolume<=0)// target container is empty (liquid source)
{
msg="mopping-system-target-container-empty";
user.PopupMessage(user,Loc.GetString(msg,("target",target)));// play message now because we are returning.
return;
}
else
{
// Determine transferAmount
transferAmount=FixedPoint2.Min(availableVolume*0.5,drainableSolution.CurrentVolume);// Let's transfer up to to half the tool's available capacity to the tool.
donor=target;// the drainable container's Uid
donorSolutionName=drainable.Solution;
acceptor=used;// the mop/tool Uid
acceptorSolutionName="absorbed";// by definition on AbsorbentComponent
// Set delay/popup/sound if nondefault. Popup and sound will only play on a successful doAfter.