Predict InjectorSystem (#39976)

* predict injectors

* hide verbs if no options
This commit is contained in:
slarticodefast
2025-09-01 17:24:37 +02:00
committed by GitHub
parent feb0fac20f
commit 86e77f05ce
11 changed files with 512 additions and 503 deletions

View File

@@ -2,7 +2,6 @@ using Content.Client.Chemistry.UI;
using Content.Client.Items; using Content.Client.Items;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Chemistry.EntitySystems;
using Robust.Shared.GameStates;
namespace Content.Client.Chemistry.EntitySystems; namespace Content.Client.Chemistry.EntitySystems;
@@ -11,6 +10,7 @@ public sealed class InjectorSystem : SharedInjectorSystem
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent, SolutionContainers));
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent, SolutionContainer));
} }
} }

View File

@@ -38,13 +38,13 @@ public sealed class InjectorStatusControl : Control
// only updates the UI if any of the details are different than they previously were // only updates the UI if any of the details are different than they previously were
if (PrevVolume == solution.Volume if (PrevVolume == solution.Volume
&& PrevMaxVolume == solution.MaxVolume && PrevMaxVolume == solution.MaxVolume
&& PrevTransferAmount == _parent.Comp.TransferAmount && PrevTransferAmount == _parent.Comp.CurrentTransferAmount
&& PrevToggleState == _parent.Comp.ToggleState) && PrevToggleState == _parent.Comp.ToggleState)
return; return;
PrevVolume = solution.Volume; PrevVolume = solution.Volume;
PrevMaxVolume = solution.MaxVolume; PrevMaxVolume = solution.MaxVolume;
PrevTransferAmount = _parent.Comp.TransferAmount; PrevTransferAmount = _parent.Comp.CurrentTransferAmount;
PrevToggleState = _parent.Comp.ToggleState; PrevToggleState = _parent.Comp.ToggleState;
// Update current volume and injector state // Update current volume and injector state
@@ -59,6 +59,6 @@ public sealed class InjectorStatusControl : Control
("currentVolume", solution.Volume), ("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume), ("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized), ("modeString", modeStringLocalized),
("transferVolume", _parent.Comp.TransferAmount))); ("transferVolume", _parent.Comp.CurrentTransferAmount)));
} }
} }

View File

