Decompiled source of LabUtils v0.3.2

Mods/LabUtils.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Bonelab.SaveData;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.SaveData;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LabFusion.Entities;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.Representation;
using LabFusion.SDK.Gamemodes;
using LabUtils;
using LabUtils.Developer;
using LabUtils.Developer.Extensions;
using LabUtils.Developer.Patches;
using LabUtils.Utils.All;
using LabUtils.Utils.AssetWarehouseUtil;
using LabUtils.Utils.InfiniteAmmoUtil;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "LabUtils", "1.0.0", "cheesy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib", "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LabUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1a653c9341a29dbbf5ddfa5ac8a18a6b7722f0e4")]
[assembly: AssemblyProduct("LabUtils")]
[assembly: AssemblyTitle("LabUtils")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.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;
		}
	}
	[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;
		}
	}
}
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct ColorPlus
{
	private static Color[] colors = (Color[])(object)new Color[5]
	{
		GetColor("#F54842"),
		GetColor("#ff8c00"),
		GetColor("#61ff61"),
		GetColor("#5797ff"),
		GetColor("#bf00ff")
	};

	private static byte _nextId = 0;

	private static byte nextId
	{
		get
		{
			if (_nextId >= colors.Length)
			{
				_nextId = 0;
			}
			return _nextId++;
		}
	}

	public static Color GetColor(string hexcode)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		if (ColorUtility.TryParseHtmlString(hexcode, ref result))
		{
			return result;
		}
		return Color.white;
	}

	public static Color GetNextColor()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return colors[nextId];
	}
}
namespace LabUtils
{
	public class Core : MelonMod
	{
		public static MelonPreferences_Category Preferences;

		public static Core Instance;

		private float autoSaveTimer;

		public override void OnInitializeMelon()
		{
			Preferences = MelonPreferences.CreateCategory("Lab-Utils");
			((MelonBase)this).LoggerInstance.Msg("Loaded LabUtils.");
			((MelonBase)this).HarmonyInstance.PatchAll();
			Instance = this;
			UICore.Init();
			Utility.Init();
		}

		public override void OnLateUpdate()
		{
			autoSaveTimer += Time.deltaTime;
			if (autoSaveTimer > 120f)
			{
				autoSaveTimer = 0f;
				Save();
			}
		}

		public static void Save()
		{
			Preferences.SaveToFile(true);
			MelonPreferences.Save();
		}

		public override void OnApplicationQuit()
		{
			Save();
		}
	}
}
namespace LabUtils.Utils.InfiniteAmmoUtil
{
	public class AmmoUtility : Utility
	{
		public static Page Page;

		public static MelonPreferences_Entry<bool> UnlimitedAmmo { get; set; } = Core.Preferences.CreateEntry<bool>("UnlimitedAmmo", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<bool> UnlimitedMagazines { get; set; } = Core.Preferences.CreateEntry<bool>("UnlimitedMagazines", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<bool> UnlimitedShells { get; set; } = Core.Preferences.CreateEntry<bool>("UnlimitedShells", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<bool> GripMagazineRefill { get; set; } = Core.Preferences.CreateEntry<bool>("GripMagazineRefill", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		protected override void OnLoad()
		{
			//IL_001f: 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_0066: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Random.Range(0, 100) > 90) ? "AmmoLab" : "Ammo Utility");
			Page = UICore.UtilitiesPage.CreatePage(text, ColorPlus.GetNextColor(), 10, true);
			Page.CreateBool("Unlimited Ammo", ColorPlus.GetNextColor(), UnlimitedAmmo.Value, (Action<bool>)VeryHappyAmmoMode);
			Page.CreateBool("Unlimited Magazines", ColorPlus.GetNextColor(), UnlimitedMagazines.Value, (Action<bool>)delegate(bool a)
			{
				UnlimitedMagazines.Value = a;
			});
			Page.CreateBool("Unlimited Shells/Slugs/Cartridges", ColorPlus.GetNextColor(), UnlimitedShells.Value, (Action<bool>)delegate(bool a)
			{
				UnlimitedShells.Value = a;
			});
			Page.CreateBool("Grip Magazine Refill", ColorPlus.GetNextColor(), GripMagazineRefill.Value, (Action<bool>)delegate(bool a)
			{
				GripMagazineRefill.Value = a;
			});
		}

		private void VeryHappyAmmoMode(bool obj)
		{
			UnlimitedAmmo.Value = obj;
			string[] groups = AmmoPatches.groups;
			foreach (string text in groups)
			{
				if (AmmoInventory.Instance.GetCartridgeCount(text) < 1)
				{
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.lightAmmoGroup, 2000);
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.mediumAmmoGroup, 2000);
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.heavyAmmoGroup, 2000);
				}
			}
			DevUtils.Notify(obj ? "Very Happy Ammo Added" : "Very Happy Ammo Removed", 1f);
		}
	}
}
namespace LabUtils.Utils.AssetWarehouseUtil
{
	public class AssetWarehouseUtility : Utility
	{
		public static Page Page;

		public static Page ResultsPage;

		public static Page SelectedPage;

		public static Page FavoritesPage;

