Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Droppers Respect Closed/Sealed Containers #33011

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Content.Server/Chemistry/EntitySystems/InjectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
using Content.Shared.Interaction;
using Content.Shared.Mobs.Components;
using Content.Shared.Stacks;
using Content.Shared.Nutrition.EntitySystems;

namespace Content.Server.Chemistry.EntitySystems;

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()
{
Expand All @@ -34,10 +36,10 @@ private bool TryUseInjector(Entity<InjectorComponent> injector, EntityUid target
// Handle injecting/drawing for solutions
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
if (SolutionContainers.TryGetInjectableSolution(target, out var injectableSolution, out _))
if (SolutionContainers.TryGetInjectableSolution(target, out var injectableSolution, out _) && (injector.Comp.IgnoreClosed || !_openable.IsClosed(target)))
return TryInject(injector, target, injectableSolution.Value, user, false);

if (SolutionContainers.TryGetRefillableSolution(target, out var refillableSolution, out _))
if (SolutionContainers.TryGetRefillableSolution(target, out var refillableSolution, out _) && (injector.Comp.IgnoreClosed || !_openable.IsClosed(target)))
return TryInject(injector, target, refillableSolution.Value, user, true);

if (TryComp<BloodstreamComponent>(target, out var bloodstream))
Expand All @@ -58,7 +60,7 @@ private bool TryUseInjector(Entity<InjectorComponent> injector, EntityUid target
}

// Draw from an object (food, beaker, etc)
if (SolutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _))
if (SolutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _) && (injector.Comp.IgnoreClosed || !_openable.IsClosed(target)))
return TryDraw(injector, target, drawableSolution.Value, user);

Popup.PopupEntity(Loc.GetString("injector-component-cannot-draw-message",
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Chemistry/Components/InjectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public sealed partial class InjectorComponent : Component
[DataField]
public bool IgnoreMobs;

/// <summary>
/// Whether or not the injector is able to draw from or inject into containers that are closed/sealed
/// </summary>
/// <remarks>
/// for example: droppers can not inject into cans, but syringes can
/// </remarks>
[DataField]
public bool IgnoreClosed = true;

/// <summary>
/// The minimum amount of solution that can be transferred at once from this solution.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
- type: Injector
injectOnly: false
ignoreMobs: true
ignoreClosed: false
minTransferAmount: 1
maxTransferAmount: 5
transferAmount: 1
Expand Down
Loading