Decompiled source of ToggleableGodMode v1.3.8

Mods/ToggleableGodMode.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using Godmodebonelab;
using Il2CppSLZ.Marrow;
using LabFusion.Utilities;
using MelonLoader;
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(Class1), "ToggleableGodMode", "1.0.0", "BananaBL", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("ToggleableGodMode")]
[assembly: AssemblyDescription("Makes your player unkillable")]
[assembly: AssemblyProduct("ToggleableGodMode")]
[assembly: ComVisible(false)]
[assembly: Guid("038a7bb2-b4e5-47c8-9ae9-2746bec04fcb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Godmodebonelab
{
	public class Class1 : MelonMod
	{
		private bool Toggle;

		private bool thisisliterallytocheckiftheguyisded = false;

		private bool joinedserver;

		public override void OnInitializeMelon()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_004e: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Page val = Page.Root.CreatePage("Godmode", Color.green, 0, true);
			val.CreateBool("Toggle", Color.green, false, (Action<bool>)delegate(bool value)
			{
				Toggle = value;
			});
			joinedserver = false;
			MultiplayerHooking.OnJoinServer += new ServerEvent(MultiplayerHooking_OnJoinServer);
			MultiplayerHooking.OnDisconnect += new ServerEvent(MultiplayerHooking_OnDisconnect);
		}

		public override void OnUpdate()
		{
			if (!((Object)(object)Player.RigManager != (Object)null) || !((Object)(object)Player.RigManager.health != (Object)null))
			{
				return;
			}
			bool alive = Player.RigManager.health.alive;
			if (!joinedserver)
			{
				return;
			}
			if (!alive && !thisisliterallytocheckiftheguyisded)
			{
				thisisliterallytocheckiftheguyisded = true;
				Mortal();
			}
			if (alive && thisisliterallytocheckiftheguyisded)
			{
				thisisliterallytocheckiftheguyisded = false;
				if (Toggle)
				{
					Immortal();
				}
			}
			if (Toggle && alive)
			{
				Immortal();
			}
		}

		private void Immortal()
		{
			if ((Object)(object)Player.RigManager != (Object)null && (Object)(object)Player.RigManager.health != (Object)null && Player.RigManager.health.curr_Health < float.MaxValue)
			{
				MelonLogger.Msg("Immortal: Setting health to max.");
				Player.RigManager.health.max_Health = float.MaxValue;
				Player.RigManager.health.curr_Health = float.MaxValue;
			}
		}

		private void Mortal()
		{
			if ((Object)(object)Player.RigManager != (Object)null && (Object)(object)Player.RigManager.health != (Object)null && Player.RigManager.health.curr_Health == float.MaxValue)
			{
				MelonLogger.Msg("Mortal: Resetting health to normal.");
				float num = ((Rig)Player.GetPhysicsRig()).avatar.vitality * 10f;
				Player.RigManager.health.max_Health = num;
				Player.RigManager.health.curr_Health = num;
			}
		}

		private void MultiplayerHooking_OnDisconnect()
		{
			joinedserver = false;
		}

		private void MultiplayerHooking_OnJoinServer()
		{
			joinedserver = true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}