FoodSequenceStartPointComponent.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System.Numerics;
  2. using Content.Shared.Nutrition.EntitySystems;
  3. using Content.Shared.Nutrition.Prototypes;
  4. using Content.Shared.Tag;
  5. using Robust.Shared.GameStates;
  6. using Robust.Shared.Prototypes;
  7. using Robust.Shared.Serialization;
  8. using Robust.Shared.Utility;
  9. namespace Content.Shared.Nutrition.Components;
  10. /// <summary>
  11. /// A starting point for the creation of procedural food.
  12. /// </summary>
  13. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), Access(typeof(SharedFoodSequenceSystem))]
  14. public sealed partial class FoodSequenceStartPointComponent : Component
  15. {
  16. /// <summary>
  17. /// A key that determines which types of food elements can be attached to a food.
  18. /// </summary>
  19. [DataField(required: true)]
  20. public ProtoId<TagPrototype> Key = string.Empty;
  21. /// <summary>
  22. /// The maximum number of layers of food that can be placed on this item.
  23. /// </summary>
  24. [DataField]
  25. public int MaxLayers = 10;
  26. /// <summary>
  27. /// Can we put more layers?
  28. /// </summary>
  29. [DataField]
  30. public bool Finished;
  31. /// <summary>
  32. /// solution where reagents will be added from newly added ingredients
  33. /// </summary>
  34. [DataField]
  35. public string Solution = "food";
  36. #region name generation
  37. /// <summary>
  38. /// LocId with a name generation pattern.
  39. /// </summary>
  40. [DataField]
  41. public LocId? NameGeneration;
  42. /// <summary>
  43. /// the part of the name generation used in the pattern
  44. /// </summary>
  45. [DataField]
  46. public LocId? NamePrefix;
  47. /// <summary>
  48. /// content in the form of all added ingredients will be separated by these symbols
  49. /// </summary>
  50. [DataField]
  51. public string? ContentSeparator;
  52. /// <summary>
  53. /// the part of the name generation used in the pattern
  54. /// </summary>
  55. [DataField]
  56. public LocId? NameSuffix;
  57. #endregion
  58. #region visual
  59. /// <summary>
  60. /// list of sprite states to be displayed on this object.
  61. /// </summary>
  62. [DataField, AutoNetworkedField]
  63. public List<FoodSequenceVisualLayer> FoodLayers = new();
  64. /// <summary>
  65. /// If true, the generative layers will be placed in reverse order.
  66. /// </summary>
  67. [DataField]
  68. public bool InverseLayers;
  69. /// <summary>
  70. /// target layer, where new layers will be added. This allows you to control the order of generative layers and static layers.
  71. /// </summary>
  72. [DataField]
  73. public string TargetLayerMap = "foodSequenceLayers";
  74. /// <summary>
  75. /// Start shift from the center of the sprite where the first layer of food will be placed.
  76. /// </summary>
  77. [DataField]
  78. public Vector2 StartPosition = Vector2.Zero;
  79. /// <summary>
  80. /// Shift from the start position applied to each subsequent layer.
  81. /// </summary>
  82. [DataField]
  83. public Vector2 Offset = Vector2.Zero;
  84. /// <summary>
  85. /// each layer will get a random offset in the specified range
  86. /// </summary>
  87. [DataField]
  88. public Vector2 MaxLayerOffset = Vector2.Zero;
  89. /// <summary>
  90. /// each layer will get a random offset in the specified range
  91. /// </summary>
  92. [DataField]
  93. public Vector2 MinLayerOffset = Vector2.Zero;
  94. [DataField]
  95. public bool AllowHorizontalFlip = true;
  96. public HashSet<string> RevealedLayers = new();
  97. #endregion
  98. }
  99. /// <summary>
  100. /// class that synchronizes with the client
  101. /// Stores all the necessary information for rendering the FoodSequence element
  102. /// </summary>
  103. [DataRecord, Serializable, NetSerializable]
  104. public partial record struct FoodSequenceVisualLayer
  105. {
  106. /// <summary>
  107. /// reference to the original prototype of the layer. Used to edit visual layers.
  108. /// </summary>
  109. public ProtoId<FoodSequenceElementPrototype> Proto;
  110. /// <summary>
  111. /// Sprite rendered in sequence
  112. /// </summary>
  113. public SpriteSpecifier? Sprite { get; set; } = SpriteSpecifier.Invalid;
  114. /// <summary>
  115. /// Relative size of the sprite displayed in FoodSequence
  116. /// </summary>
  117. public Vector2 Scale { get; set; } = Vector2.One;
  118. /// <summary>
  119. /// The offset of a particular layer. Allows a little position randomization of each layer.
  120. /// </summary>
  121. public Vector2 LocalOffset { get; set; } = Vector2.Zero;
  122. public FoodSequenceVisualLayer(ProtoId<FoodSequenceElementPrototype> proto,
  123. SpriteSpecifier? sprite,
  124. Vector2 scale,
  125. Vector2 offset)
  126. {
  127. Proto = proto;
  128. Sprite = sprite;
  129. Scale = scale;
  130. LocalOffset = offset;
  131. }
  132. }