Radiation collector sprite update (#20956)

This commit is contained in:
chromiumboy
2023-10-13 18:08:00 -05:00
committed by GitHub
parent dd6b7b337f
commit 4c630d0b17
14 changed files with 93 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ using Content.Server.Atmos.Components;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Server.Atmos; using Content.Server.Atmos;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Shared.Atmos;
namespace Content.Server.Singularity.EntitySystems; namespace Content.Server.Singularity.EntitySystems;
@@ -27,6 +28,9 @@ public sealed class RadiationCollectorSystem : EntitySystem
SubscribeLocalEvent<RadiationCollectorComponent, OnIrradiatedEvent>(OnRadiation); SubscribeLocalEvent<RadiationCollectorComponent, OnIrradiatedEvent>(OnRadiation);
SubscribeLocalEvent<RadiationCollectorComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<RadiationCollectorComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<RadiationCollectorComponent, GasAnalyzerScanEvent>(OnAnalyzed); SubscribeLocalEvent<RadiationCollectorComponent, GasAnalyzerScanEvent>(OnAnalyzed);
SubscribeLocalEvent<RadiationCollectorComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<RadiationCollectorComponent, EntInsertedIntoContainerMessage>(OnTankChanged);
SubscribeLocalEvent<RadiationCollectorComponent, EntRemovedFromContainerMessage>(OnTankChanged);
} }
private bool TryGetLoadedGasTank(EntityUid uid, [NotNullWhen(true)] out GasTankComponent? gasTankComponent) private bool TryGetLoadedGasTank(EntityUid uid, [NotNullWhen(true)] out GasTankComponent? gasTankComponent)
@@ -43,6 +47,18 @@ public sealed class RadiationCollectorSystem : EntitySystem
return true; return true;
} }
private void OnMapInit(EntityUid uid, RadiationCollectorComponent component, MapInitEvent args)
{
TryGetLoadedGasTank(uid, out var gasTank);
UpdateTankAppearance(uid, component, gasTank);
}
private void OnTankChanged(EntityUid uid, RadiationCollectorComponent component, ContainerModifiedMessage args)
{
TryGetLoadedGasTank(uid, out var gasTank);
UpdateTankAppearance(uid, component, gasTank);
}
private void OnInteractHand(EntityUid uid, RadiationCollectorComponent component, InteractHandEvent args) private void OnInteractHand(EntityUid uid, RadiationCollectorComponent component, InteractHandEvent args)
{ {
var curTime = _gameTiming.CurTime; var curTime = _gameTiming.CurTime;
@@ -97,22 +113,20 @@ public sealed class RadiationCollectorSystem : EntitySystem
{ {
batteryComponent.CurrentCharge += charge; batteryComponent.CurrentCharge += charge;
} }
// Update appearance
UpdatePressureIndicatorAppearance(uid, component, gasTankComponent);
} }
private void OnExamined(EntityUid uid, RadiationCollectorComponent component, ExaminedEvent args) private void OnExamined(EntityUid uid, RadiationCollectorComponent component, ExaminedEvent args)
{ {
if (!TryGetLoadedGasTank(uid, out var gasTankComponent)) if (!TryGetLoadedGasTank(uid, out var gasTank))
{ {
args.PushMarkup(Loc.GetString("power-radiation-collector-gas-tank-missing")); args.PushMarkup(Loc.GetString("power-radiation-collector-gas-tank-missing"));
return; return;
} }
args.PushMarkup(Loc.GetString("power-radiation-collector-gas-tank-present")); args.PushMarkup(Loc.GetString("power-radiation-collector-gas-tank-present"));
if (gasTankComponent.IsLowPressure)
{
args.PushMarkup(Loc.GetString("power-radiation-collector-gas-tank-low-pressure"));
}
} }
private void OnAnalyzed(EntityUid uid, RadiationCollectorComponent component, GasAnalyzerScanEvent args) private void OnAnalyzed(EntityUid uid, RadiationCollectorComponent component, GasAnalyzerScanEvent args)
@@ -133,7 +147,7 @@ public sealed class RadiationCollectorSystem : EntitySystem
public void SetCollectorEnabled(EntityUid uid, bool enabled, EntityUid? user = null, RadiationCollectorComponent? component = null) public void SetCollectorEnabled(EntityUid uid, bool enabled, EntityUid? user = null, RadiationCollectorComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component, false))
return; return;
component.Enabled = enabled; component.Enabled = enabled;
@@ -146,15 +160,43 @@ public sealed class RadiationCollectorSystem : EntitySystem
} }
// Update appearance // Update appearance
UpdateAppearance(uid, component); UpdateMachineAppearance(uid, component);
} }
private void UpdateAppearance(EntityUid uid, RadiationCollectorComponent? component, AppearanceComponent? appearance = null) private void UpdateMachineAppearance(EntityUid uid, RadiationCollectorComponent component, AppearanceComponent? appearance = null)
{ {
if (!Resolve(uid, ref component, ref appearance)) if (!Resolve(uid, ref appearance))
return; return;
var state = component.Enabled ? RadiationCollectorVisualState.Active : RadiationCollectorVisualState.Deactive; var state = component.Enabled ? RadiationCollectorVisualState.Active : RadiationCollectorVisualState.Deactive;
_appearance.SetData(uid, RadiationCollectorVisuals.VisualState, state, appearance); _appearance.SetData(uid, RadiationCollectorVisuals.VisualState, state, appearance);
} }
private void UpdatePressureIndicatorAppearance(EntityUid uid, RadiationCollectorComponent component, GasTankComponent? gasTank = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref appearance, false))
return;
if (gasTank == null || gasTank.Air.Pressure < 10)
_appearance.SetData(uid, RadiationCollectorVisuals.PressureState, 0, appearance);
else if (gasTank.Air.Pressure < Atmospherics.OneAtmosphere)
_appearance.SetData(uid, RadiationCollectorVisuals.PressureState, 1, appearance);
else if (gasTank.Air.Pressure < 3f * Atmospherics.OneAtmosphere)
_appearance.SetData(uid, RadiationCollectorVisuals.PressureState, 2, appearance);
else
_appearance.SetData(uid, RadiationCollectorVisuals.PressureState, 3, appearance);
}
private void UpdateTankAppearance(EntityUid uid, RadiationCollectorComponent component, GasTankComponent? gasTank = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref appearance, false))
return;
_appearance.SetData(uid, RadiationCollectorVisuals.TankInserted, gasTank != null, appearance);
UpdatePressureIndicatorAppearance(uid, component, gasTank, appearance);
}
} }

