Files
tbd-station-14/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs
Leon Friedrich bfd95c493b hands ECS (#7081)
2022-03-17 18:13:31 +11:00

23 lines
693 B
C#

using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Shared.Hands.Components;
using System.Linq;
namespace Content.Server.AI.Utility.Considerations.Hands
{
public sealed class FreeHandCon : Consideration
{
protected override float GetScore(Blackboard context)
{
var owner = context.GetState<SelfState>().GetValue();
if (!owner.IsValid() || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SharedHandsComponent? handsComponent))
{
return 0.0f;
}
return (float) handsComponent.CountFreeHands() / handsComponent.Count;
}
}
}