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 InfiniteAmmoLab;
using MelonLoader;
using MelonLoader.Preferences;
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), "InfiniteAmmoLab", "1.0.0", "pietr", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InfiniteAmmoLab")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InfiniteAmmoLab")]
[assembly: AssemblyTitle("InfiniteAmmoLab")]
[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 InfiniteAmmoLab
{
public class Core : MelonMod
{
public static Page mainPage;
public static Page refillPage;
public static Page ammoPage;
private static MelonPreferences_Category IACat;
public static MelonPreferences_Entry<bool> ActivateMod;
public static MelonPreferences_Entry<bool> EmptyRefill;
public static MelonPreferences_Entry<bool> AutoMagazineRefill;
public static MelonPreferences_Entry<bool> EnableStaticAmmo;
public static MelonPreferences_Entry<bool> MakeMagazinesGold;
private static MelonPreferences_Entry<int> StaticAmmo;
private static MelonPreferences_Entry<Color> gold;
private static Color red => Color.HSVToRGB(0f, 0.7f, 1f);
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Initialized.");
Menu.Initialize();
InitSettings();
CreateBonemenu();
AmmoInventoryUtils.OnAddCartridge = (Action<AmmoInventory, AmmoGroup, int>)Delegate.Combine(AmmoInventoryUtils.OnAddCartridge, (Action<AmmoInventory, AmmoGroup, int>)delegate
{
AmmoInventoryUpdate();
});
AmmoInventoryUtils.OnRemoveCartridge = (Action<AmmoInventory, AmmoGroup, int>)Delegate.Combine(AmmoInventoryUtils.OnRemoveCartridge, (Action<AmmoInventory, AmmoGroup, int>)delegate
{
AmmoInventoryUpdate();
});
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 static void AmmoInventoryUpdate()
{
if (AutoMagazineRefill.Value)
{
MagazineUtils.RefillAllMagazines();
}
if (EnableStaticAmmo.Value)
{
AmmoInventoryUtils.AddAmmoToInventory(StaticAmmo.Value);
}
}
private static void InitSettings()
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
IACat = MelonPreferences.CreateCategory("InfiniteAmmoMod");
ActivateMod = IACat.CreateEntry<bool>("ActivateMod", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
EmptyRefill = IACat.CreateEntry<bool>("EmptyRefill", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
AutoMagazineRefill = IACat.CreateEntry<bool>("AutoMagazineRefill", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
EnableStaticAmmo = IACat.CreateEntry<bool>("EnableStaticAmmo", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
StaticAmmo = IACat.CreateEntry<int>("StaticAmmo", 2000, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MakeMagazinesGold = IACat.CreateEntry<bool>("MakeMagazinesGold", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
Color val = default(Color);
ColorUtility.TryParseHtmlString("#DAA520", ref val);
gold = IACat.CreateEntry<Color>("gold", val, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
private void RefillMagazine(Magazine magazine)
{
if (ActivateMod.Value && EmptyRefill.Value)
{
MagazineUtils.RefillMagazine(magazine);
}
}
private static void MakeMagsGold(Magazine __instance)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (!ActivateMod.Value || !MakeMagazinesGold.Value)
{
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.material.shader);
val.color = gold.Value;
val.SetFloat("_Metallic", 1f);
val.SetFloat("_Smoothness", 1f);
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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
if (mainPage == null)
{
mainPage = Page.Root.CreatePage("Infinite Ammo Mod", Color.yellow, 0, true);
}
mainPage.Name = "Infinite <color=white>Ammo Mod";
refillPage = mainPage.CreatePage("Refill Settings", Color.cyan, 0, true);
ammoPage = mainPage.CreatePage("Ammo Settings", red, 0, true);
mainPage.CreateBool("Activate Mod", red, ActivateMod.Value, (Action<bool>)delegate(bool a)
{
ActivateMod.Value = a;
Save();
});
refillPage.CreateBool("Refill on Empty", Color.white, EmptyRefill.Value, (Action<bool>)delegate(bool a)
{
EmptyRefill.Value = a;
Save();
});
refillPage.CreateBool("Auto Refill", Color.white, AutoMagazineRefill.Value, (Action<bool>)delegate(bool a)
{
AutoMagazineRefill.Value = a;
Save();
});
ammoPage.CreateBool("Enable Static Ammo", Color.white, EnableStaticAmmo.Value, (Action<bool>)delegate(bool a)
{
EnableStaticAmmo.Value = a;
Save();
});
ammoPage.CreateInt("Static Ammo Count", Color.white, StaticAmmo.Value, 10, 0, 2000, (Action<int>)delegate(int a)
{
StaticAmmo.Value = a;
Save();
});
ammoPage.CreateBool("Gold Magazines", Color.yellow, MakeMagazinesGold.Value, (Action<bool>)delegate(bool a)
{
MakeMagazinesGold.Value = a;
Save();
});
ammoPage.CreateString("Gold Color", Color.yellow, ColorUtility.ToHtmlStringRGB(gold.Value), (Action<string>)delegate
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
Color value = default(Color);
ColorUtility.TryParseHtmlString("a", ref value);
gold.Value = value;
Save();
});
}
private static void Save()
{
MelonPreferences.Save();
}
}
}