From ce7587a34efe1c24411db2ccf4d046d11a7a7212 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 11 Mar 2024 02:41:42 +1100 Subject: [PATCH] Cherry-picked commit 819ec6361d0d2792b43357a6c45f8c95cb08d9ed from space-wizards/space-station-14/master --- .../NPC/Systems/NPCSteeringSystem.Context.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Content.Server/NPC/Systems/NPCSteeringSystem.Context.cs b/Content.Server/NPC/Systems/NPCSteeringSystem.Context.cs index 7ac6768e359..e7af2c91073 100644 --- a/Content.Server/NPC/Systems/NPCSteeringSystem.Context.cs +++ b/Content.Server/NPC/Systems/NPCSteeringSystem.Context.cs @@ -56,7 +56,30 @@ private bool IsFreeSpace( return true; } - return false; + // TODO: Ideally for "FreeSpace" we check all entities on the tile and build flags dynamically (pathfinder refactor in future). + var ents = _entSetPool.Get(); + _lookup.GetLocalEntitiesIntersecting(node.GraphUid, node.ChunkOrigin, ents, flags: LookupFlags.Static); + var result = true; + + if (ents.Count > 0) + { + var fixtures = _fixturesQuery.GetComponent(uid); + var physics = _physicsQuery.GetComponent(uid); + + foreach (var intersecting in ents) + { + if (!_physics.IsCurrentlyHardCollidable((uid, fixtures, physics), intersecting)) + { + continue; + } + + result = false; + break; + } + } + + _entSetPool.Return(ents); + return result; } ///