hands ECS (#7081)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user