Files
OldThink/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs
2021-03-16 15:50:20 +01:00

38 lines
1.1 KiB
C#

using System.Collections.Generic;
using Content.Server.GameObjects.Components.GUI;
using Content.Shared.GameObjects.Components.Inventory;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.AI.WorldState.States.Clothing
{
[UsedImplicitly]
public sealed class EquippedClothingState : StateData<Dictionary<EquipmentSlotDefines.Slots, IEntity>>
{
public override string Name => "EquippedClothing";
public override Dictionary<EquipmentSlotDefines.Slots, IEntity> GetValue()
{
var result = new Dictionary<EquipmentSlotDefines.Slots, IEntity>();
if (!Owner.TryGetComponent(out InventoryComponent? inventoryComponent))
{
return result;
}
foreach (var slot in EquipmentSlotDefines.AllSlots)
{
if (!inventoryComponent.HasSlot(slot)) continue;
var slotItem = inventoryComponent.GetSlotItem(slot);
if (slotItem != null)
{
result.Add(slot, slotItem.Owner);
}
}
return result;
}
}
}