Basic bleeding mechanics (#6710)
This commit is contained in:
@@ -61,10 +61,10 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
var cloneSolution = solution.Clone();
|
||||
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction * (1 - protection),
|
||||
bloodstream.Solution.AvailableVolume);
|
||||
bloodstream.ChemicalSolution.AvailableVolume);
|
||||
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
||||
|
||||
bloodstreamSys.TryAddToBloodstream(entity, transferSolution, bloodstream);
|
||||
bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream);
|
||||
}
|
||||
|
||||
protected override void OnKill()
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
var chemistry = EntitySystem.Get<ReactiveSystem>();
|
||||
var cloneSolution = solution.Clone();
|
||||
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.Solution.AvailableVolume);
|
||||
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.ChemicalSolution.AvailableVolume);
|
||||
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
||||
|
||||
foreach (var reagentQuantity in transferSolution.Contents.ToArray())
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
var bloodstreamSys = EntitySystem.Get<BloodstreamSystem>();
|
||||
bloodstreamSys.TryAddToBloodstream(entity, transferSolution, bloodstream);
|
||||
bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class ChemistrySystem
|
||||
}
|
||||
|
||||
private void UseInjector(EntityUid target, EntityUid user, InjectorComponent component)
|
||||
{
|
||||
{
|
||||
// Handle injecting/drawing for solutions
|
||||
if (component.ToggleState == SharedInjectorComponent.InjectorToggleMode.Inject)
|
||||
{
|
||||
@@ -247,7 +247,7 @@ public sealed partial class ChemistrySystem
|
||||
private void TryInjectIntoBloodstream(InjectorComponent component, BloodstreamComponent targetBloodstream, EntityUid user)
|
||||
{
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = FixedPoint2.Min(component.TransferAmount, targetBloodstream.Solution.AvailableVolume);
|
||||
var realTransferAmount = FixedPoint2.Min(component.TransferAmount, targetBloodstream.ChemicalSolution.AvailableVolume);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
{
|
||||
@@ -257,9 +257,9 @@ public sealed partial class ChemistrySystem
|
||||
}
|
||||
|
||||
// Move units from attackSolution to targetSolution
|
||||
var removedSolution = _solutions.SplitSolution(user, targetBloodstream.Solution, realTransferAmount);
|
||||
var removedSolution = _solutions.SplitSolution(user, targetBloodstream.ChemicalSolution, realTransferAmount);
|
||||
|
||||
_blood.TryAddToBloodstream((targetBloodstream).Owner, removedSolution, targetBloodstream);
|
||||
_blood.TryAddToChemicals((targetBloodstream).Owner, removedSolution, targetBloodstream);
|
||||
|
||||
removedSolution.DoEntityReaction(targetBloodstream.Owner, ReactionMethod.Injection);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
|
||||
var solToInject = solRemoved.SplitSolution(solRemovedVol * component.TransferEfficiency);
|
||||
|
||||
_bloodstreamSystem.TryAddToBloodstream((args.OtherFixture.Body).Owner, solToInject, bloodstream);
|
||||
_bloodstreamSystem.TryAddToChemicals((args.OtherFixture.Body).Owner, solToInject, bloodstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs
Normal file
25
Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects;
|
||||
|
||||
public sealed class ModifyBleedAmount : ReagentEffect
|
||||
{
|
||||
[DataField("scaled")]
|
||||
public bool Scaled = false;
|
||||
|
||||
[DataField("amount")]
|
||||
public float Amount = -1.0f;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.EntityManager.TryGetComponent<BloodstreamComponent>(args.SolutionEntity, out var blood))
|
||||
{
|
||||
var sys = EntitySystem.Get<BloodstreamSystem>();
|
||||
var amt = Scaled ? Amount * args.Quantity.Float() : Amount;
|
||||
sys.TryModifyBleedAmount(args.SolutionEntity, amt, blood);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs
Normal file
25
Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects;
|
||||
|
||||
public sealed class ModifyBloodLevel : ReagentEffect
|
||||
{
|
||||
[DataField("scaled")]
|
||||
public bool Scaled = false;
|
||||
|
||||
[DataField("amount")]
|
||||
public FixedPoint2 Amount = 1.0f;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.EntityManager.TryGetComponent<BloodstreamComponent>(args.SolutionEntity, out var blood))
|
||||
{
|
||||
var sys = EntitySystem.Get<BloodstreamSystem>();
|
||||
var amt = Scaled ? Amount * args.Quantity : Amount;
|
||||
sys.TryModifyBloodLevel(args.SolutionEntity, amt, blood);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user