Puddle Evaporation Fix (#6584)

This commit is contained in:
Willhelm53
2022-02-10 15:07:21 -06:00
committed by GitHub
parent 08b773d394
commit 8d29047a3a
5 changed files with 37 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Fluids.EntitySystems
if (!_solutionContainerSystem.TryGetSolution(uid, evaporationComponent.SolutionName, out var solution))
{
// If no solution, delete the entity
queueDelete.Add(evaporationComponent);
EntityManager.QueueDeleteEntity(uid);
continue;
}
@@ -34,19 +34,22 @@ namespace Content.Server.Fluids.EntitySystems
evaporationComponent.Accumulator -= evaporationComponent.EvaporateTime;
if (evaporationComponent.EvaporationToggle == true)
{
_solutionContainerSystem.SplitSolution(uid, solution,
FixedPoint2.Min(FixedPoint2.New(1), solution.CurrentVolume)); // removes 1 unit, or solution current volume, whichever is lower.
}
_solutionContainerSystem.SplitSolution(uid, solution,
FixedPoint2.Min(FixedPoint2.New(1), solution.CurrentVolume));
if (solution.CurrentVolume == 0)
if (solution.CurrentVolume <= 0)
{
EntityManager.QueueDeleteEntity(uid);
}
else if (solution.CurrentVolume <= evaporationComponent.LowerLimit
else if (solution.CurrentVolume <= evaporationComponent.LowerLimit // if puddle is too big or too small to evaporate.
|| solution.CurrentVolume >= evaporationComponent.UpperLimit)
{
queueDelete.Add(evaporationComponent);
evaporationComponent.EvaporationToggle = false; // pause evaporation
}
else evaporationComponent.EvaporationToggle = true; // unpause evaporation, e.g. if a puddle previously above evaporation UpperLimit was brought down below evaporation UpperLimit via mopping.
}
foreach (var evaporationComponent in queueDelete)

View File

@@ -68,10 +68,14 @@ namespace Content.Server.Fluids.EntitySystems
var volumeScale = puddleComponent.CurrentVolume.Float() / puddleComponent.OverflowVolume.Float();
var puddleSolution = _solutionContainerSystem.EnsureSolution(uid, puddleComponent.SolutionName);
// Puddles with volume below this threshold will have their sprite changed to a wet floor effect
var wetFloorEffectThreshold = FixedPoint2.New(5);
bool hasEvaporationComponent = EntityManager.TryGetComponent<EvaporationComponent>(uid, out var evaporationComponent);
bool canEvaporate = (hasEvaporationComponent &&
(evaporationComponent.LowerLimit == 0 || puddleComponent.CurrentVolume > evaporationComponent.LowerLimit));
// "Does this puddle's sprite need changing to the wet floor effect sprite?"
bool changeToWetFloor = (puddleComponent.CurrentVolume <= wetFloorEffectThreshold);
bool changeToWetFloor = (puddleComponent.CurrentVolume <= puddleComponent.WetFloorEffectThreshold
&& canEvaporate);
appearanceComponent.SetData(PuddleVisuals.VolumeScale, volumeScale);
appearanceComponent.SetData(PuddleVisuals.SolutionColor, puddleSolution.Color);