StatusIconPrototype.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using Content.Shared.Stealth.Components;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
  6. using Robust.Shared.Utility;
  7. namespace Content.Shared.StatusIcon;
  8. /// <summary>
  9. /// A data structure that holds relevant
  10. /// information for status icons.
  11. /// </summary>
  12. [Virtual, DataDefinition]
  13. public partial class StatusIconData : IComparable<StatusIconData>
  14. {
  15. /// <summary>
  16. /// The icon that's displayed on the entity.
  17. /// </summary>
  18. [DataField(required: true)]
  19. public SpriteSpecifier Icon = default!;
  20. /// <summary>
  21. /// A priority for the order in which the icons will be displayed.
  22. /// </summary>
  23. [DataField]
  24. public int Priority = 10;
  25. /// <summary>
  26. /// Whether or not to hide the icon to ghosts
  27. /// </summary>
  28. [DataField]
  29. public bool VisibleToGhosts = true;
  30. /// <summary>
  31. /// Whether or not to hide the icon when we are inside a container like a locker or a crate.
  32. /// </summary>
  33. [DataField]
  34. public bool HideInContainer = true;
  35. /// <summary>
  36. /// Whether or not to hide the icon when the entity has an active <see cref="StealthComponent"/>
  37. /// </summary>
  38. [DataField]
  39. public bool HideOnStealth = true;
  40. /// <summary>
  41. /// Specifies what entities and components/tags this icon can be shown to.
  42. /// </summary>
  43. [DataField]
  44. public EntityWhitelist? ShowTo;
  45. /// <summary>
  46. /// A preference for where the icon will be displayed. None | Left | Right
  47. /// </summary>
  48. [DataField]
  49. public StatusIconLocationPreference LocationPreference = StatusIconLocationPreference.None;
  50. /// <summary>
  51. /// The layer the icon is displayed on. Mod is drawn above Base. Base | Mod
  52. /// </summary>
  53. [DataField]
  54. public StatusIconLayer Layer = StatusIconLayer.Base;
  55. /// <summary>
  56. /// Offset of the status icon, up and down only.
  57. /// </summary>
  58. [DataField]
  59. public int Offset = 0;
  60. /// <summary>
  61. /// Sets if the icon should be rendered with or without the effect of lighting.
  62. /// </summary>
  63. [DataField]
  64. public bool IsShaded = false;
  65. public int CompareTo(StatusIconData? other)
  66. {
  67. return Priority.CompareTo(other?.Priority ?? int.MaxValue);
  68. }
  69. }
  70. /// <summary>
  71. /// <see cref="StatusIconData"/> but in new convenient prototype form!
  72. /// </summary>
  73. public abstract partial class StatusIconPrototype : StatusIconData, IPrototype
  74. {
  75. /// <inheritdoc/>
  76. [IdDataField]
  77. public string ID { get; private set; } = default!;
  78. }
  79. /// <summary>
  80. /// StatusIcons for showing jobs on the sec HUD
  81. /// </summary>
  82. [Prototype]
  83. public sealed partial class JobIconPrototype : StatusIconPrototype, IInheritingPrototype
  84. {
  85. /// <inheritdoc />
  86. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<JobIconPrototype>))]
  87. public string[]? Parents { get; private set; }
  88. /// <inheritdoc />
  89. [NeverPushInheritance]
  90. [AbstractDataField]
  91. public bool Abstract { get; private set; }
  92. /// <summary>
  93. /// Name of the icon used for menu tooltips.
  94. /// </summary>
  95. [DataField]
  96. public string JobName { get; private set; } = string.Empty;
  97. [ViewVariables(VVAccess.ReadOnly)]
  98. public string LocalizedJobName => Loc.GetString(JobName);
  99. /// <summary>
  100. /// Should the agent ID or ID card console be able to use this job icon?
  101. /// </summary>
  102. [DataField]
  103. public bool AllowSelection = true;
  104. }
  105. /// <summary>
  106. /// StatusIcons for the med HUD
  107. /// </summary>
  108. [Prototype]
  109. public sealed partial class HealthIconPrototype : StatusIconPrototype, IInheritingPrototype
  110. {
  111. /// <inheritdoc />
  112. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<HealthIconPrototype>))]
  113. public string[]? Parents { get; private set; }
  114. /// <inheritdoc />
  115. [NeverPushInheritance]
  116. [AbstractDataField]
  117. public bool Abstract { get; private set; }
  118. }
  119. /// <summary>
  120. /// StatusIcons for the beer goggles and fried onion goggles
  121. /// </summary>
  122. [Prototype]
  123. public sealed partial class SatiationIconPrototype : StatusIconPrototype, IInheritingPrototype
  124. {
  125. /// <inheritdoc />
  126. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<SatiationIconPrototype>))]
  127. public string[]? Parents { get; private set; }
  128. /// <inheritdoc />
  129. [NeverPushInheritance]
  130. [AbstractDataField]
  131. public bool Abstract { get; private set; }
  132. }
  133. /// <summary>
  134. /// StatusIcons for showing the wanted status on the sec HUD
  135. /// </summary>
  136. [Prototype]
  137. public sealed partial class SecurityIconPrototype : StatusIconPrototype, IInheritingPrototype
  138. {
  139. /// <inheritdoc />
  140. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<SecurityIconPrototype>))]
  141. public string[]? Parents { get; private set; }
  142. /// <inheritdoc />
  143. [NeverPushInheritance]
  144. [AbstractDataField]
  145. public bool Abstract { get; private set; }
  146. }
  147. /// <summary>
  148. /// StatusIcons for faction membership
  149. /// </summary>
  150. [Prototype]
  151. public sealed partial class FactionIconPrototype : StatusIconPrototype, IInheritingPrototype
  152. {
  153. /// <inheritdoc />
  154. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<FactionIconPrototype>))]
  155. public string[]? Parents { get; private set; }
  156. /// <inheritdoc />
  157. [NeverPushInheritance]
  158. [AbstractDataField]
  159. public bool Abstract { get; private set; }
  160. }
  161. /// <summary>
  162. /// StatusIcons for debugging purposes
  163. /// </summary>
  164. [Prototype]
  165. public sealed partial class DebugIconPrototype : StatusIconPrototype, IInheritingPrototype
  166. {
  167. /// <inheritdoc />
  168. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<DebugIconPrototype>))]
  169. public string[]? Parents { get; private set; }
  170. /// <inheritdoc />
  171. [NeverPushInheritance]
  172. [AbstractDataField]
  173. public bool Abstract { get; private set; }
  174. }
  175. /// <summary>
  176. /// StatusIcons for the SSD indicator
  177. /// </summary>
  178. [Prototype]
  179. public sealed partial class SsdIconPrototype : StatusIconPrototype, IInheritingPrototype
  180. {
  181. /// <inheritdoc />
  182. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<SsdIconPrototype>))]
  183. public string[]? Parents { get; private set; }
  184. /// <inheritdoc />
  185. [NeverPushInheritance]
  186. [AbstractDataField]
  187. public bool Abstract { get; private set; }
  188. }
  189. [Serializable, NetSerializable]
  190. public enum StatusIconLocationPreference : byte
  191. {
  192. None,
  193. Left,
  194. Right,
  195. }
  196. public enum StatusIconLayer : byte
  197. {
  198. Base,
  199. Mod,
  200. }