using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Prototypes;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.DoAfter;
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Chemistry.Components;
///
/// Implements draw/inject behavior for droppers 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 mob's bloodstream.
///
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(InjectorSystem))]
public sealed partial class InjectorComponent : Component
{
///
/// The solution to draw into or inject from.
///
[DataField]
public string SolutionName = "injector";
///
/// A cached reference to the solution.
///
[ViewVariables]
public Entity? Solution = null;
///
/// Amount to inject or draw on each usage.
///
///
/// If its set null, this injector is marked to inject its entire contents upon usage.
///
[DataField, AutoNetworkedField]
public FixedPoint2? CurrentTransferAmount = FixedPoint2.New(5);
///
/// The mode that this injector starts with on MapInit.
///
[DataField(required: true), AutoNetworkedField]
public ProtoId ActiveModeProtoId;
///
/// The possible that it can switch between.
///
[DataField(required: true)]
public List> AllowedModes;
///
/// Whether the injector is able to draw from or inject from mobs.
///
///
/// Droppers ignore mobs.
///
[DataField]
public bool IgnoreMobs;
///
/// Whether the injector is able to draw from or inject into containers that are closed/sealed.
///
///
/// Droppers can't inject into closed cans.
///
[DataField]
public bool IgnoreClosed = true;
///
/// Reagents that are allowed to be within this injector.
/// If a solution has both allowed and non-allowed reagents, only allowed reagents will be drawn into this injector.
/// A null ReagentWhitelist indicates all reagents are allowed.
///
[DataField]
public List>? ReagentWhitelist;
///
/// DeltaV - If set to true, this injector will only target the smallest reagent in the solution.
/// Incompatible with ReagentWhitelist.
///
[DataField]
public bool TargetSmallest;
#region Arguments for injection doafter
///
[DataField]
public bool NeedHand = true;
///
[DataField]
public bool BreakOnHandChange = true;
///
[DataField]
public float MovementThreshold = 0.1f;
#endregion
}
internal static class InjectorToggleModeExtensions
{
public static bool HasAnyFlag(this InjectorBehavior s1, InjectorBehavior s2)
{
return (s1 & s2) != 0;
}
}