fix airlocks inconsistently auto-closing after unbolting (#33524)
fix door auto close timer
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -700,6 +700,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
}
|
||||
|
||||
door.NextStateChange = GameTiming.CurTime + delay.Value;
|
||||
Dirty(uid, door);
|
||||
|
||||
_activeDoors.Add((uid, door));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user