using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib.BoneMenu;
using Il2CppSLZ.Marrow;
using InfiniteAmmo;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "InfiniteAmmo", "1.0.0", "mitch", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InfiniteAmmo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InfiniteAmmo")]
[assembly: AssemblyTitle("InfiniteAmmo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 InfiniteAmmo
{
public class Mod : MelonMod
{
private const int Target = 999999;
private MelonPreferences_Category _prefs;
private MelonPreferences_Entry<bool> _enabled;
private MelonPreferences_Entry<bool> _light;
private MelonPreferences_Entry<bool> _medium;
private MelonPreferences_Entry<bool> _heavy;
public override void OnInitializeMelon()
{
_prefs = MelonPreferences.CreateCategory("InfiniteAmmo");
_enabled = _prefs.CreateEntry<bool>("Enabled", true, (string)null, "Master on/off switch.", false, false, (ValueValidator)null, (string)null);
_light = _prefs.CreateEntry<bool>("LightAmmo", true, (string)null, "Keep LIGHT ammo infinite.", false, false, (ValueValidator)null, (string)null);
_medium = _prefs.CreateEntry<bool>("MediumAmmo", true, (string)null, "Keep MEDIUM ammo infinite.", false, false, (ValueValidator)null, (string)null);
_heavy = _prefs.CreateEntry<bool>("HeavyAmmo", true, (string)null, "Keep HEAVY ammo infinite.", false, false, (ValueValidator)null, (string)null);
SetupBoneMenu();
((MelonBase)this).LoggerInstance.Msg("InfiniteAmmo ready.");
}
private void SetupBoneMenu()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
Page obj = Page.Root.CreatePage("Infinite Ammo", Color.green, 0, true);
obj.CreateBool("Enabled", Color.yellow, _enabled.Value, (Action<bool>)delegate(bool v)
{
_enabled.Value = v;
_prefs.SaveToFile(false);
});
obj.CreateBool("Light Ammo", Color.cyan, _light.Value, (Action<bool>)delegate(bool v)
{
_light.Value = v;
_prefs.SaveToFile(false);
});
obj.CreateBool("Medium Ammo", Color.green, _medium.Value, (Action<bool>)delegate(bool v)
{
_medium.Value = v;
_prefs.SaveToFile(false);
});
obj.CreateBool("Heavy Ammo", Color.red, _heavy.Value, (Action<bool>)delegate(bool v)
{
_heavy.Value = v;
_prefs.SaveToFile(false);
});
}
public override void OnUpdate()
{
if (_enabled.Value)
{
AmmoInventory instance = AmmoInventory.Instance;
if (!((Object)(object)instance == (Object)null))
{
TopUp(instance, instance.lightAmmoGroup, _light.Value);
TopUp(instance, instance.mediumAmmoGroup, _medium.Value);
TopUp(instance, instance.heavyAmmoGroup, _heavy.Value);
}
}
}
private static void TopUp(AmmoInventory inv, AmmoGroup group, bool on)
{
if (on && !((Object)(object)group == (Object)null))
{
int cartridgeCount = inv.GetCartridgeCount(group.KeyName);
if (cartridgeCount < 999999)
{
inv.AddCartridge(group, 999999 - cartridgeCount);
}
}
}
}
}