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

@@ -11,6 +11,12 @@ namespace Content.Server.Fluids.Components
[Friend(typeof(EvaporationSystem))] [Friend(typeof(EvaporationSystem))]
public sealed class EvaporationComponent : Component public sealed class EvaporationComponent : Component
{ {
/// <summary>
/// Is this entity actively evaporating? This toggle lets us pause evaporation under certain conditions.
/// </summary>
[DataField("evaporationToggle")]
public bool EvaporationToggle = true;
/// <summary> /// <summary>
/// The time that it will take this puddle to lose one fixed unit of solution, in seconds. /// The time that it will take this puddle to lose one fixed unit of solution, in seconds.
/// </summary> /// </summary>
@@ -32,10 +38,10 @@ namespace Content.Server.Fluids.Components
/// <summary> /// <summary>
/// Upper limit below which puddle won't evaporate. Useful when wanting to make sure large puddle will /// Upper limit below which puddle won't evaporate. Useful when wanting to make sure large puddle will
/// remain forever. Defaults to <see cref="PuddleComponent.DefaultOverflowVolume"/>. /// remain forever. Defaults to 100.
/// </summary> /// </summary>
[DataField("upperLimit")] [DataField("upperLimit")]
public FixedPoint2 UpperLimit = PuddleComponent.DefaultOverflowVolume; public FixedPoint2 UpperLimit = FixedPoint2.New(100); //TODO: Consider setting this back to PuddleComponent.DefaultOverflowVolume once that behaviour is fixed.
/// <summary> /// <summary>
/// The time accumulated since the start. /// The time accumulated since the start.

View File

@@ -32,8 +32,18 @@ namespace Content.Server.Fluids.Components
// based on behaviour (e.g. someone being punched vs slashed with a sword would have different blood sprite) // based on behaviour (e.g. someone being punched vs slashed with a sword would have different blood sprite)
// to check for low volumes for evaporation or whatever // to check for low volumes for evaporation or whatever
/// <summary>
/// Puddles with volume above this threshold can slip players.
/// </summary>
[DataField("slipThreshold")]
public FixedPoint2 SlipThreshold = DefaultSlipThreshold;
[DataField("slipThreshold")] public FixedPoint2 SlipThreshold = DefaultSlipThreshold; /// <summary>
/// Puddles with volume below this threshold will have their sprite changed to a wet floor effect,
/// provided they can evaporate down to zero.
/// </summary>
[DataField("wetFloorEffectThreshold")]
public FixedPoint2 WetFloorEffectThreshold = FixedPoint2.New(5);
[DataField("spillSound")] [DataField("spillSound")]
public SoundSpecifier SpillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg"); public SoundSpecifier SpillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg");

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Fluids.EntitySystems
if (!_solutionContainerSystem.TryGetSolution(uid, evaporationComponent.SolutionName, out var solution)) if (!_solutionContainerSystem.TryGetSolution(uid, evaporationComponent.SolutionName, out var solution))
{ {
// If no solution, delete the entity // If no solution, delete the entity
queueDelete.Add(evaporationComponent); EntityManager.QueueDeleteEntity(uid);
continue; continue;
} }
@@ -34,19 +34,22 @@ namespace Content.Server.Fluids.EntitySystems
evaporationComponent.Accumulator -= evaporationComponent.EvaporateTime; 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, if (solution.CurrentVolume <= 0)
FixedPoint2.Min(FixedPoint2.New(1), solution.CurrentVolume));
if (solution.CurrentVolume == 0)
{ {
EntityManager.QueueDeleteEntity(uid); 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) || 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) 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 volumeScale = puddleComponent.CurrentVolume.Float() / puddleComponent.OverflowVolume.Float();
var puddleSolution = _solutionContainerSystem.EnsureSolution(uid, puddleComponent.SolutionName); 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?" // "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.VolumeScale, volumeScale);
appearanceComponent.SetData(PuddleVisuals.SolutionColor, puddleSolution.Color); appearanceComponent.SetData(PuddleVisuals.SolutionColor, puddleSolution.Color);

View File

@@ -365,7 +365,7 @@
- ReagentId: JuiceTomato - ReagentId: JuiceTomato
Quantity: 10 Quantity: 10
- type: Evaporation - type: Evaporation
lowerLimit: 2 lowerLimit: 0 # todo: reimplement stain behaviour, ideally in a way that doesn't use evaporation lowerLimit
- type: Appearance - type: Appearance
visuals: visuals:
- type: PuddleVisualizer - type: PuddleVisualizer