using System.Threading; using Content.Shared.Chemistry.Components; using Content.Shared.FixedPoint; namespace Content.Server.Chemistry.Components { /// /// Server behavior for reagent injectors and syringes. Can optionally support both /// injection and drawing or just injection. Can inject/draw reagents from solution /// containers, and can directly inject into a mobs bloodstream. /// [RegisterComponent] public sealed class InjectorComponent : SharedInjectorComponent { public const string SolutionName = "injector"; /// /// Whether or not the injector is able to draw from containers or if it's a single use /// device that can only inject. /// [DataField("injectOnly")] public bool InjectOnly; /// /// Whether or not the injector is able to draw from or inject from mobs /// /// /// for example: droppers would ignore mobs /// [DataField("ignoreMobs")] public bool IgnoreMobs = false; /// /// The minimum amount of solution that can be transferred at once from this solution. /// [DataField("minTransferAmount")] [ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 MinimumTransferAmount { get; set; } = FixedPoint2.New(5); /// /// The maximum amount of solution that can be transferred at once from this solution. /// [DataField("maxTransferAmount")] [ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 MaximumTransferAmount { get; set; } = FixedPoint2.New(50); /// /// Amount to inject or draw on each usage. If the injector is inject only, it will /// attempt to inject it's entire contents upon use. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("transferAmount")] public FixedPoint2 TransferAmount = FixedPoint2.New(5); /// /// Injection delay (seconds) when the target is a mob. /// /// /// The base delay has a minimum of 1 second, but this will still be modified if the target is incapacitated or /// in combat mode. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] public float Delay = 5; /// /// Token for interrupting a do-after action (e.g., injection another player). If not null, implies /// component is currently "in use". /// public CancellationTokenSource? CancelToken; [DataField("toggleState")] private InjectorToggleMode _toggleState; /// /// The state of the injector. Determines it's attack behavior. Containers must have the /// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should /// only ever be set to Inject /// [ViewVariables(VVAccess.ReadWrite)] public InjectorToggleMode ToggleState { get => _toggleState; set { _toggleState = value; Dirty(); } } } }