From bd59cc112e2fff33d0a49180bfbd70ce96591bf5 Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 6 Feb 2025 09:34:40 +0000 Subject: [PATCH] Reduced complexity of `UpdateProfileHealthValues` --- Libraries/Core/Controllers/GameController.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Libraries/Core/Controllers/GameController.cs b/Libraries/Core/Controllers/GameController.cs index a3d29bf2..2c3679dc 100644 --- a/Libraries/Core/Controllers/GameController.cs +++ b/Libraries/Core/Controllers/GameController.cs @@ -343,13 +343,27 @@ public class GameController( } // Check all body parts + DecreaseBodyPartEffectTimes(pmcProfile, hpRegenPerHour, diffSeconds.Value); + + // Update both values as they've both been updated + pmcProfile.Health.UpdateTime = currentTimeStamp; + } + + /// + /// Check for and update any timers on effect found on body parts + /// + /// Player + /// + /// + protected void DecreaseBodyPartEffectTimes(PmcData pmcProfile, double hpRegenPerHour, double diffSeconds) + { foreach (var bodyPart in pmcProfile.Health!.BodyParts! .Select(bodyPartKvP => bodyPartKvP.Value)) { // Check part hp if (bodyPart.Health!.Current < bodyPart.Health.Maximum) { - bodyPart.Health.Current += Math.Round(hpRegenPerHour * (diffSeconds!.Value / 3600)); + bodyPart.Health.Current += Math.Round(hpRegenPerHour * (diffSeconds / 3600)); } if (bodyPart.Health.Current > bodyPart.Health.Maximum) @@ -382,9 +396,6 @@ public class GameController( effectKvP.Value.Time = 1; } } - - // Update both values as they've both been updated - pmcProfile.Health.UpdateTime = currentTimeStamp; } ///