Bloodstreams now have their own drawing behavior (#8920)
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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<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))
|
||||
{
|
||||
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!;
|
||||
|
||||
@@ -70,8 +70,6 @@
|
||||
types:
|
||||
Bloodloss:
|
||||
-0.25
|
||||
- type: DrawableSolution
|
||||
solution: bloodstream
|
||||
- type: Damageable
|
||||
damageContainer: Biological
|
||||
- type: AtmosExposed
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
# Organs
|
||||
- type: InjectableSolution
|
||||
solution: chemicals
|
||||
- type: DrawableSolution
|
||||
solution: bloodstream
|
||||
- type: IdExaminable
|
||||
- type: HealthExaminable
|
||||
examinableTypes:
|
||||
|
||||
Reference in New Issue
Block a user