Skip to content

Commit

Permalink
Adds Repair Heal Rate Preference
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
data-bomb committed Mar 23, 2024
1 parent 2bd6639 commit bc3a26c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
7 changes: 6 additions & 1 deletion Si_BasicBanlist/Si_BasicBans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand Down Expand Up @@ -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?
Expand Down
16 changes: 4 additions & 12 deletions Si_CommManagement/Si_CmdrMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 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", "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")]

Expand All @@ -46,12 +46,17 @@ public class RepairFacility : MelonMod
{
static List<DamageManager> vehiclesAtRepairShop = null!;
static float Timer_HealVehicles = 0f;
static MelonPreferences_Category _modCategory = null!;
static MelonPreferences_Entry<float> _Pref_Humans_Vehicle_HealRate = null!;



public override void OnInitializeMelon()
{
_modCategory ??= MelonPreferences.CreateCategory("Silica");
_Pref_Humans_Vehicle_HealRate ??= _modCategory.CreateEntry<float>("RepairFacility_HumanVehicle_HealRate", 0.035f);

vehiclesAtRepairShop = new List<DamageManager>();

}

#if NET6_0
Expand All @@ -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);
}
Expand Down

0 comments on commit bc3a26c

Please sign in to comment.