		public static MelonPreferences_Entry<bool> HideRedacted { get; set; } = Core.Preferences.CreateEntry<bool>("HideRedacted", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<bool> HideUnlockable { get; set; } = Core.Preferences.CreateEntry<bool>("HideUnlockable", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<bool> ExcludeTags { get; set; } = Core.Preferences.CreateEntry<bool>("ExcTags", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<string[]> FavoriteCrates { get; set; } = Core.Preferences.CreateEntry<string[]>("Favorites", new string[0], (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		protected override void OnLoad()
		{
			//IL_000a: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			Page = UICore.UtilitiesPage.CreatePage("Asset Warehouse", ColorPlus.GetNextColor(), 10, true);
			Page obj = Page.CreatePage("Settings", ColorPlus.GetNextColor(), 10, true);
			obj.CreateBool("Hide Redacted", ColorPlus.GetNextColor(), HideRedacted.Value, (Action<bool>)delegate(bool a)
			{
				HideRedacted.Value = a;
			});
			obj.CreateBool("Hide Unlockable", ColorPlus.GetNextColor(), HideUnlockable.Value, (Action<bool>)delegate(bool a)
			{
				HideUnlockable.Value = a;
			});
			obj.CreateBool("Exclude Tags", ColorPlus.GetNextColor(), ExcludeTags.Value, (Action<bool>)delegate(bool a)
			{
				ExcludeTags.Value = a;
			});
			Page.CreateString("Search Query", ColorPlus.GetNextColor(), "Ford", (Action<string>)OnSearched);
			ResultsPage = Page.CreatePage("Results", ColorPlus.GetNextColor(), 10, true);
			SelectedPage = Page.CreatePage("Selected Crate", ColorPlus.GetNextColor(), 10, true);
			FavoritesPage = Page.CreatePage("Favorite Crates", ColorPlus.GetNextColor(), 10, true);
			Hooking.OnWarehouseReady += Hooking_OnWarehouseReady;
		}

		private void Hooking_OnWarehouseReady()
		{
			RefreshFavoritesPage();
		}

		private static void RefreshFavoritesPage()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Core.Save();
			FavoritesPage.RemoveAll();
			string[] value = FavoriteCrates.Value;
			Crate crate = default(Crate);
			foreach (string text in value)
			{
				if (AssetWarehouse.Instance.TryGetCrate(new Barcode(text), ref crate))
				{
					CrateRep rep = CrateRep.CreateCrateRep(crate);
					((Element)FavoritesPage.CreateFunction(rep.title, ColorPlus.GetNextColor(), (Action)delegate
					{
						OnClickCrate(rep);
					})).SetTooltip(rep.ToString());
				}
			}
		}

		private static void OnSearched(string value)
		{
			RetrievingTask.RetrieveResults(value, ReceiveResults);
		}

		internal static void ReceiveResults(CrateRep[] reps)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			ResultsPage.RemoveAll();
			for (int i = 0; i < reps.Length; i++)
			{
				CrateRep rep = reps[i];
				((Element)ResultsPage.CreateFunction(rep.title, ColorPlus.GetNextColor(), (Action)delegate
				{
					OnClickCrate(rep);
				})).SetTooltip(rep.ToString());
			}
			DevUtils.Notify("Retrieved Results - Asset Warehouse");
			RetrievingTask.isRunning = false;
		}

		private static void OnClickCrate(CrateRep rep)
		{
			//IL_0030: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			SelectedPage.RemoveAll();
			((Element)SelectedPage.CreateFunction(rep.title ?? "", ColorPlus.GetNextColor(), (Action)null)).SetTooltip(rep.ToString());
			switch (rep.type)
			{
			case CrateType.Level:
				SelectedPage.CreateFunction("Load Level", ColorPlus.GetNextColor(), (Action)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Expected O, but got Unknown
					SceneStreamer.Load(new Barcode(rep.barcode), (Barcode)null);
				});
				DevUtils.Notify("Level Loaded");
				break;
			case CrateType.Avatar:
				SelectedPage.CreateFunction("Swap Avatar", ColorPlus.GetNextColor(), (Action)delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Expected O, but got Unknown
					Player.RigManager.SwapAvatarCrate(new Barcode(rep.barcode), false, (Action<bool>)null);
				});
				DevUtils.Notify("Avatar Swapped");
				break;
			case CrateType.Spawnable:
				SelectedPage.CreateFunction("Swap Spawn Gun Crate", ColorPlus.GetNextColor(), (Action)delegate
				{
					SwapSpawnGunCrate(rep.barcode);
				});
				DevUtils.Notify("Spawn Gun Crate Swapped");
				break;
			}
			SelectedPage.CreateFunction("Load Crate Assets into Memory", ColorPlus.GetNextColor(), (Action)delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Crate val = default(Crate);
				if (AssetWarehouse.Instance.TryGetCrate(new Barcode(rep.barcode), ref val))
				{
					((Scannable)val).PreloadAssets();
					DevUtils.Notify("Preloading Crate");
				}
			});
			SelectedPage.CreateFunction("Unlock Crate", ColorPlus.GetNextColor(), (Action)delegate
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				DataManager.ActiveSave.Unlocks.IncrementUnlockForBarcode(new Barcode(rep.barcode));
				DataManager.TrySaveActiveSave((SaveFlags)0);
				DevUtils.Notify("Crate Unlocked");
			});
			SelectedPage.CreateFunction("Lock Crate", ColorPlus.GetNextColor(), (Action)delegate
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				DataManager.ActiveSave.Unlocks.ClearUnlockForBarcode(new Barcode(rep.barcode));
				DataManager.TrySaveActiveSave((SaveFlags)0);
				DevUtils.Notify("Crate Locked");
			});
			SelectedPage.CreateFunction("Favorite Crate", ColorPlus.GetNextColor(), (Action)delegate
			{
				List<string> list2 = FavoriteCrates.Value.ToList();
				if (!list2.Contains(rep.barcode))
				{
					list2.Add(rep.barcode);
				}
				FavoriteCrates.Value = list2.ToArray();
				DevUtils.Notify("Crate Favorited");
				RefreshFavoritesPage();
			});
			SelectedPage.CreateFunction("UnFavorite Crate", ColorPlus.GetNextColor(), (Action)delegate
			{
				List<string> list = FavoriteCrates.Value.ToList();
				if (list.Contains(rep.barcode))
				{
					list.Remove(rep.barcode);
				}
				FavoriteCrates.Value = list.ToArray();
				DevUtils.Notify("Crate removed from Favorites");
				RefreshFavoritesPage();
			});
			DevUtils.Notify("Selected Crate!");
		}

