Decompiled source of RecursiveSelfImprovement v1.0.0

Mods/RecursiveSelfImprovement.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WeatherElectric.RecursiveSelfImprovement;
using WeatherElectric.RecursiveSelfImprovement.Melon;
using WeatherElectric.RecursiveSelfImprovement.Menu;
using WeatherElectric.RecursiveSelfImprovement.Utilities;
using WeatherElectric.RecursiveSelfImprovement.Utilities.QolAssurance.Behaviours;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("A general quality of life/tools mod.")]
[assembly: AssemblyDescription("A general quality of life/tools mod.")]
[assembly: AssemblyCompany("Weather Electric")]
[assembly: AssemblyProduct("RecursiveSelfImprovement")]
[assembly: AssemblyCopyright("Developed by FragileDeviations")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: MelonInfo(typeof(Main), "RecursiveSelfImprovement", "1.0.0", "FragileDeviations", "https://thunderstore.io/c/bonelab/p/SoulWithMae/RecursiveSelfImprovement/")]
[assembly: MelonColor(255, 255, 255, 255)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement
{
	public class Main : MelonMod
	{
		[HarmonyPatch(typeof(Poolee))]
		private static class PooleeStart
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnInitialize")]
			private static void Postfix(Poolee __instance, IPoolable poolable)
			{
				Utility.SpawnablePlaced(__instance, ((Component)__instance).gameObject);
			}
		}

		internal const string Name = "RecursiveSelfImprovement";

		internal const string Description = "A general quality of life/tools mod.";

		internal const string Author = "FragileDeviations";

		internal const string Company = "Weather Electric";

		internal const string Version = "1.0.0";

		internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/SoulWithMae/RecursiveSelfImprovement/";

		internal static Page MenuCat { get; private set; }

		internal static Assembly CurrAsm { get; } = Assembly.GetExecutingAssembly();


		public override void OnInitializeMelon()
		{
			ModConsole.Setup(((MelonBase)this).LoggerInstance);
			Preferences.Setup();
			CreateMenu();
			SetupHooking();
			Utility.Initialize();
		}

		public override void OnUpdate()
		{
			Utility.OnUpdate();
		}

		public override void OnLateUpdate()
		{
			Utility.OnLateUpdate();
		}

		public override void OnFixedUpdate()
		{
			Utility.OnFixedUpdate();
		}

		private static void SetupHooking()
		{
			Hooking.OnWarehouseReady += OnWarehouseLoaded;
			Hooking.OnLevelLoaded += OnLevelLoad;
			Hooking.OnLevelUnloaded += OnlevelUnload;
			Hooking.OnUIRigCreated += OnPlayerReady;
		}

		private static void OnWarehouseLoaded()
		{
			List<Pallet> pallets = AssetWarehouse.Instance.GetPallets();
			List<Crate> crates = AssetWarehouse.Instance.GetCrates();
			Utility.WarehouseLoaded(pallets, crates);
			AssetWarehouse instance = AssetWarehouse.Instance;
			instance.OnPalletAdded += Action<Barcode>.op_Implicit((Action<Barcode>)OnPalletAdded);
		}

		private static void OnPalletAdded(Barcode barcode)
		{
			Utility.PalletAdded(barcode);
		}

		private static void OnLevelLoad(LevelInfo levelInfo)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Utility.LevelLoad(levelInfo);
		}

		private static void OnlevelUnload()
		{
			Utility.LevelUnload();
		}

		private static void OnPlayerReady()
		{
			Utility.PlayerReady();
		}

		private static void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			MenuCat = Page.Root.CreatePage("<color=#6FBDFF>Weather Electric</color>", Color.white, 0, true).CreatePage("<color=#009dff>Marrow Utils</color>", Color.white, 0, true);
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities
{
	public abstract class Utility
	{
		private static readonly List<Utility> Instances = new List<Utility>();

		protected internal Utility()
		{
			Instances.Add(this);
		}

		~Utility()
		{
			Instances.Remove(this);
		}

		protected virtual void OnLevelLoad(LevelInfo levelInfo)
		{
		}

		protected virtual void OnLevelUnload()
		{
		}

		protected virtual void Update()
		{
		}

		protected virtual void CreateMenu()
		{
		}

		protected virtual void Start()
		{
		}

		protected virtual void OnWarehouseInit()
		{
		}

		protected virtual void OnWarehouseInit(List<Pallet> loadedPalletList)
		{
		}

		protected virtual void OnWarehouseInit(List<Pallet> loadedPalletList, List<Crate> crateList)
		{
		}

		protected virtual void OnWarehouseInit(List<Crate> crateList)
		{
		}

		protected virtual void OnPalletAdded(Barcode barcode)
		{
		}

		protected virtual void LateUpdate()
		{
		}

		protected virtual void FixedUpdate()
		{
		}

		protected virtual void OnSpawnablePlaced(GameObject obj)
		{
		}

		protected virtual void OnSpawnablePlaced(Poolee poolee)
		{
		}

		protected virtual void OnSpawnablePlaced(GameObject obj, Poolee poolee)
		{
		}

		protected virtual void OnSpawnablePlaced()
		{
		}

		protected virtual void OnPlayerReady()
		{
		}

		public static void Initialize()
		{
			Type[] types = Main.CurrAsm.GetTypes();
			foreach (Type type in types)
			{
				if (!type.IsAbstract && type.IsSubclassOf(typeof(Utility)))
				{
					Activator.CreateInstance(type);
				}
			}
			foreach (Utility instance in Instances)
			{
				instance.Start();
				instance.CreateMenu();
			}
		}

		public static void SpawnablePlaced(Poolee poolee, GameObject obj)
		{
			foreach (Utility instance in Instances)
			{
				instance.OnSpawnablePlaced();
				instance.OnSpawnablePlaced(poolee);
				instance.OnSpawnablePlaced(obj);
				instance.OnSpawnablePlaced(obj, poolee);
			}
		}

		public static void LevelLoad(LevelInfo levelInfo)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			foreach (Utility instance in Instances)
			{
				instance.OnLevelLoad(levelInfo);
			}
		}

		public static void LevelUnload()
		{
			foreach (Utility instance in Instances)
			{
				instance.OnLevelUnload();
			}
		}

		public static void PlayerReady()
		{
			foreach (Utility instance in Instances)
			{
				instance.OnPlayerReady();
			}
		}

		public static void OnUpdate()
		{
			foreach (Utility instance in Instances)
			{
				instance.Update();
			}
		}

		public static void OnLateUpdate()
		{
			foreach (Utility instance in Instances)
			{
				instance.LateUpdate();
			}
		}

		public static void OnFixedUpdate()
		{
			foreach (Utility instance in Instances)
			{
				instance.FixedUpdate();
			}
		}

		public static void WarehouseLoaded(List<Pallet> loadedPalletList, List<Crate> crateList)
		{
			foreach (Utility instance in Instances)
			{
				instance.OnWarehouseInit();
				instance.OnWarehouseInit(loadedPalletList);
				instance.OnWarehouseInit(crateList);
				instance.OnWarehouseInit(loadedPalletList, crateList);
			}
		}

		public static void PalletAdded(Barcode barcode)
		{
			foreach (Utility instance in Instances)
			{
				instance.OnPalletAdded(barcode);
			}
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.Unredacted
{
	internal class Unredacted : Utility
	{
		protected override void Start()
		{
			ModConsole.Msg("Loading Unredacted...", 1);
		}

		protected override void OnWarehouseInit(List<Pallet> loadedPalletList)
		{
			if (!Preferences.UnredactCrates.Value)
			{
				return;
			}
			Enumerator<Pallet> enumerator = loadedPalletList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Enumerator<Crate> enumerator2 = enumerator.Current.Crates.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					Crate current = enumerator2.Current;
					if (((Scannable)current).Redacted)
					{
						((Scannable)current).Redacted = false;
						((Scannable)current)._redacted = false;
						ModConsole.Msg("[Unredacted] Unredacted " + ((Object)current).name + "!", 1);
					}
				}
			}
		}

		protected override void OnPalletAdded(Barcode barcode)
		{
			Pallet val = default(Pallet);
			if (!Preferences.UnredactCrates.Value || !AssetWarehouse.Instance.TryGetPallet(barcode, ref val))
			{
				return;
			}
			Enumerator<Crate> enumerator = val.Crates.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Crate current = enumerator.Current;
				if (((Scannable)current).Redacted)
				{
					((Scannable)current).Redacted = false;
					((Scannable)current)._redacted = false;
					ModConsole.Msg("[Unredacted] Unredacted " + ((Object)current).name + "!", 1);
				}
			}
		}

		protected override void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Main.MenuCat.CreatePage("Unredacted", Color.magenta, 0, true).CreateBoolPreference("Toggle Unredaction", Color.white, Preferences.UnredactCrates, Preferences.UnredactedCategory);
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.TheJanitor
{
	internal class Janitor : Utility
	{
		private enum ClearType
		{
			Everything,
			UtilityGuns,
			Npcs,
			Guns,
			Melee,
			Props,
			Decals
		}

		private static bool _fusionInstalled;

		private static ClearType _clearType = ClearType.Everything;

		private static readonly List<CrateSpawner> SpawnableCratePlacers = new List<CrateSpawner>();

		private static Notification EverythingCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared every spawnable!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification NpcsCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all NPCs!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification GunsCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all guns!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification MeleeCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all melee!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification PropsCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all props!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification DecalsCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all decals!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification InFusionServer { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("You are in a fusion server! This would cause desync. Not doing it."),
			Type = (NotificationType)2,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification ResetMap { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Reset the map!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		private static Notification UtilityGunsCleared { get; } = new Notification
		{
			Title = NotificationText.op_Implicit("The Janitor"),
			Message = NotificationText.op_Implicit("Cleared all utility guns!"),
			Type = (NotificationType)3,
			PopupLength = 1f,
			ShowTitleOnPopup = true
		};


		protected override void Start()
		{
			ModConsole.Msg("Loading The Janitor...", 1);
			_fusionInstalled = HelperMethods.CheckIfAssemblyLoaded("labfusion");
		}

		protected override void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			Page obj = Main.MenuCat.CreatePage("<color=#ecff6d>The Janitor</color>", Color.white, 0, true);
			obj.CreateEnum("Clear Type", Color.white, (Enum)ClearType.Everything, (Action<Enum>)UpdateType);
			obj.CreateFunction("Clear", Color.white, (Action)Clear);
			obj.CreateFunction("Reset Map", Color.white, (Action)Reset);
			obj.CreateBoolPreference("Override Fusion Check", Color.red, Preferences.OverrideFusionCheck, Preferences.JanitorCategory);
		}

		protected override void OnLevelUnload()
		{
			SpawnableCratePlacers.Clear();
		}

		private static void UpdateType(Enum @enum)
		{
			_clearType = (ClearType)(object)@enum;
		}

		private static void Clear()
		{
			switch (_clearType)
			{
			case ClearType.Everything:
				ClearEverything();
				break;
			case ClearType.UtilityGuns:
				ClearUtilGuns();
				break;
			case ClearType.Npcs:
				ClearNPCs();
				break;
			case ClearType.Guns:
				ClearGuns();
				break;
			case ClearType.Melee:
				ClearMelee();
				break;
			case ClearType.Props:
				ClearProps();
				break;
			case ClearType.Decals:
				ClearDecals();
				break;
			default:
				ModConsole.Error("[TheJanitor] Invalid clear type!");
				break;
			}
		}

		private static void Reset()
		{
			ClearEverything(nonotif: true);
			if (SpawnableCratePlacers.Count == 0)
			{
				Il2CppArrayBase<CrateSpawner> val = Object.FindObjectsOfType<CrateSpawner>();
				if (val.Length == 0)
				{
					return;
				}
				SpawnableCratePlacers.AddRange((IEnumerable<CrateSpawner>)val);
			}
			foreach (CrateSpawner spawnableCratePlacer in SpawnableCratePlacers)
			{
				spawnableCratePlacer.ReSpawnSpawnable();
			}
			Notifier.Send(ResetMap);
		}

		private static void ClearEverything(bool nonotif = false)
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Scannable)item.SpawnableCrate).Barcode.ID == "SLZ.BONELAB.Core.Spawnable.RigManagerBlank" || ((Scannable)item.SpawnableCrate).Barcode.ID == "SLZ.BONELAB.Core.Spawnable.LegacyUIEventSystem")
				{
					return;
				}
				item.Despawn();
			}
			if (!nonotif)
			{
				Notifier.Send(EverythingCleared);
			}
		}

		private static void ClearUtilGuns()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				bool flag;
				switch (((Scannable)item.SpawnableCrate).Barcode.ID)
				{
				case "c1534c5a-6b38-438a-a324-d7e147616467":
				case "c1534c5a-5747-42a2-bd08-ab3b47616467":
				case "c1534c5a-3813-49d6-a98c-f595436f6e73":
					flag = true;
					break;
				default:
					flag = false;
					break;
				}
				if (flag)
				{
					item.Despawn();
				}
			}
			Notifier.Send(UtilityGunsCleared);
		}

		private static void ClearNPCs()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Crate)item.SpawnableCrate).Tags.Contains("NPC"))
				{
					item.Despawn();
				}
			}
			Notifier.Send(NpcsCleared);
		}

		private static void ClearGuns()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Crate)item.SpawnableCrate).Tags.Contains("Gun"))
				{
					item.Despawn();
				}
			}
			Notifier.Send(GunsCleared);
		}

		private static void ClearMelee()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Crate)item.SpawnableCrate).Tags.Contains("Melee"))
				{
					item.Despawn();
				}
			}
			Notifier.Send(MeleeCleared);
		}

		private static void ClearProps()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Crate)item.SpawnableCrate).Tags.Contains("Prop"))
				{
					item.Despawn();
				}
			}
			Notifier.Send(PropsCleared);
		}

		private static void ClearDecals()
		{
			Il2CppArrayBase<Poolee> val = Object.FindObjectsOfType<Poolee>();
			if (val.Length == 0)
			{
				return;
			}
			foreach (Poolee item in val)
			{
				if (((Crate)item.SpawnableCrate).Tags.Contains("Decal"))
				{
					item.Despawn();
				}
			}
			Notifier.Send(DecalsCleared);
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.QolAssurance
{
	internal class QolAssurance : Utility
	{
		private static class Assets
		{
			private static AssetBundle _bundle;

			public static AudioClip AlarmSound { get; private set; }

			public static void Load()
			{
				_bundle = HelperMethods.LoadEmbeddedAssetBundle(Main.CurrAsm, HelperMethods.IsAndroid() ? "WeatherElectric.RecursiveSelfImprovement.Utilities.QolAssurance.Resources.Android.bundle" : "WeatherElectric.RecursiveSelfImprovement.Utilities.QolAssurance.Resources.Windows.bundle");
				AlarmSound = HelperMethods.LoadPersistentAsset<AudioClip>(_bundle, "Assets/MarrowUtils/QOLAssurance/BoneTheme.wav");
			}
		}

		protected override void Start()
		{
			ModConsole.Msg("Loading QualityOfLifeAssurance...", 1);
			Assets.Load();
		}

		protected override void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Main.MenuCat.CreatePage("Quality of Life Assurance", Color.green, 0, true).CreateBoolPreference("Enabled", Color.white, Preferences.EnableItemPatches, Preferences.QualityOfLifeAssuranceCategory);
		}

		protected override void OnSpawnablePlaced(GameObject obj, Poolee poolee)
		{
			if (Preferences.EnableItemPatches.Value && ((Scannable)poolee.SpawnableCrate).Barcode.ID == "SLZ.BONELAB.Content.Spawnable.AlarmClock")
			{
				FixAlarmClock(obj);
			}
		}

		private static void FixAlarmClock(GameObject obj)
		{
			TextMeshPro componentInChildren = obj.GetComponentInChildren<TextMeshPro>();
			UIClock val = obj.AddComponent<UIClock>();
			AlarmClock alarmClock = obj.AddComponent<AlarmClock>();
			AudioSource audioSource;
			if (!((Object)(object)componentInChildren == (Object)null) && !((Object)(object)val == (Object)null))
			{
				val.txt_clock = componentInChildren;
				val.OnEnable();
				audioSource = obj.AddComponent<AudioSource>();
				SetupAudioSource();
				alarmClock.AudioSource = audioSource;
			}
			void SetupAudioSource()
			{
				audioSource.playOnAwake = false;
				audioSource.loop = false;
				audioSource.spatialBlend = 1f;
				audioSource.maxDistance = 10f;
				audioSource.minDistance = 1f;
				audioSource.rolloffMode = (AudioRolloffMode)1;
				audioSource.volume = 0.5f;
				audioSource.clip = Assets.AlarmSound;
			}
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.QolAssurance.Behaviours
{
	[RegisterTypeInIl2Cpp]
	public class AlarmClock : MonoBehaviour
	{
		[NonSerialized]
		public AudioSource AudioSource;

		private readonly int[] _playTimes = new int[2] { 0, 12 };

		private bool _hasPlayedToday;

		private void Update()
		{
			if (!_hasPlayedToday && Array.IndexOf(_playTimes, DateTime.Now.Hour) != -1 && DateTime.Now.Minute == 0)
			{
				AudioSource.Play();
				_hasPlayedToday = true;
			}
			if (DateTime.Now.Hour == 0 && DateTime.Now.Minute == 0)
			{
				_hasPlayedToday = false;
			}
		}

		public AlarmClock(IntPtr ptr)
			: base(ptr)
		{
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.LevelReloader
{
	internal class LevelReloader : Utility
	{
		protected override void Start()
		{
			ModConsole.Msg("Loading LevelReloader...");
		}

		protected override void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Main.MenuCat.CreatePage("Level Reloader", Color.cyan, 0, true).CreateBoolPreference("Enabled", Color.white, Preferences.EnableReloader, Preferences.ReloaderCategory);
		}

		protected override void Update()
		{
			if (Preferences.EnableReloader.Value && !HelperMethods.IsAndroid() && (Input.GetKeyDown((KeyCode)306) || Input.GetKeyDown((KeyCode)305)) && Input.GetKeyDown((KeyCode)114))
			{
				SceneStreamer.Reload();
			}
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Utilities.EmergencyRelocation
{
	internal class Teleporter : Utility
	{
		private static Vector3 _levelStart;

		protected override void Start()
		{
			ModConsole.Msg("Loading EmergencyRelocation...");
		}

		protected override void CreateMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Main.MenuCat.CreatePage("Emergency Relocation", Color.green, 0, true).CreateFunction("Relocate", Color.white, (Action)Relocate);
		}

		protected override void OnLevelLoad(LevelInfo levelInfo)
		{
			//IL_003a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			PlayerMarker val = Object.FindObjectOfType<PlayerMarker>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = GameObject.Find("[RigManager (Blank)]");
				if (!((Object)(object)val2 == (Object)null))
				{
					_levelStart = val2.transform.position;
				}
			}
			else
			{
				_levelStart = ((Component)val).transform.position;
			}
		}

		private static void Relocate()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Player.RigManager.Teleport(_levelStart, true);
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Melon
{
	internal static class ModConsole
	{
		private static Instance _logger;

		public static void Setup(Instance loggerInstance)
		{
			_logger = loggerInstance;
		}

		public static void Msg(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text);
			}
		}

		public static void Msg(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text);
			}
		}

		public static void Msg(ConsoleColor txtcolor, object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text);
			}
		}

		public static void Msg(ConsoleColor txtcolor, string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text);
			}
		}

		public static void Msg(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text, args);
			}
		}

		public static void Msg(ConsoleColor txtcolor, string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text, args);
			}
		}

		public static void Error(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text);
			}
		}

		public static void Error(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text);
			}
		}

		public static void Error(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text, args);
			}
		}

		public static void Warning(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text);
			}
		}

		public static void Warning(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text);
			}
		}

		public static void Warning(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text, args);
			}
		}
	}
	internal static class Preferences
	{
		public static readonly MelonPreferences_Category GlobalCategory = MelonPreferences.CreateCategory("Global");

		public static readonly MelonPreferences_Category JanitorCategory = MelonPreferences.CreateCategory("TheJanitor");

		public static readonly MelonPreferences_Category ReloaderCategory = MelonPreferences.CreateCategory("LevelReloader");

		public static readonly MelonPreferences_Category UnredactedCategory = MelonPreferences.CreateCategory("Unredacted");

		public static readonly MelonPreferences_Category QualityOfLifeAssuranceCategory = MelonPreferences.CreateCategory("QualityOfLifeAssurance");

		public static MelonPreferences_Entry<bool> OverrideFusionCheck { get; set; }

		public static MelonPreferences_Entry<bool> EnableReloader { get; set; }

		public static MelonPreferences_Entry<bool> UnredactCrates { get; set; }

		public static MelonPreferences_Entry<bool> EnableItemPatches { get; set; }

		public static MelonPreferences_Entry<int> LoggingMode { get; set; }

		public static void Setup()
		{
			LoggingMode = GlobalCategory.GetEntry<int>("LoggingMode") ?? GlobalCategory.CreateEntry<int>("LoggingMode", 0, "Logging Mode", "The level of logging to use. 0 = Important Only, 1 = All", false, false, (ValueValidator)null, (string)null);
			GlobalCategory.SetFilePath(MelonEnvironment.UserDataDirectory + "/WeatherElectric.cfg");
			GlobalCategory.SaveToFile(false);
			OverrideFusionCheck = JanitorCategory.GetEntry<bool>("OverrideFusionCheck") ?? JanitorCategory.CreateEntry<bool>("OverrideFusionCheck", false, "Override Fusion Check", "Whether or not to override the Fusion check. This is not recommended, as it causes desync.", false, false, (ValueValidator)null, (string)null);
			JanitorCategory.SetFilePath(MelonEnvironment.UserDataDirectory + "/WeatherElectric.cfg");
			JanitorCategory.SaveToFile(false);
			EnableReloader = ReloaderCategory.GetEntry<bool>("EnabledReloader") ?? ReloaderCategory.CreateEntry<bool>("EnabledReloader", true, "Enabled", "Whether or not to check for Control + R.", false, false, (ValueValidator)null, (string)null);
			UnredactCrates = UnredactedCategory.GetEntry<bool>("UnredactCrates") ?? UnredactedCategory.CreateEntry<bool>("UnredactCrates", true, "Unredact Crates", "Whether or not to unredact crates.", false, false, (ValueValidator)null, (string)null);
			UnredactedCategory.SetFilePath(MelonEnvironment.UserDataDirectory + "/WeatherElectric.cfg");
			UnredactedCategory.SaveToFile(false);
			EnableItemPatches = QualityOfLifeAssuranceCategory.GetEntry<bool>("EnableItemPatches") ?? QualityOfLifeAssuranceCategory.CreateEntry<bool>("EnableItemPatches", true, "Enable Item Patches", "Whether or not to enable small item fixes.", false, false, (ValueValidator)null, (string)null);
			QualityOfLifeAssuranceCategory.SetFilePath(MelonEnvironment.UserDataDirectory + "/WeatherElectric.cfg");
			QualityOfLifeAssuranceCategory.SaveToFile(false);
			ModConsole.Msg("Finished preferences setup for RecursiveSelfImprovement", 1);
		}
	}
}
namespace WeatherElectric.RecursiveSelfImprovement.Menu
{
	internal static class BoneMenuExtensions
	{
		public static BoolElement CreateBoolPreference(this Page category, string name, Color color, MelonPreferences_Entry<bool> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateBool(name, color, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this Page category, string name, Color color, float increment, float min, float max, MelonPreferences_Entry<float> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateFloat(name, color, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this Page category, string name, Color color, int increment, int min, int max, MelonPreferences_Entry<int> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateInt(name, color, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement CreateEnumPreference(this Page category, string name, Color color, Enum pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateEnum(name, color, pref, (Action<Enum>)delegate(Enum v)
			{
				pref = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}
	}
}