Files
tbd-station-14/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs
2021-12-08 17:04:21 +01:00

30 lines
893 B
C#

using System.Collections.Generic;
using Content.Server.Hands.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Inventory
{
[UsedImplicitly]
public sealed class EnumerableInventoryState : StateData<IEnumerable<EntityUid>>
{
public override string Name => "EnumerableInventory";
public override IEnumerable<EntityUid> GetValue()
{
var entMan = IoCManager.Resolve<IEntityManager>();
if (entMan.TryGetComponent(Owner, out HandsComponent? handsComponent))
{
foreach (var item in handsComponent.GetAllHeldItems())
{
if (entMan.Deleted(item.Owner))
continue;
yield return item.Owner;
}
}
}
}
}