Files
OldThink/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs

74 lines
2.3 KiB
C#
Raw Normal View History

using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.Components.Items;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
2020-01-21 18:11:15 +01:00
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Clothing
{
2019-07-31 15:02:36 +02:00
[RegisterComponent]
[ComponentReference(typeof(ItemComponent))]
2020-07-08 18:28:59 +02:00
[ComponentReference(typeof(IItemComponent))]
public class ClothingComponent : ItemComponent
{
2020-01-21 18:11:15 +01:00
private FemaleClothingMask _femaleMask;
public override string Name => "Clothing";
public override uint? NetID => ContentNetIDs.CLOTHING;
[ViewVariables(VVAccess.ReadWrite)]
public string ClothingEquippedPrefix { get; set; }
2020-01-21 18:11:15 +01:00
[ViewVariables(VVAccess.ReadWrite)]
public FemaleClothingMask FemaleMask
{
get => _femaleMask;
set => _femaleMask = value;
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _femaleMask, "femaleMask", FemaleClothingMask.UniformFull);
2020-07-21 23:37:46 +00:00
serializer.DataField(this, p => p.ClothingEquippedPrefix, "ClothingPrefix", null);
2020-01-21 18:11:15 +01:00
}
public (RSI rsi, RSI.StateId stateId)? GetEquippedStateInfo(EquipmentSlotDefines.SlotFlags slot)
{
if (RsiPath == null)
{
return null;
}
var rsi = GetRSI();
var prefix = ClothingEquippedPrefix ?? EquippedPrefix;
var stateId = prefix != null ? $"{prefix}-equipped-{slot}" : $"equipped-{slot}";
if (rsi.TryGetState(stateId, out _))
{
return (rsi, stateId);
}
return null;
}
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (curState == null)
return;
var clothingComponentState = (ClothingComponentState)curState;
ClothingEquippedPrefix = clothingComponentState.ClothingEquippedPrefix;
EquippedPrefix = clothingComponentState.EquippedPrefix;
}
}
2020-01-21 18:11:15 +01:00
public enum FemaleClothingMask
{
NoMask = 0,
UniformFull,
UniformTop
}
}