Decompiled source of God Mode v1.0.1

Mods\GodMode.dll

Decompiled 3 days ago
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;
using BoneLib.BoneMenu;
using GodMode;
using HarmonyLib;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.VRMK;
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), "GodMode", "1.0.1", "mitch", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GodMode")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GodMode")]
[assembly: AssemblyTitle("GodMode")]
[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 GodMode
{
	public class Mod : MelonMod
	{
		public static bool SuperStrengthOn = true;

		public static float StrengthMult = 10f;

		private MelonPreferences_Category _prefs;

		private MelonPreferences_Entry<bool> _invincible;

		private MelonPreferences_Entry<bool> _superStrength;

		private MelonPreferences_Entry<float> _strengthMult;

		public override void OnInitializeMelon()
		{
			_prefs = MelonPreferences.CreateCategory("GodMode");
			_invincible = _prefs.CreateEntry<bool>("Invincible", true, (string)null, "When on, you cannot be killed. Works for your local player in Fusion too.", false, false, (ValueValidator)null, (string)null);
			_superStrength = _prefs.CreateEntry<bool>("SuperStrength", true, (string)null, "When on, your strength is multiplied way up.", false, false, (ValueValidator)null, (string)null);
			_strengthMult = _prefs.CreateEntry<float>("StrengthMultiplier", 10f, (string)null, "Strength multiplier (1 = normal, 10 = maxed). Lower it if you get jittery.", false, false, (ValueValidator)null, (string)null);
			SuperStrengthOn = _superStrength.Value;
			StrengthMult = _strengthMult.Value;
			SetupBoneMenu();
			((MelonBase)this).LoggerInstance.Msg($"GodMode ready. Invincible={_invincible.Value}, SuperStrength={SuperStrengthOn} ({StrengthMult}x)");
		}

		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_0043: Unknown result type (might be due to invalid IL or missing references)
			Page obj = Page.Root.CreatePage("God Mode", Color.yellow, 0, true);
			obj.CreateBool("Invincible", Color.cyan, _invincible.Value, (Action<bool>)OnSetInvincible);
			obj.CreateBool("Super Strength", Color.red, _superStrength.Value, (Action<bool>)OnSetStrength);
		}

		private void OnSetInvincible(bool v)
		{
			_invincible.Value = v;
			_prefs.SaveToFile(false);
		}

		private void OnSetStrength(bool v)
		{
			_superStrength.Value = v;
			SuperStrengthOn = v;
			_prefs.SaveToFile(false);
			Avatar val = (Object.op_Implicit((Object)(object)Player.RigManager) ? Player.RigManager.avatar : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				val.RefreshBodyMeasurements();
			}
		}

		public override void OnUpdate()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			RigManager rigManager = Player.RigManager;
			if (!Object.op_Implicit((Object)(object)rigManager))
			{
				return;
			}
			Health health = rigManager.health;
			if (Object.op_Implicit((Object)(object)health))
			{
				if (_invincible.Value)
				{
					health.healthMode = (HealthMode)0;
					health.curr_Health = health.max_Health;
				}
				else if ((int)health.healthMode == 0)
				{
					health.healthMode = (HealthMode)1;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Avatar), "ComputeBaseStats")]
	public static class AvatarStrengthPatch
	{
		[HarmonyPostfix]
		public static void Postfix(Avatar __instance)
		{
			if (Mod.SuperStrengthOn)
			{
				float strengthMult = Mod.StrengthMult;
				__instance._strengthUpper *= strengthMult;
				__instance._strengthLower *= strengthMult;
				__instance._strengthGrip *= strengthMult;
			}
		}
	}
}