ECS BloodstreamComponent (#5629)

This commit is contained in:
mirrorcult
2021-11-30 16:47:21 -07:00
committed by GitHub
parent 9f3549c3c2
commit e3af2b5727
12 changed files with 114 additions and 124 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
@@ -38,7 +39,7 @@ namespace Content.Server.Chemistry.Components
var chemistry = EntitySystem.Get<ReactiveSystem>();
var cloneSolution = solution.Clone();
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.EmptyVolume);
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.Solution.AvailableVolume);
var transferSolution = cloneSolution.SplitSolution(transferAmount);
foreach (var reagentQuantity in transferSolution.Contents.ToArray())
@@ -47,7 +48,8 @@ namespace Content.Server.Chemistry.Components
chemistry.ReactionEntity(entity.Uid, ReactionMethod.Ingestion, reagentQuantity.ReagentId, reagentQuantity.Quantity, transferSolution);
}
bloodstream.TryTransferSolution(transferSolution);
var bloodstreamSys = EntitySystem.Get<BloodstreamSystem>();
bloodstreamSys.TryAddToBloodstream(entity.Uid, transferSolution, bloodstream);
}