This commit is contained in:
Leon Friedrich
2022-03-17 20:13:31 +13:00
committed by GitHub
parent 7b84362901
commit bfd95c493b
94 changed files with 1454 additions and 2185 deletions

View File

@@ -1,8 +1,7 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.Hands.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Content.Shared.Hands.Components;
using System.Linq;
namespace Content.Server.AI.Utility.Considerations.Hands
{
@@ -12,24 +11,12 @@ namespace Content.Server.AI.Utility.Considerations.Hands
{
var owner = context.GetState<SelfState>().GetValue();
if (!owner.IsValid() || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out HandsComponent? handsComponent))
if (!owner.IsValid() || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SharedHandsComponent? handsComponent))
{
return 0.0f;
}
var handCount = 0;
var freeCount = 0;
foreach (var hand in handsComponent.ActivePriorityEnumerable())
{
handCount++;
if (handsComponent.GetItem(hand) == null)
{
freeCount += 1;
}
}
return (float) freeCount / handCount;
return (float) handsComponent.CountFreeHands() / handsComponent.Count;
}
}
}