ToggleableClothingComponent.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Content.Shared.Clothing.EntitySystems;
  2. using Content.Shared.Inventory;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Shared.Clothing.Components;
  8. /// <summary>
  9. /// This component gives an item an action that will equip or un-equip some clothing e.g. hardsuits and hardsuit helmets.
  10. /// </summary>
  11. [Access(typeof(ToggleableClothingSystem))]
  12. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  13. public sealed partial class ToggleableClothingComponent : Component
  14. {
  15. public const string DefaultClothingContainerId = "toggleable-clothing";
  16. /// <summary>
  17. /// Action used to toggle the clothing on or off.
  18. /// </summary>
  19. [DataField, AutoNetworkedField]
  20. public EntProtoId Action = "ActionToggleSuitPiece";
  21. [DataField, AutoNetworkedField]
  22. public EntityUid? ActionEntity;
  23. /// <summary>
  24. /// Default clothing entity prototype to spawn into the clothing container.
  25. /// </summary>
  26. [DataField(required: true), AutoNetworkedField]
  27. public EntProtoId ClothingPrototype = default!;
  28. /// <summary>
  29. /// The inventory slot that the clothing is equipped to.
  30. /// </summary>
  31. [ViewVariables(VVAccess.ReadWrite)]
  32. [DataField, AutoNetworkedField]
  33. public string Slot = "head";
  34. /// <summary>
  35. /// The inventory slot flags required for this component to function.
  36. /// </summary>
  37. [DataField("requiredSlot"), AutoNetworkedField]
  38. public SlotFlags RequiredFlags = SlotFlags.OUTERCLOTHING;
  39. /// <summary>
  40. /// The container that the clothing is stored in when not equipped.
  41. /// </summary>
  42. [DataField, AutoNetworkedField]
  43. public string ContainerId = DefaultClothingContainerId;
  44. [ViewVariables]
  45. public ContainerSlot? Container;
  46. /// <summary>
  47. /// The Id of the piece of clothing that belongs to this component. Required for map-saving if the clothing is
  48. /// currently not inside of the container.
  49. /// </summary>
  50. [DataField, AutoNetworkedField]
  51. public EntityUid? ClothingUid;
  52. /// <summary>
  53. /// Time it takes for this clothing to be toggled via the stripping menu verbs. Null prevents the verb from even showing up.
  54. /// </summary>
  55. [DataField, AutoNetworkedField]
  56. public TimeSpan? StripDelay = TimeSpan.FromSeconds(3);
  57. /// <summary>
  58. /// Text shown in the toggle-clothing verb. Defaults to using the name of the <see cref="ActionEntity"/> action.
  59. /// </summary>
  60. [DataField, AutoNetworkedField]
  61. public string? VerbText;
  62. }