Add more DNA interactions (#21989)

* Add more DNA interactions

* remove unused import

* update based on feedback

* Add event for chemistrysystem.injector

* move event to shared; transfer dna to implanter

* doafter and interaction event fixes

* add BreakOnHandChange

* doh

* use events instead of updating component directly

* Add DataFields to ForensicScannerComponent fields

* Convert most events to system api call
This commit is contained in:
themias
2023-12-15 04:52:55 -05:00
committed by GitHub
parent 2455980090
commit 9cc4a50692
20 changed files with 291 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Verbs;
using Content.Shared.Stacks;
using Robust.Shared.Player;
using Content.Shared.Forensics;
namespace Content.Server.Chemistry.EntitySystems;
@@ -290,7 +291,7 @@ public sealed partial class ChemistrySystem
("target", Identity.Entity(target, EntityManager))), injector, user);
Dirty(component);
AfterInject(component, injector);
AfterInject(component, injector, target);
}
private void TryInject(InjectorComponent component, EntityUid injector, EntityUid targetEntity, Solution targetSolution, EntityUid user, bool asRefill)
@@ -328,10 +329,10 @@ public sealed partial class ChemistrySystem
("target", Identity.Entity(targetEntity, EntityManager))), injector, user);
Dirty(component);
AfterInject(component, injector);
AfterInject(component, injector, targetEntity);
}
private void AfterInject(InjectorComponent component, EntityUid injector)
private void AfterInject(InjectorComponent component, EntityUid injector, EntityUid target)
{
// Automatically set syringe to draw after completely draining it.
if (_solutions.TryGetSolution(injector, InjectorComponent.SolutionName, out var solution)
@@ -339,9 +340,13 @@ public sealed partial class ChemistrySystem
{
component.ToggleState = SharedInjectorComponent.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(InjectorComponent component, EntityUid injector)
private void AfterDraw(InjectorComponent component, EntityUid injector, EntityUid target)
{
// Automatically set syringe to inject after completely filling it.
if (_solutions.TryGetSolution(injector, InjectorComponent.SolutionName, out var solution)
@@ -349,6 +354,10 @@ public sealed partial class ChemistrySystem
{
component.ToggleState = SharedInjectorComponent.InjectorToggleMode.Inject;
}
// Leave some DNA from the drawee on it
var ev = new TransferDnaEvent { Donor = target, Recipient = injector };
RaiseLocalEvent(target, ref ev);
}
private void TryDraw(InjectorComponent component, EntityUid injector, EntityUid targetEntity, Solution targetSolution, EntityUid user, BloodstreamComponent? stream = null)
@@ -389,7 +398,7 @@ public sealed partial class ChemistrySystem
("target", Identity.Entity(targetEntity, EntityManager))), injector, user);
Dirty(component);
AfterDraw(component, injector);
AfterDraw(component, injector, targetEntity);
}
private void DrawFromBlood(EntityUid user, EntityUid injector, EntityUid target, InjectorComponent component, Solution injectorSolution, BloodstreamComponent stream, FixedPoint2 transferAmount)
@@ -414,7 +423,7 @@ public sealed partial class ChemistrySystem
("target", Identity.Entity(target, EntityManager))), injector, user);
Dirty(component);
AfterDraw(component, injector);
AfterDraw(component, injector, target);
}
}

View File

@@ -14,6 +14,7 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Timing;
using Robust.Shared.GameStates;
using Content.Shared.Forensics;
namespace Content.Server.Chemistry.EntitySystems
{
@@ -138,6 +139,9 @@ namespace Content.Server.Chemistry.EntitySystems
_reactiveSystem.DoEntityReaction(target.Value, removedSolution, ReactionMethod.Injection);
_solutions.TryAddSolution(target.Value, targetSolution, removedSolution);
var ev = new TransferDnaEvent { Donor = target.Value, Recipient = uid };
RaiseLocalEvent(target.Value, ref ev);
// same LogType as syringes...
_adminLogger.Add(LogType.ForceFeed, $"{_entMan.ToPrettyString(user):user} injected {_entMan.ToPrettyString(target.Value):target} with a solution {SolutionContainerSystem.ToPrettyString(removedSolution):removedSolution} using a {_entMan.ToPrettyString(uid):using}");