Actual lockers (#195)

Adds storing entities into lockers the way we all know and love.
Relies on an implementation of ITileDefinition in https://github.com/space-wizards/space-station-14/pull/193 (just like origin/master)
#191
This commit is contained in:
PrPleGoo
2019-04-17 23:26:00 +02:00
committed by Pieter-Jan Briers
parent 1fe24eeb12
commit 903961771b
19 changed files with 272 additions and 41 deletions

View File

@@ -6,10 +6,13 @@ using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using System;
using Content.Shared.GameObjects.Components.Items;
using Content.Server.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Maths;
namespace Content.Server.GameObjects
{
public class ItemComponent : StoreableComponent, IAttackHand
public class ItemComponent : StoreableComponent, IAttackHand, IAfterAttack
{
public override string Name => "Item";
public override uint? NetID => ContentNetIDs.ITEM;
@@ -87,5 +90,38 @@ namespace Content.Server.GameObjects
{
return new ItemComponentState(EquippedPrefix);
}
public void AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent<HandsComponent>(out var handComponent))
{
return;
}
if (!eventArgs.Attacked.TryGetComponent<PlaceableSurfaceComponent>(out var placeableSurfaceComponent))
{
return;
}
handComponent.Drop(handComponent.ActiveIndex);
Owner.Transform.WorldPosition = eventArgs.ClickLocation.Position;
return;
}
public void Fumble()
{
if (Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
{
physicsComponent.LinearVelocity += RandomOffset();
}
}
private Vector2 RandomOffset()
{
return new Vector2(RandomOffset(), RandomOffset());
float RandomOffset()
{
var size = 15.0F;
return (new Random().NextFloat() * size) - size / 2;
}
}
}
}