View File

@@ -1,11 +1,13 @@
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Singularity.Components namespace Content.Shared.Singularity.Components
{ {
[NetSerializable, Serializable] [NetSerializable, Serializable]
public enum RadiationCollectorVisuals public enum RadiationCollectorVisuals
{ {
VisualState VisualState,
TankInserted,
PressureState,
} }
[NetSerializable, Serializable] [NetSerializable, Serializable]

View File

@@ -1,3 +1,2 @@
power-radiation-collector-gas-tank-missing = [color=red]No gas tank attached.[/color] power-radiation-collector-gas-tank-missing = [color=darkred]No plasma tank attached.[/color]
power-radiation-collector-gas-tank-present = A gas tank is [color=darkgreen]connected[/color]. power-radiation-collector-gas-tank-present = A plasma tank is [color=darkgreen]connected[/color].
power-radiation-collector-gas-tank-low-pressure = The gas tank [color=orange]low pressure[/color] light is on.

View File

@@ -31,6 +31,18 @@
- state: ca_off - state: ca_off
map: ["enum.RadiationCollectorVisualLayers.Main"] map: ["enum.RadiationCollectorVisualLayers.Main"]
- type: Appearance - type: Appearance
- type: GenericVisualizer
visuals:
enum.RadiationCollectorVisuals.TankInserted:
tankInserted:
False: { state: ca-tank, visible: false }
True: { state: ca-tank, visible: true }
enum.RadiationCollectorVisuals.PressureState:
pressureLight:
0: { state: ca-o0, shader: "unshaded" }
1: { state: ca-o1, shader: "unshaded" }
2: { state: ca-o2, shader: "unshaded" }
3: { state: ca-o3, shader: "unshaded" }
- type: AnimationPlayer - type: AnimationPlayer
- type: NodeContainer - type: NodeContainer
examinable: true examinable: true
@@ -44,7 +56,6 @@
- reactantPrototype: Plasma - reactantPrototype: Plasma
powerGenerationEfficiency: 1 powerGenerationEfficiency: 1
reactantBreakdownRate: 0.0002 reactantBreakdownRate: 0.0002
byproductPrototype: Tritium
# Note that this doesn't matter too much (see next comment) # Note that this doesn't matter too much (see next comment)
# However it does act as a cap on power receivable via the collector. # However it does act as a cap on power receivable via the collector.
- type: Battery - type: Battery

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1021 B

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -1,7 +1,7 @@
{ {
"version": 1, "version": 1,
"license": "CC-BY-SA-3.0", "license": "CC-BY-SA-3.0",
"copyright": "Taken from goonstation at https://github.com/goonstation/goonstation/commit/cbe076402ed43b1cd861295bbcb95608c453de7a", "copyright": "Taken from goonstation at https://github.com/goonstation/goonstation/commit/cbe076402ed43b1cd861295bbcb95608c453de7a. Edited by chromiumboy",
"size": { "size": {
"x": 32, "x": 32,
"y": 32 "y": 32
@@ -39,6 +39,27 @@
}, },
{ {
"name": "cu" "name": "cu"
},
{
"name": "ca-o0",
"delays": [
[
0.2,
0.2
]
]
},
{
"name": "ca-o1"
},
{
"name": "ca-o2"
},
{
"name": "ca-o3"
},
{
"name": "ca-tank"
} }
] ]
} }