Combine solution injection systems; Fix embeddable injectors (#26268)

* Combine injection systems

* Update Content.Server/Chemistry/EntitySystems/SolutionInjectOnEventSystem.cs

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Tayrtahn
2024-03-31 23:39:34 -04:00
committed by GitHub
parent d8d4feec38
commit d0d12760a8
12 changed files with 249 additions and 182 deletions

View File

@@ -0,0 +1,60 @@
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
namespace Content.Server.Chemistry.Components;
/// <summary>
/// Base class for components that inject a solution into a target's bloodstream in response to an event.
/// </summary>
public abstract partial class BaseSolutionInjectOnEventComponent : Component
{
/// <summary>
/// How much solution to remove from this entity per target when transferring.
/// </summary>
/// <remarks>
/// Note that this amount is per target, so the total amount removed will be
/// multiplied by the number of targets hit.
/// </remarks>
[DataField]
public FixedPoint2 TransferAmount = FixedPoint2.New(1);
[ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
/// <summary>
/// Proportion of the <see cref="TransferAmount"/> that will actually be injected
/// into the target's bloodstream. The rest is lost.
/// 0 means none of the transferred solution will enter the bloodstream.
/// 1 means the entire amount will enter the bloodstream.
/// </summary>
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
/// <summary>
/// Solution to inject from.
/// </summary>
[DataField]
public string Solution = "default";
/// <summary>
/// Whether this will inject through hardsuits or not.
/// </summary>
[DataField]
public bool PierceArmor = true;
/// <summary>
/// Contents of popup message to display to the attacker when injection
/// fails due to the target wearing a hardsuit.
/// </summary>
/// <remarks>
/// Passed values: $weapon and $target
/// </remarks>
[DataField]
public LocId BlockedByHardsuitPopupMessage = "melee-inject-failed-hardsuit";
/// <summary>
/// If anything covers any of these slots then the injection fails.
/// </summary>
[DataField]
public SlotFlags BlockSlots = SlotFlags.NONE;
}

View File

@@ -1,31 +1,8 @@
using Content.Shared.FixedPoint;
namespace Content.Server.Chemistry.Components;
namespace Content.Server.Chemistry.Components
{
[RegisterComponent]
public sealed partial class MeleeChemicalInjectorComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("transferAmount")]
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(1);
[ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
/// <summary>
/// Whether this will inject through hardsuits or not.
/// </summary>
[DataField("pierceArmor"), ViewVariables(VVAccess.ReadWrite)]
public bool PierceArmor = true;
/// <summary>
/// Solution to inject from.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("solution")]
public string Solution { get; set; } = "default";
}
}
/// <summary>
/// Used for melee weapon entities that should try to inject a
/// contained solution into a target when used to hit it.
/// </summary>
[RegisterComponent]
public sealed partial class MeleeChemicalInjectorComponent : BaseSolutionInjectOnEventComponent { }

View File

@@ -1,28 +0,0 @@
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.Projectiles;
namespace Content.Server.Chemistry.Components;
/// <summary>
/// On colliding with an entity that has a bloodstream will dump its solution onto them.
/// </summary>
[RegisterComponent]
public sealed partial class SolutionInjectOnCollideComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("transferAmount")]
public FixedPoint2 TransferAmount = FixedPoint2.New(1);
[ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
/// <summary>
/// If anything covers any of these slots then the injection fails.
/// </summary>
[DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)]
public SlotFlags BlockSlots = SlotFlags.MASK;
}

View File

@@ -0,0 +1,8 @@
namespace Content.Server.Chemistry.Components;
/// <summary>
/// Used for embeddable entities that should try to inject a
/// contained solution into a target when they become embedded in it.
/// </summary>
[RegisterComponent]
public sealed partial class SolutionInjectOnEmbedComponent : BaseSolutionInjectOnEventComponent { }

View File

@@ -0,0 +1,8 @@
namespace Content.Server.Chemistry.Components;
/// <summary>
/// Used for projectile entities that should try to inject a
/// contained solution into a target when they hit it.
/// </summary>
[RegisterComponent]
public sealed partial class SolutionInjectOnProjectileHitComponent : BaseSolutionInjectOnEventComponent { }