Decompiled source of Infinite Ammo Mod v4.0.0

Mods/InfiniteAmmoModBonelib.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AmmoLab;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Infinite_Ammo_Mod_Bonelib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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), "Infinite Ammo Mod", "3.0.0", "freakycheesy", "https://slz.gg/lavagang")]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InfiniteAmmoModBonelib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InfiniteAmmoModBonelib")]
[assembly: AssemblyTitle("InfiniteAmmoModBonelib")]
[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 Infinite_Ammo_Mod_Bonelib
{
	public class Core : MelonMod
	{
		public static bool ActivateMod = true;

		public static bool AutoMagazineRefill = false;

		public static bool MakeMagazinesGold = true;

		public static Page mainPage;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			Menu.Initialize();
			((MelonBase)this).HarmonyInstance.PatchAll();
			CreateBonemenu();
			MagazineUtils.OnEject = (Action<Magazine>)Delegate.Combine(MagazineUtils.OnEject, new Action<Magazine>(RefillMagazine));
			MagazineUtils.OnSpawn = (Action<Magazine>)Delegate.Combine(MagazineUtils.OnSpawn, new Action<Magazine>(MakeMagsGold));
		}

		private void RefillMagazine(Magazine magazine)
		{
			if (ActivateMod)
			{
				Core.RefillMagazine(magazine);
			}
		}

		private static void MakeMagsGold(Magazine __instance)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!ActivateMod || !MakeMagazinesGold)
			{
				return;
			}
			List<Renderer> list = ((IEnumerable<Renderer>)((Component)__instance).GetComponentsInParent<Renderer>()).ToList();
			list.AddRange((IEnumerable<Renderer>)((Component)__instance).GetComponentsInChildren<Renderer>());
			foreach (Renderer item in list)
			{
				Material val = new Material(item.sharedMaterial);
				val.color = Color.yellow;
				val.SetFloat("_Metallic", 1f);
				val.SetFloat("_Smoothness", 1f);
				val.mainTexture = null;
				for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)item.materials).Length; i++)
				{
					Material[] array = ((IEnumerable<Material>)item.materials).ToArray();
					array.SetValue(val, i);
					item.materials = Il2CppReferenceArray<Material>.op_Implicit(array);
				}
			}
		}

		public static void CreateBonemenu()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			mainPage = Page.Root.CreatePage("Infinite Ammo Mod", Color.yellow, 0, true);
			mainPage.CreateBool("Activate Mod", Color.white, ActivateMod, (Action<bool>)ModToggle);
			mainPage.CreateBool("Auto Refill", Color.white, AutoMagazineRefill, (Action<bool>)RefillToggle);
			mainPage.CreateBool("Gold Magazines", Color.white, MakeMagazinesGold, (Action<bool>)GoldToggle);
		}

		public static void ModToggle(bool toggle)
		{
			ActivateMod = toggle;
		}

		public static void RefillToggle(bool toggle)
		{
			AutoMagazineRefill = toggle;
		}

		public static void GoldToggle(bool toggle)
		{
			MakeMagazinesGold = toggle;
		}

		public override void OnUpdate()
		{
			((MelonBase)this).OnUpdate();
			if (!ActivateMod)
			{
				return;
			}
			if (mainPage == null)
			{
				CreateBonemenu();
			}
			if ((Object)(object)Core.AmmoInventory != (Object)null && (Object)(object)Core.InventoryAmmoReceiver != (Object)null)
			{
				Core.AddAmmoToInventory();
				if (AutoMagazineRefill)
				{
					Core.RefillAllMagazines();
				}
			}
		}
	}
}