		private static void SwapSpawnGunCrate(string barcode)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			SpawnableCrate val = default(SpawnableCrate);
			if (!AssetWarehouse.Instance.TryGetCrate<SpawnableCrate>(new Barcode(barcode), ref val))
			{
				return;
			}
			foreach (SpawnGun item in Object.FindObjectsOfType<SpawnGun>())
			{
				item._lastSelectedCrate = val;
				item._selectedCrate = val;
			}
		}
	}
	[Serializable]
	public struct CrateRep
	{
		public CrateType type;

		public string pallet_Title;

		public string pallet_Author;

		public string barcode;

		public string title;

		public string description;

		public string[] tags;

		public bool unlockable;

		public bool redacted;

		public override string ToString()
		{
			return $"Title: {title}\nPallet: {pallet_Title}\nAuthor: {pallet_Author}\nDescription: {description}\nUnlockable: {unlockable}\nRedacted: {redacted}\nType: {type.ToString()}\nTags:{tags}";
		}

		public static CrateRep CreateCrateRep(Crate crate)
		{
			CrateRep result = default(CrateRep);
			result.pallet_Title = ((Scannable)crate.Pallet).Title;
			result.barcode = ((Scannable)crate).Barcode.ID;
			result.title = ((Scannable)crate).Title;
			result.description = ((Scannable)crate).Description;
			result.unlockable = ((Scannable)crate).Unlockable;
			result.redacted = ((Scannable)crate).Redacted;
			result.pallet_Author = crate.Pallet.Author;
			result.tags = crate.Tags.ToList<string>().ToArray();
			if (Object.op_Implicit((Object)(object)((Il2CppObjectBase)crate).TryCast<AvatarCrate>()))
			{
				result.type = CrateType.Avatar;
			}
			else if (Object.op_Implicit((Object)(object)((Il2CppObjectBase)crate).TryCast<SpawnableCrate>()))
			{
				result.type = CrateType.Spawnable;
			}
			if (Object.op_Implicit((Object)(object)((Il2CppObjectBase)crate).TryCast<LevelCrate>()))
			{
				result.type = CrateType.Level;
			}
			return result;
		}
	}
	public enum CrateType : byte
	{
		Level,
		Spawnable,
		Avatar
	}
	public static class RetrievingTask
	{
		[CompilerGenerated]
		private sealed class <InvokeOnMainThread>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Action<CrateRep[]> onComplete;

			public CrateRep[] result;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InvokeOnMainThread>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					onComplete(result);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static List<Crate> Crates = new List<Crate>();

		public static bool isRunning;

		private static readonly ReaderWriterLockSlim lockSlim = new ReaderWriterLockSlim();

		public static void RetrieveResults(string query, Action<CrateRep[]> onComplete)
		{
			if (isRunning)
			{
				return;
			}
			isRunning = true;
			bool showRedacted = !AssetWarehouseUtility.HideRedacted.Value;
			bool showUnlockable = !AssetWarehouseUtility.HideUnlockable.Value;
			_ = AssetWarehouseUtility.ExcludeTags.Value;
			List<Crate> foundCrates = new List<Crate>();
			ThreadPool.QueueUserWorkItem(delegate
			{
				lockSlim.EnterReadLock();
				try
				{
					if (string.IsNullOrWhiteSpace(query) || Crates.Count < 1 || !AssetWarehouse.ready)
					{
						onComplete(Array.Empty<CrateRep>());
					}
					else
					{
						foreach (Crate crate in Crates)
						{
							if (((Scannable)crate).Title.Contains(query, StringComparison.InvariantCultureIgnoreCase))
							{
								foundCrates.Add(crate);
							}
							Enumerator<string> enumerator2 = crate.Tags.GetEnumerator();
							while (enumerator2.MoveNext())
							{
								if (enumerator2.Current.Contains(query, StringComparison.InvariantCultureIgnoreCase))
								{
									foundCrates.Add(crate);
								}
							}
						}
						foreach (Crate item in foundCrates.ToList())
						{
							if (!showRedacted && ((Scannable)item).Redacted)
							{
								foundCrates.Remove(item);
							}
							if (!showUnlockable && ((Scannable)item).Unlockable)
							{
								foundCrates.Remove(item);
							}
						}
						CrateRep[] array = new CrateRep[foundCrates.Count];
						int num = 0;
						foreach (Crate item2 in foundCrates)
						{
							CrateRep crateRep = CrateRep.CreateCrateRep(item2);
							array[num] = crateRep;
							num++;
						}
						MelonCoroutines.Start(InvokeOnMainThread(array, onComplete));
					}
				}
				finally
				{
					lockSlim.ExitReadLock();
				}
			});
		}

		[IteratorStateMachine(typeof(<InvokeOnMainThread>d__4))]
		private static IEnumerator InvokeOnMainThread(CrateRep[] result, Action<CrateRep[]> onComplete)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InvokeOnMainThread>d__4(0)
			{
				result = result,
				onComplete = onComplete
			};
		}
	}
}
namespace LabUtils.Utils.All
{
	public class FunUtility : Utility
	{
		private static string[] floats = new string[2] { "_Metallic", "_Smoothness" };

		private const float speed = 3f;

		public static List<Renderer> Renderers = new List<Renderer>();

		public static MelonPreferences_Entry<bool> MidasTouch { get; set; } = Core.Preferences.CreateEntry<bool>("GoldenMidasTouch", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		protected override void OnLoad()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Hooking.OnGripAttached += OnGripAttached;
			((Element)UICore.UtilitiesPage.CreatePage("Fun Utlity", ColorPlus.GetNextColor(), 10, true).CreateBool("Midas (Gold) Touch", ColorPlus.GetNextColor(), MidasTouch.Value, (Action<bool>)delegate(bool a)
			{
				MidasTouch.Value = a;
			})).SetTooltip("Everything you grab is gold");
		}

		private static void Hooking_OnLevelLoaded(LevelInfo obj)
		{
			Renderers.Clear();
		}

