Decompiled source of PowerMenu v2.0.0

Mods\PowerMenu.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
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 Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.PuppetMasta;
using LabFusion.Entities;
using LabFusion.Player;
using MelonLoader;
using Microsoft.CodeAnalysis;
using PowerMenu;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PowerMenu")]
[assembly: AssemblyDescription("Menu de pouvoirs pour BONELAB")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("PowerMenu")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: MelonInfo(typeof(PowerMenuMod), "PowerMenu", "2.0.0", "You", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: MelonColor(255, 255, 90, 180)]
[assembly: MelonAuthorColor(255, 150, 220, 255)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 PowerMenu
{
	internal static class FusionIntegration
	{
		private static Page _playersPage;

		public static void BuildFusionPage(Page root)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			_playersPage = root.CreatePage("Joueurs (Fusion)", new Color(0.2f, 0.8f, 1f), 0, true);
			RebuildList();
		}

		private static void RebuildList()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (_playersPage == null)
			{
				return;
			}
			_playersPage.RemoveAll();
			_playersPage.CreateFunction("↻ Rafraîchir la liste", new Color(0.9f, 0.9f, 0.9f), (Action)RebuildList);
			int num = 0;
			foreach (PlayerID playerID in PlayerIDManager.PlayerIDs)
			{
				if (playerID != null && playerID.IsValid && !playerID.IsMe)
				{
					byte small = playerID.SmallID;
					string name = GetName(small);
					_playersPage.CreateFunction("TP vers " + name, new Color(0.3f, 1f, 0.6f), (Action)delegate
					{
						TpTo(small);
					});
					num++;
				}
			}
			if (num == 0)
			{
				_playersPage.CreateFunction("Aucun joueur distant", Color.gray, (Action)delegate
				{
				});
			}
		}

		private static string GetName(byte smallId)
		{
			NetworkPlayer val = default(NetworkPlayer);
			if (NetworkPlayerManager.TryGetPlayer(smallId, ref val) && val != null)
			{
				return val.Username ?? ("Joueur " + smallId);
			}
			return "Joueur " + smallId;
		}

		private static void TpTo(byte smallId)
		{
			//IL_004f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			NetworkPlayer val = default(NetworkPlayer);
			if (!NetworkPlayerManager.TryGetPlayer(smallId, ref val) || val == null)
			{
				return;
			}
			RigRefs rigRefs = val.RigRefs;
			if (rigRefs != null && rigRefs.IsValid && !((Object)(object)rigRefs.RigManager == (Object)null))
			{
				PhysicsRig physicsRig = Player.PhysicsRig;
				if (!((Object)(object)physicsRig == (Object)null))
				{
					Vector3 position = ((Component)rigRefs.RigManager.physicsRig).transform.position;
					((Component)physicsRig).transform.position = position + Vector3.up * 0.1f + Vector3.right * 0.5f;
				}
			}
		}
	}
	internal static class Managers
	{
		public static readonly GodModeManager God = new GodModeManager();

		public static readonly FlyManager Fly = new FlyManager();

		public static readonly SpeedManager Speed = new SpeedManager();

		public static readonly GhostManager Ghost = new GhostManager();

		public static readonly TelekinesisManager TK = new TelekinesisManager();

		public static readonly InvisibilityManager Invis = new InvisibilityManager();

		public static readonly EspManager Esp = new EspManager();

		public static readonly AntiGrabManager AntiGrab = new AntiGrabManager();

		public static readonly OneShotManager OneShot = new OneShotManager();

		public static readonly TeleportManager Tp = new TeleportManager();

		public static readonly WallClimbManager Climb = new WallClimbManager();

		public static readonly FreezeManager Freeze = new FreezeManager();

		public static readonly JumpManager Jump = new JumpManager();

		public static readonly GunManager Guns = new GunManager();

		public static void ResetAll()
		{
			Fly.Reset();
			Ghost.Reset();
			TK.Reset();
			Esp.Reset();
			Climb.Reset();
		}
	}
	internal class GodModeManager
	{
		public void Tick()
		{
			RigManager rigManager = Player.RigManager;
			if ((Object)(object)rigManager == (Object)null || (Object)(object)rigManager.health == (Object)null)
			{
				return;
			}
			Health health = rigManager.health;
			if (PowerMenuMod.Godmode)
			{
				health.curr_Health = health.max_Health;
			}
			else if (PowerMenuMod.SemiGodmode)
			{
				float num = health.max_Health * PowerMenuMod.SemiHpFloor;
				if (health.curr_Health < num)
				{
					health.curr_Health = health.max_Health * 0.6f;
				}
			}
		}
	}
	internal class SpeedManager
	{
		public void Tick()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_008e: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			Transform head = Player.Head;
			if (!((Object)(object)physicsRig == (Object)null) && !((Object)(object)head == (Object)null) && !((Object)(object)Player.LeftController == (Object)null))
			{
				Vector2 thumbstickAxis = Player.LeftController._thumbstickAxis;
				if (!(((Vector2)(ref thumbstickAxis)).sqrMagnitude < 0.01f))
				{
					Vector3 val = Vector3.ProjectOnPlane(head.forward, Vector3.up);
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					val = Vector3.Cross(Vector3.up, normalized);
					Vector3 val2 = ((Vector3)(ref val)).normalized * -1f;
					Vector3 val3 = normalized * thumbstickAxis.y + val2 * thumbstickAxis.x;
					float num = Mathf.Max(0f, PowerMenuMod.SpeedMult - 1f);
					Transform transform = ((Component)physicsRig).transform;
					transform.position += val3 * num * 2.5f * Time.deltaTime;
				}
			}
		}
	}
	internal class FlyManager
	{
		private readonly List<Rigidbody> noGrav = new List<Rigidbody>();

		public void Tick()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			Transform head = Player.Head;
			if ((Object)(object)physicsRig == (Object)null || (Object)(object)head == (Object)null)
			{
				return;
			}
			if (noGrav.Count == 0)
			{
				foreach (Rigidbody componentsInChild in ((Component)physicsRig).GetComponentsInChildren<Rigidbody>())
				{
					if ((Object)(object)componentsInChild != (Object)null && componentsInChild.useGravity)
					{
						componentsInChild.useGravity = false;
						noGrav.Add(componentsInChild);
					}
				}
			}
			Vector2 val = (((Object)(object)Player.LeftController != (Object)null) ? Player.LeftController._thumbstickAxis : Vector2.zero);
			Vector2 val2 = (((Object)(object)Player.RightController != (Object)null) ? Player.RightController._thumbstickAxis : Vector2.zero);
			Vector3 val3 = Vector3.ProjectOnPlane(head.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			val3 = Vector3.Cross(Vector3.up, normalized);
			Vector3 val4 = ((Vector3)(ref val3)).normalized * -1f;
			Vector3 val5 = normalized * val.y + val4 * val.x + Vector3.up * val2.y;
			Transform transform = ((Component)physicsRig).transform;
			transform.position += val5 * PowerMenuMod.FlySpeed * Time.deltaTime;
		}

		public void Reset()
		{
			foreach (Rigidbody item in noGrav)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.useGravity = true;
				}
			}
			noGrav.Clear();
		}
	}
	internal class GhostManager
	{
		private readonly List<Collider> disabled = new List<Collider>();

		public void Tick()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			Transform head = Player.Head;
			if ((Object)(object)physicsRig == (Object)null || (Object)(object)head == (Object)null)
			{
				return;
			}
			if (disabled.Count == 0)
			{
				foreach (Collider componentsInChild in ((Component)physicsRig).GetComponentsInChildren<Collider>())
				{
					if ((Object)(object)componentsInChild != (Object)null && componentsInChild.enabled)
					{
						componentsInChild.enabled = false;
						disabled.Add(componentsInChild);
					}
				}
			}
			Vector2 val = (((Object)(object)Player.LeftController != (Object)null) ? Player.LeftController._thumbstickAxis : Vector2.zero);
			Vector2 val2 = (((Object)(object)Player.RightController != (Object)null) ? Player.RightController._thumbstickAxis : Vector2.zero);
			Vector3 val3 = head.forward * val.y + head.right * val.x + Vector3.up * val2.y;
			Transform transform = ((Component)physicsRig).transform;
			transform.position += val3 * PowerMenuMod.GhostSpeed * Time.deltaTime;
		}

		public void Reset()
		{
			foreach (Collider item in disabled)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.enabled = true;
				}
			}
			disabled.Clear();
		}
	}
	internal class TelekinesisManager
	{
		private Rigidbody holding;

		public void Tick()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			BaseController rightController = Player.RightController;
			Transform head = Player.Head;
			if ((Object)(object)rightController == (Object)null || (Object)(object)head == (Object)null)
			{
				return;
			}
			if (rightController._primaryInteractionButton)
			{
				RaycastHit val = default(RaycastHit);
				if ((Object)(object)holding == (Object)null && Physics.Raycast(head.position, head.forward, ref val, PowerMenuMod.TKRange))
				{
					holding = ((RaycastHit)(ref val)).rigidbody;
				}
				if ((Object)(object)holding != (Object)null)
				{
					Vector3 val2 = head.position + head.forward * 1.2f - holding.position;
					holding.useGravity = false;
					holding.velocity = val2 * PowerMenuMod.TKPullForce * 0.1f;
				}
			}
			else if ((Object)(object)holding != (Object)null)
			{
				holding.useGravity = true;
				Rigidbody obj = holding;
				obj.velocity += head.forward * PowerMenuMod.TKPullForce * 0.5f;
				holding = null;
			}
		}

		public void Reset()
		{
			if ((Object)(object)holding != (Object)null)
			{
				holding.useGravity = true;
				holding = null;
			}
		}
	}
	internal class InvisibilityManager
	{
		public void Tick()
		{
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.behaviour == (Object)null))
				{
					try
					{
						item.behaviour.mentalState = (MentalState)0;
					}
					catch
					{
					}
				}
			}
		}
	}
	internal class EspManager
	{
		private static readonly Dictionary<int, GameObject> markers = new Dictionary<int, GameObject>();

		public void Tick()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			Transform head = Player.Head;
			if ((Object)(object)head == (Object)null)
			{
				return;
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)item).GetInstanceID();
				if (Vector3.Distance(head.position, ((Component)item).transform.position) > PowerMenuMod.ESPMaxDist)
				{
					continue;
				}
				hashSet.Add(instanceID);
				if (!markers.TryGetValue(instanceID, out var value) || (Object)(object)value == (Object)null)
				{
					value = GameObject.CreatePrimitive((PrimitiveType)3);
					Object.Destroy((Object)(object)value.GetComponent<Collider>());
					Renderer component = value.GetComponent<Renderer>();
					Shader val = Shader.Find("Unlit/Color");
					if ((Object)(object)val != (Object)null)
					{
						component.material.shader = val;
					}
					component.material.color = new Color(1f, 0.2f, 0.2f, 1f);
					component.material.renderQueue = 5000;
					value.transform.localScale = new Vector3(0.4f, 1.8f, 0.4f);
					markers[instanceID] = value;
				}
				value.transform.position = ((Component)item).transform.position + Vector3.up * 0.9f;
				value.transform.LookAt(head.position);
			}
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, GameObject> marker in markers)
			{
				if (!hashSet.Contains(marker.Key))
				{
					if ((Object)(object)marker.Value != (Object)null)
					{
						Object.Destroy((Object)(object)marker.Value);
					}
					list.Add(marker.Key);
				}
			}
			foreach (int item2 in list)
			{
				markers.Remove(item2);
			}
		}

		public void Reset()
		{
			foreach (KeyValuePair<int, GameObject> marker in markers)
			{
				if ((Object)(object)marker.Value != (Object)null)
				{
					Object.Destroy((Object)(object)marker.Value);
				}
			}
			markers.Clear();
		}
	}
	internal class AntiGrabManager
	{
		public void Tick()
		{
			PhysicsRig physicsRig = Player.PhysicsRig;
			if ((Object)(object)physicsRig == (Object)null)
			{
				return;
			}
			foreach (Joint componentsInChild in ((Component)physicsRig).GetComponentsInChildren<Joint>())
			{
				if (!((Object)(object)componentsInChild == (Object)null) && !((Object)(object)componentsInChild.connectedBody == (Object)null) && (Object)(object)((Component)componentsInChild.connectedBody).GetComponentInParent<AIBrain>() != (Object)null)
				{
					Object.Destroy((Object)(object)componentsInChild);
				}
			}
		}
	}
	internal class OneShotManager
	{
		public void Tick()
		{
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.behaviour == (Object)null)
				{
					continue;
				}
				SubBehaviourHealth health = item.behaviour.health;
				if (health == null)
				{
					continue;
				}
				try
				{
					if (!item.isDead && health.cur_hp < health.maxHitPoints)
					{
						health.Kill();
					}
				}
				catch
				{
				}
			}
		}
	}
	internal class TeleportManager
	{
		public void ToLookAt()
		{
			//IL_0020: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			Transform head = Player.Head;
			if (!((Object)(object)physicsRig == (Object)null) && !((Object)(object)head == (Object)null))
			{
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(head.position, head.forward, ref val, PowerMenuMod.TPRange))
				{
					((Component)physicsRig).transform.position = ((RaycastHit)(ref val)).point + Vector3.up * 0.2f;
				}
				else
				{
					((Component)physicsRig).transform.position = head.position + head.forward * PowerMenuMod.TPRange * 0.5f;
				}
			}
		}

		public void ToNearest()
		{
			ToBrain(nearest: true);
		}

		public void ToFarthest()
		{
			ToBrain(nearest: false);
		}

		private void ToBrain(bool nearest)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			Transform head = Player.Head;
			if ((Object)(object)physicsRig == (Object)null || (Object)(object)head == (Object)null)
			{
				return;
			}
			AIBrain val = null;
			float num = (nearest ? float.MaxValue : 0f);
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if (!((Object)(object)item == (Object)null))
				{
					float num2 = Vector3.Distance(head.position, ((Component)item).transform.position);
					if (nearest ? (num2 < num) : (num2 > num))
					{
						num = num2;
						val = item;
					}
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = head.position - ((Component)val).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				((Component)physicsRig).transform.position = ((Component)val).transform.position + normalized * 1.5f + Vector3.up * 0.1f;
			}
		}
	}
	internal class WallClimbManager
	{
		private Vector3? leftAnchor;

		private Vector3? rightAnchor;

		private static readonly Collider[] overlapBuf = (Collider[])(object)new Collider[4];

		public void Tick()
		{
			PhysicsRig physicsRig = Player.PhysicsRig;
			if (!((Object)(object)physicsRig == (Object)null))
			{
				if ((Object)(object)Player.LeftHand != (Object)null && (Object)(object)Player.LeftController != (Object)null)
				{
					HandleHand(physicsRig, ((Component)Player.LeftHand).transform, Player.LeftController._solvedGrip, ref leftAnchor);
				}
				if ((Object)(object)Player.RightHand != (Object)null && (Object)(object)Player.RightController != (Object)null)
				{
					HandleHand(physicsRig, ((Component)Player.RightHand).transform, Player.RightController._solvedGrip, ref rightAnchor);
				}
			}
		}

		private void HandleHand(PhysicsRig rig, Transform hand, float grip, ref Vector3? anchor)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hand == (Object)null)
			{
				anchor = null;
			}
			else if (grip > 0.6f)
			{
				if (!anchor.HasValue)
				{
					int num = Physics.OverlapSphereNonAlloc(hand.position, 0.22f, Il2CppReferenceArray<Collider>.op_Implicit(overlapBuf));
					bool flag = false;
					for (int i = 0; i < num; i++)
					{
						Collider val = overlapBuf[i];
						if (!((Object)(object)val == (Object)null) && !((Component)val).transform.IsChildOf(((Component)rig).transform))
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						return;
					}
					anchor = hand.position;
				}
				Transform transform = ((Component)rig).transform;
				transform.position += anchor.Value - hand.position;
			}
			else
			{
				anchor = null;
			}
		}

		public void Reset()
		{
			leftAnchor = null;
			rightAnchor = null;
		}
	}
	internal class FreezeManager
	{
		public void Tick()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.behaviour == (Object)null)
				{
					continue;
				}
				try
				{
					item.behaviour.mentalState = (MentalState)0;
					foreach (Rigidbody componentsInChild in ((Component)item).GetComponentsInChildren<Rigidbody>())
					{
						if (!((Object)(object)componentsInChild == (Object)null))
						{
							componentsInChild.velocity = Vector3.zero;
							componentsInChild.angularVelocity = Vector3.zero;
							componentsInChild.isKinematic = true;
						}
					}
				}
				catch
				{
				}
			}
		}

		public void KillAll()
		{
			foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.behaviour == (Object)null)
				{
					continue;
				}
				try
				{
					SubBehaviourHealth health = item.behaviour.health;
					if (health != null)
					{
						health.Kill();
					}
				}
				catch
				{
				}
			}
		}
	}
	internal class JumpManager
	{
		public void Jump()
		{
			//IL_0017: 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_0026: 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)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			PhysicsRig physicsRig = Player.PhysicsRig;
			if ((Object)(object)physicsRig == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)physicsRig).transform;
			transform.position += Vector3.up * PowerMenuMod.JumpHeight;
			foreach (Rigidbody componentsInChild in ((Component)physicsRig).GetComponentsInChildren<Rigidbody>())
			{
				if ((Object)(object)componentsInChild != (Object)null)
				{
					componentsInChild.velocity = new Vector3(componentsInChild.velocity.x, 0f, componentsInChild.velocity.z);
				}
			}
		}
	}
	internal class GunManager
	{
		public void Tick()
		{
			foreach (Gun item in Object.FindObjectsOfType<Gun>())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				try
				{
					if (item.MagazineState != null)
					{
						item.MagazineState.Refill();
					}
					if ((Object)(object)item.chamberedCartridge == (Object)null)
					{
						item.chamberedCartridge = item.defaultCartridge;
					}
					item.hasFiredOnce = false;
					if (PowerMenuMod.GunMode)
					{
						item.fireMode = (FireMode)2;
						item.roundsPerMinute = PowerMenuMod.GunRPM;
						item.muzzleVelocity = Mathf.Max(item.muzzleVelocity, 800f);
					}
					else if (PowerMenuMod.SemiGunMode)
					{
						item.fireMode = (FireMode)1;
						item.muzzleVelocity = Mathf.Max(item.muzzleVelocity, 500f);
					}
				}
				catch
				{
				}
			}
		}
	}
	public static class BuildInfo
	{
		public const string Name = "PowerMenu";

		public const string Description = "Menu de pouvoirs pour BONELAB";

		public const string Author = "You";

		public const string Company = null;

		public const string Version = "2.0.0";
	}
	public class PowerMenuMod : MelonMod
	{
		public static bool Godmode;

		public static bool SemiGodmode;

		public static bool Fly;

		public static bool SpeedHack;

		public static bool Invisible;

		public static bool Telekinesis;

		public static bool Ghost;

		public static bool ESP;

		public static bool AntiGrab;

		public static bool OneShot;

		public static bool WallClimb;

		public static bool FreezeNPCs;

		public static bool GunMode;

		public static bool SemiGunMode;

		public static float TimeScale = 1f;

		public static float JumpHeight = 5f;

		public static float SpeedMult = 2.5f;

		public static float FlySpeed = 6f;

		public static float TKRange = 25f;

		public static float TKPullForce = 20f;

		public static float GhostSpeed = 4f;

		public static float ESPMaxDist = 150f;

		public static float SemiHpFloor = 0.3f;

		public static float TPRange = 100f;

		public static float GunRPM = 1200f;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("PowerMenu v2.0.0 loaded.");
			BuildMenu();
			Hooking.OnLevelLoaded += delegate
			{
				Managers.ResetAll();
			};
		}

		public override void OnUpdate()
		{
			if (!((Object)(object)Player.PhysicsRig == (Object)null))
			{
				if (Godmode || SemiGodmode)
				{
					Managers.God.Tick();
				}
				if (Fly)
				{
					Managers.Fly.Tick();
				}
				if (SpeedHack)
				{
					Managers.Speed.Tick();
				}
				if (Ghost)
				{
					Managers.Ghost.Tick();
				}
				if (Telekinesis)
				{
					Managers.TK.Tick();
				}
				if (Invisible)
				{
					Managers.Invis.Tick();
				}
				if (ESP)
				{
					Managers.Esp.Tick();
				}
				if (AntiGrab)
				{
					Managers.AntiGrab.Tick();
				}
				if (OneShot)
				{
					Managers.OneShot.Tick();
				}
				if (WallClimb)
				{
					Managers.Climb.Tick();
				}
				else
				{
					Managers.Climb.Reset();
				}
				if (FreezeNPCs)
				{
					Managers.Freeze.Tick();
				}
				if (GunMode || SemiGunMode)
				{
					Managers.Guns.Tick();
				}
				Time.timeScale = Mathf.Clamp(TimeScale, 0.1f, 3f);
			}
		}

		private void BuildMenu()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_082d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0892: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0919: Unknown result type (might be due to invalid IL or missing references)
			//IL_093a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_097d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			Page val = Page.Root.CreatePage("PowerMenu", new Color(1f, 0.35f, 0.75f), 0, true);
			Page obj = val.CreatePage("Survie", new Color(1f, 0.3f, 0.3f), 0, true);
			obj.CreateBool("Godmode", Color.red, Godmode, (Action<bool>)delegate(bool v)
			{
				Godmode = v;
				if (v)
				{
					SemiGodmode = false;
				}
			});
			obj.CreateBool("Semi-Godmode", new Color(1f, 0.55f, 0f), SemiGodmode, (Action<bool>)delegate(bool v)
			{
				SemiGodmode = v;
				if (v)
				{
					Godmode = false;
				}
			});
			obj.CreateBool("Anti-Grab", new Color(0.9f, 0.9f, 0.3f), AntiGrab, (Action<bool>)delegate(bool v)
			{
				AntiGrab = v;
			});
			obj.CreateFloat("Semi - seuil %", new Color(1f, 0.55f, 0f), SemiHpFloor, 0.05f, 0.05f, 0.95f, (Action<float>)delegate(float v)
			{
				SemiHpFloor = v;
			});
			Page obj2 = val.CreatePage("Attaque", new Color(1f, 0.1f, 0.1f), 0, true);
			obj2.CreateBool("Gun Mode (auto + RPM max)", Color.red, GunMode, (Action<bool>)delegate(bool v)
			{
				GunMode = v;
				if (v)
				{
					SemiGunMode = false;
				}
			});
			obj2.CreateBool("Semi-Gun Mode (semi + boost)", new Color(1f, 0.55f, 0f), SemiGunMode, (Action<bool>)delegate(bool v)
			{
				SemiGunMode = v;
				if (v)
				{
					GunMode = false;
				}
			});
			obj2.CreateBool("1 patate 1 mort", Color.red, OneShot, (Action<bool>)delegate(bool v)
			{
				OneShot = v;
			});
			obj2.CreateBool("Freeze NPCs", new Color(0.3f, 0.6f, 1f), FreezeNPCs, (Action<bool>)delegate(bool v)
			{
				FreezeNPCs = v;
			});
			obj2.CreateFloat("Gun RPM", Color.red, GunRPM, 100f, 200f, 3000f, (Action<float>)delegate(float v)
			{
				GunRPM = v;
			});
			obj2.CreateFunction("\ud83d\udc80 TUER TOUS LES NPCs", Color.red, (Action)delegate
			{
				Managers.Freeze.KillAll();
			});
			Page obj3 = val.CreatePage("Mouvement", new Color(0.3f, 0.8f, 1f), 0, true);
			obj3.CreateBool("Vol", new Color(0.4f, 0.9f, 1f), Fly, (Action<bool>)delegate(bool v)
			{
				Fly = v;
			});
			obj3.CreateBool("Speed Hack", new Color(1f, 1f, 0.3f), SpeedHack, (Action<bool>)delegate(bool v)
			{
				SpeedHack = v;
			});
			obj3.CreateBool("Ghost / Noclip", new Color(0.75f, 0.75f, 1f), Ghost, (Action<bool>)delegate(bool v)
			{
				Ghost = v;
			});
			obj3.CreateBool("Wall Climb (grip)", new Color(0.8f, 0.5f, 0.2f), WallClimb, (Action<bool>)delegate(bool v)
			{
				WallClimb = v;
			});
			obj3.CreateFunction("⬆ Super Jump", new Color(0.3f, 1f, 0.6f), (Action)delegate
			{
				Managers.Jump.Jump();
			});
			obj3.CreateFloat("Jump - hauteur", new Color(0.3f, 1f, 0.6f), JumpHeight, 1f, 1f, 20f, (Action<float>)delegate(float v)
			{
				JumpHeight = v;
			});
			obj3.CreateFloat("Speed x", new Color(1f, 1f, 0.3f), SpeedMult, 0.25f, 1f, 10f, (Action<float>)delegate(float v)
			{
				SpeedMult = v;
			});
			obj3.CreateFloat("Vol - vitesse", new Color(0.4f, 0.9f, 1f), FlySpeed, 1f, 1f, 30f, (Action<float>)delegate(float v)
			{
				FlySpeed = v;
			});
			obj3.CreateFloat("Ghost - vitesse", new Color(0.75f, 0.75f, 1f), GhostSpeed, 1f, 1f, 20f, (Action<float>)delegate(float v)
			{
				GhostSpeed = v;
			});
			Page obj4 = val.CreatePage("Téléport", new Color(0.2f, 1f, 1f), 0, true);
			obj4.CreateFunction("TP vers cible visée", new Color(0.2f, 1f, 1f), (Action)delegate
			{
				Managers.Tp.ToLookAt();
			});
			obj4.CreateFunction("TP vers NPC proche", new Color(0.2f, 1f, 1f), (Action)delegate
			{
				Managers.Tp.ToNearest();
			});
			obj4.CreateFunction("TP vers NPC loin", new Color(0.2f, 1f, 1f), (Action)delegate
			{
				Managers.Tp.ToFarthest();
			});
			obj4.CreateFloat("TP - portée visée", new Color(0.2f, 1f, 1f), TPRange, 10f, 10f, 500f, (Action<float>)delegate(float v)
			{
				TPRange = v;
			});
			try
			{
				FusionIntegration.BuildFusionPage(val);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("Fusion non détecté: " + ex.Message);
				val.CreateFunction("Fusion non détecté", Color.gray, (Action)delegate
				{
				});
			}
			Page obj5 = val.CreatePage("Pouvoirs", new Color(0.7f, 0.4f, 1f), 0, true);
			obj5.CreateBool("Invisibilité", new Color(0.6f, 0.6f, 0.6f), Invisible, (Action<bool>)delegate(bool v)
			{
				Invisible = v;
			});
			obj5.CreateBool("Télékinésie", new Color(0.7f, 0.4f, 1f), Telekinesis, (Action<bool>)delegate(bool v)
			{
				Telekinesis = v;
			});
			obj5.CreateFloat("TK - portée", new Color(0.7f, 0.4f, 1f), TKRange, 5f, 5f, 100f, (Action<float>)delegate(float v)
			{
				TKRange = v;
			});
			obj5.CreateFloat("TK - force", new Color(0.7f, 0.4f, 1f), TKPullForce, 5f, 5f, 200f, (Action<float>)delegate(float v)
			{
				TKPullForce = v;
			});
			Page obj6 = val.CreatePage("Vision", new Color(0.3f, 1f, 0.5f), 0, true);
			obj6.CreateBool("ESP (voir à travers les murs)", Color.green, ESP, (Action<bool>)delegate(bool v)
			{
				ESP = v;
			});
			obj6.CreateFloat("ESP - distance max", Color.green, ESPMaxDist, 10f, 20f, 500f, (Action<float>)delegate(float v)
			{
				ESPMaxDist = v;
			});
			Page obj7 = val.CreatePage("Monde", new Color(1f, 0.6f, 0.9f), 0, true);
			obj7.CreateFloat("Time Scale (vitesse temps)", new Color(1f, 0.6f, 0.9f), TimeScale, 0.1f, 0.1f, 3f, (Action<float>)delegate(float v)
			{
				TimeScale = v;
			});
			obj7.CreateFunction("↺ Reset Time Scale", Color.white, (Action)delegate
			{
				TimeScale = 1f;
			});
			val.CreateFunction("TOUT COUPER", Color.white, (Action)DisableEverything);
		}

		private static void DisableEverything()
		{
			Godmode = (SemiGodmode = (Fly = (SpeedHack = (Invisible = (Telekinesis = (Ghost = (ESP = (AntiGrab = (OneShot = (WallClimb = (FreezeNPCs = (GunMode = (SemiGunMode = false)))))))))))));
			TimeScale = 1f;
			Managers.ResetAll();
		}
	}
}