From 9a92b604512eee4959651d8839b05b8ef534e613 Mon Sep 17 00:00:00 2001 From: data-bomb Date: Sun, 22 Sep 2024 19:37:06 -0700 Subject: [PATCH] More Debug for Repairing - Places additional debug messages for vehicle repairs when RepairFacility_ChatNotifications is set to true --- Si_RepairFacility/Si_RepairFacility.cs | 36 ++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/Si_RepairFacility/Si_RepairFacility.cs b/Si_RepairFacility/Si_RepairFacility.cs index fd52a74..cada249 100644 --- a/Si_RepairFacility/Si_RepairFacility.cs +++ b/Si_RepairFacility/Si_RepairFacility.cs @@ -36,7 +36,7 @@ You should have received a copy of the GNU General Public License using System.Collections.Generic; using System.Text; -[assembly: MelonInfo(typeof(RepairFacility), "Repair Facility", "1.1.1", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(RepairFacility), "Repair Facility", "1.1.2", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -97,12 +97,38 @@ private static void Postfix(MusicJukeboxHandler __instance) foreach (Unit vehicle in vehiclesAtRepairShop) { float healAmount = vehicle.DamageManager.MaxHealth * (vehicle.IsFlyingType ? _Pref_Humans_Aircraft_HealRate.Value : _Pref_Humans_Vehicle_HealRate.Value); - float newHealth = Mathf.Clamp(vehicle.DamageManager.Health + healAmount, 0.0f, vehicle.DamageManager.MaxHealth); - vehicle.DamageManager.SetHealth(newHealth); - if (_Pref_Repair_Notification.Value && vehicle.ControlledBy != null) + if (vehicle.DamageManager.Health == vehicle.DamageManager.MaxHealth) { - HelperMethods.SendChatMessageToPlayer(vehicle.ControlledBy, HelperMethods.chatPrefix, " Debug Info: Health[" + vehicle.DamageManager.Health + "] MaxHP[" + vehicle.DamageManager.MaxHealth + "] HealAmt[" + healAmount + "]"); + if (_Pref_Repair_Notification.Value && vehicle.ControlledBy != null) + { + HelperMethods.SendChatMessageToPlayer(vehicle.ControlledBy, HelperMethods.chatPrefix, " Debug Info: (Skipping) Health[" + vehicle.DamageManager.Health + "] MaxHP[" + vehicle.DamageManager.MaxHealth + "] HealAmt[" + healAmount + "]"); + } + + continue; + } + + float newHealthUnclamped = vehicle.DamageManager.Health + healAmount; + + if (newHealthUnclamped >= vehicle.DamageManager.MaxHealth) + { + vehicle.DamageManager.SetHealth01(1f); + + if (_Pref_Repair_Notification.Value && vehicle.ControlledBy != null) + { + HelperMethods.SendChatMessageToPlayer(vehicle.ControlledBy, HelperMethods.chatPrefix, " Debug Info: (Max) Health[" + vehicle.DamageManager.Health + "] MaxHP[" + vehicle.DamageManager.MaxHealth + "] HealAmt[" + healAmount + "]"); + } + } + else + { + float newHealth = Mathf.Clamp(newHealthUnclamped, 0.0f, vehicle.DamageManager.MaxHealth); + + vehicle.DamageManager.SetHealth(newHealth); + + if (_Pref_Repair_Notification.Value && vehicle.ControlledBy != null) + { + HelperMethods.SendChatMessageToPlayer(vehicle.ControlledBy, HelperMethods.chatPrefix, " Debug Info: (Incremental) Health[" + vehicle.DamageManager.Health + "] MaxHP[" + vehicle.DamageManager.MaxHealth + "] HealAmt[" + healAmount + "]"); + } } } }