2020-06-18 22:52:44 +10:00
|
|
|
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;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Utility.Considerations.Hands
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class FreeHandCon : Consideration
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2020-07-08 09:37:35 +10:00
|
|
|
protected override float GetScore(Blackboard context)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
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))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-17 20:13:31 +13:00
|
|
|
return (float) handsComponent.CountFreeHands() / handsComponent.Count;
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|