Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable pump #2721

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add visual state enums, basic logic
Alkheemist committed Jan 27, 2025
commit 81fb8de3ddcf6e8745839d9b882f28caf10bf283
19 changes: 15 additions & 4 deletions Content.Server/_NF/Fluids/EntitySystems/AdvDrainSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
@@ -20,7 +22,7 @@
using Robust.Shared.Utility;


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

public sealed class AdvDrainSystem : SharedDrainSystem
{
@@ -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();

@@ -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;
}

@@ -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)
@@ -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;
@@ -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)
@@ -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
@@ -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)
Original file line number Diff line number Diff line change
@@ -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: