diff --git a/Main.cs b/Main.cs index 52e7c0b..347bc9e 100644 --- a/Main.cs +++ b/Main.cs @@ -6,7 +6,7 @@ public class Main : MelonMod internal const string Description = "Infinite ammo. What else?"; internal const string Author = "SoulWithMae"; internal const string Company = "Weather Electric"; - internal const string Version = "1.0.1"; + internal const string Version = "1.1.0"; internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/SoulWithMae/InfiniteAmmo/"; public override void OnInitializeMelon() diff --git a/Patching/Patching.cs b/Patching/Patching.cs index 2a7e7f5..133f5de 100644 --- a/Patching/Patching.cs +++ b/Patching/Patching.cs @@ -1,5 +1,7 @@ using HarmonyLib; using Il2CppSLZ.Marrow; +using Il2CppSLZ.Marrow.Data; +// ReSharper disable InconsistentNaming namespace WeatherElectric.InfiniteAmmo.Patching; @@ -11,22 +13,32 @@ public static class AmmoInventoryPatch public static void Awake(AmmoInventory __instance) { if (!Preferences.Enabled.Value) return; - ModConsole.Msg("Adding shit ton of ammo", 1); - __instance.AddCartridge(__instance.lightAmmoGroup, 500000); - __instance.AddCartridge(__instance.mediumAmmoGroup, 500000); - __instance.AddCartridge(__instance.heavyAmmoGroup, 500000); + + __instance.AddCartridge(__instance.lightAmmoGroup, 1000); + __instance.AddCartridge(__instance.mediumAmmoGroup, 1000); + __instance.AddCartridge(__instance.heavyAmmoGroup, 1000); } [HarmonyPatch(nameof(AmmoInventory.RemoveCartridge))] [HarmonyPostfix] - public static void RemoveCartridge(AmmoInventory __instance) + public static void RemoveCartridge(AmmoInventory __instance, CartridgeData cartridge, int count) { if (!Preferences.Enabled.Value) return; -#if DEBUG - ModConsole.Msg("Adding a shit ton of ammo", 1); -#endif - __instance.AddCartridge(__instance.lightAmmoGroup, 1); - __instance.AddCartridge(__instance.mediumAmmoGroup, 1); - __instance.AddCartridge(__instance.heavyAmmoGroup, 1); + + var group = __instance.GetGroupByCartridge(cartridge); + if (group == null) return; + + switch (group) + { + case "light": + __instance.AddCartridge(__instance.lightAmmoGroup, count); + break; + case "medium": + __instance.AddCartridge(__instance.mediumAmmoGroup, count); + break; + case "heavy": + __instance.AddCartridge(__instance.heavyAmmoGroup, count); + break; + } } } \ No newline at end of file