Puddle refactor 2: Spillastic boogaloo (#4784)
* Refactor PuddleComponent * Move puddle effects into separate RSIs Basically egg/tomato/powder puddle will be moved into separate /Textures/Fluids RSIs * Fix YAML for puddles * Fix issues sloth pointed out. * Ensure Puddle Component are properly added when spawned * Remove unnecessary method init puddle with starting maxVolume * Addressed ElectroSr comments * Add Resolves * Try fix error in ensureSolution * Puddle unanchoring * Address some issues with puddles * Fix continue -> return
This commit is contained in:
58
Content.Server/Fluids/EntitySystems/EvaporationSystem.cs
Normal file
58
Content.Server/Fluids/EntitySystems/EvaporationSystem.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class EvaporationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
var queueDelete = new RemQueue<EvaporationComponent>();
|
||||
foreach (var evaporationComponent in EntityManager.EntityQuery<EvaporationComponent>())
|
||||
{
|
||||
var uid = evaporationComponent.Owner.Uid;
|
||||
evaporationComponent.Accumulator += frameTime;
|
||||
|
||||
if (!_solutionContainerSystem.TryGetSolution(uid, evaporationComponent.SolutionName, out var solution))
|
||||
{
|
||||
// If no solution, delete the entity
|
||||
queueDelete.Add(evaporationComponent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (evaporationComponent.Accumulator < evaporationComponent.EvaporateTime)
|
||||
continue;
|
||||
|
||||
evaporationComponent.Accumulator -= evaporationComponent.EvaporateTime;
|
||||
|
||||
|
||||
_solutionContainerSystem.SplitSolution(uid, solution,
|
||||
ReagentUnit.Min(ReagentUnit.New(1), solution.CurrentVolume));
|
||||
|
||||
if (solution.CurrentVolume == 0)
|
||||
{
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
else if (solution.CurrentVolume <= evaporationComponent.LowerLimit
|
||||
|| solution.CurrentVolume >= evaporationComponent.UpperLimit)
|
||||
{
|
||||
queueDelete.Add(evaporationComponent);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var evaporationComponent in queueDelete)
|
||||
{
|
||||
EntityManager.RemoveComponent(evaporationComponent.Owner.Uid, evaporationComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user