diff --git a/Content.Shared/Doors/Components/DoorComponent.cs b/Content.Shared/Doors/Components/DoorComponent.cs index b90e482fdf..7a86117a2a 100644 --- a/Content.Shared/Doors/Components/DoorComponent.cs +++ b/Content.Shared/Doors/Components/DoorComponent.cs @@ -140,7 +140,7 @@ public sealed class DoorComponent : Component, ISerializationHooks /// List of EntityUids of entities we're currently crushing. Cleared in OnPartialOpen(). /// [DataField("currentlyCrushing")] - public List CurrentlyCrushing = new(); + public HashSet CurrentlyCrushing = new(); #endregion #region Serialization @@ -238,7 +238,7 @@ public enum DoorVisuals public sealed class DoorComponentState : ComponentState { public readonly DoorState DoorState; - public readonly List CurrentlyCrushing; + public readonly HashSet CurrentlyCrushing; public readonly TimeSpan? NextStateChange; public readonly bool Partial; diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index f6540e3a6d..2e901dcc52 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -99,7 +99,7 @@ public abstract class SharedDoorSystem : EntitySystem if (args.Current is not DoorComponentState state) return; - door.CurrentlyCrushing = state.CurrentlyCrushing; + door.CurrentlyCrushing = new(state.CurrentlyCrushing); door.State = state.DoorState; door.NextStateChange = state.NextStateChange; door.Partial = state.Partial; @@ -337,7 +337,6 @@ public abstract class SharedDoorSystem : EntitySystem if (!Resolve(uid, ref door, ref physics)) return false; - SetCollidable(uid, true, door, physics); door.Partial = true; door.Dirty(); @@ -350,6 +349,7 @@ public abstract class SharedDoorSystem : EntitySystem return false; } + SetCollidable(uid, true, door, physics); door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo; _activeDoors.Add(door); @@ -421,16 +421,22 @@ public abstract class SharedDoorSystem : EntitySystem // TODO SLOTH fix electro's code. var doorAABB = physics.GetWorldAABB(); - foreach (var body in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) + foreach (var otherPhysics in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) { - // static bodies (e.g., furniture) shouldn't stop airlocks/windoors from closing. - if (body.BodyType == BodyType.Static) + if (otherPhysics == physics) continue; - if (body.GetWorldAABB().IntersectPercentage(doorAABB) < IntersectPercentage) + if (!otherPhysics.CanCollide) continue; - yield return body.Owner; + if ((physics.CollisionMask & otherPhysics.CollisionLayer) == 0 + && (otherPhysics.CollisionMask & physics.CollisionLayer) == 0) + continue; + + if (otherPhysics.GetWorldAABB().IntersectPercentage(doorAABB) < IntersectPercentage) + continue; + + yield return otherPhysics.Owner; } }