Fix pickup verb. (#165)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
c5e077efc1
commit
c0caaaa8e5
@@ -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 />
|
/// <inheritdoc />
|
||||||
public void RemoveHandEntity(IEntity entity)
|
public void RemoveHandEntity(IEntity entity)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,17 +38,25 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
protected override string GetText(IEntity user, ItemComponent component)
|
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";
|
return "Pick Up";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsDisabled(IEntity user, ItemComponent component)
|
protected override bool IsDisabled(IEntity user, ItemComponent component)
|
||||||
{
|
{
|
||||||
|
if (user.TryGetComponent(out HandsComponent hands) && hands.IsHolding(component.Owner))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Activate(IEntity user, ItemComponent component)
|
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);
|
hands.PutInHand(component);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user