HumanoidAppearanceComponent.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using Content.Shared.Humanoid.Markings;
  2. using Content.Shared.Humanoid.Prototypes;
  3. using Content.Shared.Inventory;
  4. using Robust.Shared.Enums;
  5. using Robust.Shared.GameStates;
  6. using Robust.Shared.Prototypes;
  7. using Robust.Shared.Serialization;
  8. using Robust.Shared.Utility;
  9. namespace Content.Shared.Humanoid;
  10. [NetworkedComponent, RegisterComponent, AutoGenerateComponentState(true)]
  11. public sealed partial class HumanoidAppearanceComponent : Component
  12. {
  13. public MarkingSet ClientOldMarkings = new();
  14. [DataField, AutoNetworkedField]
  15. public MarkingSet MarkingSet = new();
  16. [DataField]
  17. public Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer> BaseLayers = new();
  18. [DataField, AutoNetworkedField]
  19. public HashSet<HumanoidVisualLayers> PermanentlyHidden = new();
  20. // Couldn't these be somewhere else?
  21. [DataField, AutoNetworkedField]
  22. public Gender Gender;
  23. [DataField, AutoNetworkedField]
  24. public int Age = 18;
  25. /// <summary>
  26. /// Any custom base layers this humanoid might have. See:
  27. /// limb transplants (potentially), robotic arms, etc.
  28. /// Stored on the server, this is merged in the client into
  29. /// all layer settings.
  30. /// </summary>
  31. [DataField, AutoNetworkedField]
  32. public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers = new();
  33. /// <summary>
  34. /// Current species. Dictates things like base body sprites,
  35. /// base humanoid to spawn, etc.
  36. /// </summary>
  37. [DataField(required: true), AutoNetworkedField]
  38. public ProtoId<SpeciesPrototype> Species { get; set; }
  39. /// <summary>
  40. /// The initial profile and base layers to apply to this humanoid.
  41. /// </summary>
  42. [DataField]
  43. public ProtoId<HumanoidProfilePrototype>? Initial { get; private set; }
  44. /// <summary>
  45. /// Skin color of this humanoid.
  46. /// </summary>
  47. [DataField, AutoNetworkedField]
  48. public Color SkinColor { get; set; } = Color.FromHex("#C0967F");
  49. /// <summary>
  50. /// A map of the visual layers currently hidden to the equipment
  51. /// slots that are currently hiding them. This will affect the base
  52. /// sprite on this humanoid layer, and any markings that sit above it.
  53. /// </summary>
  54. [DataField, AutoNetworkedField]
  55. public Dictionary<HumanoidVisualLayers, SlotFlags> HiddenLayers = new();
  56. [DataField, AutoNetworkedField]
  57. public Sex Sex = Sex.Male;
  58. [DataField, AutoNetworkedField]
  59. public Color EyeColor = Color.Brown;
  60. /// <summary>
  61. /// Hair color of this humanoid. Used to avoid looping through all markings
  62. /// </summary>
  63. [ViewVariables(VVAccess.ReadOnly)]
  64. public Color? CachedHairColor;
  65. /// <summary>
  66. /// Facial Hair color of this humanoid. Used to avoid looping through all markings
  67. /// </summary>
  68. [ViewVariables(VVAccess.ReadOnly)]
  69. public Color? CachedFacialHairColor;
  70. /// <summary>
  71. /// Which layers of this humanoid that should be hidden on equipping a corresponding item..
  72. /// </summary>
  73. [DataField]
  74. public HashSet<HumanoidVisualLayers> HideLayersOnEquip = [HumanoidVisualLayers.Hair];
  75. /// <summary>
  76. /// Which markings the humanoid defaults to when nudity is toggled off.
  77. /// </summary>
  78. [DataField]
  79. public ProtoId<MarkingPrototype>? UndergarmentTop = new ProtoId<MarkingPrototype>("UndergarmentTopTanktop");
  80. [DataField]
  81. public ProtoId<MarkingPrototype>? UndergarmentBottom = new ProtoId<MarkingPrototype>("UndergarmentBottomBoxers");
  82. }
  83. [DataDefinition]
  84. [Serializable, NetSerializable]
  85. public readonly partial struct CustomBaseLayerInfo
  86. {
  87. public CustomBaseLayerInfo(string? id, Color? color = null)
  88. {
  89. DebugTools.Assert(id == null || IoCManager.Resolve<IPrototypeManager>().HasIndex<HumanoidSpeciesSpriteLayer>(id));
  90. Id = id;
  91. Color = color;
  92. }
  93. /// <summary>
  94. /// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>.
  95. /// </summary>
  96. [DataField]
  97. public ProtoId<HumanoidSpeciesSpriteLayer>? Id { get; init; }
  98. /// <summary>
  99. /// Color of this custom base layer. Null implies skin colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin.
  100. /// </summary>
  101. [DataField]
  102. public Color? Color { get; init; }
  103. }