Adds InRangeUnobstructed method to InteractionSystem (#698)

* You cannot pickup items across walls, or pickup items when dead/in crit.

* Adds InRangeUnobstructed method to InteractionSystem.
Changes HandsSystem and ItemComponent to use it.
This commit is contained in:
Víctor Aguilera Puerto
2020-02-16 23:04:06 +01:00
committed by GitHub
parent c7a171cf14
commit 70c41f63b0
6 changed files with 88 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
@@ -126,11 +127,9 @@ namespace Content.Server.GameObjects.EntitySystems
if (handsComp.GetActiveHand == null)
return false;
var dir = (coords.Position - ent.Transform.GridPosition.Position);
var ray = new CollisionRay(ent.Transform.GridPosition.Position, dir.Normalized, (int) CollisionGroup.Impassable);
var rayResults = IoCManager.Resolve<IPhysicsManager>().IntersectRay(ent.Transform.MapID, ray, dir.Length, ent);
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
if(!rayResults.DidHitObject)
if(interactionSystem.InRangeUnobstructed(coords, ent.Transform.GridPosition, 0f, ignoredEnt:ent))
if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange))
{
handsComp.Drop(handsComp.ActiveIndex, coords);