From e5150d3714eb8280fa18db706fa623f25ecef7ac Mon Sep 17 00:00:00 2001 From: rok-povsic Date: Sun, 10 Nov 2019 21:50:13 +0100 Subject: [PATCH] Fix crowbar distance to work on adjacent tiles (#424) * Fix crowbar distance to work on max 1.5 tiles * Use existing distance methods * Use the existing InteractionRange --- .../Interactable/Tools/CrowbarComponent.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs index 2f61ad57ed..eb97ac142d 100644 --- a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs @@ -1,4 +1,5 @@ -using Content.Server.GameObjects.EntitySystems; +using System; +using Content.Server.GameObjects.EntitySystems; using Content.Shared.Maps; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; @@ -27,6 +28,15 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools { var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); + + var coordinates = mapGrid.GridTileToLocal(tile.GridIndices); + float distance = coordinates.Distance(_mapManager, Owner.Transform.GridPosition); + + if (distance > InteractionSystem.InteractionRange) + { + return; + } + var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId]; if (tileDef.CanCrowbar) {