ArtifactComponent.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using Content.Shared.Xenoarchaeology.XenoArtifacts;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  5. namespace Content.Server.Xenoarchaeology.XenoArtifacts;
  6. [RegisterComponent, Access(typeof(ArtifactSystem))]
  7. public sealed partial class ArtifactComponent : Component
  8. {
  9. /// <summary>
  10. /// Every node contained in the tree
  11. /// </summary>
  12. [DataField("nodeTree"), ViewVariables]
  13. public List<ArtifactNode> NodeTree = new();
  14. /// <summary>
  15. /// The current node the artifact is on.
  16. /// </summary>
  17. [DataField("currentNodeId"), ViewVariables]
  18. public int? CurrentNodeId;
  19. #region Node Tree Gen
  20. /// <summary>
  21. /// Minimum number of nodes to generate, inclusive
  22. /// </summary>
  23. [DataField("nodesMin")]
  24. public int NodesMin = 3;
  25. /// <summary>
  26. /// Maximum number of nodes to generate, exclusive
  27. /// </summary>
  28. [DataField("nodesMax")]
  29. public int NodesMax = 9;
  30. #endregion
  31. /// <summary>
  32. /// Cooldown time between artifact activations (in seconds).
  33. /// </summary>
  34. [DataField("timer"), ViewVariables(VVAccess.ReadWrite)]
  35. public TimeSpan CooldownTime = TimeSpan.FromSeconds(5);
  36. /// <summary>
  37. /// Is this artifact under some suppression device?
  38. /// f true, will ignore all trigger activations attempts.
  39. /// </summary>
  40. [DataField("isSuppressed"), ViewVariables(VVAccess.ReadWrite)]
  41. public bool IsSuppressed;
  42. /// <summary>
  43. /// The last time the artifact was activated.
  44. /// </summary>
  45. [DataField("lastActivationTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
  46. public TimeSpan LastActivationTime;
  47. /// <summary>
  48. /// A multiplier applied to the calculated point value
  49. /// to determine the monetary value of the artifact
  50. /// </summary>
  51. [DataField("priceMultiplier"), ViewVariables(VVAccess.ReadWrite)]
  52. public float PriceMultiplier = 0.05f;
  53. /// <summary>
  54. /// The base amount of research points for each artifact node.
  55. /// </summary>
  56. [DataField("pointsPerNode"), ViewVariables(VVAccess.ReadWrite)]
  57. public int PointsPerNode = 6500;
  58. /// <summary>
  59. /// Research points which have been "consumed" from the theoretical max value of the artifact.
  60. /// </summary>
  61. [DataField("consumedPoints"), ViewVariables(VVAccess.ReadWrite)]
  62. public int ConsumedPoints;
  63. /// <summary>
  64. /// A multiplier that is raised to the power of the average depth of a node.
  65. /// Used for calculating the research point value of an artifact node.
  66. /// </summary>
  67. [DataField("pointDangerMultiplier"), ViewVariables(VVAccess.ReadWrite)]
  68. public float PointDangerMultiplier = 1.35f;
  69. /// <summary>
  70. /// The sound that plays when an artifact is activated
  71. /// </summary>
  72. [DataField("activationSound")]
  73. public SoundSpecifier ActivationSound = new SoundCollectionSpecifier("ArtifactActivation")
  74. {
  75. Params = new()
  76. {
  77. Variation = 0.1f,
  78. Volume = 3f
  79. }
  80. };
  81. [DataField("activateActionEntity")] public EntityUid? ActivateActionEntity;
  82. }
  83. /// <summary>
  84. /// A single "node" of an artifact that contains various data about it.
  85. /// </summary>
  86. [DataDefinition]
  87. public sealed partial class ArtifactNode : ICloneable
  88. {
  89. /// <summary>
  90. /// A numeric id corresponding to each node.
  91. /// </summary>
  92. [DataField("id"), ViewVariables]
  93. public int Id;
  94. /// <summary>
  95. /// how "deep" into the node tree. used for generation and price/value calculations
  96. /// </summary>
  97. [DataField("depth"), ViewVariables]
  98. public int Depth;
  99. /// <summary>
  100. /// A list of surrounding nodes. Used for tree traversal
  101. /// </summary>
  102. [DataField("edges"), ViewVariables]
  103. public HashSet<int> Edges = new();
  104. /// <summary>
  105. /// Whether or not the node has been entered
  106. /// </summary>
  107. [DataField("discovered"), ViewVariables(VVAccess.ReadWrite)]
  108. public bool Discovered;
  109. /// <summary>
  110. /// The trigger for the node
  111. /// </summary>
  112. [DataField("trigger", customTypeSerializer: typeof(PrototypeIdSerializer<ArtifactTriggerPrototype>), required: true), ViewVariables]
  113. public string Trigger = default!;
  114. /// <summary>
  115. /// Whether or not the node has been triggered
  116. /// </summary>
  117. [DataField("triggered"), ViewVariables(VVAccess.ReadWrite)]
  118. public bool Triggered;
  119. /// <summary>
  120. /// The effect when the node is activated
  121. /// </summary>
  122. [DataField("effect", customTypeSerializer: typeof(PrototypeIdSerializer<ArtifactEffectPrototype>), required: true), ViewVariables]
  123. public string Effect = default!;
  124. /// <summary>
  125. /// Used for storing cumulative information about nodes
  126. /// </summary>
  127. [DataField("nodeData"), ViewVariables]
  128. public Dictionary<string, object> NodeData = new();
  129. public object Clone()
  130. {
  131. return new ArtifactNode
  132. {
  133. Id = Id,
  134. Depth = Depth,
  135. Edges = Edges,
  136. Discovered = Discovered,
  137. Trigger = Trigger,
  138. Triggered = Triggered,
  139. Effect = Effect,
  140. NodeData = NodeData
  141. };
  142. }
  143. }