@@ -1,414 +1,6 @@
using Content.Server.Body.Systems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Body.Components;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.FixedPoint;
using Content.Shared.Forensics;
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; namespace Content.Server.Chemistry.EntitySystems;
public sealed class InjectorSystem : SharedInjectorSystem 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()
{
base.Initialize();
SubscribeLocalEvent<InjectorComponent, InjectorDoAfterEvent>(OnInjectDoAfter);
SubscribeLocalEvent<InjectorComponent, AfterInteractEvent>(OnInjectorAfterInteract);
}
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 (isOpenOrIgnored && SolutionContainers.TryGetInjectableSolution(target, out var injectableSolution, out _))
return TryInject(injector, target, injectableSolution.Value, user, false);
if (isOpenOrIgnored && SolutionContainers.TryGetRefillableSolution(target, out var refillableSolution, out _))
return TryInject(injector, target, refillableSolution.Value, user, true);
if (TryComp<BloodstreamComponent>(target, out var bloodstream))
return TryInjectIntoBloodstream(injector, (target, bloodstream), user);
Popup.PopupEntity(Loc.GetString("injector-component-cannot-transfer-message",
("target", Identity.Entity(target, EntityManager))), injector, user);
return false;
}
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
// Draw from a bloodstream, if the target has that
if (TryComp<BloodstreamComponent>(target, out var stream) &&
SolutionContainers.ResolveSolution(target, stream.BloodSolutionName, ref stream.BloodSolution))
{
return TryDraw(injector, (target, stream), stream.BloodSolution.Value, user);
}
// Draw from an object (food, beaker, etc)
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",
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
return false;
}
return false;
}
private void OnInjectDoAfter(Entity<InjectorComponent> entity, ref InjectorDoAfterEvent args)
{
if (args.Cancelled || args.Handled || args.Args.Target == null)
return;
args.Handled = TryUseInjector(entity, args.Args.Target.Value, args.Args.User);
}
private void OnInjectorAfterInteract(Entity<InjectorComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled || !args.CanReach)
return;
//Make sure we have the attacking entity
if (args.Target is not { Valid: true } target || !HasComp<SolutionContainerManagerComponent>(entity))
return;
// Is the target a mob? If yes, use a do-after to give them time to respond.
if (HasComp<MobStateComponent>(target) || HasComp<BloodstreamComponent>(target))
{
// Are use using an injector capable of targeting a mob?
if (entity.Comp.IgnoreMobs)
return;
InjectDoAfter(entity, target, args.User);
args.Handled = true;
return;
}
args.Handled = TryUseInjector(entity, target, args.User);
}
/// <summary>
/// Send informative pop-up messages and wait for a do-after to complete.
/// </summary>
private void InjectDoAfter(Entity<InjectorComponent> injector, EntityUid target, EntityUid user)
{
// Create a pop-up for the user
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
Popup.PopupEntity(Loc.GetString("injector-component-drawing-user"), target, user);
}
else
{
Popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user);
}
if (!SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out _, out var solution))
return;
var actualDelay = injector.Comp.Delay;
FixedPoint2 amountToInject;
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
// additional delay is based on actual volume left to draw in syringe when smaller than transfer amount
amountToInject = FixedPoint2.Min(injector.Comp.TransferAmount, (solution.MaxVolume - solution.Volume));
}
else
{
// additional delay is based on actual volume left to inject in syringe when smaller than transfer amount
amountToInject = FixedPoint2.Min(injector.Comp.TransferAmount, solution.Volume);
}
// Injections take 0.5 seconds longer per 5u of possible space/content
// First 5u(MinimumTransferAmount) doesn't incur delay
actualDelay += injector.Comp.DelayPerVolume * FixedPoint2.Max(0, amountToInject - injector.Comp.MinimumTransferAmount).Double();
// Ensure that minimum delay before incapacitation checks is 1 seconds
actualDelay = MathHelper.Max(actualDelay, TimeSpan.FromSeconds(1));
var isTarget = user != target;
if (isTarget)
{
// Create a pop-up for the target
var userName = Identity.Entity(user, EntityManager);
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
Popup.PopupEntity(Loc.GetString("injector-component-drawing-target",
("user", userName)), user, target);
}
else
{
Popup.PopupEntity(Loc.GetString("injector-component-injecting-target",
("user", userName)), user, target);
}
// Check if the target is incapacitated or in combat mode and modify time accordingly.
if (MobState.IsIncapacitated(target))
{
actualDelay /= 2.5f;
}
else if (Combat.IsInCombatMode(target))
{
// Slightly increase the delay when the target is in combat mode. Helps prevents cheese injections in
// combat with fast syringes & lag.
actualDelay += TimeSpan.FromSeconds(1);
}
// Add an admin log, using the "force feed" log type. It's not quite feeding, but the effect is the same.
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
AdminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to inject {ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}");
}
else
{
AdminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from {ToPrettyString(target):target}");
}
}
else
{
// Self-injections take half as long.
actualDelay /= 2;
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
AdminLogger.Add(LogType.Ingestion,
$"{ToPrettyString(user):user} is attempting to inject themselves with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}.");
}
else
{
AdminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from themselves.");
}
}
DoAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, actualDelay, new InjectorDoAfterEvent(), injector.Owner, target: target, used: injector.Owner)
{
BreakOnMove = true,
BreakOnWeightlessMove = false,
BreakOnDamage = true,
NeedHand = injector.Comp.NeedHand,
BreakOnHandChange = injector.Comp.BreakOnHandChange,
MovementThreshold = injector.Comp.MovementThreshold,
});
}
private bool TryInjectIntoBloodstream(Entity<InjectorComponent> injector, Entity<BloodstreamComponent> target,
EntityUid user)
{
// Get transfer amount. May be smaller than _transferAmount if not enough room
if (!SolutionContainers.ResolveSolution(target.Owner, target.Comp.ChemicalSolutionName,
ref target.Comp.ChemicalSolution, out var chemSolution))
{
Popup.PopupEntity(
Loc.GetString("injector-component-cannot-inject-message",
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
return false;
}
var realTransferAmount = FixedPoint2.Min(injector.Comp.TransferAmount, chemSolution.AvailableVolume);
if (realTransferAmount <= 0)
{
Popup.PopupEntity(
Loc.GetString("injector-component-cannot-inject-message",
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
return false;
}
// Move units from attackSolution to targetSolution
var removedSolution = SolutionContainers.SplitSolution(target.Comp.ChemicalSolution.Value, realTransferAmount);
_blood.TryAddToChemicals(target.AsNullable(), removedSolution);
_reactiveSystem.DoEntityReaction(target, removedSolution, ReactionMethod.Injection);
Popup.PopupEntity(Loc.GetString("injector-component-inject-success-message",
("amount", removedSolution.Volume),
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
Dirty(injector);
AfterInject(injector, target);
return true;
}
private bool TryInject(Entity<InjectorComponent> injector, EntityUid targetEntity,
Entity<SolutionComponent> targetSolution, EntityUid user, bool asRefill)
{
if (!SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out var soln,
out var solution) || solution.Volume == 0)
return false;
// Get transfer amount. May be smaller than _transferAmount if not enough room
var realTransferAmount =
FixedPoint2.Min(injector.Comp.TransferAmount, targetSolution.Comp.Solution.AvailableVolume);
if (realTransferAmount <= 0)
{
Popup.PopupEntity(
Loc.GetString("injector-component-target-already-full-message",
("target", Identity.Entity(targetEntity, EntityManager))),
injector.Owner, user);
return false;
}
// Move units from attackSolution to targetSolution
Solution removedSolution;
if (TryComp<StackComponent>(targetEntity, out var stack))
removedSolution = SolutionContainers.SplitStackSolution(soln.Value, realTransferAmount, stack.Count);
else
removedSolution = SolutionContainers.SplitSolution(soln.Value, realTransferAmount);
_reactiveSystem.DoEntityReaction(targetEntity, removedSolution, ReactionMethod.Injection);
if (!asRefill)
SolutionContainers.Inject(targetEntity, targetSolution, removedSolution);
else
SolutionContainers.Refill(targetEntity, targetSolution, removedSolution);
Popup.PopupEntity(Loc.GetString("injector-component-transfer-success-message",
("amount", removedSolution.Volume),
("target", Identity.Entity(targetEntity, EntityManager))), injector.Owner, user);
Dirty(injector);
AfterInject(injector, targetEntity);
return true;
}
private void AfterInject(Entity<InjectorComponent> injector, EntityUid target)
{
// Automatically set syringe to draw after completely draining it.
if (SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out _,
out var solution) && solution.Volume == 0)
{
SetMode(injector, InjectorToggleMode.Draw);
}
// Leave some DNA from the injectee on it
var ev = new TransferDnaEvent { Donor = target, Recipient = injector };
RaiseLocalEvent(target, ref ev);
}
private void AfterDraw(Entity<InjectorComponent> injector, EntityUid target)
{
// Automatically set syringe to inject after completely filling it.
if (SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out _,
out var solution) && solution.AvailableVolume == 0)
{
SetMode(injector, InjectorToggleMode.Inject);
}
// Leave some DNA from the drawee on it
var ev = new TransferDnaEvent { Donor = target, Recipient = injector };
RaiseLocalEvent(target, ref ev);
}
private bool TryDraw(Entity<InjectorComponent> injector, Entity<BloodstreamComponent?> target,
Entity<SolutionComponent> targetSolution, EntityUid user)
{
if (!SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out var soln,
out var solution) || solution.AvailableVolume == 0)
{
return false;
}
var applicableTargetSolution = targetSolution.Comp.Solution;
// If a whitelist exists, remove all non-whitelisted reagents from the target solution temporarily
var temporarilyRemovedSolution = new Solution();
if (injector.Comp.ReagentWhitelist is { } reagentWhitelist)
{
string[] reagentPrototypeWhitelistArray = new string[reagentWhitelist.Count];
var i = 0;
foreach (var reagent in reagentWhitelist)
{
reagentPrototypeWhitelistArray[i] = reagent;
++i;
}
temporarilyRemovedSolution = applicableTargetSolution.SplitSolutionWithout(applicableTargetSolution.Volume, reagentPrototypeWhitelistArray);
}
// Get transfer amount. May be smaller than _transferAmount if not enough room, also make sure there's room in the injector
var realTransferAmount = FixedPoint2.Min(injector.Comp.TransferAmount, applicableTargetSolution.Volume,
solution.AvailableVolume);
if (realTransferAmount <= 0)
{
Popup.PopupEntity(
Loc.GetString("injector-component-target-is-empty-message",
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
return false;
}
// We have some snowflaked behavior for streams.
if (target.Comp != null)
{
DrawFromBlood(injector, (target.Owner, target.Comp), soln.Value, realTransferAmount, user);
return true;
}
// Move units from attackSolution to targetSolution
var removedSolution = SolutionContainers.Draw(target.Owner, targetSolution, realTransferAmount);
// Add back non-whitelisted reagents to the target solution
SolutionContainers.TryAddSolution(targetSolution, temporarilyRemovedSolution);
if (!SolutionContainers.TryAddSolution(soln.Value, removedSolution))
{
return false;
}
Popup.PopupEntity(Loc.GetString("injector-component-draw-success-message",
("amount", removedSolution.Volume),
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
Dirty(injector);
AfterDraw(injector, target);
return true;
}
private void DrawFromBlood(Entity<InjectorComponent> injector, Entity<BloodstreamComponent> target,
Entity<SolutionComponent> injectorSolution, FixedPoint2 transferAmount, EntityUid user)
{
var drawAmount = (float) transferAmount;
if (SolutionContainers.ResolveSolution(target.Owner, target.Comp.ChemicalSolutionName,
ref target.Comp.ChemicalSolution))
{
var chemTemp = SolutionContainers.SplitSolution(target.Comp.ChemicalSolution.Value, drawAmount * 0.15f);
SolutionContainers.TryAddSolution(injectorSolution, chemTemp);
drawAmount -= (float) chemTemp.Volume;
}
if (SolutionContainers.ResolveSolution(target.Owner, target.Comp.BloodSolutionName,
ref target.Comp.BloodSolution))
{
var bloodTemp = SolutionContainers.SplitSolution(target.Comp.BloodSolution.Value, drawAmount);
SolutionContainers.TryAddSolution(injectorSolution, bloodTemp);
}
Popup.PopupEntity(Loc.GetString("injector-component-draw-success-message",
("amount", transferAmount),
("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
Dirty(injector);
AfterDraw(injector, target);
}
}

View File

@@ -307,6 +307,8 @@ namespace Content.Server.Forensics
component.Fingerprints.Add(fingerprint.Fingerprint ?? ""); component.Fingerprints.Add(fingerprint.Fingerprint ?? "");
} }
// TODO: Delete this. A lot of systems are manually raising this method event instead of calling the identical <see cref="TransferDna"/> method.
// According to our code conventions we should not use method events.
private void OnTransferDnaEvent(EntityUid uid, DnaComponent component, ref TransferDnaEvent args) private void OnTransferDnaEvent(EntityUid uid, DnaComponent component, ref TransferDnaEvent args)
{ {
if (component.DNA == null) if (component.DNA == null)
@@ -339,13 +341,7 @@ namespace Content.Server.Forensics
Dirty(ent); Dirty(ent);
} }
/// <summary> public override void TransferDna(EntityUid recipient, EntityUid donor, bool canDnaBeCleaned = true)
/// Transfer DNA from one entity onto the forensics of another
/// </summary>
/// <param name="recipient">The entity receiving the DNA</param>
/// <param name="donor">The entity applying its DNA</param>
/// <param name="canDnaBeCleaned">If this DNA be cleaned off of the recipient. e.g. cleaning a knife vs cleaning a puddle of blood</param>
public void TransferDna(EntityUid recipient, EntityUid donor, bool canDnaBeCleaned = true)
{ {
if (TryComp<DnaComponent>(donor, out var donorComp) && donorComp.DNA != null) if (TryComp<DnaComponent>(donor, out var donorComp) && donorComp.DNA != null)
{ {

View File

@@ -8,11 +8,6 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Chemistry.Components; namespace Content.Shared.Chemistry.Components;
[Serializable, NetSerializable]
public sealed partial class InjectorDoAfterEvent : SimpleDoAfterEvent
{
}
/// <summary> /// <summary>
/// Implements draw/inject behavior for droppers and syringes. /// Implements draw/inject behavior for droppers and syringes.
/// </summary> /// </summary>
@@ -26,9 +21,18 @@ public sealed partial class InjectorDoAfterEvent : SimpleDoAfterEvent
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class InjectorComponent : Component public sealed partial class InjectorComponent : Component
{ {
/// <summary>
/// The solution to draw into or inject from.
/// </summary>
[DataField] [DataField]
public string SolutionName = "injector"; public string SolutionName = "injector";
/// <summary>
/// A cached reference to the solution.
/// </summary>
[ViewVariables]
public Entity<SolutionComponent>? Solution = null;
/// <summary> /// <summary>
/// Whether or not the injector is able to draw from containers or if it's a single use /// Whether or not the injector is able to draw from containers or if it's a single use
/// device that can only inject. /// device that can only inject.
@@ -37,42 +41,35 @@ public sealed partial class InjectorComponent : Component
public bool InjectOnly; public bool InjectOnly;
/// <summary> /// <summary>
/// Whether or not the injector is able to draw from or inject from mobs /// Whether or not the injector is able to draw from or inject from mobs.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// for example: droppers would ignore mobs /// For example: droppers would ignore mobs.
/// </remarks> /// </remarks>
[DataField] [DataField]
public bool IgnoreMobs; public bool IgnoreMobs;
/// <summary> /// <summary>
/// Whether or not the injector is able to draw from or inject into containers that are closed/sealed /// Whether or not the injector is able to draw from or inject into containers that are closed/sealed.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// for example: droppers can not inject into cans, but syringes can /// For example: droppers can not inject into cans, but syringes can.
/// </remarks> /// </remarks>
[DataField] [DataField]
public bool IgnoreClosed = true; public bool IgnoreClosed = true;
/// <summary> /// <summary>
/// The minimum amount of solution that can be transferred at once from this solution. /// The transfer amounts for the set-transfer verb.
/// </summary> /// </summary>
[DataField("minTransferAmount")] [DataField]
public FixedPoint2 MinimumTransferAmount = FixedPoint2.New(5); public List<FixedPoint2> TransferAmounts = new() { 1, 5, 10, 15 };
/// <summary>
/// The maximum amount of solution that can be transferred at once from this solution.
/// </summary>
[DataField("maxTransferAmount")]
public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(15);
/// <summary> /// <summary>
/// Amount to inject or draw on each usage. If the injector is inject only, it will /// Amount to inject or draw on each usage. If the injector is inject only, it will
/// attempt to inject it's entire contents upon use. /// attempt to inject it's entire contents upon use.
/// </summary> /// </summary>
[DataField] [DataField, AutoNetworkedField]
[AutoNetworkedField] public FixedPoint2 CurrentTransferAmount = FixedPoint2.New(5);
public FixedPoint2 TransferAmount = FixedPoint2.New(5);
/// <summary> /// <summary>
/// Injection delay (seconds) when the target is a mob. /// Injection delay (seconds) when the target is a mob.
@@ -95,8 +92,7 @@ public sealed partial class InjectorComponent : Component
/// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should /// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should
/// only ever be set to Inject /// only ever be set to Inject
/// </summary> /// </summary>
[AutoNetworkedField] [DataField, AutoNetworkedField]
[DataField]
public InjectorToggleMode ToggleState = InjectorToggleMode.Draw; public InjectorToggleMode ToggleState = InjectorToggleMode.Draw;
/// <summary> /// <summary>
@@ -127,6 +123,7 @@ public sealed partial class InjectorComponent : Component
/// <summary> /// <summary>
/// Possible modes for an <see cref="InjectorComponent"/>. /// Possible modes for an <see cref="InjectorComponent"/>.
/// </summary> /// </summary>
[Serializable, NetSerializable]
public enum InjectorToggleMode : byte public enum InjectorToggleMode : byte
{ {
/// <summary> /// <summary>
@@ -137,5 +134,11 @@ public enum InjectorToggleMode : byte
/// <summary> /// <summary>
/// The injector will try to draw reagent from things. /// The injector will try to draw reagent from things.
/// </summary> /// </summary>
Draw Draw,
} }
/// <summary>
/// Raised on the injector when the doafter has finished.
/// </summary>
[Serializable, NetSerializable]
public sealed partial class InjectorDoAfterEvent : SimpleDoAfterEvent;

View File

@@ -1,48 +1,60 @@
using System.Linq;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.CombatMode; using Content.Shared.CombatMode;
using Content.Shared.Database;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Forensics.Systems;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Player;
namespace Content.Shared.Chemistry.EntitySystems; namespace Content.Shared.Chemistry.EntitySystems;
public abstract class SharedInjectorSystem : EntitySystem public abstract class SharedInjectorSystem : EntitySystem
{ {
/// <summary> [Dependency] private readonly SharedBloodstreamSystem _blood = default!;
/// Default transfer amounts for the set-transfer verb. [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
/// </summary> [Dependency] private readonly MobStateSystem _mobState = default!;
public static readonly FixedPoint2[] TransferAmounts = { 1, 5, 10, 15 }; [Dependency] private readonly OpenableSystem _openable = default!;
[Dependency] private readonly ReactiveSystem _reactiveSystem = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
[Dependency] protected readonly SharedSolutionContainerSystem SolutionContainers = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] protected readonly MobStateSystem MobState = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] protected readonly SharedCombatModeSystem Combat = default!; [Dependency] private readonly SharedForensicsSystem _forensics = default!;
[Dependency] protected readonly SharedDoAfterSystem DoAfter = default!; [Dependency] protected readonly SharedSolutionContainerSystem SolutionContainer = default!;
[Dependency] protected readonly ISharedAdminLogManager AdminLogger = default!;
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<InjectorComponent, GetVerbsEvent<AlternativeVerb>>(AddSetTransferVerbs); SubscribeLocalEvent<InjectorComponent, GetVerbsEvent<AlternativeVerb>>(AddSetTransferVerbs);
SubscribeLocalEvent<InjectorComponent, ComponentStartup>(OnInjectorStartup);
SubscribeLocalEvent<InjectorComponent, UseInHandEvent>(OnInjectorUse); SubscribeLocalEvent<InjectorComponent, UseInHandEvent>(OnInjectorUse);
SubscribeLocalEvent<InjectorComponent, AfterInteractEvent>(OnInjectorAfterInteract);
SubscribeLocalEvent<InjectorComponent, InjectorDoAfterEvent>(OnInjectDoAfter);
} }
private void AddSetTransferVerbs(Entity<InjectorComponent> entity, ref GetVerbsEvent<AlternativeVerb> args) private void AddSetTransferVerbs(Entity<InjectorComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || args.Hands == null) if (!args.CanAccess || !args.CanInteract || args.Hands == null)
return; return;
var user = args.User; if (ent.Comp.TransferAmounts.Count <= 1)
var (_, component) = entity; return; // No options to cycle between
var min = component.MinimumTransferAmount; var user = args.User;
var max = component.MaximumTransferAmount;
var cur = component.TransferAmount; var min = ent.Comp.TransferAmounts.Min();
var max = ent.Comp.TransferAmounts.Max();
var cur = ent.Comp.CurrentTransferAmount;
var toggleAmount = cur == max ? min : max; var toggleAmount = cur == max ? min : max;
var priority = 0; var priority = 0;
@@ -52,9 +64,9 @@ public abstract class SharedInjectorSystem : EntitySystem
Category = VerbCategory.SetTransferAmount, Category = VerbCategory.SetTransferAmount,
Act = () => Act = () =>
{ {
component.TransferAmount = toggleAmount; ent.Comp.CurrentTransferAmount = toggleAmount;
Popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", toggleAmount)), user, user); _popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", toggleAmount)), user, user);
Dirty(entity); Dirty(ent);
}, },
Priority = priority Priority = priority
@@ -63,21 +75,18 @@ public abstract class SharedInjectorSystem : EntitySystem
priority -= 1; priority -= 1;
// Add specific transfer verbs according to the container's size // Add specific transfer verbs for amounts defined in the component
foreach (var amount in TransferAmounts) foreach (var amount in ent.Comp.TransferAmounts)
{ {
if (amount < component.MinimumTransferAmount || amount > component.MaximumTransferAmount)
continue;
AlternativeVerb verb = new() AlternativeVerb verb = new()
{ {
Text = Loc.GetString("comp-solution-transfer-verb-amount", ("amount", amount)), Text = Loc.GetString("comp-solution-transfer-verb-amount", ("amount", amount)),
Category = VerbCategory.SetTransferAmount, Category = VerbCategory.SetTransferAmount,
Act = () => Act = () =>
{ {
component.TransferAmount = amount; ent.Comp.CurrentTransferAmount = amount;
Popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", amount)), user, user); _popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", amount)), user, user);
Dirty(entity); Dirty(ent);
}, },
// we want to sort by size, not alphabetically by the verb text. // we want to sort by size, not alphabetically by the verb text.
@@ -90,30 +99,407 @@ public abstract class SharedInjectorSystem : EntitySystem
} }
} }
private void OnInjectorStartup(Entity<InjectorComponent> entity, ref ComponentStartup args) private void OnInjectorUse(Entity<InjectorComponent> ent, ref UseInHandEvent args)
{
// ???? why ?????
Dirty(entity);
}
private void OnInjectorUse(Entity<InjectorComponent> entity, ref UseInHandEvent args)
{ {
if (args.Handled) if (args.Handled)
return; return;
Toggle(entity, args.User); Toggle(ent, args.User);
args.Handled = true; args.Handled = true;
} }
private void OnInjectorAfterInteract(Entity<InjectorComponent> ent, ref AfterInteractEvent args)
{
if (args.Handled || !args.CanReach)
return;
//Make sure we have the attacking entity
if (args.Target is not { Valid: true } target || !HasComp<SolutionContainerManagerComponent>(ent))
return;
// Is the target a mob? If yes, use a do-after to give them time to respond.
if (HasComp<MobStateComponent>(target) || HasComp<BloodstreamComponent>(target))
{
// Are use using an injector capable of targeting a mob?
if (ent.Comp.IgnoreMobs)
return;
InjectDoAfter(ent, target, args.User);
args.Handled = true;
return;
}
// Instantly draw from or inject into jugs, bottles etc.
args.Handled = TryUseInjector(ent, target, args.User);
}
private void OnInjectDoAfter(Entity<InjectorComponent> ent, ref InjectorDoAfterEvent args)
{
if (args.Cancelled || args.Handled || args.Args.Target == null)
return;
args.Handled = TryUseInjector(ent, args.Args.Target.Value, args.Args.User);
}
/// <summary> /// <summary>
/// Toggle between draw/inject state if applicable /// Send informative pop-up messages and wait for a do-after to complete.
/// </summary> /// </summary>
private void Toggle(Entity<InjectorComponent> injector, EntityUid user) private void InjectDoAfter(Entity<InjectorComponent> injector, EntityUid target, EntityUid user)
{
// Create a pop-up for the user
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
_popup.PopupClient(Loc.GetString("injector-component-drawing-user"), target, user);
}
else
{
_popup.PopupClient(Loc.GetString("injector-component-injecting-user"), target, user);
}
if (!SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution, out var solution))
return;
var actualDelay = injector.Comp.Delay;
FixedPoint2 amountToInject;
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
// additional delay is based on actual volume left to draw in syringe when smaller than transfer amount
amountToInject = FixedPoint2.Min(injector.Comp.CurrentTransferAmount, solution.MaxVolume - solution.Volume);
}
else
{
// additional delay is based on actual volume left to inject in syringe when smaller than transfer amount
amountToInject = FixedPoint2.Min(injector.Comp.CurrentTransferAmount, solution.Volume);
}
// Injections take 0.5 seconds longer per 5u of possible space/content
// First 5u(MinimumTransferAmount) doesn't incur delay
actualDelay += injector.Comp.DelayPerVolume * FixedPoint2.Max(0, amountToInject - injector.Comp.TransferAmounts.Min()).Double();
// Ensure that minimum delay before incapacitation checks is 1 seconds
actualDelay = MathHelper.Max(actualDelay, TimeSpan.FromSeconds(1));
if (user != target) // injecting someone else
{
// Create a pop-up for the target
var userName = Identity.Entity(user, EntityManager);
if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
_popup.PopupEntity(Loc.GetString("injector-component-drawing-target",
("user", userName)), user, target);
}
else
{
_popup.PopupEntity(Loc.GetString("injector-component-injecting-target",
("user", userName)), user, target);
}
// Check if the target is incapacitated or in combat mode and modify time accordingly.
if (_mobState.IsIncapacitated(target))
{
actualDelay /= 2.5f;
}
else if (_combatMode.IsInCombatMode(target))
{
// Slightly increase the delay when the target is in combat mode. Helps prevents cheese injections in
// combat with fast syringes & lag.
actualDelay += TimeSpan.FromSeconds(1);
}
// Add an admin log, using the "force feed" log type. It's not quite feeding, but the effect is the same.
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
_adminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to inject {ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}");
}
else
{
_adminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to draw {injector.Comp.CurrentTransferAmount.ToString()} units from {ToPrettyString(target):target}");
}
}
else // injecting yourself
{
// Self-injections take half as long.
actualDelay /= 2;
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
_adminLogger.Add(LogType.Ingestion,
$"{ToPrettyString(user):user} is attempting to inject themselves with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}.");
}
else
{
_adminLogger.Add(LogType.ForceFeed,
$"{ToPrettyString(user):user} is attempting to draw {injector.Comp.CurrentTransferAmount.ToString()} units from themselves.");
}
}
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, actualDelay, new InjectorDoAfterEvent(), injector.Owner, target: target, used: injector.Owner)
{
BreakOnMove = true,
BreakOnWeightlessMove = false,
BreakOnDamage = true,
NeedHand = injector.Comp.NeedHand,
BreakOnHandChange = injector.Comp.BreakOnHandChange,
MovementThreshold = injector.Comp.MovementThreshold,
});
}
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 (isOpenOrIgnored && SolutionContainer.TryGetInjectableSolution(target, out var injectableSolution, out _))
return TryInject(injector, target, injectableSolution.Value, user, false);
if (isOpenOrIgnored && SolutionContainer.TryGetRefillableSolution(target, out var refillableSolution, out _))
return TryInject(injector, target, refillableSolution.Value, user, true);
if (TryComp<BloodstreamComponent>(target, out var bloodstream))
return TryInjectIntoBloodstream(injector, (target, bloodstream), user);
LocId msg = target == user ? "injector-component-cannot-transfer-message-self" : "injector-component-cannot-transfer-message";
_popup.PopupClient(Loc.GetString(msg, ("target", Identity.Entity(target, EntityManager))), injector, user);
}
else if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
{
// Draw from a bloodstream, if the target has that
if (TryComp<BloodstreamComponent>(target, out var stream) &&
SolutionContainer.ResolveSolution(target, stream.BloodSolutionName, ref stream.BloodSolution))
{
return TryDraw(injector, (target, stream), stream.BloodSolution.Value, user);
}
// Draw from an object (food, beaker, etc)
if (isOpenOrIgnored && SolutionContainer.TryGetDrawableSolution(target, out var drawableSolution, out _))
return TryDraw(injector, target, drawableSolution.Value, user);
LocId msg = target == user ? "injector-component-cannot-draw-message-self" : "injector-component-cannot-draw-message";
_popup.PopupClient(Loc.GetString(msg, ("target", Identity.Entity(target, EntityManager))), injector.Owner, user);
}
return false;
}
private bool TryInject(Entity<InjectorComponent> injector, EntityUid target,
Entity<SolutionComponent> targetSolution, EntityUid user, bool asRefill)
{
if (!SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution,
out var solution) || solution.Volume == 0)
return false;
// Get transfer amount. May be smaller than _transferAmount if not enough room
var realTransferAmount =
FixedPoint2.Min(injector.Comp.CurrentTransferAmount, targetSolution.Comp.Solution.AvailableVolume);
if (realTransferAmount <= 0)
{
LocId msg = target == user ? "injector-component-target-already-full-message-self" : "injector-component-target-already-full-message";
_popup.PopupClient(
Loc.GetString(msg,
("target", Identity.Entity(target, EntityManager))),
injector.Owner,
user);
return false;
}
// Move units from attackSolution to targetSolution
Solution removedSolution;
if (TryComp<StackComponent>(target, out var stack))
removedSolution = SolutionContainer.SplitStackSolution(injector.Comp.Solution.Value, realTransferAmount, stack.Count);
else
removedSolution = SolutionContainer.SplitSolution(injector.Comp.Solution.Value, realTransferAmount);
_reactiveSystem.DoEntityReaction(target, removedSolution, ReactionMethod.Injection);
if (!asRefill)
SolutionContainer.Inject(target, targetSolution, removedSolution);
else
SolutionContainer.Refill(target, targetSolution, removedSolution);
LocId msgSuccess = target == user ? "injector-component-transfer-success-message-self" : "injector-component-transfer-success-message";
_popup.PopupClient(
Loc.GetString(msgSuccess,
("amount", removedSolution.Volume),
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
AfterInject(injector, target);
return true;
}
private bool TryInjectIntoBloodstream(Entity<InjectorComponent> injector, Entity<BloodstreamComponent> target,
EntityUid user)
{
// Get transfer amount. May be smaller than _transferAmount if not enough room
if (!SolutionContainer.ResolveSolution(target.Owner, target.Comp.ChemicalSolutionName,
ref target.Comp.ChemicalSolution, out var chemSolution))
{
LocId msg = target.Owner == user ? "injector-component-cannot-inject-message-self" : "injector-component-cannot-inject-message";
_popup.PopupClient(
Loc.GetString(msg,
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
return false;
}
var realTransferAmount = FixedPoint2.Min(injector.Comp.CurrentTransferAmount, chemSolution.AvailableVolume);
if (realTransferAmount <= 0)
{
LocId msg = target.Owner == user ? "injector-component-cannot-inject-message-self" : "injector-component-cannot-inject-message";
_popup.PopupClient(
Loc.GetString(msg,
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
return false;
}
// Move units from attackSolution to targetSolution
var removedSolution = SolutionContainer.SplitSolution(target.Comp.ChemicalSolution.Value, realTransferAmount);
_blood.TryAddToChemicals(target.AsNullable(), removedSolution);
_reactiveSystem.DoEntityReaction(target, removedSolution, ReactionMethod.Injection);
LocId msgSuccess = target.Owner == user ? "injector-component-inject-success-message-self" : "injector-component-inject-success-message";
_popup.PopupClient(
Loc.GetString(msgSuccess,
("amount", removedSolution.Volume),
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
AfterInject(injector, target);
return true;
}
private bool TryDraw(Entity<InjectorComponent> injector, Entity<BloodstreamComponent?> target,
Entity<SolutionComponent> targetSolution, EntityUid user)
{
if (!SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution,
out var solution) || solution.AvailableVolume == 0)
{
return false;
}
var applicableTargetSolution = targetSolution.Comp.Solution;
// If a whitelist exists, remove all non-whitelisted reagents from the target solution temporarily
var temporarilyRemovedSolution = new Solution();
if (injector.Comp.ReagentWhitelist is { } reagentWhitelist)
{
temporarilyRemovedSolution = applicableTargetSolution.SplitSolutionWithout(applicableTargetSolution.Volume, reagentWhitelist.ToArray());
}
// Get transfer amount. May be smaller than _transferAmount if not enough room, also make sure there's room in the injector
var realTransferAmount = FixedPoint2.Min(injector.Comp.CurrentTransferAmount, applicableTargetSolution.Volume,
solution.AvailableVolume);
if (realTransferAmount <= 0)
{
LocId msg = target.Owner == user ? "injector-component-target-is-empty-message-self" : "injector-component-target-is-empty-message";
_popup.PopupClient(
Loc.GetString(msg,
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
return false;
}
// We have some snowflaked behavior for streams.
if (target.Comp != null)
{
DrawFromBlood(injector, (target.Owner, target.Comp), injector.Comp.Solution.Value, realTransferAmount, user);
return true;
}
// Move units from attackSolution to targetSolution
var removedSolution = SolutionContainer.Draw(target.Owner, targetSolution, realTransferAmount);
// Add back non-whitelisted reagents to the target solution
SolutionContainer.TryAddSolution(targetSolution, temporarilyRemovedSolution);
if (!SolutionContainer.TryAddSolution(injector.Comp.Solution.Value, removedSolution))
{
return false;
}
LocId msgSuccess = target.Owner == user ? "injector-component-draw-success-message-self" : "injector-component-draw-success-message";
_popup.PopupClient(
Loc.GetString(msgSuccess,
("amount", removedSolution.Volume),
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
AfterDraw(injector, target);
return true;
}
private void DrawFromBlood(Entity<InjectorComponent> injector, Entity<BloodstreamComponent> target,
Entity<SolutionComponent> injectorSolution, FixedPoint2 transferAmount, EntityUid user)
{
var drawAmount = (float)transferAmount;
if (SolutionContainer.ResolveSolution(target.Owner, target.Comp.ChemicalSolutionName,
ref target.Comp.ChemicalSolution))
{
var chemTemp = SolutionContainer.SplitSolution(target.Comp.ChemicalSolution.Value, drawAmount * 0.15f);
SolutionContainer.TryAddSolution(injectorSolution, chemTemp);
drawAmount -= (float)chemTemp.Volume;
}
if (SolutionContainer.ResolveSolution(target.Owner, target.Comp.BloodSolutionName,
ref target.Comp.BloodSolution))
{
var bloodTemp = SolutionContainer.SplitSolution(target.Comp.BloodSolution.Value, drawAmount);
SolutionContainer.TryAddSolution(injectorSolution, bloodTemp);
}
LocId msg = target.Owner == user ? "injector-component-draw-success-message-self" : "injector-component-draw-success-message";
_popup.PopupClient(
Loc.GetString(msg,
("amount", transferAmount),
("target", Identity.Entity(target, EntityManager))),
injector.Owner, user);
AfterDraw(injector, target);
}
private void AfterInject(Entity<InjectorComponent> injector, EntityUid target)
{
// Automatically set syringe to draw after completely draining it.
if (SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution,
out var solution) && solution.Volume == 0)
{
SetMode(injector, InjectorToggleMode.Draw);
}
// Leave some DNA from the injectee on it
_forensics.TransferDna(injector, target);
}
private void AfterDraw(Entity<InjectorComponent> injector, EntityUid target)
{
// Automatically set syringe to inject after completely filling it.
if (SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution,
out var solution) && solution.AvailableVolume == 0)
{
SetMode(injector, InjectorToggleMode.Inject);
}
// Leave some DNA from the drawee on it
_forensics.TransferDna(injector, target);
}
/// <summary>
/// Toggle the injector between draw/inject state if applicable.
/// </summary>
public void Toggle(Entity<InjectorComponent> injector, EntityUid user)
{ {
if (injector.Comp.InjectOnly) if (injector.Comp.InjectOnly)
return; return;
if (!SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out var solEnt, out var solution)) if (!SolutionContainer.ResolveSolution(injector.Owner, injector.Comp.SolutionName, ref injector.Comp.Solution, out var solution))
return; return;
string msg; string msg;
@@ -146,9 +532,12 @@ public abstract class SharedInjectorSystem : EntitySystem
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
Popup.PopupClient(Loc.GetString(msg), injector, user); _popup.PopupClient(Loc.GetString(msg), injector, user);
} }
/// <summary>
/// Set the mode of the injector to draw or inject.
/// </summary>
public void SetMode(Entity<InjectorComponent> injector, InjectorToggleMode mode) public void SetMode(Entity<InjectorComponent> injector, InjectorToggleMode mode)
{ {
injector.Comp.ToggleState = mode; injector.Comp.ToggleState = mode;

View File

@@ -60,6 +60,8 @@ public abstract partial class SharedPuddleSystem
var puddleSolution = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume); var puddleSolution = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume);
TrySpillAt(Transform(target).Coordinates, puddleSolution, out _); TrySpillAt(Transform(target).Coordinates, puddleSolution, out _);
// TODO: Make this an event subscription once spilling puddles is predicted.
// Injectors should not be hardcoded here.
if (TryComp<InjectorComponent>(entity, out var injectorComp)) if (TryComp<InjectorComponent>(entity, out var injectorComp))
{ {
injectorComp.ToggleState = InjectorToggleMode.Draw; injectorComp.ToggleState = InjectorToggleMode.Draw;

View File

@@ -15,4 +15,13 @@ public abstract class SharedForensicsSystem : EntitySystem
/// Does nothing if it does not have the FingerprintComponent. /// Does nothing if it does not have the FingerprintComponent.
/// </summary> /// </summary>
public virtual void RandomizeFingerprint(Entity<FingerprintComponent?> ent) { } public virtual void RandomizeFingerprint(Entity<FingerprintComponent?> ent) { }
/// <summary>
/// Transfer DNA from one entity onto the forensics of another.
/// </summary>
/// <param name="recipient">The entity receiving the DNA.</param>
/// <param name="donor">The entity applying its DNA.</param>
/// <param name="canDnaBeCleaned">If this DNA be cleaned off of the recipient. e.g. cleaning a knife vs cleaning a puddle of blood.</param>
public virtual void TransferDna(EntityUid recipient, EntityUid donor, bool canDnaBeCleaned = true) { }
} }

View File

@@ -10,14 +10,22 @@ injector-volume-label = Volume: [color=white]{$currentVolume}/{$totalVolume}[/co
injector-component-drawing-text = Now drawing injector-component-drawing-text = Now drawing
injector-component-injecting-text = Now injecting injector-component-injecting-text = Now injecting
injector-component-cannot-transfer-message = You aren't able to transfer to {THE($target)}! injector-component-cannot-transfer-message = You aren't able to transfer into {THE($target)}!
injector-component-cannot-transfer-message-self = You aren't able to transfer into yourself!
injector-component-cannot-draw-message = You aren't able to draw from {THE($target)}! injector-component-cannot-draw-message = You aren't able to draw from {THE($target)}!
injector-component-cannot-inject-message = You aren't able to inject to {THE($target)}! injector-component-cannot-draw-message-self = You aren't able to draw from yourself!
injector-component-cannot-inject-message = You aren't able to inject into {THE($target)}!
injector-component-cannot-inject-message-self = You aren't able to inject into yourself!
injector-component-inject-success-message = You inject {$amount}u into {THE($target)}! injector-component-inject-success-message = You inject {$amount}u into {THE($target)}!
injector-component-inject-success-message-self = You inject {$amount}u into yourself!
injector-component-transfer-success-message = You transfer {$amount}u into {THE($target)}. injector-component-transfer-success-message = You transfer {$amount}u into {THE($target)}.
injector-component-transfer-success-message-self = You transfer {$amount}u into yourself.
injector-component-draw-success-message = You draw {$amount}u from {THE($target)}. injector-component-draw-success-message = You draw {$amount}u from {THE($target)}.
injector-component-draw-success-message-self = You draw {$amount}u from youself.
injector-component-target-already-full-message = {CAPITALIZE(THE($target))} is already full! injector-component-target-already-full-message = {CAPITALIZE(THE($target))} is already full!
injector-component-target-already-full-message-self = You are already full!
injector-component-target-is-empty-message = {CAPITALIZE(THE($target))} is empty! injector-component-target-is-empty-message = {CAPITALIZE(THE($target))} is empty!
injector-component-target-is-empty-message-self = You are empty!
injector-component-cannot-toggle-draw-message = Too full to draw! injector-component-cannot-toggle-draw-message = Too full to draw!
injector-component-cannot-toggle-inject-message = Nothing to inject! injector-component-cannot-toggle-inject-message = Nothing to inject!

View File

@@ -286,10 +286,13 @@
injectOnly: false injectOnly: false
ignoreMobs: true ignoreMobs: true
ignoreClosed: false ignoreClosed: false
minTransferAmount: 1 transferAmounts:
maxTransferAmount: 5 - 1
transferAmount: 1 - 2
toggleState: 1 # draw - 3
- 4
- 5
currentTransferAmount: 1
- type: ExaminableSolution - type: ExaminableSolution
solution: dropper solution: dropper
exactVolume: true exactVolume: true
@@ -385,8 +388,7 @@
id: Syringe id: Syringe
components: components:
- type: Injector - type: Injector
transferAmount: 15 currentTransferAmount: 15
toggleState: Draw
- type: Tag - type: Tag
tags: tags:
- Syringe - Syringe
@@ -410,9 +412,13 @@
injector: injector:
maxVol: 5 maxVol: 5
- type: Injector - type: Injector
minTransferAmount: 1 transferAmounts:
maxTransferAmount: 5 - 1
transferAmount: 5 - 2
- 3
- 4
- 5
currentTransferAmount: 5
- type: SolutionContainerVisuals - type: SolutionContainerVisuals
maxFillLevels: 3 maxFillLevels: 3
fillBaseName: minisyringe fillBaseName: minisyringe
@@ -461,6 +467,7 @@
- SyringeGunAmmo - SyringeGunAmmo
- type: entity - type: entity
abstract: true
parent: BaseSyringe parent: BaseSyringe
id: PrefilledSyringe id: PrefilledSyringe
components: components:
@@ -521,15 +528,15 @@
canReact: false canReact: false
- type: Injector - type: Injector
injectOnly: false injectOnly: false
minTransferAmount: 5 transferAmounts:
maxTransferAmount: 10 - 5
transferAmount: 10 - 10
currentTransferAmount: 10
- type: Tag - type: Tag
tags: tags:
- Syringe - Syringe
- Trash - Trash
- type: entity - type: entity
name: pill name: pill
parent: BaseItem parent: BaseItem

View File

@@ -713,3 +713,6 @@ FoodDonutJellySlugcat: FoodDonutJellyScurret
# 2025-08-11 # 2025-08-11
ClothingUniformJumpsuitChiefEngineerNT: ClothingUniformJumpsuitChiefEngineer ClothingUniformJumpsuitChiefEngineerNT: ClothingUniformJumpsuitChiefEngineer
ClothingUniformJumpsuitParamedicNT: ClothingUniformJumpsuitParamedic ClothingUniformJumpsuitParamedicNT: ClothingUniformJumpsuitParamedic
# 2025-08-29
PrefilledSyringe: Syringe