From 0812233f206683e4783d82582b10420a8ef5edf2 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 2 Dec 2020 04:26:39 +1100 Subject: [PATCH] "Fix" doors getting stuck ond eny (#2647) Co-authored-by: Metal Gear Sloth --- .../Components/Doors/ServerDoorComponent.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index 641eb2a253..3f1810deb4 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -63,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Doors [ViewVariables(VVAccess.ReadWrite)] protected float CloseSpeed = AutoCloseDelay; - private readonly CancellationTokenSource _cancellationTokenSource = new(); + private CancellationTokenSource? _cancellationTokenSource; protected virtual TimeSpan CloseTimeOne => TimeSpan.FromSeconds(0.3f); protected virtual TimeSpan CloseTimeTwo => TimeSpan.FromSeconds(0.9f); @@ -259,6 +259,9 @@ namespace Content.Server.GameObjects.Components.Doors occluder.Enabled = false; } + _cancellationTokenSource?.Cancel(); + _cancellationTokenSource = new(); + Owner.SpawnTimer(OpenTimeOne, async () => { if (Owner.TryGetComponent(out AirtightComponent? airtight)) @@ -412,6 +415,9 @@ namespace Content.Server.GameObjects.Components.Doors occluder.Enabled = true; } + _cancellationTokenSource?.Cancel(); + _cancellationTokenSource = new(); + Owner.SpawnTimer(CloseTimeOne, async () => { if (shouldCheckCrush && _canCrush) @@ -444,6 +450,8 @@ namespace Content.Server.GameObjects.Components.Doors if (State == DoorState.Open || _isWeldedShut) return; + _cancellationTokenSource?.Cancel(); + _cancellationTokenSource = new(); SetAppearance(DoorVisualState.Deny); Owner.SpawnTimer(DenyTime, () => {