		private static void OnGripAttached(Grip grip, Hand hand)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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)
			if (!MidasTouch.Value)
			{
				return;
			}
			List<Renderer> list = ((IEnumerable<Renderer>)((Component)((Component)grip).transform.root).GetComponentsInChildren<Renderer>()).ToArray().ToList();
			list.AddRange(((IEnumerable<Renderer>)((Component)((Component)grip).transform.root).GetComponentsInParent<Renderer>()).ToArray());
			foreach (Renderer item in list)
			{
				foreach (Material item2 in (Il2CppArrayBase<Material>)(object)item.materials)
				{
					Color yellow = Color.yellow;
					item2.color = yellow;
					for (int i = 0; i < floats.Length; i++)
					{
						item2.SetFloat(floats[i], 1f);
					}
					if ((Object)(object)((Component)item).GetComponent<Graphic>() == (Object)null)
					{
						item2.mainTexture = null;
					}
				}
			}
		}
	}
	public class HealthUtility : Utility
	{
		public enum DeathSettings : byte
		{
			Default,
			On,
			Off
		}

		public static Page Page;

		private static bool defaultReloadOnDeath;

		public static MelonPreferences_Entry<bool> GodMode { get; set; } = Core.Preferences.CreateEntry<bool>("IDDQD ", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public static MelonPreferences_Entry<DeathSettings> ReloadOnDeath { get; set; } = Core.Preferences.CreateEntry<DeathSettings>("ReloadOnDeath ", DeathSettings.Default, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		public HealthMode HealthMode
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)Player.RigManager))
				{
					return Player.RigManager.health.healthMode;
				}
				return (HealthMode)1;
			}
			set
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected I4, but got Unknown
				if (Object.op_Implicit((Object)(object)Player.RigManager))
				{
					Player.RigManager.health.SetHealthMode((int)value);
				}
			}
		}

		protected override void OnLoad()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			//IL_0083: 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_00aa: 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)
			Hooking.OnLevelLoaded += Hooking_OnLevelLoaded;
			Page = UICore.UtilitiesPage.CreatePage("Health Utility", ColorPlus.GetNextColor(), 10, true);
			Page.CreateBool("God Mode", ColorPlus.GetNextColor(), GodMode.Value, (Action<bool>)ChangeGodMode);
			Page.CreateFunction("Heal", ColorPlus.GetNextColor(), (Action)Heal);
			Page.CreateFunction("DIE", ColorPlus.GetNextColor(), (Action)Die);
			Page.CreateEnum("Health Mode", ColorPlus.GetNextColor(), (Enum)(object)HealthMode, (Action<Enum>)ChangeHealthMode);
			Page.CreateEnum("Reload Level On Death", ColorPlus.GetNextColor(), (Enum)ReloadOnDeath.Value, (Action<Enum>)ReloadOnDeathMode);
		}

		private void Hooking_OnLevelLoaded(LevelInfo obj)
		{
			Health health = Player.RigManager.health;
			Player_Health val = (Player_Health)(object)((health is Player_Health) ? health : null);
			if (!((Object)(object)val == (Object)null))
			{
				defaultReloadOnDeath = val.reloadLevelOnDeath;
				ReloadOnDeathMode(ReloadOnDeath.Value);
			}
		}

		private void ReloadOnDeathMode(Enum @enum)
		{
			ReloadOnDeath.Value = (DeathSettings)(object)@enum;
			Health health = Player.RigManager.health;
			Player_Health val = (Player_Health)(object)((health is Player_Health) ? health : null);
			if (!((Object)(object)val == (Object)null))
			{
				switch (ReloadOnDeath.Value)
				{
				case DeathSettings.Default:
					val.reloadLevelOnDeath = defaultReloadOnDeath;
					break;
				case DeathSettings.On:
					val.reloadLevelOnDeath = true;
					break;
				case DeathSettings.Off:
					val.reloadLevelOnDeath = false;
					break;
				}
			}
		}

		private void ChangeHealthMode(Enum @enum)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			HealthMode = (HealthMode)(object)@enum;
		}

		private void Die()
		{
			if (Random.Shared.Next(0, 3) > 3)
			{
				DevUtils.Notify("Go tell aunt rhody");
			}
			Player.RigManager.health.curr_Health = 0f;
			Player.RigManager.health.TAKEDAMAGE(65535f);
		}

		private void Heal()
		{
			Player.RigManager.health.SetFullHealth();
		}

		private void ChangeGodMode(bool obj)
		{
			GodMode.Value = obj;
			DevUtils.Notify(obj ? "Degreelessness Mode On" : "Degreelessness Mode Off", 1f);
		}
	}
	public class RagdollUtility : Utility
	{
		public static Page page;

		public static MelonPreferences_Entry<bool> RagdollOnDeath { get; set; } = Core.Preferences.CreateEntry<bool>("RagdollOnDeath", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);


		protected override void OnLoad()
		{
			//IL_000a: 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_0064: 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)
			page = UICore.UtilitiesPage.CreatePage("Ragdoll Utility", ColorPlus.GetNextColor(), 10, true);
			page.CreateBool("Ragdoll On Death", ColorPlus.GetNextColor(), RagdollOnDeath.Value, (Action<bool>)delegate(bool a)
			{
				RagdollOnDeath.Value = a;
			});
			page.CreateFunction("Ragdoll", ColorPlus.GetNextColor(), (Action)Ragdoll);
			page.CreateFunction("Unragdoll", ColorPlus.GetNextColor(), (Action)UnRagdoll);
		}

		public static void Ragdoll()
		{
			Player.PhysicsRig.ShutdownRig();
			Player.PhysicsRig.RagdollRig();
		}

		public static void UnRagdoll()
		{
			Player.PhysicsRig.TurnOnRig();
			Player.PhysicsRig.UnRagdollRig();
		}
	}
}
namespace LabUtils.Utils.All.Developer
{
	public class SceneUtility : Utility
	{
		public struct SceneSetting
		{
			public bool fog;

			public float sunIntensity;

			public Color sunColor;

