Puddle Evaporation Fix (#6584)
This commit is contained in:
@@ -11,6 +11,12 @@ namespace Content.Server.Fluids.Components
|
||||
[Friend(typeof(EvaporationSystem))]
|
||||
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>
|
||||
/// The time that it will take this puddle to lose one fixed unit of solution, in seconds.
|
||||
/// </summary>
|
||||
@@ -32,10 +38,10 @@ namespace Content.Server.Fluids.Components
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
[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>
|
||||
/// The time accumulated since the start.
|
||||
|
||||
@@ -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)
|
||||
// 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")]
|
||||
public SoundSpecifier SpillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -365,7 +365,7 @@
|
||||
- ReagentId: JuiceTomato
|
||||
Quantity: 10
|
||||
- type: Evaporation
|
||||
lowerLimit: 2
|
||||
lowerLimit: 0 # todo: reimplement stain behaviour, ideally in a way that doesn't use evaporation lowerLimit
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PuddleVisualizer
|
||||
|
||||
Reference in New Issue
Block a user