diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 22a87d717f..f3c30211e4 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -78,11 +78,16 @@ namespace Content.Server.GameObjects public bool CanPickup(IEntity user) { - var coords = Owner.Transform.GridPosition; - if (!ActionBlockerSystem.CanPickup(user)) return false; + + if (user.Transform.MapID != Owner.Transform.MapID) + return false; + + var userPos = user.Transform.MapPosition; + var itemPos = Owner.Transform.WorldPosition; + return _entitySystemManager.GetEntitySystem() - .InRangeUnobstructed(coords, user.Transform.GridPosition, ignoredEnt:Owner); + .InRangeUnobstructed(userPos, itemPos, ignoredEnt: Owner); } public bool AttackHand(AttackHandEventArgs eventArgs) diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index e8297572f2..9f633b3c08 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -273,24 +273,26 @@ namespace Content.Server.GameObjects.EntitySystems /// If the is zero or negative, /// this method will only check if nothing obstructs the two sets of coordinates.. /// - /// Map manager containing the two GridIds. /// Set of coordinates to use. /// Other set of coordinates to use. /// maximum distance between the two sets of coordinates. /// the mask to check for collisions /// the entity to be ignored when checking for collisions. + /// Map manager containing the two GridIds. /// True if the two points are within a given range without being obstructed. - public bool InRangeUnobstructed(GridCoordinates coords, GridCoordinates otherCoords, float range = InteractionRange, int collisionMask = (int)CollisionGroup.Impassable, IEntity ignoredEnt = null) + public bool InRangeUnobstructed(MapCoordinates coords, Vector2 otherCoords, float range = InteractionRange, + int collisionMask = (int) CollisionGroup.Impassable, IEntity ignoredEnt = null) { - if (range > 0f && !coords.InRange(_mapManager, otherCoords, range)) - { - return false; - } + var dir = otherCoords - coords.Position; + + if (dir.LengthSquared.Equals(0f)) + return true; + + if (range > 0f && !(dir.LengthSquared <= range*range)) + return false; - var dir = (otherCoords.Position - coords.Position); - if (!(dir.Length > 0f)) return true; var ray = new CollisionRay(coords.Position, dir.Normalized, collisionMask); - var rayResults = _physicsManager.IntersectRay(_mapManager.GetGrid(coords.GridID).ParentMapId, ray, dir.Length, ignoredEnt); + var rayResults = _physicsManager.IntersectRay(coords.MapId, ray, dir.Length, ignoredEnt); return !rayResults.DidHitObject; } diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index ff0ba8f614..79d0048f76 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -126,7 +126,7 @@ namespace Content.Server.GameObjects.EntitySystems var interactionSystem = _entitySystemManager.GetEntitySystem(); - if(interactionSystem.InRangeUnobstructed(coords, ent.Transform.GridPosition, 0f, ignoredEnt:ent)) + if(interactionSystem.InRangeUnobstructed(coords.ToMap(_mapManager), ent.Transform.WorldPosition, 0f, ignoredEnt: ent)) if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange)) { handsComp.Drop(handsComp.ActiveIndex, coords); diff --git a/RobustToolbox b/RobustToolbox index 643c76b28e..8f968760cb 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 643c76b28ea9d0612a38326d08c277de013153b6 +Subproject commit 8f968760cbc3a4d4ce84b38d51845ee2ff435c0f