]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Radiation collector sprite update (#20956)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Fri, 13 Oct 2023 23:08:00 +0000 (18:08 -0500)
committerGitHub <noreply@github.com>
Fri, 13 Oct 2023 23:08:00 +0000 (19:08 -0400)
14 files changed:
Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs
Content.Shared/Singularity/Components/SharedRadiationCollectorComponent.cs
Resources/Locale/en-US/power/components/radiation-collector.ftl
Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o0.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o1.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o2.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-o3.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-tank.png [new file with mode: 0644]
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_active.png
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_deactive.png
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_off.png
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca_on.png
Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/meta.json

index 19d9b98f4abbbf9119691d271a75518b4a176c94..27219bb1837c6f100b5414cc7cbd6839b09c0856 100644 (file)
@@ -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<RadiationCollectorComponent, OnIrradiatedEvent>(OnRadiation);
         SubscribeLocalEvent<RadiationCollectorComponent, ExaminedEvent>(OnExamined);
         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)
@@ -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);
+    }
 }
index 44cdea4fb69171948d816cadefc18a62aad85253..0b5fbea648907639ef8af367c707b20374f1eda1 100644 (file)
@@ -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),
index d68296fbeaccd60adde3236b9f302db7ad0a60e9..c38050f1e0ac29940d974fb1954b0582944565ca 100644 (file)
@@ -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
index ecdc3b3fbcb5ebd154228368999eb7276b208cd0..d83e8b21fe1ea6d4abd73c8d0b219edbe3258bc0 100644 (file)
       - 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 (file)
index 0000000..5eefb01
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 (file)
index 0000000..1902bbd
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 (file)
index 0000000..57a1eaa
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 (file)
index 0000000..3522af8
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 (file)
index 0000000..4d5049f
Binary files /dev/null and b/Resources/Textures/Structures/Power/Generation/Singularity/collector.rsi/ca-tank.png differ
index 39dbf8d014cf2f650810a0061cee098b6aad2676..134c51bccb01fbcd4dcbb68fd1b7df8a6fafc0e5 100644 (file)
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
index 81f95545f44d23948b217d7300988dda110d729d..e40e276e04035dd21310865827ea52c80f704fde 100644 (file)
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
index fa2741995e7fc5ef59d4996c3d17c953462db377..a3cac04acb3b5f649436c9c04811396ee7ab9eb9 100644 (file)
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
index 122c0ce45fba16f8503c1e86a73b5a1c409fe45b..b9a49e1ec9892b4a4beb9175fc56754b5d90d413 100644 (file)
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
index f03f3b29a6b9f2a4d067c5b9f2d3a0edfe48f863..f111c8a64adb973bc47e30ac6157b775ae09c78c 100644 (file)
@@ -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
     },
     {
       "name": "cu"
+    },
+       {
+      "name": "ca-o0",
+      "delays": [
+        [
+          0.2,
+          0.2
+        ]
+      ]
+    },
+    {
+      "name": "ca-o1"
+    },
+    {
+      "name": "ca-o2"
+    },
+    {
+      "name": "ca-o3"
+    },
+       {
+      "name": "ca-tank"
     }
   ]
 }