From bc3a26cedc238d2de5be53fe7ec38bde9bea8bbd Mon Sep 17 00:00:00 2001 From: data-bomb Date: Sat, 23 Mar 2024 13:25:06 -0700 Subject: [PATCH] Adds Repair Heal Rate Preference - Adds preference (RepairFacility_HumanVehicle_HealRate) with default value of 0.035. Every 5 seconds this percentage of the total health of the vehicle will be healed. - Fixes warnings in Commander Management mod - Fixes warnings in Basic Bans mod --- Si_BasicBanlist/Si_BasicBans.cs | 7 ++++++- Si_CommManagement/Si_CmdrMgr.cs | 16 ++++------------ Si_RepairFacility/Si_RepairFacility.cs | 11 ++++++++--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Si_BasicBanlist/Si_BasicBans.cs b/Si_BasicBanlist/Si_BasicBans.cs index 4e6c92c..0d83508 100644 --- a/Si_BasicBanlist/Si_BasicBans.cs +++ b/Si_BasicBanlist/Si_BasicBans.cs @@ -35,7 +35,7 @@ You should have received a copy of the GNU General Public License using System.Collections.Generic; using System.Linq; -[assembly: MelonInfo(typeof(BasicBanlist), "Basic Banlist", "1.3.2", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(BasicBanlist), "Basic Banlist", "1.3.3", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -246,6 +246,11 @@ public static void Command_Unban(Player? callerPlayer, String args) public static void BanPlayer(Player playerToBan, Player? adminPlayer) { + if (MasterBanList == null) + { + return; + } + BanEntry thisBan = GenerateBanEntry(playerToBan, adminPlayer); // are we already banned? diff --git a/Si_CommManagement/Si_CmdrMgr.cs b/Si_CommManagement/Si_CmdrMgr.cs index c8e40ec..368c117 100644 --- a/Si_CommManagement/Si_CmdrMgr.cs +++ b/Si_CommManagement/Si_CmdrMgr.cs @@ -40,7 +40,7 @@ You should have received a copy of the GNU General Public License using SilicaAdminMod; using System.Linq; -[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.5.1", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.5.2", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -556,21 +556,13 @@ public static void Command_CommanderDemote(Player? callerPlayer, String args) // if no team was specified then try and use current team of the admin if (argumentCount == 0) { - Team? callerTeam = null; - if (callerPlayer != null) - { - callerTeam = callerPlayer.Team; - } - - if (callerTeam != null) - { - targetTeamIndex = callerPlayer.Team.Index; - } - else + if (callerPlayer == null || callerPlayer.Team == null) { HelperMethods.SendChatMessageToPlayer(callerPlayer, HelperMethods.chatPrefix, commandName, ": Too few arguments"); return; } + + targetTeamIndex = callerPlayer.Team.Index; } // argument is present and targets team where current commander needs to get demoted else diff --git a/Si_RepairFacility/Si_RepairFacility.cs b/Si_RepairFacility/Si_RepairFacility.cs index 161473b..fbeaf49 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", "0.9.0", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(RepairFacility), "Repair Facility", "0.9.1", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -46,12 +46,17 @@ public class RepairFacility : MelonMod { static List vehiclesAtRepairShop = null!; static float Timer_HealVehicles = 0f; + static MelonPreferences_Category _modCategory = null!; + static MelonPreferences_Entry _Pref_Humans_Vehicle_HealRate = null!; + + public override void OnInitializeMelon() { + _modCategory ??= MelonPreferences.CreateCategory("Silica"); + _Pref_Humans_Vehicle_HealRate ??= _modCategory.CreateEntry("RepairFacility_HumanVehicle_HealRate", 0.035f); vehiclesAtRepairShop = new List(); - } #if NET6_0 @@ -78,7 +83,7 @@ private static void Postfix(MusicJukeboxHandler __instance) continue; } - float healAmount = vehicleDamageManager.MaxHealth * 0.035f; + float healAmount = vehicleDamageManager.MaxHealth * _Pref_Humans_Vehicle_HealRate.Value; float newHealth = Mathf.Clamp(vehicleDamageManager.Health + healAmount, 0.0f, vehicleDamageManager.MaxHealth); vehicleDamageManager.SetHealth(newHealth); }