using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Interaction;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Data;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Linq;
using LabFusion.Extensions;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using PowerTools;
using PowerTools.Tools;
using Steamworks;
using Steamworks.Data;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Adds a few quality of life features")]
[assembly: AssemblyDescription("Adds a few quality of life features")]
[assembly: AssemblyCompany("cheesydev")]
[assembly: AssemblyProduct("Powertools")]
[assembly: AssemblyCopyright("Developed by freakycheesy/Breadsoup")]
[assembly: AssemblyTrademark("cheesydev")]
[assembly: AssemblyFileVersion("0.6.5")]
[assembly: MelonInfo(typeof(Main), "Powertools", "0.6.5", "freakycheesy/Breadsoup", "https://thunderstore.io/c/bonelab/p/team_cheesy/PowerTools")]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.6.5.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 PowerTools
{
public class Main : MelonMod
{
internal const string Name = "Powertools";
public const string ModName = "<color=#00FF72>P</color><color=#00FF80>o</color><color=#00FF8D>w</color><color=#00FF99>e</color><color=#00FFA5>r</color><color=#00FFB0> </color><color=#00FFBA>T</color><color=#00FFC3>o</color><color=#00FFCC>o</color><color=#00FFD4>l</color><color=#00FFD4>s</color>";
internal const string Description = "Adds a few quality of life features";
internal const string Author = "freakycheesy/Breadsoup";
internal const string Company = "cheesydev";
internal const string Version = "0.6.5";
internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/team_cheesy/PowerTools";
public static Page MainPage;
public static Action OnUpdateEvent;
public static Action OnFixedUpdateEvent;
public static Action OnGUIEvent;
public static BaseTool[] defaultMods = new BaseTool[8]
{
new ButtonDisabler(),
new AchievementTool(),
new HealthSettings(),
new GravityAdjuster(),
new InfiniteAmmo(),
new PhysicsTool(),
new RagdollLegs(),
new VaultingToggle()
};
public static bool CanUseSteamworks => MelonBase.FindMelon("LabFusion", "Lakatrazz") != null && !Application.isMobilePlatform;
public static MelonPreferences_Category Preferences { get; private set; }
public override void OnInitializeMelon()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (!CanUseSteamworks)
{
MelonLogger.Error("BONELAB FUSION NEEDED FOR STEAMWORKS SINCE IM LAZY AF TO PORT IT ");
}
Preferences = MelonPreferences.CreateCategory("PowerTools", "Power Tools");
Preferences.SetFilePath("UserData/freakycheesy.cfg");
MainPage = Page.Root.CreatePage("<color=#00FF72>P</color><color=#00FF80>o</color><color=#00FF8D>w</color><color=#00FF99>e</color><color=#00FFA5>r</color><color=#00FFB0> </color><color=#00FFBA>T</color><color=#00FFC3>o</color><color=#00FFCC>o</color><color=#00FFD4>l</color><color=#00FFD4>s</color>", Color.white, 0, true);
ToolLoader.LoadTools(defaultMods);
Hooking.OnLevelLoaded += delegate
{
OnSceneAwake();
};
Hooking.OnLevelUnloaded += Save;
}
public override void OnUpdate()
{
((MelonBase)this).OnUpdate();
OnUpdateEvent?.Invoke();
}
public override void OnFixedUpdate()
{
((MelonBase)this).OnFixedUpdate();
OnFixedUpdateEvent?.Invoke();
}
public override void OnGUI()
{
((MelonBase)this).OnGUI();
if (!Application.isMobilePlatform)
{
OnGUIEvent?.Invoke();
}
}
private static void OnSceneAwake()
{
ToolLoader.ResetTools();
Save();
}
public override void OnApplicationQuit()
{
Save();
((MelonBase)this).OnApplicationQuit();
}
public static void Save()
{
Preferences.SaveToFile(true);
MelonPreferences.Save();
}
}
public static class ToolLoader
{
public static List<BaseTool> loadedTools = new List<BaseTool>();
public static void LoadTool(BaseTool tool)
{
loadedTools.Add(tool);
tool.Start();
}
public static void LoadTools()
{
foreach (BaseTool loadedTool in loadedTools)
{
loadedTool.Start();
}
}
public static void LoadTools(IEnumerable<BaseTool> tools)
{
loadedTools.AddRange(tools);
foreach (BaseTool tool in tools)
{
tool.Start();
}
}
public static void ResetTools()
{
ResetTools(loadedTools);
}
public static void ResetTools(IEnumerable<BaseTool> tools)
{
foreach (BaseTool tool in tools)
{
tool.Reset();
}
}
public static BaseTool GetToolInLoadedToolsFromType(Type type)
{
return GetToolInLoadedToolsFromType(type.FullName);
}
public static BaseTool GetToolInLoadedToolsFromType(string fullname)
{
foreach (BaseTool loadedTool in loadedTools)
{
if (loadedTool.GetType().FullName == fullname)
{
MelonLogger.Msg("Found tool: (" + fullname + ")");
return loadedTool;
}
}
MelonLogger.Error("Could not find Tool with type: (" + fullname + ")");
return null;
}
}
}
namespace PowerTools.Tools
{
public class ToolTemplate : BaseTool
{
public override string ToolName
{
get
{
throw new NotImplementedException();
}
}
public override Color ToolTheme
{
get
{
throw new NotImplementedException();
}
}
public override void Start()
{
base.Start();
}
public override void MelonCreator()
{
base.MelonCreator();
}
public override void BoneMenuCreator()
{
base.BoneMenuCreator();
}
public override void OnSetEnabled(bool value)
{
base.OnSetEnabled(value);
}
public override void Reset()
{
base.Reset();
}
}
public enum Platform : byte
{
Steam,
Oculus
}
public class AchievementTool : BaseTool
{
public static Page AchievementsPage;
public static Action InitiatedSteam;
public override string ToolName => "Achievement Tool";
public override Color ToolTheme => Color.red + Color.yellow;
public override void Start()
{
base.Start();
if (Main.CanUseSteamworks)
{
InitiatedSteam = (Action)Delegate.Combine(InitiatedSteam, new Action(AddAchievements));
}
}
private void AddAchievements()
{
//IL_0021: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
foreach (Achievement achievement2 in SteamUserStats.Achievements)
{
Achievement achievement = achievement2;
Page val = AchievementsPage.CreatePage(((Achievement)(ref achievement)).Name + "\n(" + ((Achievement)(ref achievement)).Identifier + ")", Color.green, 0, true);
val.CreateFunction("Unlock", Color.green, (Action)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
UnlockAchievement(achievement);
});
val.CreateFunction("Lock", Color.green, (Action)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
LockAchievement(achievement);
});
}
}
private void LockAchievement(Achievement achievement)
{
((Achievement)(ref achievement)).Clear();
SteamUserStats.StoreStats();
SteamUserStats.RequestCurrentStats();
}
private void UnlockAchievement(Achievement achievement)
{
((Achievement)(ref achievement)).Trigger(true);
SteamUserStats.StoreStats();
SteamUserStats.RequestCurrentStats();
}
public override void MelonCreator()
{
base.MelonCreator();
if (Main.CanUseSteamworks)
{
}
}
public override void BoneMenuCreator()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
if (!Main.CanUseSteamworks)
{
Page.CreateFunction("Steam Only", ToolTheme, (Action)delegate
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
Notification val = new Notification();
val.ShowTitleOnPopup = true;
val.PopupLength = 0.1f;
val.Title = NotificationText.op_Implicit("guess what");
val.Message = NotificationText.op_Implicit("impossible on oculus");
});
}
else
{
Page.CreateFunction("Initiate Steam", ToolTheme, (Action)InitPlatform);
Page.CreateFunction("Unlock All Achievements", ToolTheme, (Action)UnlockAchievements);
Page.CreateFunction("Lock All Achievements", ToolTheme, (Action)LockAchievements);
AchievementsPage = Page.CreatePage("Achievements", Color.green, 12, true);
}
}
private void InitPlatform()
{
SteamClient.Init(1592190u, true);
InitiatedSteam?.Invoke();
}
private void LockAchievements()
{
UnlockSteamAchievements();
}
private void UnlockAchievements()
{
LockSteamAchievements();
}
private void UnlockSteamAchievements()
{
IEnumerableExtensions.ForEach<Achievement>(SteamUserStats.Achievements, (Action<Achievement>)UnlockAchievement);
}
private void LockSteamAchievements()
{
IEnumerableExtensions.ForEach<Achievement>(SteamUserStats.Achievements, (Action<Achievement>)LockAchievement);
}
public override void OnSetEnabled(bool value)
{
base.OnSetEnabled(value);
}
public override void Reset()
{
base.Reset();
}
}
public abstract class BaseTool
{
public Page Page;
public MelonPreferences_Entry<bool> ToolEnabled;
public bool started;
public abstract string ToolName { get; }
public abstract Color ToolTheme { get; }
public virtual void Start()
{
if (!started)
{
MelonCreator();
BoneMenuCreator();
MelonLogger.Msg("Loaded tool: (" + ToolName + ")");
started = true;
}
}
public virtual void MelonCreator()
{
ToolEnabled = Main.Preferences.CreateEntry<bool>(ToolName + " Enabled", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public virtual void BoneMenuCreator()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Page = Main.MainPage.CreatePage(ToolName, ToolTheme, 0, true);
Page.CreateBool("Enabled", ToolTheme, ToolEnabled.Value, (Action<bool>)delegate(bool a)
{
ToolEnabled.Value = a;
});
}
public virtual void OnSetEnabled(bool value)
{
ToolEnabled.Value = value;
}
public virtual void Reset()
{
if (ToolEnabled != null)
{
}
}
}
public class ButtonDisabler : BaseTool
{
public static MelonPreferences_Entry<bool> EndOfLevelButton { get; set; }
public override string ToolName => "Button Disabler";
public override Color ToolTheme => Color.red + Color.yellow / 2f;
public override void Start()
{
base.Start();
}
public override void MelonCreator()
{
base.MelonCreator();
EndOfLevelButton = Main.Preferences.CreateEntry<bool>("Disableendoflevelbutton", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public override void BoneMenuCreator()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
Page.CreateBool("Disable Next Level Button", ToolTheme, EndOfLevelButton.Value, (Action<bool>)OnEndOfLevelButtonEnabled);
}
public override void OnSetEnabled(bool value)
{
base.OnSetEnabled(value);
DisableButtons();
}
public override void Reset()
{
base.Reset();
DisableButtons();
}
public void DisableButtons()
{
Il2CppArrayBase<Transform> val = Object.FindObjectsOfType<Transform>(true);
foreach (Transform item in val)
{
if (!((Object)item).name.Contains("FLOORS") && !((Object)item).name.Contains("LoadButtons") && !((Object)item).name.Contains("prop_bigButton") && !((Object)item).name.Contains("INTERACTION"))
{
continue;
}
for (int i = 0; i < item.childCount; i++)
{
Transform child = item.GetChild(i);
ButtonToggle component = ((Component)child).GetComponent<ButtonToggle>();
if ((Object)(object)component != (Object)null && ToolEnabled.Value)
{
if (EndOfLevelButton.Value)
{
((Behaviour)component).enabled = false;
}
else if (!EndOfLevelButton.Value)
{
if (!((Object)child).name.Contains("prop_bigButton_NEXTLEVEL"))
{
((Behaviour)component).enabled = false;
}
if (((Object)child).name.Contains("prop_bigButton_NEXTLEVEL"))
{
((Behaviour)component).enabled = true;
}
}
}
else if ((Object)(object)component != (Object)null && !ToolEnabled.Value)
{
((Behaviour)component).enabled = true;
}
}
}
}
private void OnEndOfLevelButtonEnabled(bool value)
{
EndOfLevelButton.Value = value;
Main.Save();
DisableButtons();
}
}
public class GravityAdjuster : BaseTool
{
private static float _gravity = -9.81f;
public static MelonPreferences_Entry<float> MelonPrefGravityValue { get; set; }
public override string ToolName => "Gravity Adjuster";
public override Color ToolTheme => Color.blue;
public override void MelonCreator()
{
base.MelonCreator();
MelonPrefGravityValue = Main.Preferences.CreateEntry<float>("Gravity Adjuster Value", -9.81f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
if (MelonPrefGravityValue != null)
{
_gravity = MelonPrefGravityValue.Value;
}
}
public override void BoneMenuCreator()
{
//IL_0030: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
FloatElement one = null;
FloatElement ten = null;
FloatElement pointOne = Page.CreateFloat("Gravity Value (0.1)", ToolTheme, _gravity, 0.1f, -25f, 25f, (Action<float>)delegate(float r)
{
MelonPrefGravityValue.Value = r;
_gravity = r;
one.Value = r;
ten.Value = r;
GravityAdjust();
});
one = Page.CreateFloat("Gravity Value (1)", ToolTheme, _gravity, 1f, -25f, 25f, (Action<float>)delegate(float r)
{
MelonPrefGravityValue.Value = r;
pointOne.Value = r;
ten.Value = r;
_gravity = r;
GravityAdjust();
});
ten = Page.CreateFloat("Gravity Value (5)", ToolTheme, _gravity, 5f, -25f, 25f, (Action<float>)delegate(float r)
{
MelonPrefGravityValue.Value = r;
pointOne.Value = r;
one.Value = r;
_gravity = r;
GravityAdjust();
});
}
public override void OnSetEnabled(bool value)
{
base.OnSetEnabled(value);
if (value)
{
GravityAdjust();
}
else
{
GravityReset();
}
Main.Save();
}
private static void GravityReset()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Physics.gravity = new Vector3(0f, -9.81f, 0f);
}
public override void Reset()
{
GravityAdjust();
}
public void GravityAdjust()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (ToolEnabled.Value)
{
Physics.gravity = new Vector3(0f, _gravity, 0f);
}
Main.Save();
}
}
public enum Bool : byte
{
Default,
True,
False
}
public class HealthSettings : BaseTool
{
[HarmonyPatch(typeof(Player_Health))]
public static class PlayerHealthPatch
{
[HarmonyPatch("SetFullHealth")]
[HarmonyPrefix]
public static void Respawn()
{
MelonLogger.Msg("Respawn");
Unragdoll();
}
[HarmonyPatch("Death")]
[HarmonyPostfix]
public static void Death()
{
MelonLogger.Msg("Death");
if (RagdollOnDeath.Value)
{
Ragdoll();
}
}
[HarmonyPatch("TAKEDAMAGE")]
[HarmonyPostfix]
public static void TAKEDAMAGE(float damage)
{
Hooking_OnPlayerDamageRecieved(damage);
}
}
public static MelonPreferences_Entry<bool> GodMode;
public static MelonPreferences_Entry<bool> RagdollOnDeath;
public static MelonPreferences_Entry<Bool> ReloadLevel;
public static MelonPreferences_Entry<float> DeathTime;
public static Player_Health PlayerHealth
{
get
{
RigManager rigManager = Player.RigManager;
if ((Object)(object)((rigManager != null) ? rigManager.health : null) != (Object)null)
{
return ((Il2CppObjectBase)Player.RigManager.health).TryCast<Player_Health>();
}
return null;
}
}
public override string ToolName => "Health Settings";
public override Color ToolTheme => Color.green + Color.yellow;
public override void Start()
{
base.Start();
}
private static void Hooking_OnPlayerDamageRecieved(float obj)
{
MelonLogger.Msg("Damage Recieved");
if (GodMode.Value)
{
((Health)PlayerHealth).SetFullHealth();
}
if (RagdollOnDeath.Value && ((Health)PlayerHealth).curr_Health <= 0f)
{
Ragdoll();
}
}
private static void Ragdoll()
{
Player.PhysicsRig.ShutdownRig();
Player.PhysicsRig.RagdollRig();
}
private static void Unragdoll()
{
Player.PhysicsRig.TurnOnRig();
Player.PhysicsRig.UnRagdollRig();
}
public override void MelonCreator()
{
base.MelonCreator();
GodMode = Main.Preferences.CreateEntry<bool>("God Mode", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
RagdollOnDeath = Main.Preferences.CreateEntry<bool>("Ragdoll On Death", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
ReloadLevel = Main.Preferences.CreateEntry<Bool>("ReloadLevel", Bool.Default, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
DeathTime = Main.Preferences.CreateEntry<float>("Damage Threshold", 3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public override void BoneMenuCreator()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
Page.CreateBool("God Mode", ToolTheme, GodMode.Value, (Action<bool>)delegate(bool a)
{
GodMode.Value = a;
Main.Save();
});
Page.CreateBool("Ragdoll On Death", ToolTheme, RagdollOnDeath.Value, (Action<bool>)delegate(bool a)
{
RagdollOnDeath.Value = a;
((Health)PlayerHealth)._testRagdollOnDeath = RagdollOnDeath.Value;
Main.Save();
});
Page.CreateEnum("Reload Level On Death", ToolTheme, (Enum)ReloadLevel.Value, (Action<Enum>)delegate(Enum a)
{
ReloadLevel.Value = (Bool)(object)a;
EditReloadOnDeath(a);
Main.Save();
});
Page.CreateFloat("Death Time", ToolTheme, DeathTime.Value, 10f, 0f, 100f, (Action<float>)delegate(float dt)
{
DeathTime.Value = dt;
PlayerHealth.deathTimeAmount = DeathTime.Value;
Main.Save();
});
Page.CreateFunction("Die", ToolTheme, (Action)OnDie);
Page.CreateFunction("Refill Health", ToolTheme, (Action)SetFullHealth);
}
public static void EditReloadOnDeath(Enum a)
{
if (!(a is Bool))
{
return;
}
switch ((Bool)(object)a)
{
case Bool.True:
PlayerHealth.reloadLevelOnDeath = true;
break;
case Bool.False:
PlayerHealth.reloadLevelOnDeath = true;
break;
case Bool.Default:
{
PlayerHealthDecorator val = Object.FindObjectOfType<PlayerHealthDecorator>();
if (Object.op_Implicit((Object)(object)val))
{
PlayerHealth.reloadLevelOnDeath = val._reloadLevelOnDeath;
}
break;
}
}
}
public static void SetFullHealth()
{
Player_Health playerHealth = PlayerHealth;
if (playerHealth != null)
{
((Health)playerHealth).SetFullHealth();
}
}
private static void OnDie()
{
Player_Health playerHealth = PlayerHealth;
if (playerHealth != null)
{
((Health)playerHealth).Dying(100f);
}
Player_Health playerHealth2 = PlayerHealth;
if (playerHealth2 != null)
{
((Health)playerHealth2).Death();
}
Player_Health playerHealth3 = PlayerHealth;
if (playerHealth3 != null)
{
((Health)playerHealth3).Respawn();
}
}
public override void Reset()
{
base.Reset();
EditReloadOnDeath(ReloadLevel.Value);
PlayerHealth.deathTimeAmount = DeathTime.Value;
}
}
public class InfiniteAmmo : BaseTool
{
public static class GunPatches
{
[HarmonyPatch(typeof(AmmoInventory), "RemoveCartridge")]
public static class TaxReturn
{
[HarmonyPrefix]
public static void Prefix(AmmoInventory __instance, CartridgeData cartridge, int count)
{
if (Enabled)
{
__instance.AddCartridge(cartridge, count);
}
}
}
[HarmonyPatch(typeof(InventoryAmmoReceiver), "OnHandGrab")]
public static class AmmoCheckPatch
{
[HarmonyPrefix]
public static void Prefix()
{
if (Enabled && InfiniteAmmoEnabled.Value)
{
int cartridgeCount = AmmoInventory.Instance.GetCartridgeCount("light");
if (cartridgeCount <= 0)
{
Bankruptcy(AmmoInventory.Instance.lightAmmoGroup);
}
int cartridgeCount2 = AmmoInventory.Instance.GetCartridgeCount("medium");
if (cartridgeCount2 <= 0)
{
Bankruptcy(AmmoInventory.Instance.mediumAmmoGroup);
}
int cartridgeCount3 = AmmoInventory.Instance.GetCartridgeCount("heavy");
if (cartridgeCount3 <= 25)
{
Bankruptcy(AmmoInventory.Instance.heavyAmmoGroup);
}
}
}
private static void Bankruptcy(AmmoGroup group)
{
AmmoInventory.Instance.AddCartridge(group, 1);
}
}
[HarmonyPatch(typeof(Magazine), "OnGrab")]
public static class CashBack
{
[HarmonyPostfix]
public static void Postfix()
{
if (Enabled)
{
Magazine componentInHand = Player.GetComponentInHand<Magazine>(Player.LeftHand);
Magazine componentInHand2 = Player.GetComponentInHand<Magazine>(Player.RightHand);
if ((Object)(object)componentInHand != (Object)null)
{
MagMax(componentInHand);
}
if ((Object)(object)componentInHand2 != (Object)null)
{
MagMax(componentInHand2);
}
}
}
private static void MagMax(Magazine mag)
{
if (InfiniteAmmoEnabled.Value)
{
int rounds = mag.magazineState.magazineData.rounds;
int cartridgeCount = AmmoInventory.Instance.GetCartridgeCount(mag.magazineState.cartridgeData);
if (cartridgeCount < rounds)
{
BankStatement(mag, rounds, cartridgeCount);
}
}
if (InfiniteAmmo.MidasTouch.Value)
{
MidasTouch(mag);
}
}
private static void MidasTouch(Magazine mag)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
Il2CppArrayBase<Renderer> componentsInChildren = ((Component)mag).GetComponentsInChildren<Renderer>();
foreach (Renderer item in componentsInChildren)
{
foreach (Material item2 in (Il2CppArrayBase<Material>)(object)item.materials)
{
item2.mainTexture = null;
item2.color = Color.yellow;
item2.SetFloat("_Metallic", 1f);
item2.SetFloat("_Smoothness", 1f);
}
}
}
private static void BankStatement(Magazine mag, int magMax, int cartridgeCount)
{
if (AmmoInventory.Instance.GetCartridgeCount("light") == cartridgeCount)
{
Loan(mag, AmmoInventory.Instance.lightAmmoGroup, magMax);
}
else if (AmmoInventory.Instance.GetCartridgeCount("medium") == cartridgeCount)
{
Loan(mag, AmmoInventory.Instance.mediumAmmoGroup, magMax);
}
else if (AmmoInventory.Instance.GetCartridgeCount("heavy") == cartridgeCount)
{
Loan(mag, AmmoInventory.Instance.heavyAmmoGroup, magMax);
}
}
private static void Loan(Magazine mag, AmmoGroup group, int amount)
{
if (AmmoInventory.Instance.GetCartridgeCount(group.KeyName) == 1)
{
AmmoInventory.Instance.AddCartridge(group, -1);
}
AmmoInventory.Instance.AddCartridge(group, amount);
mag.magazineState.Refill();
}
}
[HarmonyPatch(typeof(Gun), "OnFire")]
public static class CreditCard
{
[HarmonyPostfix]
public static void Postfix(Gun __instance)
{
if (Enabled && InfMags.Value && (Object)(object)((Component)__instance).gameObject.GetComponentInChildren<Magazine>() != (Object)null)
{
((Component)__instance).gameObject.GetComponentInChildren<Magazine>().magazineState.Refill();
}
}
}
[HarmonyPatch(typeof(Magazine), "OnEject")]
public static class Withdraw
{
[HarmonyPostfix]
public static void Postfix(Magazine __instance)
{
if (Enabled && EjectRefill.Value)
{
__instance.magazineState.Refill();
}
}
}
[HarmonyPatch(typeof(Gun), "AmmoCount")]
public static class ShotgunCreditCard
{
[HarmonyPrefix]
public static bool Prefix(Gun __instance, ref int __result)
{
if (Enabled && InfMags.Value)
{
__result = 1;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Gun), "CheckGunRequirements")]
public static class Paycheck
{
[HarmonyPrefix]
public static void Prefix(Gun __instance)
{
if (Enabled && AutoChamber.Value)
{
__instance.Charge();
}
if (Enabled && AutoLoad.Value && !__instance._hasMagState)
{
__instance.InstantLoadAsync();
}
}
}
[HarmonyPatch(typeof(Gun), "OnTriggerGripAttached")]
public static class DirectDeposit
{
[HarmonyPrefix]
public static void Prefix(Gun __instance)
{
if (Enabled && AutoLoad.Value && !__instance._hasMagState)
{
__instance.InstantLoadAsync();
}
}
}
public static bool Enabled
{
get
{
if (Instance == null)
{
return false;
}
if (Instance != null && Instance.ToolEnabled == null)
{
return false;
}
return Instance.ToolEnabled.Value;
}
}
}
public static InfiniteAmmo Instance { get; private set; }
public static MelonPreferences_Entry<bool> InfiniteAmmoEnabled { get; set; }
public static MelonPreferences_Entry<bool> InfMags { get; set; }
public static MelonPreferences_Entry<bool> AutoChamber { get; set; }
public static MelonPreferences_Entry<bool> AutoLoad { get; set; }
public static MelonPreferences_Entry<bool> EjectRefill { get; set; }
public static MelonPreferences_Entry<bool> MidasTouch { get; set; }
public override string ToolName => "Infinite Ammo";
public override Color ToolTheme => Color.yellow;
public override void Start()
{
base.Start();
Instance = this;
}
public override void MelonCreator()
{
base.MelonCreator();
InfiniteAmmoEnabled = Main.Preferences.CreateEntry<bool>("Infinite Ammo", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
AutoChamber = Main.Preferences.CreateEntry<bool>("AutoChamber", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
AutoLoad = Main.Preferences.CreateEntry<bool>("AutoLoad", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
InfMags = Main.Preferences.CreateEntry<bool>("AutoRefill", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
EjectRefill = Main.Preferences.CreateEntry<bool>("EjectRefill", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MidasTouch = Main.Preferences.CreateEntry<bool>("MidasTouch", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public override void BoneMenuCreator()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
Page.CreateBool("Infinte Ammo", ToolTheme, InfiniteAmmoEnabled.Value, (Action<bool>)OnGiveAmmoWhenEmpty);
Page.CreateBool("Auto Chamber", ToolTheme, AutoChamber.Value, (Action<bool>)OnAutoChamber);
Page.CreateBool("Auto Load Guns", ToolTheme, InfiniteAmmoEnabled.Value, (Action<bool>)OnAutoLoad);
Page.CreateBool("Auto Refill", ToolTheme, InfMags.Value, (Action<bool>)OnInfiniteMags);
Page.CreateBool("Eject Refill", ToolTheme, EjectRefill.Value, (Action<bool>)OnEjectRefill);
Page.CreateBool("Midas Touch", ToolTheme, MidasTouch.Value, (Action<bool>)OnGoldMags);
}
private static void OnGoldMags(bool obj)
{
MidasTouch.Value = obj;
Main.Save();
}
private static void OnEjectRefill(bool obj)
{
EjectRefill.Value = obj;
Main.Save();
}
public override void OnSetEnabled(bool value)
{
base.OnSetEnabled(value);
Main.Save();
}
private static void OnGiveAmmoWhenEmpty(bool value)
{
InfiniteAmmoEnabled.Value = value;
Main.Save();
}
private static void OnInfiniteMags(bool value)
{
InfMags.Value = value;
Main.Save();
}
private static void OnAutoChamber(bool value)
{
AutoChamber.Value = value;
Main.Save();
}
private static void OnAutoLoad(bool value)
{
AutoLoad.Value = value;
Main.Save();
}
}
public class PhysicsTool : BaseTool
{
[HarmonyPatch(typeof(Grip))]
private static class GripPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake(Grip __instance)
{
AddForcePull(__instance);
}
public static void AddForcePull(Grip __instance)
{
if (ForcePullAnything.Value)
{
ForcePullGrip val = default(ForcePullGrip);
if (!((Component)__instance).gameObject.TryGetComponent<ForcePullGrip>(ref val))
{
val = ((Component)__instance).gameObject.AddComponent<ForcePullGrip>();
}
((Component)val).gameObject.layer = LayerMask.NameToLayer("Interactable");
val._grip = __instance;
val.maxForce = maxForce;
val.maxSpeed = maxSpeed;
}
}
}
public static MelonPreferences_Entry<bool> ForcePullAnything;
public static float maxForce = 1000f;
public static float maxSpeed = 1E+10f;
public override string ToolName => "Physics Tool";
public override Color ToolTheme => Color.green;
public override void MelonCreator()
{
base.MelonCreator();
ForcePullAnything = Main.Preferences.CreateEntry<bool>("ForcePullAnything", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public override void BoneMenuCreator()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
base.BoneMenuCreator();
Page.CreateBool("Force Pull Anything (Cannot Reverse)", ToolTheme, ForcePullAnything.Value, (Action<bool>)delegate(bool a)
{
ForcePullAnything.Value = a;
foreach (Grip item in Resources.FindObjectsOfTypeAll<Grip>())
{
GripPatch.AddForcePull(item);
}
Main.Save();
});
}
}
public class RagdollLegs : BaseTool
{
public override string ToolName => "Ragdoll Legs";
public override Color ToolTheme => Color.cyan;
public override void OnSetEnabled(bool value)
{
if (value)
{
Player.PhysicsRig.PhysicalLegs();
}
else
{
Player.PhysicsRig.UnRagdollRig();
}
}
}
public class VaultingToggle : BaseTool
{
[HarmonyPatch(typeof(PhysicsRig))]
public static class VaultPatch
{
[HarmonyPatch("CheckDangle")]
[HarmonyPrefix]
public static bool CheckDangle(PhysicsRig __instance, ref bool __result)
{
if (!instance.ToolEnabled.Value)
{
__result = false;
return false;
}
return true;
}
}
public static VaultingToggle instance;
public override string ToolName => "Vaulting Toggle";
public override Color ToolTheme => Color.magenta;
public override void Start()
{
base.Start();
}
public override void BoneMenuCreator()
{
base.BoneMenuCreator();
instance = this;
}
}
}
namespace PowerTools.src
{
public static class Extensions
{
public static List<T> ToList<T>(this IEnumerable<T> dirtyList)
{
return ((IEnumerable<T>)Enumerable.ToArray<T>(dirtyList)).ToList();
}
}
}