From 0cc6c4c5556c20891a6aeb4386b6a4407e75abfb Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 20 Mar 2022 14:46:07 +1300 Subject: [PATCH] Crafting obstruction check. (#7198) * Crafting obstruction check. * and container check --- Content.Server/Construction/ConstructionSystem.Initial.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 3795c575fa..80f99afb70 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -27,6 +27,7 @@ namespace Content.Server.Construction [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly EntityLookupSystem _lookupSystem = default!; // --- WARNING! LEGACY CODE AHEAD! --- // This entire file contains the legacy code for initial construction. @@ -75,9 +76,12 @@ namespace Content.Server.Construction } } - foreach (var near in EntitySystem.Get().GetEntitiesInRange(user!, 2f, LookupFlags.Approximate)) + var pos = Transform(user).MapPosition; + + foreach (var near in _lookupSystem.GetEntitiesInRange(user!, 2f, LookupFlags.Approximate)) { - yield return near; + if (_interactionSystem.InRangeUnobstructed(pos, near, 2f) && _containerSystem.IsInSameOrParentContainer(user, near)) + yield return near; } }