From: Plykiya <58439124+Plykiya@users.noreply.github.com> Date: Sun, 28 Jul 2024 03:18:12 +0000 (-0700) Subject: Update SharedDoorSystem.cs to not use Component.Owner (#29963) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=7f9e06501f392df12e05b8db7c2f315b33e42115;p=space-station-14.git Update SharedDoorSystem.cs to not use Component.Owner (#29963) * Update SharedDoorSystem.cs * comment * empty space --------- Co-authored-by: plykiya --- diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index ab2df72568..2319d5e916 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -21,6 +21,7 @@ using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; using Robust.Shared.Audio.Systems; using Robust.Shared.Network; +using Robust.Shared.Map.Components; namespace Content.Shared.Doors.Systems; @@ -40,6 +41,8 @@ public abstract partial class SharedDoorSystem : EntitySystem [Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!; [Dependency] private readonly PryingSystem _pryingSystem = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!; + [Dependency] private readonly SharedMapSystem _mapSystem = default!; + [ValidatePrototypeId] public const string DoorBumpTag = "DoorBumpOpener"; @@ -546,29 +549,37 @@ public abstract partial class SharedDoorSystem : EntitySystem if (!Resolve(uid, ref physics)) yield break; + var xform = Transform(uid); + // Getting the world bounds from the gridUid allows us to use the version of + // GetCollidingEntities that returns Entity + if (!TryComp(xform.GridUid, out var mapGridComp)) + yield break; + var tileRef = _mapSystem.GetTileRef(xform.GridUid.Value, mapGridComp, xform.Coordinates); + var doorWorldBounds = _entityLookup.GetWorldBounds(tileRef); + // TODO SLOTH fix electro's code. // ReSharper disable once InconsistentNaming var doorAABB = _entityLookup.GetWorldAABB(uid); - foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) + foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorWorldBounds)) { - if (otherPhysics == physics) + if (otherPhysics.Comp == physics) 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.CanCollide || otherPhysics.CollisionLayer == (int)CollisionGroup.GlassLayer || otherPhysics.CollisionLayer == (int)CollisionGroup.GlassAirlockLayer || otherPhysics.CollisionLayer == (int)CollisionGroup.TableLayer) + if (!otherPhysics.Comp.CanCollide || 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 - if (otherPhysics.CollisionLayer == (int)CollisionGroup.SlipLayer && otherPhysics.CollisionMask == (int)CollisionGroup.ItemMask) + if (otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.SlipLayer && otherPhysics.Comp.CollisionMask == (int) CollisionGroup.ItemMask) continue; //For when doors need to close over conveyor belts - if (otherPhysics.CollisionLayer == (int) CollisionGroup.ConveyorMask) + if (otherPhysics.Comp.CollisionLayer == (int) CollisionGroup.ConveyorMask) continue; - if ((physics.CollisionMask & otherPhysics.CollisionLayer) == 0 && (otherPhysics.CollisionMask & physics.CollisionLayer) == 0) + if ((physics.CollisionMask & otherPhysics.Comp.CollisionLayer) == 0 && (otherPhysics.Comp.CollisionMask & physics.CollisionLayer) == 0) continue; if (_entityLookup.GetWorldAABB(otherPhysics.Owner).IntersectPercentage(doorAABB) < IntersectPercentage)