fix stomach bug (#4571)

This commit is contained in:
Leon Friedrich
2021-09-08 17:19:19 +10:00
committed by GitHub
parent b47bba83c8
commit c19b32d2ee

View File

@@ -46,15 +46,13 @@ namespace Content.Server.Body.Behavior
_accumulatedFrameTime -= 1; _accumulatedFrameTime -= 1;
// Note that "Owner" should be the organ that has this behaviour/mechanism, and it should have a dedicated if (!Body.Owner.TryGetComponent(out BloodstreamComponent? bloodstream) ||
// solution container. "Body.Owner" is something else, and may have more than one solution container. StomachSolution == null) // Something has gone wrong here.
if (!Body.Owner.TryGetComponent(out BloodstreamComponent? bloodstream)
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SharedBloodstreamComponent.DefaultSolutionName, out var solution))
{ {
return; return;
} }
// Add reagents ready for transfer to bloodstream to transferSolution // Reagents ready to transfer into the bloodstream are added to this solution
var transferSolution = new Solution(); var transferSolution = new Solution();
// Use ToList here to remove entries while iterating // Use ToList here to remove entries while iterating
@@ -64,10 +62,10 @@ namespace Content.Server.Body.Behavior
delta.Increment(1); delta.Increment(1);
if (delta.Lifetime > _digestionDelay) if (delta.Lifetime > _digestionDelay)
{ {
// This reagent has been in the somach long enough, TRY to transfer it. // This reagent has been in the stomach long enough, TRY to transfer it.
// But first, check if the reagent still exists, and how much is left. // But first, check if the reagent still exists, and how much is left.
// Some poor spessman may have washed down a potassium snack with some water. // Some poor spessman may have washed down a potassium snack with some water.
if (solution.ContainsReagent(delta.ReagentId, out ReagentUnit quantity)) if (StomachSolution.ContainsReagent(delta.ReagentId, out ReagentUnit quantity))
{ {
if (quantity > delta.Quantity) if (quantity > delta.Quantity)
{ {
@@ -75,7 +73,7 @@ namespace Content.Server.Body.Behavior
} }
EntitySystem.Get<SolutionContainerSystem>() EntitySystem.Get<SolutionContainerSystem>()
.TryRemoveReagent(Owner.Uid, solution, delta.ReagentId, quantity); .TryRemoveReagent(Owner.Uid, StomachSolution, delta.ReagentId, quantity);
transferSolution.AddReagent(delta.ReagentId, quantity); transferSolution.AddReagent(delta.ReagentId, quantity);
} }