Decompiled source of InfiniteAmmoWorks v1.0.0

Mods/bw_InfiniteAmmoWorks.dll

Decompiled 2 weeks 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 AmmoWorks;
using InfiniteAmmoWorks;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ModThatIsNotMod.BoneMenu;
using StressLevelZero.Props.Weapons;
using UnhollowerBaseLib;
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), "InfiniteAmmoWorks", "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_InfiniteAmmoWorks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("bw_InfiniteAmmoWorks")]
[assembly: AssemblyTitle("bw_InfiniteAmmoWorks")]
[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 InfiniteAmmoWorks
{
	public class Core : MelonMod
	{
		public static bool ActivateMod = true;

		public static bool AutoMagazineRefill = false;

		public static bool MakeMagazinesGold = true;

		public static MenuCategory mainPage;

		public override void OnApplicationStart()
		{
			((MelonBase)this).OnApplicationStart();
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			((MelonBase)this).HarmonyInstance.PatchAll();
			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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				mainPage = MenuManager.CreateCategory("Infinite Ammo Mod", Color.yellow);
				mainPage.CreateBoolElement("Activate Mod", Color.white, ActivateMod, (Action<bool>)ModToggle);
				mainPage.CreateBoolElement("Auto Refill", Color.white, AutoMagazineRefill, (Action<bool>)RefillToggle);
				mainPage.CreateBoolElement("Gold Magazines", Color.white, MakeMagazinesGold, (Action<bool>)GoldToggle);
				mainPage.CreateStringElement("To toggle these features, toggle it and go out of this category and close bonemenu!", Color.red, "Understood?", (Action<string>)null);
			}
			catch
			{
				MelonLogger.Msg("Bonemenu Not Created");
			}
		}

		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.PlayerInventory != (Object)null)
			{
				Core.AddAmmoToInventory();
				if (AutoMagazineRefill)
				{
					Core.RefillAllMagazines();
				}
			}
		}
	}
}