diff --git a/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs b/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs
index 66a09b79f4..2e86e82793 100644
--- a/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs
+++ b/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs
@@ -1,6 +1,7 @@
using System;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
+using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -23,5 +24,11 @@ namespace Content.Server.Chemistry.Components
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
+
+ ///
+ /// If anything covers any of these slots then the injection fails.
+ ///
+ [DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)]
+ public SlotFlags BlockSlots = SlotFlags.MASK;
}
}
diff --git a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs
index bbebedb4a4..1f91439591 100644
--- a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs
+++ b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs
@@ -2,18 +2,22 @@ using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.Components.SolutionManager;
+using Content.Server.Nutrition.EntitySystems;
+using Content.Shared.Inventory;
using JetBrains.Annotations;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
using Robust.Shared.Physics.Dynamics;
+using Robust.Shared.Prototypes;
+
namespace Content.Server.Chemistry.EntitySystems
{
[UsedImplicitly]
internal sealed class SolutionInjectOnCollideSystem : EntitySystem
{
+ [Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
[Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!;
+ [Dependency] private readonly InventorySystem _inventorySystem = default!;
public override void Initialize()
{
@@ -30,15 +34,29 @@ namespace Content.Server.Chemistry.EntitySystems
private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, StartCollideEvent args)
{
- if (!EntityManager.TryGetComponent(args.OtherFixture.Body.Owner, out var bloodstream) ||
+ var target = args.OtherFixture.Body.Owner;
+
+ if (!args.OtherFixture.Body.Hard ||
+ !EntityManager.TryGetComponent(target, out var bloodstream) ||
!_solutionsSystem.TryGetInjectableSolution(component.Owner, out var solution)) return;
+ if (component.BlockSlots != 0x0 && TryComp(target, out var inventory))
+ {
+ var containerEnumerator = new InventorySystem.ContainerSlotEnumerator(target, inventory.TemplateId, _protoManager, _inventorySystem, component.BlockSlots);
+
+ while (containerEnumerator.MoveNext(out var container))
+ {
+ if (!container.ContainedEntity.HasValue) continue;
+ return;
+ }
+ }
+
var solRemoved = solution.SplitSolution(component.TransferAmount);
var solRemovedVol = solRemoved.TotalVolume;
var solToInject = solRemoved.SplitSolution(solRemovedVol * component.TransferEfficiency);
- _bloodstreamSystem.TryAddToChemicals((args.OtherFixture.Body).Owner, solToInject, bloodstream);
+ _bloodstreamSystem.TryAddToChemicals(target, solToInject, bloodstream);
}
}
}
diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml
index ad0fa4d485..53bee35db2 100644
--- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml
+++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml
@@ -114,6 +114,9 @@
- state: tin
- state: plain
- type: CreamPie
+ - type: SolutionInjectOnCollide
+ transferAmount: 20
+ transferEfficiency: 0.2
# Tastes like pie, cream, banana.
- type: entity