From: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Date: Mon, 25 Nov 2024 04:26:54 +0000 (+0100)
Subject: fix airlocks inconsistently auto-closing after unbolting (#33524)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3c6c5ab6c937f7b36da73fc171eb3179f230ee30;p=space-station-14.git
fix airlocks inconsistently auto-closing after unbolting (#33524)
fix door auto close timer
---
diff --git a/Content.Shared/Doors/Components/DoorComponent.cs b/Content.Shared/Doors/Components/DoorComponent.cs
index 21fad142b3..5e35045b10 100644
--- a/Content.Shared/Doors/Components/DoorComponent.cs
+++ b/Content.Shared/Doors/Components/DoorComponent.cs
@@ -66,7 +66,7 @@ public sealed partial class DoorComponent : Component
///
/// When the door is active, this is the time when the state will next update.
///
- [AutoNetworkedField]
+ [AutoNetworkedField, ViewVariables]
public TimeSpan? NextStateChange;
///
diff --git a/Content.Shared/Doors/DoorEvents.cs b/Content.Shared/Doors/DoorEvents.cs
index 08a2c8b18b..849ea83730 100644
--- a/Content.Shared/Doors/DoorEvents.cs
+++ b/Content.Shared/Doors/DoorEvents.cs
@@ -15,6 +15,19 @@ namespace Content.Shared.Doors
}
}
+ ///
+ /// Raised when the door's bolt status was changed.
+ ///
+ public sealed class DoorBoltsChangedEvent : EntityEventArgs
+ {
+ public readonly bool BoltsDown;
+
+ public DoorBoltsChangedEvent(bool boltsDown)
+ {
+ BoltsDown = boltsDown;
+ }
+ }
+
///
/// Raised when the door is determining whether it is able to open.
/// Cancel to stop the door from being opened.
diff --git a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs
index e404a91bdd..bdd119004e 100644
--- a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs
+++ b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs
@@ -22,6 +22,7 @@ public abstract class SharedAirlockSystem : EntitySystem
SubscribeLocalEvent(OnBeforeDoorClosed);
SubscribeLocalEvent(OnStateChanged);
+ SubscribeLocalEvent(OnBoltsChanged);
SubscribeLocalEvent(OnBeforeDoorOpened);
SubscribeLocalEvent(OnBeforeDoorDenied);
SubscribeLocalEvent(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);
diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.Bolts.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.Bolts.cs
index 13050616e1..d14b6c7190 100644
--- a/Content.Shared/Doors/Systems/SharedDoorSystem.Bolts.cs
+++ b/Content.Shared/Doors/Systems/SharedDoorSystem.Bolts.cs
@@ -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);
diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs
index 7fd5d61db7..835adb31c0 100644
--- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs
+++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs
@@ -700,6 +700,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
}
door.NextStateChange = GameTiming.CurTime + delay.Value;
+ Dirty(uid, door);
+
_activeDoors.Add((uid, door));
}