From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 28 Sep 2024 09:02:43 +0000 (+1000) Subject: Fix multiple door issues (#32483) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=bed968465c94516732e5b1528e2efb704cadbeaf;p=space-station-14.git Fix multiple door issues (#32483) * Fix multiple door issues - Doors should no longer cycle open-and-closed anymore (at least nowhere near as easily). - Door sprites shouldn't flicker as much (needs my engine PRs to remove all but one of them). * woops conversion --- diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 3d9a721473..4d88663ca0 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -23,6 +23,7 @@ using Robust.Shared.Timing; using Robust.Shared.Audio.Systems; using Robust.Shared.Network; using Robust.Shared.Map.Components; +using Robust.Shared.Physics; namespace Content.Shared.Doors.Systems; @@ -49,21 +50,13 @@ public abstract partial class SharedDoorSystem : EntitySystem [ValidatePrototypeId] public const string DoorBumpTag = "DoorBumpOpener"; - /// - /// A body must have an intersection percentage larger than this in order to be considered as colliding with a - /// door. Used for safety close-blocking and crushing. - /// - /// - /// The intersection percentage relies on WORLD AABBs. So if this is too small, and the grid is rotated 45 - /// degrees, then an entity outside of the airlock may be crushed. - /// - public const float IntersectPercentage = 0.2f; - /// /// A set of doors that are currently opening, closing, or just queued to open/close after some delay. /// private readonly HashSet> _activeDoors = new(); + private readonly HashSet> _doorIntersecting = new(); + public override void Initialize() { base.Initialize(); @@ -163,7 +156,6 @@ public abstract partial class SharedDoorSystem : EntitySystem _activeDoors.Add(ent); RaiseLocalEvent(ent, new DoorStateChangedEvent(door.State)); - AppearanceSystem.SetData(ent, DoorVisuals.State, door.State); } protected bool SetState(EntityUid uid, DoorState state, DoorComponent? door = null) @@ -211,6 +203,7 @@ public abstract partial class SharedDoorSystem : EntitySystem door.State = state; Dirty(uid, door); RaiseLocalEvent(uid, new DoorStateChangedEvent(state)); + AppearanceSystem.SetData(uid, DoorVisuals.State, door.State); return true; } @@ -557,20 +550,25 @@ public abstract partial class SharedDoorSystem : EntitySystem if (!TryComp(xform.GridUid, out var mapGridComp)) yield break; var tileRef = _mapSystem.GetTileRef(xform.GridUid.Value, mapGridComp, xform.Coordinates); - var doorWorldBounds = _entityLookup.GetWorldBounds(tileRef); + + _doorIntersecting.Clear(); + + _entityLookup.GetLocalEntitiesIntersecting(xform.GridUid.Value, tileRef.GridIndices, _doorIntersecting, gridComp: mapGridComp); // TODO SLOTH fix electro's code. // ReSharper disable once InconsistentNaming - var doorAABB = _entityLookup.GetWorldAABB(uid); - foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorWorldBounds)) + foreach (var otherPhysics in _doorIntersecting) { if (otherPhysics.Comp == physics) continue; + if (!otherPhysics.Comp.CanCollide) + continue; + //TODO: Make only shutters ignore these objects upon colliding instead of all airlocks // Excludes Glasslayer for windows, GlassAirlockLayer for windoors, TableLayer for tables - if (!otherPhysics.Comp.CanCollide || otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.GlassLayer || otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.GlassAirlockLayer || otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.TableLayer) + if (otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.GlassLayer || otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.GlassAirlockLayer || otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.TableLayer) continue; //If the colliding entity is a slippable item ignore it by the airlock @@ -584,9 +582,6 @@ public abstract partial class SharedDoorSystem : EntitySystem if ((physics.CollisionMask & otherPhysics.Comp.CollisionLayer) == 0 && (otherPhysics.Comp.CollisionMask & physics.CollisionLayer) == 0) continue; - if (_entityLookup.GetWorldAABB(otherPhysics.Owner).IntersectPercentage(doorAABB) < IntersectPercentage) - continue; - yield return otherPhysics.Owner; } } @@ -614,7 +609,7 @@ public abstract partial class SharedDoorSystem : EntitySystem var otherUid = args.OtherEntity; if (Tags.HasTag(otherUid, DoorBumpTag)) - TryOpen(uid, door, otherUid, quiet: door.State == DoorState.Denying); + TryOpen(uid, door, otherUid, quiet: door.State == DoorState.Denying, predicted: true); } #endregion @@ -714,7 +709,7 @@ public abstract partial class SharedDoorSystem : EntitySystem var (uid, door, physics) = ent; if (door.BumpOpen) { - foreach (var other in PhysicsSystem.GetContactingEntities(uid, physics, approximate: true)) + foreach (var other in PhysicsSystem.GetContactingEntities(uid, physics)) { if (Tags.HasTag(other, DoorBumpTag) && TryOpen(uid, door, other, quiet: true)) break;