ClothingComponent.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System.Diagnostics.CodeAnalysis;
  2. using Content.Shared.Clothing.EntitySystems;
  3. using Content.Shared.DoAfter;
  4. using Content.Shared.Inventory;
  5. using Robust.Shared.Audio;
  6. using Robust.Shared.GameStates;
  7. using Robust.Shared.Serialization;
  8. namespace Content.Shared.Clothing.Components;
  9. /// <summary>
  10. /// This handles entities which can be equipped.
  11. /// </summary>
  12. [NetworkedComponent]
  13. [RegisterComponent]
  14. [Access(typeof(ClothingSystem), typeof(InventorySystem))]
  15. public sealed partial class ClothingComponent : Component
  16. {
  17. [DataField("clothingVisuals")]
  18. public Dictionary<string, List<PrototypeLayerData>> ClothingVisuals = new();
  19. /// <summary>
  20. /// The name of the layer in the user that this piece of clothing will map to
  21. /// </summary>
  22. [DataField]
  23. public string? MappedLayer;
  24. [ViewVariables(VVAccess.ReadWrite)]
  25. [DataField("quickEquip")]
  26. public bool QuickEquip = true;
  27. /// <summary>
  28. /// The slots in which the clothing is considered "worn" or "equipped". E.g., putting shoes in your pockets does not
  29. /// equip them as far as clothing related events are concerned.
  30. /// </summary>
  31. /// <remarks>
  32. /// Note that this may be a combination of different slot flags, not a singular bit.
  33. /// </remarks>
  34. [ViewVariables(VVAccess.ReadWrite)]
  35. [DataField(required: true)]
  36. [Access(typeof(ClothingSystem), typeof(InventorySystem), Other = AccessPermissions.ReadExecute)]
  37. public SlotFlags Slots = SlotFlags.NONE;
  38. [ViewVariables(VVAccess.ReadWrite)]
  39. [DataField("equipSound")]
  40. public SoundSpecifier? EquipSound;
  41. [ViewVariables(VVAccess.ReadWrite)]
  42. [DataField("unequipSound")]
  43. public SoundSpecifier? UnequipSound;
  44. [Access(typeof(ClothingSystem))]
  45. [ViewVariables(VVAccess.ReadWrite)]
  46. [DataField("equippedPrefix")]
  47. public string? EquippedPrefix;
  48. /// <summary>
  49. /// Allows the equipped state to be directly overwritten.
  50. /// useful when prototyping INNERCLOTHING items into OUTERCLOTHING items without duplicating/modifying RSIs etc.
  51. /// </summary>
  52. [Access(typeof(ClothingSystem))]
  53. [ViewVariables(VVAccess.ReadWrite)]
  54. [DataField("equippedState")]
  55. public string? EquippedState;
  56. [ViewVariables(VVAccess.ReadWrite)]
  57. [DataField("sprite")]
  58. public string? RsiPath;
  59. /// <summary>
  60. /// Name of the inventory slot the clothing is currently in.
  61. /// Note that this being non-null does not mean the clothing is considered "worn" or "equipped" unless the slot
  62. /// satisfies the <see cref="Slots"/> flags.
  63. /// </summary>
  64. [DataField]
  65. public string? InSlot;
  66. // TODO CLOTHING
  67. // Maybe keep this null unless its in a valid slot?
  68. // To lazy to figure out ATM if that would break anything.
  69. // And when doing this, combine InSlot and InSlotFlag, as it'd be a breaking change for downstreams anyway
  70. /// <summary>
  71. /// Slot flags of the slot the clothing is currently in. See also <see cref="InSlot"/>.
  72. /// </summary>
  73. [DataField]
  74. public SlotFlags? InSlotFlag;
  75. // TODO CLOTHING
  76. // Maybe keep this null unless its in a valid slot?
  77. // And when doing this, combine InSlot and InSlotFlag, as it'd be a breaking change for downstreams anyway
  78. [DataField, ViewVariables(VVAccess.ReadWrite)]
  79. public TimeSpan EquipDelay = TimeSpan.Zero;
  80. [DataField, ViewVariables(VVAccess.ReadWrite)]
  81. public TimeSpan UnequipDelay = TimeSpan.Zero;
  82. /// <summary>
  83. /// Offset for the strip time for an entity with this component.
  84. /// Only applied when it is being equipped or removed by another player.
  85. /// </summary>
  86. [DataField]
  87. public TimeSpan StripDelay = TimeSpan.Zero;
  88. }
  89. [Serializable, NetSerializable]
  90. public sealed class ClothingComponentState : ComponentState
  91. {
  92. public string? EquippedPrefix;
  93. public ClothingComponentState(string? equippedPrefix)
  94. {
  95. EquippedPrefix = equippedPrefix;
  96. }
  97. }
  98. public enum ClothingMask : byte
  99. {
  100. NoMask = 0,
  101. UniformFull,
  102. UniformTop
  103. }
  104. [Serializable, NetSerializable]
  105. public sealed partial class ClothingEquipDoAfterEvent : DoAfterEvent
  106. {
  107. public string Slot;
  108. public ClothingEquipDoAfterEvent(string slot)
  109. {
  110. Slot = slot;
  111. }
  112. public override DoAfterEvent Clone() => this;
  113. }
  114. [Serializable, NetSerializable]
  115. public sealed partial class ClothingUnequipDoAfterEvent : DoAfterEvent
  116. {
  117. public string Slot;
  118. public ClothingUnequipDoAfterEvent(string slot)
  119. {
  120. Slot = slot;
  121. }
  122. public override DoAfterEvent Clone() => this;
  123. }