Fix pickup verb. (#165)

This commit is contained in:
Remie Richards
2019-03-27 12:29:43 +00:00
committed by Pieter-Jan Briers
parent c5e077efc1
commit c0caaaa8e5
2 changed files with 21 additions and 1 deletions

View File

@@ -75,6 +75,18 @@ namespace Content.Server.GameObjects
}
}
public bool IsHolding(IEntity entity)
{
foreach (var slot in hands.Values)
{
if (slot.ContainedEntity == entity)
{
return true;
}
}
return false;
}
/// <inheritdoc />
public void RemoveHandEntity(IEntity entity)
{

View File

@@ -38,17 +38,25 @@ namespace Content.Server.GameObjects
{
protected override string GetText(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent hands) && hands.IsHolding(component.Owner))
{
return "Pick Up (Already Holding)";
}
return "Pick Up";
}
protected override bool IsDisabled(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent hands) && hands.IsHolding(component.Owner))
{
return true;
}
return false;
}
protected override void Activate(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent hands))
if (user.TryGetComponent(out HandsComponent hands) && !hands.IsHolding(component.Owner))
{
hands.PutInHand(component);
}