			public Vector3 gravity;

			public static SceneSetting Create()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: 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_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				float num = 1f;
				Color val = ColorPlus.GetNextColor();
				if (Object.op_Implicit((Object)(object)RenderSettings.sun))
				{
					num = RenderSettings.sun.intensity;
					val = RenderSettings.sun.color;
				}
				SceneSetting result = default(SceneSetting);
				result.fog = RenderSettings.fog;
				result.sunIntensity = num;
				result.sunColor = val;
				result.gravity = Physics.gravity;
				return result;
			}
		}

		public static Page Page;

		public static Page SceneSettings;

		public static Page MarrowEntities;

		public static Page SelectedEntity;

		private static MarrowEntity entity;

		public static SceneSetting sceneSettings = SceneSetting.Create();

		private static bool isListening;

		public static GameObject Forward;

		protected override void OnLoad()
		{
			//IL_000a: 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_0047: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			Page = UICore.UtilitiesPage.CreatePage("Scene Utility", ColorPlus.GetNextColor(), 10, true);
			Page.CreateFunction("Refresh", ColorPlus.GetNextColor(), (Action)Refresh);
			((Element)Page.CreateFunction("Entity Grip Listen", ColorPlus.GetNextColor(), (Action)EntityGripListen)).SetTooltip("Listens for a Grip on any object that has an entity to automatically select them faster!");
			SceneSettings = Page.CreatePage("Scene Settings", ColorPlus.GetNextColor(), 10, true);
			MarrowEntities = Page.CreatePage("Marrow Entities", ColorPlus.GetNextColor(), 10, true);
			SelectedEntity = Page.CreatePage("Selected Entity", ColorPlus.GetNextColor(), 10, true);
			Hooking.OnGripAttached += Hooking_OnGripAttached;
			Hooking.OnLevelLoaded += delegate
			{
				CreateSceneSettings();
			};
		}

		private void CreateSceneSettings()
		{
			//IL_0024: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_016d: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			sceneSettings = SceneSetting.Create();
			SceneSettings.RemoveAll();
			SceneSettings.CreateBool("Fog", ColorPlus.GetNextColor(), sceneSettings.fog, (Action<bool>)delegate(bool a)
			{
				sceneSettings.fog = a;
			});
			if (Object.op_Implicit((Object)(object)RenderSettings.sun))
			{
				SceneSettings.CreateFloat("Sun Intensity", ColorPlus.GetNextColor(), sceneSettings.sunIntensity, 1f, 0f, 65535f, (Action<float>)delegate(float a)
				{
					sceneSettings.sunIntensity = a;
				});
				SceneSettings.CreateString("Sun Color", ColorPlus.GetNextColor(), ColorUtility.ToHtmlStringRGBA(sceneSettings.sunColor), (Action<string>)delegate(string a)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					sceneSettings.sunColor = ColorPlus.GetColor(a);
				});
			}
			Vector3 ogPhysicsGravity = Physics.gravity;
			Page obj = SceneSettings.CreatePage("Gravity", ColorPlus.GetNextColor(), 10, true);
			obj.CreateFloat("x", ColorPlus.GetNextColor(), sceneSettings.gravity.x, 1f, -32768f, 32767f, (Action<float>)delegate(float a)
			{
				sceneSettings.gravity.x = a;
			});
			obj.CreateFloat("y", ColorPlus.GetNextColor(), sceneSettings.gravity.y, 1f, -32768f, 32767f, (Action<float>)delegate(float a)
			{
				sceneSettings.gravity.y = a;
			});
			obj.CreateFloat("z", ColorPlus.GetNextColor(), sceneSettings.gravity.z, 1f, -32768f, 32767f, (Action<float>)delegate(float a)
			{
				sceneSettings.gravity.z = a;
			});
			obj.CreateFunction("Reset Gravity", ColorPlus.GetNextColor(), (Action)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				sceneSettings.gravity = ogPhysicsGravity;
			});
			SceneSettings.CreateFunction("Apply Scene Settings", ColorPlus.GetNextColor(), (Action)ApplySceneSettings);
		}

		private static void ApplySceneSettings()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			RenderSettings.fog = sceneSettings.fog;
			if (Object.op_Implicit((Object)(object)RenderSettings.sun))
			{
				RenderSettings.sun.intensity = sceneSettings.sunIntensity;
				RenderSettings.sun.color = sceneSettings.sunColor;
			}
			DevUtils.Notify("Applied Scene Settings");
			if (!NetworkInfo.HasServer)
			{
				Physics.gravity = sceneSettings.gravity;
			}
		}

		private static void EntityGripListen()
		{
			isListening = !isListening;
			DevUtils.Notify("Entity Grip Listen " + (isListening ? "Started" : "Stopped"));
		}

		private void Hooking_OnGripAttached(Grip grip, Hand hand)
		{
			if (isListening)
			{
				isListening = false;
				MarrowEntity marrowEntity = grip._marrowEntity;
				SelectEntity(marrowEntity);
				DevUtils.Notify("via Grip Listen, Listening Stopped");
			}
		}

		private void Refresh()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			SelectedEntity.RemoveAll();
			MarrowEntities.RemoveAll();
			if (NetworkInfo.HasServer && !FusionExtensions.IsPermissionLevelMatch((PermissionLevel)1))
			{
				return;
			}
			foreach (MarrowEntity entity in Object.FindObjectsOfType<MarrowEntity>())
			{
				MarrowEntities.CreateFunction(((Object)entity).name, ColorPlus.GetNextColor(), (Action)delegate
				{
					SelectEntity(entity);
				});
			}
		}

		private void SelectEntity(MarrowEntity _entity)
		{
			//IL_0031: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkInfo.HasServer && !FusionExtensions.IsPermissionLevelMatch((PermissionLevel)1))
			{
				return;
			}
			entity = _entity;
			SelectedEntity.RemoveAll();
			Page bodiesPage = SelectedEntity.CreatePage("Bodies", ColorPlus.GetNextColor(), 10, true);
			Page val = SelectedEntity.CreatePage("Poolee", ColorPlus.GetNextColor(), 10, true);
			((IEnumerable<MarrowBody>)entity.Bodies).ToList().ForEach(delegate(MarrowBody body)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: 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_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				Page obj = bodiesPage.CreatePage(((Object)body).name, ColorPlus.GetNextColor(), 10, true);
				obj.CreateFloat("Mass", ColorPlus.GetNextColor(), body._rigidbody.mass, 1f, 0.01f, 65535f, (Action<float>)delegate(float a)
				{
					body._rigidbody.mass = a;
				});
				obj.CreateFloat("Drag", ColorPlus.GetNextColor(), body._rigidbody.drag, 1f, 0f, 65535f, (Action<float>)delegate(float a)
				{
					body._rigidbody.drag = a;
				});
				obj.CreateFloat("Angular Drag", ColorPlus.GetNextColor(), body._rigidbody.angularDrag, 1f, 0f, 65535f, (Action<float>)delegate(float a)
				{
					body._rigidbody.angularDrag = a;
				});
				obj.CreateFloat("Max Depenetration Velocity", ColorPlus.GetNextColor(), body._rigidbody.maxDepenetrationVelocity, 1f, 0f, 65535f, (Action<float>)delegate(float a)
				{
					body._rigidbody.maxDepenetrationVelocity = a;
				});
				obj.CreateFloat("Max Angular Velocity", ColorPlus.GetNextColor(), body._rigidbody.maxAngularVelocity, 1f, 0f, 65535f, (Action<float>)delegate(float a)
				{
					body._rigidbody.maxAngularVelocity = a;
				});
				obj.CreateBool("Is Kinematic", ColorPlus.GetNextColor(), body._rigidbody.isKinematic, (Action<bool>)delegate(bool a)
				{
					body._rigidbody.isKinematic = a;
				});
				obj.CreateBool("Use Gravity", ColorPlus.GetNextColor(), body._rigidbody.useGravity, (Action<bool>)delegate(bool a)
				{
					body._rigidbody.useGravity = a;
				});
			});
			Poolee poolee = entity._poolee;
			if (Object.op_Implicit((Object)(object)poolee))
			{
				val.CreateFunction("Despawn", ColorPlus.GetNextColor(), (Action)delegate
				{
					if ((!NetworkInfo.HasServer || FusionExtensions.IsPermissionLevelMatch((PermissionLevel)1)) && !Object.op_Implicit((Object)(object)((Component)entity).GetComponentInParent<RigManager>()) && !Object.op_Implicit((Object)(object)((Component)entity).GetComponentInChildren<RigManager>()) && !Object.op_Implicit((Object)(object)((Component)entity).GetComponentInParent<Rig>()) && !Object.op_Implicit((Object)(object)((Component)entity).GetComponentInChildren<Rig>()))
					{
						poolee.Despawn();
						SelectedEntity.RemoveAll();
					}
				});
			}
			DevUtils.Notify("Selected Entity " + ((Object)entity).name);
		}
	}
}
namespace LabUtils.Utils.Dangerous
{
	public class AchivementUtility : Utility
	{
		public static Dictionary<string, string> achievements;

