Prevent items from being dropped across impassable entities (#670)
This commit is contained in:
committed by
GitHub
parent
9544099c99
commit
f8a64bcd5c
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Server.GameObjects.Components;
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Server.GameObjects.Components.Stack;
|
using Content.Server.GameObjects.Components.Stack;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
@@ -15,8 +15,10 @@ using Robust.Shared.GameObjects.Systems;
|
|||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Map;
|
using Robust.Shared.Interfaces.Map;
|
||||||
|
using Robust.Shared.Interfaces.Physics;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
@@ -124,18 +126,25 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
if (handsComp.GetActiveHand == null)
|
if (handsComp.GetActiveHand == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange))
|
var dir = (coords.Position - ent.Transform.GridPosition.Position);
|
||||||
{
|
var ray = new CollisionRay(ent.Transform.GridPosition.Position, dir.Normalized, (int) CollisionGroup.Impassable);
|
||||||
handsComp.Drop(handsComp.ActiveIndex, coords);
|
var rayResults = IoCManager.Resolve<IPhysicsManager>().IntersectRay(ent.Transform.MapID, ray, dir.Length, ent);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var entCoords = ent.Transform.GridPosition.Position;
|
|
||||||
var entToDesiredDropCoords = coords.Position - entCoords;
|
|
||||||
var clampedDropCoords = ((entToDesiredDropCoords.Normalized * InteractionSystem.InteractionRange) + entCoords);
|
|
||||||
|
|
||||||
handsComp.Drop(handsComp.ActiveIndex, new GridCoordinates(clampedDropCoords, coords.GridID));
|
if(!rayResults.DidHitObject)
|
||||||
}
|
if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange))
|
||||||
|
{
|
||||||
|
handsComp.Drop(handsComp.ActiveIndex, coords);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var entCoords = ent.Transform.GridPosition.Position;
|
||||||
|
var entToDesiredDropCoords = coords.Position - entCoords;
|
||||||
|
var clampedDropCoords = ((entToDesiredDropCoords.Normalized * InteractionSystem.InteractionRange) + entCoords);
|
||||||
|
|
||||||
|
handsComp.Drop(handsComp.ActiveIndex, new GridCoordinates(clampedDropCoords, coords.GridID));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handsComp.Drop(handsComp.ActiveIndex, ent.Transform.GridPosition);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user