]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix airlocks inconsistently auto-closing after unbolting (#33524)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Mon, 25 Nov 2024 04:26:54 +0000 (05:26 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Nov 2024 04:26:54 +0000 (15:26 +1100)
fix door auto close timer

Content.Shared/Doors/Components/DoorComponent.cs
Content.Shared/Doors/DoorEvents.cs
Content.Shared/Doors/Systems/SharedAirlockSystem.cs
Content.Shared/Doors/Systems/SharedDoorSystem.Bolts.cs
Content.Shared/Doors/Systems/SharedDoorSystem.cs

index 21fad142b3a2d0641f37f58b673b643d56db83d5..5e35045b109eedf46e6b14d2b12d915fabf72756 100644 (file)
@@ -66,7 +66,7 @@ public sealed partial class DoorComponent : Component
     /// <summary>
     ///     When the door is active, this is the time when the state will next update.
     /// </summary>
-    [AutoNetworkedField]
+    [AutoNetworkedField, ViewVariables]
     public TimeSpan? NextStateChange;
 
     /// <summary>
index 08a2c8b18b103c102f0085644b6996dd7f60c706..849ea837303ac635b0bc3ad6ccfda48545f33a6e 100644 (file)
@@ -15,6 +15,19 @@ namespace Content.Shared.Doors
         }
     }
 
+    /// <summary>
+    /// Raised when the door's bolt status was changed.
+    /// </summary>
+    public sealed class DoorBoltsChangedEvent : EntityEventArgs
+    {
+        public readonly bool BoltsDown;
+
+        public DoorBoltsChangedEvent(bool boltsDown)
+        {
+            BoltsDown = boltsDown;
+        }
+    }
+
     /// <summary>
     /// Raised when the door is determining whether it is able to open.
     /// Cancel to stop the door from being opened.
index e404a91bdd74ff4ad1cbe76b6e0a36bdcabfe4f4..bdd119004e84a37f0721fa119adbea893a6413f1 100644 (file)
@@ -22,6 +22,7 @@ public abstract class SharedAirlockSystem : EntitySystem
 
         SubscribeLocalEvent<AirlockComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
         SubscribeLocalEvent<AirlockComponent, DoorStateChangedEvent>(OnStateChanged);
+        SubscribeLocalEvent<AirlockComponent, DoorBoltsChangedEvent>(OnBoltsChanged);
         SubscribeLocalEvent<AirlockComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
         SubscribeLocalEvent<AirlockComponent, BeforeDoorDeniedEvent>(OnBeforeDoorDenied);
         SubscribeLocalEvent<AirlockComponent, GetPryTimeModifierEvent>(OnGetPryMod);
@@ -70,6 +71,13 @@ public abstract class SharedAirlockSystem : EntitySystem
         }
     }
 
+    private void OnBoltsChanged(EntityUid uid, AirlockComponent component, DoorBoltsChangedEvent args)
+    {
+        // If unbolted, reset the auto close timer
+        if (!args.BoltsDown)
+            UpdateAutoClose(uid, component);
+    }
+
     private void OnBeforeDoorOpened(EntityUid uid, AirlockComponent component, BeforeDoorOpenedEvent args)
     {
         if (!CanChangeState(uid, component))
@@ -145,7 +153,7 @@ public abstract class SharedAirlockSystem : EntitySystem
         ent.Comp.EmergencyAccess = value;
         Dirty(ent, ent.Comp); // This only runs on the server apparently so we need this.
         UpdateEmergencyLightStatus(ent, ent.Comp);
-               
+
         var sound = ent.Comp.EmergencyAccess ? ent.Comp.EmergencyOnSound : ent.Comp.EmergencyOffSound;
         if (predicted)
             Audio.PlayPredicted(sound, ent, user: user);
index 13050616e1ba5e5fed59683bfe894d39ff96a8ef..d14b6c71906e231d03f218dddcbfb29aff13d9f5 100644 (file)
@@ -96,6 +96,10 @@ public abstract partial class SharedDoorSystem
         Dirty(ent, ent.Comp);
         UpdateBoltLightStatus(ent);
 
+        // used to reset the auto-close timer after unbolting
+        var ev = new DoorBoltsChangedEvent(value);
+        RaiseLocalEvent(ent.Owner, ev);
+
         var sound = value ? ent.Comp.BoltDownSound : ent.Comp.BoltUpSound;
         if (predicted)
             Audio.PlayPredicted(sound, ent, user: user);
index 7fd5d61db7dd8ac74459f30a8a79819d22c9ea30..835adb31c05bae2f72ca1ff28dfc968a09b60088 100644 (file)
@@ -700,6 +700,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
         }
 
         door.NextStateChange = GameTiming.CurTime + delay.Value;
+        Dirty(uid, door);
+
         _activeDoors.Add((uid, door));
     }