Fix remote solution injection (#23429)

Checks if its own fixture is hard so the fly-by fixture can't also proc it.
This commit is contained in:
metalgearsloth
2024-01-03 18:57:36 +11:00
committed by GitHub
parent bc304a3127
commit 9f47079d02
2 changed files with 52 additions and 55 deletions

View File

@@ -1,18 +1,17 @@
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Inventory; using Content.Shared.Inventory;
namespace Content.Server.Chemistry.Components namespace Content.Server.Chemistry.Components;
{
/// <summary> /// <summary>
/// On colliding with an entity that has a bloodstream will dump its solution onto them. /// On colliding with an entity that has a bloodstream will dump its solution onto them.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
internal sealed partial class SolutionInjectOnCollideComponent : Component public sealed partial class SolutionInjectOnCollideComponent : Component
{ {
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("transferAmount")] [DataField("transferAmount")]
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(1); public FixedPoint2 TransferAmount = FixedPoint2.New(1);
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); } public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
@@ -26,4 +25,3 @@ namespace Content.Server.Chemistry.Components
[DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)] [DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)]
public SlotFlags BlockSlots = SlotFlags.MASK; public SlotFlags BlockSlots = SlotFlags.MASK;
} }
}

View File

@@ -6,10 +6,9 @@ using Content.Shared.Inventory;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
namespace Content.Server.Chemistry.EntitySystems namespace Content.Server.Chemistry.EntitySystems;
{
[UsedImplicitly] public sealed class SolutionInjectOnCollideSystem : EntitySystem
internal sealed class SolutionInjectOnCollideSystem : EntitySystem
{ {
[Dependency] private readonly SolutionContainerSystem _solutionContainersSystem = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainersSystem = default!;
[Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!; [Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!;
@@ -27,6 +26,7 @@ namespace Content.Server.Chemistry.EntitySystems
var target = args.OtherEntity; var target = args.OtherEntity;
if (!args.OtherBody.Hard || if (!args.OtherBody.Hard ||
!args.OurBody.Hard ||
!EntityManager.TryGetComponent<BloodstreamComponent>(target, out var bloodstream) || !EntityManager.TryGetComponent<BloodstreamComponent>(target, out var bloodstream) ||
!_solutionContainersSystem.TryGetInjectableSolution(ent.Owner, out var solution, out _)) !_solutionContainersSystem.TryGetInjectableSolution(ent.Owner, out var solution, out _))
{ {
@@ -50,4 +50,3 @@ namespace Content.Server.Chemistry.EntitySystems
_bloodstreamSystem.TryAddToChemicals(target, solToInject, bloodstream); _bloodstreamSystem.TryAddToChemicals(target, solToInject, bloodstream);
} }
} }
}