Skip to content

Commit

Permalink
add visual state enums, basic logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkheemist committed Jan 27, 2025
1 parent 89d5c57 commit 81fb8de
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
19 changes: 15 additions & 4 deletions Content.Server/_NF/Fluids/EntitySystems/AdvDrainSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using Content.Shared.FixedPoint;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
using Content.Shared._NF.Fluids.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Content.Shared.Verbs;
Expand All @@ -20,7 +22,7 @@
using Robust.Shared.Utility;


namespace Content.Server.Fluids.EntitySystems;
namespace Content.Server._NF.Fluids.EntitySystems;

public sealed class AdvDrainSystem : SharedDrainSystem
{
Expand All @@ -36,6 +38,7 @@ public sealed class AdvDrainSystem : SharedDrainSystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;

private readonly HashSet<Entity<PuddleComponent>> _puddles = new();

Expand Down Expand Up @@ -136,13 +139,17 @@ public override void Update(float frameTime)
if (!TryComp(uid, out TransformComponent? xform) || !xform.Anchored)
{
_ambientSoundSystem.SetAmbience(uid, false);
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsRunning, false);
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsDraining, false);
continue;
}

// not powered
if (!_powerCell.HasCharge(uid, drain.Wattage))
{
_ambientSoundSystem.SetAmbience(uid, false);
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsRunning, false);
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsDraining, false);
continue;
}

Expand All @@ -152,7 +159,7 @@ public override void Update(float frameTime)
continue;
}
drain.Accumulator -= drain.DrainFrequency;

_appearanceSystem.SetData(uid, AdvDrainVisualState.IsRunning, true);

// Disable ambient sound from emptying manually
if (!drain.AutoDrain)
Expand All @@ -177,8 +184,13 @@ public override void Update(float frameTime)
// Remove a bit from the buffer
if (drainSolution.Volume > drain.UnitsDestroyedThreshold)
{
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsVoiding, true);
_solutionContainerSystem.SplitSolution(drain.Solution.Value, Math.Min(drain.UnitsDestroyedPerSecond * drain.DrainFrequency, (float)drainSolution.Volume - drain.UnitsDestroyedThreshold));
}
else
{
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsVoiding, false);
}

// This will ensure that UnitsPerSecond is per second...
var amount = drain.UnitsPerSecond * drain.DrainFrequency;
Expand All @@ -196,6 +208,7 @@ public override void Update(float frameTime)

// only use power if it's actively draining puddles
_powerCell.TryUseCharge(uid, drain.Wattage * drain.DrainFrequency);
_appearanceSystem.SetData(uid, AdvDrainVisualState.IsDraining, true);
amount /= _puddles.Count;

foreach (var puddle in _puddles)
Expand Down Expand Up @@ -240,6 +253,4 @@ private void OnExamined(Entity<AdvDrainComponent> entity, ref ExaminedEvent args
var text = Loc.GetString("adv-drain-component-examine-volume", ("volume", drainSolution.Volume), ("maxvolume", drain.UnitsDestroyedThreshold));
args.PushMarkup(text);
}


}
10 changes: 10 additions & 0 deletions Content.Shared/Fluids/SharedDrainSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ public sealed partial class DrainDoAfterEvent : SimpleDoAfterEvent
{
}
}

// Start Frontier: portable pump visual state
[Serializable, NetSerializable]
public enum AdvDrainVisualState : byte
{
IsRunning,
IsDraining,
IsVoiding
}
// End Frontier
3 changes: 2 additions & 1 deletion Content.Shared/_NF/Fluids/Components/AdvDrainComponent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.Tag;
using Robust.Shared.Audio;
using Content.Shared.Fluids;

namespace Content.Shared.Fluids.Components;
namespace Content.Shared._NF.Fluids.Components;

/// <summary>
/// A Drain allows an entity to absorb liquid in a disposal goal. Drains can be filled manually (with the Empty verb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
noRot: true
layers:
- state: base
map: ["enum.PortableScrubberVisualLayers.IsRunning"]
map: ["enum.AdvDrainVisualState.IsRunning"]
- state: pumping
map: ["enum.PowerDeviceVisualLayers.Powered"]
map: ["enum.AdvDrainVisualState.IsDraining"]
- state: powered
shader: unshaded
# visible: false
# map: ["enum.PortableScrubberVisualLayers.IsDraining"]
map: ["enum.PowerDeviceVisualLayers.Powered"]
- state: voiding
shader: unshaded
map: ["enum.AdvDrainVisualState.IsVoiding"]
- type: Appearance
- type: GenericVisualizer
visuals:
Expand Down

0 comments on commit 81fb8de

Please sign in to comment.