diff --git a/Content.Server/Chemistry/EntitySystems/InjectorSystem.cs b/Content.Server/Chemistry/EntitySystems/InjectorSystem.cs index c5c45daa5bd581..eb2039604afdab 100644 --- a/Content.Server/Chemistry/EntitySystems/InjectorSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/InjectorSystem.cs @@ -13,6 +13,7 @@ using Content.Shared.Interaction; using Content.Shared.Mobs.Components; using Content.Shared.Stacks; +using Content.Shared.Nutrition.EntitySystems; namespace Content.Server.Chemistry.EntitySystems; @@ -20,6 +21,7 @@ public sealed class InjectorSystem : SharedInjectorSystem { [Dependency] private readonly BloodstreamSystem _blood = default!; [Dependency] private readonly ReactiveSystem _reactiveSystem = default!; + [Dependency] private readonly OpenableSystem _openable = default!; public override void Initialize() { @@ -31,13 +33,14 @@ public override void Initialize() private bool TryUseInjector(Entity injector, EntityUid target, EntityUid user) { + var isOpenOrIgnored = injector.Comp.IgnoreClosed || !_openable.IsClosed(target); // Handle injecting/drawing for solutions if (injector.Comp.ToggleState == InjectorToggleMode.Inject) { - if (SolutionContainers.TryGetInjectableSolution(target, out var injectableSolution, out _)) + if (isOpenOrIgnored && SolutionContainers.TryGetInjectableSolution(target, out var injectableSolution, out _)) return TryInject(injector, target, injectableSolution.Value, user, false); - if (SolutionContainers.TryGetRefillableSolution(target, out var refillableSolution, out _)) + if (isOpenOrIgnored && SolutionContainers.TryGetRefillableSolution(target, out var refillableSolution, out _)) return TryInject(injector, target, refillableSolution.Value, user, true); if (TryComp(target, out var bloodstream)) @@ -58,7 +61,7 @@ private bool TryUseInjector(Entity injector, EntityUid target } // Draw from an object (food, beaker, etc) - if (SolutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _)) + if (isOpenOrIgnored && SolutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _)) return TryDraw(injector, target, drawableSolution.Value, user); Popup.PopupEntity(Loc.GetString("injector-component-cannot-draw-message", diff --git a/Content.Shared/Chemistry/Components/InjectorComponent.cs b/Content.Shared/Chemistry/Components/InjectorComponent.cs index 17a65ef1c179cf..ebd6654d9f5ca3 100644 --- a/Content.Shared/Chemistry/Components/InjectorComponent.cs +++ b/Content.Shared/Chemistry/Components/InjectorComponent.cs @@ -45,6 +45,15 @@ public sealed partial class InjectorComponent : Component [DataField] public bool IgnoreMobs; + /// + /// Whether or not the injector is able to draw from or inject into containers that are closed/sealed + /// + /// + /// for example: droppers can not inject into cans, but syringes can + /// + [DataField] + public bool IgnoreClosed = true; + /// /// The minimum amount of solution that can be transferred at once from this solution. /// diff --git a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml index 527b0ba5e620cc..edaa8288145ebd 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml @@ -283,6 +283,7 @@ - type: Injector injectOnly: false ignoreMobs: true + ignoreClosed: false minTransferAmount: 1 maxTransferAmount: 5 transferAmount: 1