		public static Page SelectedAchivement;

		protected override void OnLoad()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			achievements = Achievements.AchievementsDict.ToDictionary<string, string>();
			Page obj = UICore.DangerousPage.CreatePage("Achivements", ColorPlus.GetNextColor(), 10, true);
			Page val = obj.CreatePage("Achivements", ColorPlus.GetNextColor(), 10, true);
			SelectedAchivement = obj.CreatePage("Selected Achivement", ColorPlus.GetNextColor(), 10, true);
			foreach (KeyValuePair<string, string> item in achievements)
			{
				val.CreateFunction(item.Value, ColorPlus.GetNextColor(), (Action)delegate
				{
					SelectAchivement(item);
				});
			}
		}

		private void SelectAchivement(KeyValuePair<string, string> item)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			SelectedAchivement.RemoveAll();
			SelectedAchivement.Name = item.Value;
			((Element)SelectedAchivement.CreateConfirmationFunction("Unlock " + item.Value, ColorPlus.GetNextColor(), delegate
			{
				Achievements.Unlock(item.Key);
				DevUtils.Notify("Unlocked Achivement: " + item.Value);
			})).SetTooltip("CANNOT BE REVERTED");
			DevUtils.Notify("Selected Achivement: " + item.Value);
		}
	}
	internal class SaveDataUtility : Utility
	{
		public float percentage;

		protected override void OnLoad()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0052: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			Page obj = UICore.DangerousPage.CreatePage("Save Data", ColorPlus.GetNextColor(), 10, true);
			Page page = obj.CreatePage("Player Unlocks", ColorPlus.GetNextColor(), 10, true);
			page.CreateConfirmationFunction("Unlock Everything", ColorPlus.GetNextColor(), UnlockEverything);
			page.CreateConfirmationFunction("Lock Everything", ColorPlus.GetNextColor(), LockEverything);
			BonelabGameControl gameControl = new GameObject("Bonelab Game Control").AddComponent<BonelabGameControl>();
			GameControl_CheatButtons @object = ((Component)gameControl).gameObject.AddComponent<GameControl_CheatButtons>();
			Object.DontDestroyOnLoad((Object)(object)((Component)gameControl).gameObject);
			Page obj2 = obj.CreatePage("Player Progession", ColorPlus.GetNextColor(), 10, true);
			obj2.CreateBool("Beat Game", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.BeatGame, (Action<bool>)delegate(bool a)
			{
				DataManager.ActiveSave.Progression.BeatGame = a;
			});
			obj2.CreateBool("Bodylog Enabled", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.BodyLogEnabled, (Action<bool>)delegate(bool a)
			{
				DataManager.ActiveSave.Progression.BodyLogEnabled = a;
			});
			obj2.CreateBool("Has Bodylog", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.HasBodyLog, (Action<bool>)delegate(bool a)
			{
				DataManager.ActiveSave.Progression.HasBodyLog = a;
			});
			obj2.CreateInt("Menu Resume", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.MenuResume, 1, 0, 65535, (Action<int>)delegate(int a)
			{
				DataManager.ActiveSave.Progression.MenuResume = a;
			});
			obj2.CreateString("Current Campaign Level", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.CurrentCampaignLevel, (Action<string>)delegate(string a)
			{
				DataManager.ActiveSave.Progression.CurrentCampaignLevel = a;
			});
			obj2.CreateString("Current Level", ColorPlus.GetNextColor(), DataManager.ActiveSave.Progression.CurrentLevel, (Action<string>)delegate(string a)
			{
				DataManager.ActiveSave.Progression.CurrentLevel = a;
			});
			obj2.CreateInt("Progress", ColorPlus.GetNextColor(), gameControl.Progress, 1, 0, 65535, (Action<int>)gameControl.SetProgress);
			obj2.CreateConfirmationFunction("Set Full Progress", ColorPlus.GetNextColor(), (Action)@object.SetFullProgress);
			obj.CreateConfirmationFunction("CONFIRM ALL CHANGES", ColorPlus.GetNextColor(), delegate
			{
				gameControl.JustSave();
				DataManager.TrySaveActiveSave((SaveFlags)2);
			});
		}

		private void UnlockEverything()
		{
			Enumerator<Crate> enumerator = AssetWarehouse.Instance.GetCrates().GetEnumerator();
			while (enumerator.MoveNext())
			{
				Crate current = enumerator.Current;
				DataManager.ActiveSave.Unlocks.IncrementUnlockForBarcode(((Scannable)current).Barcode);
			}
		}

		private void LockEverything()
		{
			Enumerator<Crate> enumerator = AssetWarehouse.Instance.GetCrates().GetEnumerator();
			while (enumerator.MoveNext())
			{
				Crate current = enumerator.Current;
				DataManager.ActiveSave.Unlocks.ClearUnlockForBarcode(((Scannable)current).Barcode);
			}
		}
	}
}
namespace LabUtils.Developer
{
	public static class DevUtils
	{
		internal static Notification Notification { get; private set; } = new Notification();


