Delta-v/Content.Server/AI/WorldState/States/Hands/AnyFreeHandState.cs

31 lines
820 B
C#

using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Hands
{
[UsedImplicitly]
public sealed class AnyFreeHandState : StateData<bool>
{
public override string Name => "AnyFreeHand";
public override bool GetValue()
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
{
return false;
}
foreach (var hand in handsComponent.ActivePriorityEnumerable())
{
if (handsComponent.GetItem(hand) == null)
{
return true;
}
}
return false;
}
}
}