2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Hands.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Operators.Inventory
|
|
|
|
|
{
|
|
|
|
|
public sealed class EquipEntityOperator : AiOperator
|
|
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
private readonly EntityUid _owner;
|
|
|
|
|
private readonly EntityUid _entity;
|
|
|
|
|
public EquipEntityOperator(EntityUid owner, EntityUid entity)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
_owner = owner;
|
|
|
|
|
_entity = entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Outcome Execute(float frameTime)
|
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out HandsComponent? handsComponent))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
return Outcome.Failed;
|
|
|
|
|
}
|
|
|
|
|
// TODO: If in clothing then click on it
|
|
|
|
|
foreach (var hand in handsComponent.ActivePriorityEnumerable())
|
|
|
|
|
{
|
2020-07-25 15:11:16 +02:00
|
|
|
if (handsComponent.GetItem(hand)?.Owner == _entity)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2020-07-25 15:11:16 +02:00
|
|
|
handsComponent.ActiveHand = hand;
|
2020-06-18 22:52:44 +10:00
|
|
|
return Outcome.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Get free hand count; if no hands free then fail right here
|
|
|
|
|
|
|
|
|
|
// TODO: Go through inventory
|
|
|
|
|
return Outcome.Failed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|