From 093d65e92a8b696f2aca437b7dcb4b371c821861 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 12 Jun 2022 11:15:53 +1000 Subject: [PATCH] Hotfix door bumps (#8665) Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> --- Content.Server/Doors/Systems/DoorSystem.cs | 19 ++++++++++--- .../Doors/Systems/SharedDoorSystem.cs | 27 ++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index 81988efacf..3b9d3c5efe 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -25,11 +25,10 @@ namespace Content.Server.Doors.Systems; public sealed class DoorSystem : SharedDoorSystem { + [Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!; + [Dependency] private readonly AirtightSystem _airtightSystem = default!; [Dependency] private readonly ConstructionSystem _constructionSystem = default!; [Dependency] private readonly ToolSystem _toolSystem = default!; - [Dependency] private readonly AirtightSystem _airtightSystem = default!; - [Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!; - [Dependency] private readonly TagSystem _tagSystem = default!; public override void Initialize() { @@ -239,7 +238,7 @@ public sealed class DoorSystem : SharedDoorSystem var otherUid = args.OtherFixture.Body.Owner; - if (_tagSystem.HasTag(otherUid, "DoorBumpOpener")) + if (Tags.HasTag(otherUid, "DoorBumpOpener")) TryOpen(uid, door, otherUid); } @@ -298,6 +297,18 @@ public sealed class DoorSystem : SharedDoorSystem if(lastState == DoorState.Emagging && TryComp(door.Owner, out var airlockComponent)) airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted()); } + + protected override void CheckDoorBump(DoorComponent component, PhysicsComponent body) + { + if (component.BumpOpen) + { + foreach (var other in PhysicsSystem.GetCollidingEntities(body)) + { + if (Tags.HasTag(other.Owner, "DoorBumpOpener") && + TryOpen(component.Owner, component, other.Owner)) break; + } + } + } } public sealed class PryFinishedEvent : EntityEventArgs { } diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 4b61af267a..d91185ac17 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -10,14 +10,16 @@ using Robust.Shared.Physics; using Robust.Shared.Physics.Dynamics; using Robust.Shared.Timing; using System.Linq; +using Content.Shared.Tag; namespace Content.Shared.Doors.Systems; public abstract class SharedDoorSystem : EntitySystem { - [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; + [Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly SharedStunSystem _stunSystem = default!; + [Dependency] protected readonly TagSystem Tags = default!; [Dependency] protected readonly IGameTiming GameTiming = default!; /// @@ -139,15 +141,18 @@ public abstract class SharedDoorSystem : EntitySystem break; case DoorState.Open: - case DoorState.Closed: door.Partial = false; if (door.NextStateChange == null) _activeDoors.Remove(door); break; + case DoorState.Closed: + // May want to keep the door around to re-check for opening if we got a contact during closing. + door.Partial = false; + break; } door.State = state; - door.Dirty(); + Dirty(door); RaiseLocalEvent(uid, new DoorStateChangedEvent(state), false); UpdateAppearance(uid, door); } @@ -280,7 +285,7 @@ public abstract class SharedDoorSystem : EntitySystem door.Partial = true; door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo; _activeDoors.Add(door); - door.Dirty(); + Dirty(door); } #endregion @@ -335,7 +340,7 @@ public abstract class SharedDoorSystem : EntitySystem return false; door.Partial = true; - door.Dirty(); + Dirty(door); // Make sure no entity waled into the airlock when it started closing. if (!CanClose(uid, door)) @@ -417,7 +422,7 @@ public abstract class SharedDoorSystem : EntitySystem // TODO SLOTH fix electro's code. var doorAABB = physics.GetWorldAABB(); - foreach (var otherPhysics in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) + foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) { if (otherPhysics == physics) continue; @@ -536,9 +541,19 @@ public abstract class SharedDoorSystem : EntitySystem if (door.NextStateChange.Value < time) NextState(door, time); + + if (door.State == DoorState.Closed && + TryComp(door.Owner, out var doorBody)) + { + // If something bumped into us during closing then start to re-open, otherwise, remove it from active. + _activeDoors.Remove(door); + CheckDoorBump(door, doorBody); + } } } + protected virtual void CheckDoorBump(DoorComponent component, PhysicsComponent body) {} + /// /// Makes a door proceed to the next state (if applicable). ///