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,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;
}
}
}