diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs index 7e10507e50..4124a7a219 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs @@ -31,9 +31,10 @@ namespace Content.Server.GameObjects.Components.Construction SpriteComponent Sprite; ITransformComponent Transform; - #pragma warning disable 649 +#pragma warning disable 649 [Dependency] private IRobustRandom _random; - #pragma warning restore 649 + [Dependency] private readonly IEntitySystemManager _entitySystemManager; +#pragma warning restore 649 public override void Initialize() { @@ -46,6 +47,13 @@ namespace Content.Server.GameObjects.Components.Construction public bool AttackBy(AttackByEventArgs eventArgs) { + var playerEntity = eventArgs.User; + var interactionSystem = _entitySystemManager.GetEntitySystem(); + if (!interactionSystem.InRangeUnobstructed(playerEntity.Transform.MapPosition, Owner.Transform.WorldPosition, ignoredEnt: Owner, insideBlockerValid: true)) + { + return false; + } + var stage = Prototype.Stages[Stage]; if (TryProcessStep(stage.Forward, eventArgs.AttackWith)) diff --git a/Content.Server/GameObjects/Components/Construction/ConstructorComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructorComponent.cs index 6dc83b2640..3ef1905fc6 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructorComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructorComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using Content.Server.GameObjects.Components.Stack; using Content.Server.GameObjects.EntitySystems; using Content.Shared.Construction; @@ -29,7 +29,6 @@ namespace Content.Server.GameObjects.Components.Construction public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) { base.HandleMessage(message, netChannel, component); - switch (message) { case TryStartStructureConstructionMessage tryStart: @@ -43,7 +42,9 @@ namespace Content.Server.GameObjects.Components.Construction var prototype = _prototypeManager.Index(prototypeName); var transform = Owner.Transform; - if (!loc.InRange(_mapManager, transform.GridPosition, InteractionSystem.InteractionRange)) + + var interactionSystem = _entitySystemManager.GetEntitySystem(); + if (!interactionSystem.InRangeUnobstructed(loc.ToMap(_mapManager), Owner.Transform.WorldPosition, ignoredEnt: Owner, insideBlockerValid: true)) { return; }