Latest versions of MelonLoader are known to have issues with some games. Use version 0.5.4 until the issue has been fixed!
Decompiled source of AmmoWorks v1.0.0
Mods/bw_AmmoWorks.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AmmoWorks; using HarmonyLib; using MelonLoader; using Microsoft.CodeAnalysis; using StressLevelZero.Combat; using StressLevelZero.Player; using StressLevelZero.Props.Weapons; using UnhollowerBaseLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "AmmoWorks", "1.0.0", "freakycheesy", null)] [assembly: MelonGame("Stress Level Zero", "BONEWORKS")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("bw_AmmoWorks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("bw_AmmoWorks")] [assembly: AssemblyTitle("bw_AmmoWorks")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AmmoWorks { [HarmonyPatch] public static class MagazineUtils { public static List<Magazine> magazines = new List<Magazine>(); public static Action<Magazine> OnSpawn; public static Action<Magazine> OnEject; [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(Magazine), "OnEnable")] [HarmonyPostfix] private static void OnSpawnPostfix(Magazine __instance) { MelonLogger.Msg($"On Spawn Postfix {__instance}"); magazines.Add(((Il2CppObjectBase)__instance).TryCast<Magazine>()); OnSpawn(__instance); } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(Magazine), "OnEject")] [HarmonyPrefix] private static void OnEjectPrefix(Magazine __instance) { MelonLogger.Msg($"On Eject Prefix {__instance}"); magazines.Remove(((Il2CppObjectBase)__instance).TryCast<Magazine>()); OnEject(__instance); } } public class Core : MelonMod { public const int ammo = 26000; public static PlayerInventory PlayerInventory => PlayerInventory.Instance; public static void RefillAllMagazines() { foreach (Magazine magazine in MagazineUtils.magazines) { magazine.ResetMagazine(); } } public static void RefillMagazine(Magazine mag) { mag.ResetMagazine(); } public static void AddAmmoToInventory() { PlayerInventory.ClearAmmo(); PlayerInventory.AddAmmo((Weight)0, 26000); PlayerInventory.AddAmmo((Weight)1, 26000); PlayerInventory.AddAmmo((Weight)2, 26000); } public static void AddAmmoToInventory(int ammo) { PlayerInventory.ClearAmmo(); PlayerInventory.AddAmmo((Weight)0, ammo); PlayerInventory.AddAmmo((Weight)1, ammo); PlayerInventory.AddAmmo((Weight)2, ammo); } public static void AddCartridgeToInventory(Weight ammoGroup, int ammo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) PlayerInventory.AddAmmo(ammoGroup, ammo); } public static void RemoveCartridgeToInventory(Weight ammoGroup, int ammo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) PlayerInventory.RemoveAmmo(ammoGroup, ammo); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { ((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName); MagazineUtils.magazines.Clear(); } } }