Moved dropping items over PlaceableSurfaces from AfterAttack to AttackBy (#209)

Added ClickLocation variable to AttackByEventArgs
This commit is contained in:
DamianX
2019-04-25 22:22:51 +01:00
committed by Pieter-Jan Briers
parent 8655dcaaf6
commit b16768fd0b
3 changed files with 16 additions and 19 deletions

View File

@@ -1,9 +1,10 @@
using Robust.Shared.GameObjects;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components
{
public class PlaceableSurfaceComponent : Component
public class PlaceableSurfaceComponent : Component, IAttackBy
{
public override string Name => "PlaceableSurface";
@@ -16,5 +17,15 @@ namespace Content.Server.GameObjects.Components
serializer.DataField(ref _isPlaceable, "IsPlaceable", true);
}
public bool AttackBy(AttackByEventArgs eventArgs)
{
if(!eventArgs.User.TryGetComponent<HandsComponent>(out var handComponent))
{
return true;
}
handComponent.Drop(eventArgs.AttackWith);
eventArgs.AttackWith.Transform.WorldPosition = eventArgs.ClickLocation.Position;
return true;
}
}
}