Files
tbd-station-14/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs
Pieter-Jan Briers de26699cfe Pick up verb.
2019-03-26 13:46:07 +01:00

59 lines
1.6 KiB
C#

using Content.Server.Interfaces.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects
{
public class ItemComponent : StoreableComponent, EntitySystems.IAttackHand
{
public override string Name => "Item";
public void RemovedFromSlot()
{
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
{
component.Visible = true;
}
}
public void EquippedToSlot()
{
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
{
component.Visible = false;
}
}
public bool Attackhand(IEntity user)
{
var hands = user.GetComponent<IHandsComponent>();
hands.PutInHand(this, hands.ActiveIndex, fallback: false);
return true;
}
[Verb]
public sealed class PickUpVerb : Verb<ItemComponent>
{
protected override string GetText(IEntity user, ItemComponent component)
{
return "Pick Up";
}
protected override bool IsDisabled(IEntity user, ItemComponent component)
{
return false;
}
protected override void Activate(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent hands))
{
hands.PutInHand(component);
}
}
}
}
}