diff --git a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs index 19d9b98f4a..27219bb183 100644 --- a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs @@ -10,6 +10,7 @@ using Content.Server.Atmos.Components; using Content.Shared.Examine; using Content.Server.Atmos; using System.Diagnostics.CodeAnalysis; +using Content.Shared.Atmos; namespace Content.Server.Singularity.EntitySystems; @@ -27,6 +28,9 @@ public sealed class RadiationCollectorSystem : EntitySystem SubscribeLocalEvent(OnRadiation); SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnAnalyzed); + SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnTankChanged); + SubscribeLocalEvent(OnTankChanged); } private bool TryGetLoadedGasTank(EntityUid uid, [NotNullWhen(true)] out GasTankComponent? gasTankComponent) @@ -43,6 +47,18 @@ public sealed class RadiationCollectorSystem : EntitySystem 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) { var curTime = _gameTiming.CurTime; @@ -97,22 +113,20 @@ public sealed class RadiationCollectorSystem : EntitySystem { batteryComponent.CurrentCharge += charge; } + + // Update appearance + UpdatePressureIndicatorAppearance(uid, component, gasTankComponent); } 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")); return; } 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) @@ -133,7 +147,7 @@ public sealed class RadiationCollectorSystem : EntitySystem 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; component.Enabled = enabled; @@ -146,15 +160,43 @@ public sealed class RadiationCollectorSystem : EntitySystem } // 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; var state = component.Enabled ? RadiationCollectorVisualState.Active : RadiationCollectorVisualState.Deactive; _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); + } } diff --git a/Content.Shared/Singularity/Components/SharedRadiationCollectorComponent.cs b/Content.Shared/Singularity/Components/SharedRadiationCollectorComponent.cs index 44cdea4fb6..0b5fbea648 100644 --- a/Content.Shared/Singularity/Components/SharedRadiationCollectorComponent.cs +++ b/Content.Shared/Singularity/Components/SharedRadiationCollectorComponent.cs @@ -1,16 +1,18 @@ -using Robust.Shared.Serialization; +using Robust.Shared.Serialization; namespace Content.Shared.Singularity.Components { [NetSerializable, Serializable] public enum RadiationCollectorVisuals { - VisualState + VisualState, + TankInserted, + PressureState, } [NetSerializable, Serializable] public enum RadiationCollectorVisualState - { + { Active = (1<<0), Activating = (1<<1) | Active, Deactivating = (1<<1), diff --git a/Resources/Locale/en-US/power/components/radiation-collector.ftl b/Resources/Locale/en-US/power/components/radiation-collector.ftl index d68296fbea..c38050f1e0 100644 --- a/Resources/Locale/en-US/power/components/radiation-collector.ftl +++ b/Resources/Locale/en-US/power/components/radiation-collector.ftl @@ -1,3 +1,2 @@ -power-radiation-collector-gas-tank-missing = [color=red]No gas tank attached.[/color] -power-radiation-collector-gas-tank-present = A gas tank is [color=darkgreen]connected[/color]. -power-radiation-collector-gas-tank-low-pressure = The gas tank [color=orange]low pressure[/color] light is on. \ No newline at end of file +power-radiation-collector-gas-tank-missing = [color=darkred]No plasma tank attached.[/color] +power-radiation-collector-gas-tank-present = A plasma tank is [color=darkgreen]connected[/color]. \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml index ecdc3b3fbc..d83e8b21fe 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml @@ -31,6 +31,18 @@ - state: ca_off map: ["enum.RadiationCollectorVisualLayers.Main"] - 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: NodeContainer examinable: true @@ -44,7 +56,6 @@ - reactantPrototype: Plasma powerGenerationEfficiency: 1 reactantBreakdownRate: 0.0002 - byproductPrototype: Tritium # Note that this doesn't matter too much (see next comment) # However it does act as a cap on power receivable via the collector. - type: Battery diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o0.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o0.png new file mode 100644 index 0000000000..5eefb01db6 Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o0.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o1.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o1.png new file mode 100644 index 0000000000..1902bbd8b9 Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o1.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o2.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o2.png new file mode 100644 index 0000000000..57a1eaa3ab Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o2.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o3.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o3.png new file mode 100644 index 0000000000..3522af81e5 Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o3.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-tank.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-tank.png new file mode 100644 index 0000000000..4d5049f7b4 Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-tank.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_active.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_active.png index 39dbf8d014..134c51bccb 100644 Binary files a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_active.png and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_active.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_deactive.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_deactive.png index 81f95545f4..e40e276e04 100644 Binary files a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_deactive.png and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_deactive.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_off.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_off.png index fa2741995e..a3cac04acb 100644 Binary files a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_off.png and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_off.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_on.png b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_on.png index 122c0ce45f..b9a49e1ec9 100644 Binary files a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_on.png and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_on.png differ diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/meta.json b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/meta.json index f03f3b29a6..f111c8a64a 100644 --- a/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/meta.json +++ b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/meta.json @@ -1,7 +1,7 @@ { "version": 1, "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": { "x": 32, "y": 32 @@ -39,6 +39,27 @@ }, { "name": "cu" + }, + { + "name": "ca-o0", + "delays": [ + [ + 0.2, + 0.2 + ] + ] + }, + { + "name": "ca-o1" + }, + { + "name": "ca-o2" + }, + { + "name": "ca-o3" + }, + { + "name": "ca-tank" } ] }