From 6f9e3cc4615f4535eda348acd5cb4bb13a87af6f Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Mon, 4 Jul 2022 20:37:21 -0400 Subject: [PATCH] Bloodstreams now have their own drawing behavior (#8920) --- .../Body/Components/BloodstreamComponent.cs | 3 +- .../EntitySystems/ChemistrySystem.Injector.cs | 39 ++++++++++++++++++- .../Entities/Mobs/NPCs/simplemob.yml | 2 - .../Entities/Mobs/Species/human.yml | 2 - 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Content.Server/Body/Components/BloodstreamComponent.cs b/Content.Server/Body/Components/BloodstreamComponent.cs index b5adfa3a42..4ac3cdbc6f 100644 --- a/Content.Server/Body/Components/BloodstreamComponent.cs +++ b/Content.Server/Body/Components/BloodstreamComponent.cs @@ -4,11 +4,12 @@ using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using Content.Shared.Sound; +using Content.Server.Chemistry.EntitySystems; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Body.Components { - [RegisterComponent, Access(typeof(BloodstreamSystem))] + [RegisterComponent, Access(typeof(BloodstreamSystem), (typeof(ChemistrySystem)))] public sealed class BloodstreamComponent : Component { public static string DefaultChemicalsSolutionName = "chemicals"; diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs index 1d3694ae17..a6add96c94 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs @@ -68,6 +68,13 @@ public sealed partial class ChemistrySystem } else if (component.ToggleState == SharedInjectorComponent.InjectorToggleMode.Draw) { + /// Draw from a bloodstream, if the target has that + if (TryComp(target, out var stream)) + { + TryDraw(component, target, stream.BloodSolution, user, stream); + return; + } + /// Draw from an object (food, beaker, etc) if (_solutions.TryGetDrawableSolution(target, out var drawableSolution)) { TryDraw(component, target, drawableSolution, user); @@ -329,7 +336,7 @@ public sealed partial class ChemistrySystem } } - private void TryDraw(InjectorComponent component, EntityUid targetEntity, Solution targetSolution, EntityUid user) + private void TryDraw(InjectorComponent component, EntityUid targetEntity, Solution targetSolution, EntityUid user, BloodstreamComponent? stream = null) { if (!_solutions.TryGetSolution(component.Owner, InjectorComponent.SolutionName, out var solution) || solution.AvailableVolume == 0) @@ -347,6 +354,13 @@ public sealed partial class ChemistrySystem return; } + /// We have some snowflaked behavior for streams. + if (stream != null) + { + DrawFromBlood(user, targetEntity, component, solution, stream, (float) realTransferAmount); + return; + } + // Move units from attackSolution to targetSolution var removedSolution = _solutions.Draw(targetEntity, targetSolution, realTransferAmount); @@ -363,6 +377,29 @@ public sealed partial class ChemistrySystem AfterDraw(component); } + private void DrawFromBlood(EntityUid user, EntityUid target, InjectorComponent component, Solution injectorSolution, BloodstreamComponent stream, float drawAmount) + { + float bloodAmount = drawAmount; + float chemAmount = 0f; + if (stream.ChemicalSolution.CurrentVolume > 0f) // If they have stuff in their chem stream, we'll draw some of that + { + bloodAmount = drawAmount * 0.85f; + chemAmount = drawAmount * 0.15f; + } + + var bloodTemp = stream.BloodSolution.SplitSolution(bloodAmount); + var chemTemp = stream.ChemicalSolution.SplitSolution(chemAmount); + + _solutions.TryAddSolution(component.Owner, injectorSolution, bloodTemp); + _solutions.TryAddSolution(component.Owner, injectorSolution, chemTemp); + + _popup.PopupEntity(Loc.GetString("injector-component-draw-success-message", + ("amount", drawAmount), + ("target", target)), component.Owner, Filter.Entities(user)); + + Dirty(component); + AfterDraw(component); + } private sealed class InjectionCompleteEvent : EntityEventArgs { public InjectorComponent Component { get; init; } = default!; diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml index bc35c09d75..5295cb6a3d 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml @@ -70,8 +70,6 @@ types: Bloodloss: -0.25 - - type: DrawableSolution - solution: bloodstream - type: Damageable damageContainer: Biological - type: AtmosExposed diff --git a/Resources/Prototypes/Entities/Mobs/Species/human.yml b/Resources/Prototypes/Entities/Mobs/Species/human.yml index 0c5672d4f4..2b54430a68 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/human.yml @@ -50,8 +50,6 @@ # Organs - type: InjectableSolution solution: chemicals - - type: DrawableSolution - solution: bloodstream - type: IdExaminable - type: HealthExaminable examinableTypes: