2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Hands.Components;
|
2022-03-17 20:13:31 +13:00
|
|
|
using Content.Shared.Hands.EntitySystems;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.AI.Operators.Inventory
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class DropHandItemsOperator : AiOperator
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
private readonly EntityUid _owner;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
public DropHandItemsOperator(EntityUid owner)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
_owner = owner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2021-03-16 15:50:20 +01:00
|
|
|
|
2022-03-17 20:13:31 +13:00
|
|
|
var sys = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedHandsSystem>();
|
|
|
|
|
|
|
|
|
|
foreach (var hand in handsComponent.Hands.Values)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2022-03-17 20:13:31 +13:00
|
|
|
if (!hand.IsEmpty)
|
|
|
|
|
sys.TryDrop(_owner, hand, handsComp: handsComponent);
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Outcome.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|