Files
crystall-punk-14/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs

23 lines
693 B
C#
Raw Normal View History

using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
2022-03-17 20:13:31 +13:00
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();
2022-03-17 20:13:31 +13:00
if (!owner.IsValid() || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SharedHandsComponent? handsComponent))
{
return 0.0f;
}
2022-03-17 20:13:31 +13:00
return (float) handsComponent.CountFreeHands() / handsComponent.Count;
}
}
}