Bloodstreams now have their own drawing behavior (#8920)

This commit is contained in:
Rane
2022-07-04 20:37:21 -04:00
committed by GitHub
parent 598e350afc
commit 6f9e3cc461
4 changed files with 40 additions and 6 deletions

View File

@@ -4,11 +4,12 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Server.Chemistry.EntitySystems;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Body.Components namespace Content.Server.Body.Components
{ {
[RegisterComponent, Access(typeof(BloodstreamSystem))] [RegisterComponent, Access(typeof(BloodstreamSystem), (typeof(ChemistrySystem)))]
public sealed class BloodstreamComponent : Component public sealed class BloodstreamComponent : Component
{ {
public static string DefaultChemicalsSolutionName = "chemicals"; public static string DefaultChemicalsSolutionName = "chemicals";

View File

@@ -68,6 +68,13 @@ public sealed partial class ChemistrySystem
} }
else if (component.ToggleState == SharedInjectorComponent.InjectorToggleMode.Draw) else if (component.ToggleState == SharedInjectorComponent.InjectorToggleMode.Draw)
{ {
/// Draw from a bloodstream, if the target has that
if (TryComp<BloodstreamComponent>(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)) if (_solutions.TryGetDrawableSolution(target, out var drawableSolution))
{ {
TryDraw(component, target, drawableSolution, user); 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) if (!_solutions.TryGetSolution(component.Owner, InjectorComponent.SolutionName, out var solution)
|| solution.AvailableVolume == 0) || solution.AvailableVolume == 0)
@@ -347,6 +354,13 @@ public sealed partial class ChemistrySystem
return; 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 // Move units from attackSolution to targetSolution
var removedSolution = _solutions.Draw(targetEntity, targetSolution, realTransferAmount); var removedSolution = _solutions.Draw(targetEntity, targetSolution, realTransferAmount);
@@ -363,6 +377,29 @@ public sealed partial class ChemistrySystem
AfterDraw(component); 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 private sealed class InjectionCompleteEvent : EntityEventArgs
{ {
public InjectorComponent Component { get; init; } = default!; public InjectorComponent Component { get; init; } = default!;

View File

@@ -70,8 +70,6 @@
types: types:
Bloodloss: Bloodloss:
-0.25 -0.25
- type: DrawableSolution
solution: bloodstream
- type: Damageable - type: Damageable
damageContainer: Biological damageContainer: Biological
- type: AtmosExposed - type: AtmosExposed

View File

@@ -50,8 +50,6 @@
# Organs # Organs
- type: InjectableSolution - type: InjectableSolution
solution: chemicals solution: chemicals
- type: DrawableSolution
solution: bloodstream
- type: IdExaminable - type: IdExaminable
- type: HealthExaminable - type: HealthExaminable
examinableTypes: examinableTypes: