Make Droppers Respect Closed/Sealed Containers (#33011)
* Make droppers respect closed/sealed * Combine nested * Optimize conditions a bit
This commit is contained in:
@@ -13,6 +13,7 @@ using Content.Shared.IdentityManagement;
|
||||
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 sealed class InjectorSystem : SharedInjectorSystem
|
||||
|
||||
private bool TryUseInjector(Entity<InjectorComponent> 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<BloodstreamComponent>(target, out var bloodstream))
|
||||
@@ -58,7 +61,7 @@ public sealed class InjectorSystem : SharedInjectorSystem
|
||||
}
|
||||
|
||||
// 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",
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -283,6 +283,7 @@
|
||||
- type: Injector
|
||||
injectOnly: false
|
||||
ignoreMobs: true
|
||||
ignoreClosed: false
|
||||
minTransferAmount: 1
|
||||
maxTransferAmount: 5
|
||||
transferAmount: 1
|
||||
|
||||
Reference in New Issue
Block a user