InjectorComponent.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using Content.Shared.Chemistry.EntitySystems;
  2. using Content.Shared.Chemistry.Reagent;
  3. using Content.Shared.DoAfter;
  4. using Content.Shared.FixedPoint;
  5. using Robust.Shared.GameStates;
  6. using Robust.Shared.Prototypes;
  7. using Robust.Shared.Serialization;
  8. namespace Content.Shared.Chemistry.Components;
  9. [Serializable, NetSerializable]
  10. public sealed partial class InjectorDoAfterEvent : SimpleDoAfterEvent
  11. {
  12. }
  13. /// <summary>
  14. /// Implements draw/inject behavior for droppers and syringes.
  15. /// </summary>
  16. /// <remarks>
  17. /// Can optionally support both
  18. /// injection and drawing or just injection. Can inject/draw reagents from solution
  19. /// containers, and can directly inject into a mobs bloodstream.
  20. /// </remarks>
  21. /// <seealso cref="SharedInjectorSystem"/>
  22. /// <seealso cref="InjectorToggleMode"/>
  23. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  24. public sealed partial class InjectorComponent : Component
  25. {
  26. [DataField]
  27. public string SolutionName = "injector";
  28. /// <summary>
  29. /// Whether or not the injector is able to draw from containers or if it's a single use
  30. /// device that can only inject.
  31. /// </summary>
  32. [DataField]
  33. public bool InjectOnly;
  34. /// <summary>
  35. /// Whether or not the injector is able to draw from or inject from mobs
  36. /// </summary>
  37. /// <remarks>
  38. /// for example: droppers would ignore mobs
  39. /// </remarks>
  40. [DataField]
  41. public bool IgnoreMobs;
  42. /// <summary>
  43. /// Whether or not the injector is able to draw from or inject into containers that are closed/sealed
  44. /// </summary>
  45. /// <remarks>
  46. /// for example: droppers can not inject into cans, but syringes can
  47. /// </remarks>
  48. [DataField]
  49. public bool IgnoreClosed = true;
  50. /// <summary>
  51. /// The minimum amount of solution that can be transferred at once from this solution.
  52. /// </summary>
  53. [DataField("minTransferAmount")]
  54. public FixedPoint2 MinimumTransferAmount = FixedPoint2.New(5);
  55. /// <summary>
  56. /// The maximum amount of solution that can be transferred at once from this solution.
  57. /// </summary>
  58. [DataField("maxTransferAmount")]
  59. public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(15);
  60. /// <summary>
  61. /// Amount to inject or draw on each usage. If the injector is inject only, it will
  62. /// attempt to inject it's entire contents upon use.
  63. /// </summary>
  64. [DataField]
  65. [AutoNetworkedField]
  66. public FixedPoint2 TransferAmount = FixedPoint2.New(5);
  67. /// <summary>
  68. /// Injection delay (seconds) when the target is a mob.
  69. /// </summary>
  70. /// <remarks>
  71. /// The base delay has a minimum of 1 second, but this will still be modified if the target is incapacitated or
  72. /// in combat mode.
  73. /// </remarks>
  74. [DataField]
  75. public TimeSpan Delay = TimeSpan.FromSeconds(5);
  76. /// <summary>
  77. /// Each additional 1u after first 5u increases the delay by X seconds.
  78. /// </summary>
  79. [DataField]
  80. public TimeSpan DelayPerVolume = TimeSpan.FromSeconds(0.1);
  81. /// <summary>
  82. /// The state of the injector. Determines it's attack behavior. Containers must have the
  83. /// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should
  84. /// only ever be set to Inject
  85. /// </summary>
  86. [AutoNetworkedField]
  87. [DataField]
  88. public InjectorToggleMode ToggleState = InjectorToggleMode.Draw;
  89. /// <summary>
  90. /// Reagents that are allowed to be within this injector.
  91. /// If a solution has both allowed and non-allowed reagents, only allowed reagents will be drawn into this injector.
  92. /// A null ReagentWhitelist indicates all reagents are allowed.
  93. /// </summary>
  94. [DataField]
  95. public List<ProtoId<ReagentPrototype>>? ReagentWhitelist = null;
  96. #region Arguments for injection doafter
  97. /// <inheritdoc cref=DoAfterArgs.NeedHand>
  98. [DataField]
  99. public bool NeedHand = true;
  100. /// <inheritdoc cref=DoAfterArgs.BreakOnHandChange>
  101. [DataField]
  102. public bool BreakOnHandChange = true;
  103. /// <inheritdoc cref=DoAfterArgs.MovementThreshold>
  104. [DataField]
  105. public float MovementThreshold = 0.1f;
  106. #endregion
  107. }
  108. /// <summary>
  109. /// Possible modes for an <see cref="InjectorComponent"/>.
  110. /// </summary>
  111. public enum InjectorToggleMode : byte
  112. {
  113. /// <summary>
  114. /// The injector will try to inject reagent into things.
  115. /// </summary>
  116. Inject,
  117. /// <summary>
  118. /// The injector will try to draw reagent from things.
  119. /// </summary>
  120. Draw
  121. }