Added blocked visuals to volumetric pump (#20610)

This commit is contained in:
daerSeebaer
2023-09-30 05:35:23 +02:00
committed by GitHub
parent 812b8fff3f
commit 0bb8c222bd
6 changed files with 50 additions and 5 deletions

View File

@@ -9,6 +9,9 @@ namespace Content.Server.Atmos.Piping.Binary.Components
[DataField("enabled")] [DataField("enabled")]
public bool Enabled { get; set; } = true; public bool Enabled { get; set; } = true;
[DataField("blocked")]
public bool Blocked { get; set; } = false;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public bool Overclocked { get; set; } = false; public bool Overclocked { get; set; } = false;

View File

@@ -12,6 +12,7 @@ using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos.Piping; using Content.Shared.Atmos.Piping;
using Content.Shared.Atmos.Piping.Binary.Components; using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Visuals;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Examine; using Content.Shared.Examine;
@@ -83,12 +84,24 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
var inputStartingPressure = inlet.Air.Pressure; var inputStartingPressure = inlet.Air.Pressure;
var outputStartingPressure = outlet.Air.Pressure; var outputStartingPressure = outlet.Air.Pressure;
var previouslyBlocked = pump.Blocked;
pump.Blocked = false;
// Pump mechanism won't do anything if the pressure is too high/too low unless you overclock it. // Pump mechanism won't do anything if the pressure is too high/too low unless you overclock it.
if ((inputStartingPressure < pump.LowerThreshold) || (outputStartingPressure > pump.HigherThreshold) && !pump.Overclocked) if ((inputStartingPressure < pump.LowerThreshold) || (outputStartingPressure > pump.HigherThreshold) && !pump.Overclocked)
return; {
pump.Blocked = true;
}
// Overclocked pumps can only force gas a certain amount. // Overclocked pumps can only force gas a certain amount.
if ((outputStartingPressure - inputStartingPressure > pump.OverclockThreshold) && pump.Overclocked) if ((outputStartingPressure - inputStartingPressure > pump.OverclockThreshold) && pump.Overclocked)
{
pump.Blocked = true;
}
if (previouslyBlocked != pump.Blocked)
UpdateAppearance(uid, pump);
if (pump.Blocked)
return; return;
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters. // We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
@@ -172,7 +185,12 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!Resolve(uid, ref pump, ref appearance, false)) if (!Resolve(uid, ref pump, ref appearance, false))
return; return;
_appearance.SetData(uid, PumpVisuals.Enabled, pump.Enabled, appearance); if (!pump.Enabled)
_appearance.SetData(uid, GasVolumePumpVisuals.State, GasVolumePumpState.Off, appearance);
else if (pump.Blocked)
_appearance.SetData(uid, GasVolumePumpVisuals.State, GasVolumePumpState.Blocked, appearance);
else
_appearance.SetData(uid, GasVolumePumpVisuals.State, GasVolumePumpState.On, appearance);
} }
private void OnPacketRecv(EntityUid uid, GasVolumePumpComponent component, DeviceNetworkPacketEvent args) private void OnPacketRecv(EntityUid uid, GasVolumePumpComponent component, DeviceNetworkPacketEvent args)

View File

@@ -0,0 +1,18 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Visuals
{
[Serializable, NetSerializable]
public enum GasVolumePumpVisuals : byte
{
State,
}
[Serializable, NetSerializable]
public enum GasVolumePumpState : byte
{
Off,
On,
Blocked,
}
}

View File

@@ -82,10 +82,11 @@
- type: Appearance - type: Appearance
- type: GenericVisualizer - type: GenericVisualizer
visuals: visuals:
enum.PumpVisuals.Enabled: enum.GasVolumePumpVisuals.State:
enabled: enabled:
True: { state: pumpVolumeOn } On: { state: pumpVolumeOn }
False: { state: pumpVolume } Off: { state: pumpVolume }
Blocked: { state: pumpVolumeBlocked }
- type: PipeColorVisuals - type: PipeColorVisuals
- type: GasVolumePump - type: GasVolumePump
enabled: false enabled: false

View File

@@ -52,6 +52,11 @@
"name":"pumpVolumeOn", "name":"pumpVolumeOn",
"directions":4, "directions":4,
"delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ] ] "delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ] ]
},
{
"name":"pumpVolumeBlocked",
"directions":4,
"delays":[ [ 1.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 1.0 ] ]
} }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB