Skip to content

Commit

Permalink
More Debug for Repairing
Browse files Browse the repository at this point in the history
- Places additional debug messages for vehicle repairs when RepairFacility_ChatNotifications is set to true
  • Loading branch information
data-bomb committed Sep 23, 2024
1 parent cf4599c commit 9a92b60
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions Si_RepairFacility/Si_RepairFacility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand Down Expand Up @@ -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 + "]");
}
}
}
}
Expand Down

0 comments on commit 9a92b60

Please sign in to comment.