hands ECS (#7081)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Item;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -22,27 +23,18 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var sysMan = IoCManager.Resolve<IEntitySystemManager>();
|
||||
var sys = sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
// TODO: Also have this check storage a la backpack etc.
|
||||
if (!entMan.TryGetComponent(_owner, out HandsComponent? handsComponent))
|
||||
if (!entMan.TryGetComponent(_owner, out HandsComponent? handsComponent)
|
||||
|| !sys.TrySelect(_owner, _target, handsComponent)
|
||||
|| !sys.TryUseItemInHand(_owner, false, handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!entMan.TryGetComponent(_target, out SharedItemComponent? itemComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
foreach (var slot in handsComponent.ActivePriorityEnumerable())
|
||||
{
|
||||
if (handsComponent.GetItem(slot) != itemComponent) continue;
|
||||
handsComponent.ActiveHand = slot;
|
||||
handsComponent.ActivateItem();
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
return Outcome.Failed;
|
||||
return Outcome.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user