		public static void LoadAllValid<T>(Assembly assembly, Action<Type> runOnValid)
		{
			string fullName = assembly.FullName;
			if (fullName != null && fullName.Contains("System"))
			{
				return;
			}
			Type[] types = assembly.GetTypes();
			foreach (Type type in types)
			{
				if ((!type.Name.Contains("Mono") || !type.Name.Contains("Security")) && typeof(T).IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface)
				{
					try
					{
						runOnValid(type);
					}
					catch (Exception ex)
					{
						Logger.Error(ex.Message);
					}
				}
			}
		}

		public static byte[] LoadBytesFromAssembly(Assembly assembly, string name)
		{
			if (!((ReadOnlySpan<string>)assembly.GetManifestResourceNames()).Contains(name))
			{
				return null;
			}
			using Stream stream = assembly.GetManifestResourceStream(name);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		public static Assembly LoadAssemblyFromAssembly(Assembly assembly, string name)
		{
			byte[] array = LoadBytesFromAssembly(assembly, name);
			if (array == null)
			{
				return null;
			}
			return Assembly.Load(array);
		}

		public static void Notify(string message, float timer = 0.3f, string title = "LabUtils")
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			Notification = new Notification();
			Notification.ShowTitleOnPopup = true;
			Notification.Title = NotificationText.op_Implicit(title);
			Notification.Message = NotificationText.op_Implicit(message);
			Notification.PopupLength = timer;
			Notifier.Send(Notification);
		}
	}
	public static class LabData
	{
	}
	public static class Logger
	{
		public static void Log(object message)
		{
			MelonLogger.Msg(message);
		}

		public static void Warn(object message)
		{
			MelonLogger.Warning(message);
		}

		public static void Error(object message, Exception exception = null)
		{
			MelonLogger.Error(message.ToString(), exception);
		}
	}
	public static class UICore
	{
		public static Page RootPage { get; private set; }

		public static Page UtilitiesPage { get; private set; }

		public static Page DangerousPage { get; private set; }

		public static Page SettingsPage { get; private set; }

		internal static void Init()
		{
			//IL_000a: 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_0072: 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)
			RootPage = Page.Root.CreatePage("LabUtils", ColorPlus.GetNextColor(), 10, true);
			RootPage.CreateFunction("Save Preferences", ColorPlus.GetNextColor(), (Action)Core.Save);
			UtilitiesPage = RootPage.CreatePage("Utilities", ColorPlus.GetNextColor(), 10, true);
			DangerousPage = RootPage.CreatePage("Dangerous", ColorPlus.GetNextColor(), 10, true);
			SettingsPage = RootPage.CreatePage("Settings", ColorPlus.GetNextColor(), 10, true);
		}

		public static FunctionElement CreateConfirmationFunction(this Page page, string text, Color color, Action onConfirm)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Page obj = page.CreatePage(text, color, 10, true);
			FunctionElement result = obj.CreateFunction("Confirm", ColorPlus.GetNextColor(), (Action)delegate
			{
				onConfirm?.Invoke();
				DevUtils.Notify("Confirmed Choice for " + text + "!", 0.5f);
			});
			PageLinkElement obj2 = obj.CreatePageLink(page);
			((Element)obj2).ElementColor = ColorPlus.GetNextColor();
			((Element)obj2).ElementName = "Cancel";
			return result;
		}
	}
	public abstract class Utility
	{
		public static List<Utility> Utilities = new List<Utility>();

		internal static void Init()
		{
			Utilities.Clear();
			Logger.Log("Loading DevUtils from Melons");
			foreach (MelonBase registeredMelon in MelonBase.RegisteredMelons)
			{
				_ = registeredMelon.MelonAssembly.Assembly;
				DevUtils.LoadAllValid<Utility>(registeredMelon.MelonAssembly.Assembly, OnUtilLoad);
			}
		}

		private static void OnUtilLoad(Type type)
		{
			if (Activator.CreateInstance(type) is Utility utility)
			{
				Utilities.Add(utility);
				utility.Load();
			}
		}

		public virtual void Load()
		{
			Logger.Log("Loaded " + GetType().FullName + " Util");
			OnLoad();
		}

		protected abstract void OnLoad();
	}
}
namespace LabUtils.Developer.Patches
{
	[HarmonyPatch]
	public static class AmmoPatches
	{
		public static string[] groups = new string[3] { "light", "medium", "heavy" };

