Files
tbd-station-14/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs
metalgearsloth 5391d3c72a Add utility AI (#806)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2020-06-18 14:52:44 +02:00

38 lines
1.1 KiB
C#

using System.Collections.Generic;
using Content.Server.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
using JetBrains.Annotations;
using Robust.Shared.Interfaces.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;
}
}
}