MetabolizerComponent.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Content.Server.Body.Systems;
  2. using Content.Shared.Body.Prototypes;
  3. using Content.Shared.FixedPoint;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  6. namespace Content.Server.Body.Components
  7. {
  8. /// <summary>
  9. /// Handles metabolizing various reagents with given effects.
  10. /// </summary>
  11. [RegisterComponent, Access(typeof(MetabolizerSystem))]
  12. public sealed partial class MetabolizerComponent : Component
  13. {
  14. /// <summary>
  15. /// The next time that reagents will be metabolized.
  16. /// </summary>
  17. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  18. public TimeSpan NextUpdate;
  19. /// <summary>
  20. /// How often to metabolize reagents.
  21. /// </summary>
  22. /// <returns></returns>
  23. [DataField]
  24. public TimeSpan UpdateInterval = TimeSpan.FromSeconds(1);
  25. /// <summary>
  26. /// From which solution will this metabolizer attempt to metabolize chemicals
  27. /// </summary>
  28. [DataField("solution")]
  29. public string SolutionName = BloodstreamComponent.DefaultChemicalsSolutionName;
  30. /// <summary>
  31. /// Does this component use a solution on it's parent entity (the body) or itself
  32. /// </summary>
  33. /// <remarks>
  34. /// Most things will use the parent entity (bloodstream).
  35. /// </remarks>
  36. [DataField]
  37. public bool SolutionOnBody = true;
  38. /// <summary>
  39. /// List of metabolizer types that this organ is. ex. Human, Slime, Felinid, w/e.
  40. /// </summary>
  41. [DataField]
  42. [Access(typeof(MetabolizerSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
  43. public HashSet<ProtoId<MetabolizerTypePrototype>>? MetabolizerTypes = null;
  44. /// <summary>
  45. /// Should this metabolizer remove chemicals that have no metabolisms defined?
  46. /// As a stop-gap, basically.
  47. /// </summary>
  48. [DataField]
  49. public bool RemoveEmpty = false;
  50. /// <summary>
  51. /// How many reagents can this metabolizer process at once?
  52. /// Used to nerf 'stacked poisons' where having 5+ different poisons in a syringe, even at low
  53. /// quantity, would be muuuuch better than just one poison acting.
  54. /// </summary>
  55. [DataField("maxReagents")]
  56. public int MaxReagentsProcessable = 3;
  57. /// <summary>
  58. /// A list of metabolism groups that this metabolizer will act on, in order of precedence.
  59. /// </summary>
  60. [DataField("groups")]
  61. public List<MetabolismGroupEntry>? MetabolismGroups = default!;
  62. }
  63. /// <summary>
  64. /// Contains data about how a metabolizer will metabolize a single group.
  65. /// This allows metabolizers to remove certain groups much faster, or not at all.
  66. /// </summary>
  67. [DataDefinition]
  68. public sealed partial class MetabolismGroupEntry
  69. {
  70. [DataField(required: true)]
  71. public ProtoId<MetabolismGroupPrototype> Id = default!;
  72. [DataField("rateModifier")]
  73. public FixedPoint2 MetabolismRateModifier = 1.0;
  74. }
  75. }