		[HarmonyPatch(typeof(AmmoInventory), "Awake")]
		[HarmonyPostfix]
		public static void AwakePostfix()
		{
			string[] array = groups;
			foreach (string text in array)
			{
				if (AmmoInventory.Instance.GetCartridgeCount(text) < 1)
				{
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.lightAmmoGroup, 2000);
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.mediumAmmoGroup, 2000);
					AmmoInventory.Instance.AddCartridge(AmmoInventory.Instance.heavyAmmoGroup, 2000);
				}
			}
		}

		[HarmonyPatch(typeof(AmmoInventory), "RemoveCartridge")]
		[HarmonyPrefix]
		public static bool RemoveCartridgePrefix(CartridgeData cartridge, int count)
		{
			return !AmmoUtility.UnlimitedAmmo.Value;
		}

		[HarmonyPatch(typeof(Gun), "OnFire")]
		[HarmonyPrefix]
		public static void OnFirePrefix(Gun __instance)
		{
			if (!AmmoUtility.UnlimitedMagazines.Value || __instance == null)
			{
				return;
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			if (gameObject == null)
			{
				return;
			}
			Magazine componentInChildren = gameObject.GetComponentInChildren<Magazine>();
			if (componentInChildren != null)
			{
				MagazineState magazineState = componentInChildren.magazineState;
				if (magazineState != null)
				{
					magazineState.Refill();
				}
			}
		}

		[HarmonyPatch(typeof(Gun), "AmmoCount")]
		[HarmonyPrefix]
		public static bool ShotgunCreditCardPrefix(Gun __instance, ref int __result)
		{
			if (AmmoUtility.UnlimitedShells.Value)
			{
				__result = 1;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Magazine), "OnGrab")]
		[HarmonyPrefix]
		public static void OnGrabPrefix(Magazine __instance, Hand hand)
		{
			if (AmmoUtility.GripMagazineRefill.Value)
			{
				__instance.magazineState.Refill();
			}
		}
	}
	[HarmonyPatch]
	public static class AssetStreamingPatches
	{
		[HarmonyPatch(typeof(AssetWarehouse), "AddPallet")]
		[HarmonyPostfix]
		public static void AddPalletPostfix(Pallet pallet)
		{
			RetrievingTask.Crates.AddRange(pallet.Crates.ToList<Crate>());
		}
	}
	[HarmonyPatch]
	public static class PlayerPatches
	{
		[HarmonyPatch(typeof(Player_Health), "TAKEDAMAGE")]
		[HarmonyPrefix]
		public static bool TakeDamagePrefix(ref float damage)
		{
			if (NetworkInfo.HasServer && GamemodeManager.IsGamemodeStarted)
			{
				return true;
			}
			return !HealthUtility.GodMode.Value;
		}

		[HarmonyPatch(typeof(Player_Health), "TAKEDAMAGE")]
		[HarmonyPostfix]
		public static void TakeDamagePostfix(float damage)
		{
			if (Player.RigManager.health.curr_Health < 1f && !HealthUtility.GodMode.Value && RagdollUtility.RagdollOnDeath.Value)
			{
				RagdollUtility.Ragdoll();
			}
		}

		[HarmonyPatch(typeof(Player_Health), "SetFullHealth")]
		[HarmonyPostfix]
		public static void SetFullHealthPostfix()
		{
			RagdollUtility.UnRagdoll();
		}

		[HarmonyPatch(typeof(Player_Health), "Death")]
		[HarmonyPrefix]
		public static bool DeathPrefix()
		{
			if (NetworkInfo.HasServer && GamemodeManager.IsGamemodeStarted)
			{
				return true;
			}
			return !HealthUtility.GodMode.Value;
		}

		[HarmonyPatch(typeof(Player_Health), "Death")]
		[HarmonyPostfix]
		public static void DeathPostfix()
		{
			if (RagdollUtility.RagdollOnDeath.Value)
			{
				RagdollUtility.Ragdoll();
			}
		}
	}
}
namespace LabUtils.Developer.Extensions
{
	public static class CppExtensions
	{
		public static List<T> ToList<T>(this List<T> dirtyList)
		{
			List<T> list = new List<T>(dirtyList.Count);
			Enumerator<T> enumerator = dirtyList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				list.Add(current);
			}
			return list;
		}

		public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this Dictionary<TKey, TValue> dirtyDictionary)
		{
			Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>();
			Enumerator<TKey, TValue> enumerator = dirtyDictionary.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<TKey, TValue> current = enumerator.Current;
				dictionary.Add(current.Key, current.Value);
			}
			return dictionary;
		}
	}
	public static class FusionExtensions
	{
		public static bool IsPermissionLevelMatch(PermissionLevel match)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			NetworkPlayer val = default(NetworkPlayer);
			if (!NetworkPlayerManager.TryGetPlayer(Player.RigManager, ref val))
			{
				return false;
			}
			return val.PlayerID.IsPermissionLevelMatch(match);
		}

		public static bool IsPermissionLevelMatch(this PlayerID id, PermissionLevel match)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			PermissionLevel val = default(PermissionLevel);
			if (!MetadataHelper.TryGetPermissionLevel(id, ref val))
			{
				return false;
			}
			return val >= match;
		}
	}
}