]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Powered stasis bed prevents body decay (#23520)
authorKot <1192090+koteq@users.noreply.github.com>
Tue, 9 Jan 2024 06:40:52 +0000 (10:40 +0400)
committerGitHub <noreply@github.com>
Tue, 9 Jan 2024 06:40:52 +0000 (01:40 -0500)
* Powered stasis bed prevents body decay

* Update following CR comments

* Remove unused import

* Simplify if-statements

* Change implementation following CR suggestions

* Add comment & remove explicit get/set

Content.Server/Atmos/Rotting/RottingSystem.cs
Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs [new file with mode: 0644]
Content.Shared/Atmos/Rotting/AntiRotOnBuckleComponent.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Structures/Machines/stasisbed.yml

index 2d430a74ac60b4d1a533e8599be1b2fd530fb4fa..db0815f3a67f83d6843d54ac886e9528ec00fff4 100644 (file)
@@ -101,7 +101,7 @@ public sealed class RottingSystem : EntitySystem
         var ev = new IsRottingEvent();
         RaiseLocalEvent(uid, ref ev);
 
-        return ev.Handled;
+        return !ev.Handled;
     }
 
     public bool IsRotten(EntityUid uid, RottingComponent? rotting = null)
@@ -154,7 +154,7 @@ public sealed class RottingSystem : EntitySystem
     {
         if (args.Handled)
             return;
-        args.Handled = component.CurrentTemperature > Atmospherics.T0C + 0.85f;
+        args.Handled = component.CurrentTemperature < Atmospherics.T0C + 0.85f;
     }
 
     public override void Update(float frameTime)
diff --git a/Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs b/Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs
new file mode 100644 (file)
index 0000000..4458b02
--- /dev/null
@@ -0,0 +1,29 @@
+using Content.Server.Power.Components;
+using Content.Shared.Atmos.Rotting;
+using Content.Shared.Buckle.Components;
+
+namespace Content.Server.Buckle.Systems;
+
+public sealed class AntiRotOnBuckleSystem : EntitySystem
+{
+    public override void Initialize()
+    {
+        base.Initialize();
+        SubscribeLocalEvent<BuckleComponent, IsRottingEvent>(OnIsRotting);
+        SubscribeLocalEvent<AntiRotOnBuckleComponent, PowerChangedEvent>(OnPowerChanged);
+    }
+
+    private void OnIsRotting(EntityUid uid, BuckleComponent buckle, ref IsRottingEvent args)
+    {
+        if (args.Handled)
+            return;
+        args.Handled = buckle is { Buckled: true, BuckledTo: not null } &&
+                       TryComp<AntiRotOnBuckleComponent>(buckle.BuckledTo.Value, out var antiRot) &&
+                       antiRot.Enabled;
+    }
+
+    private void OnPowerChanged(EntityUid uid, AntiRotOnBuckleComponent component, ref PowerChangedEvent args)
+    {
+        component.Enabled = !component.RequiresPower || args.Powered;
+    }
+}
diff --git a/Content.Shared/Atmos/Rotting/AntiRotOnBuckleComponent.cs b/Content.Shared/Atmos/Rotting/AntiRotOnBuckleComponent.cs
new file mode 100644 (file)
index 0000000..59c5543
--- /dev/null
@@ -0,0 +1,22 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Atmos.Rotting;
+
+/// <summary>
+/// Perishable entities buckled to an entity with this component will stop rotting.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class AntiRotOnBuckleComponent : Component
+{
+    /// <summary>
+    /// Does this component require power to function.
+    /// </summary>
+    [DataField("requiresPower"), ViewVariables(VVAccess.ReadWrite)]
+    public bool RequiresPower = true;
+
+    /// <summary>
+    /// Whether this component is active or not.
+    /// </summarY>
+    [ViewVariables(VVAccess.ReadWrite)]
+    public bool Enabled = true;
+}
index 45d5d2b75c4ca8a869dfe854aa3dafaa6186cddc..5f7182f7ddc6e4c03469a7af7bc144923c42dafa 100644 (file)
@@ -2,10 +2,11 @@
   id: StasisBed
   name: stasis bed
   parent: [ BaseMachinePowered, ConstructibleMachine ]
-  description: A bed that massively slows down the patient's metabolism, allowing more time to administer a proper treatment for stabilization.
+  description: A bed that massively slows down the patient's metabolism and prevents bodily decay, allowing more time to administer a proper treatment for stabilization.
   components:
   - type: StasisBed
     baseMultiplier: 10
+  - type: AntiRotOnBuckle
   - type: Sprite
     sprite: Structures/Machines/stasis_bed.rsi
     noRot: true