Decompiled source of BootstrapOverride v1.0.0

Mods/BootstrapOverride.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BootstrapOverride;
using HarmonyLib;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow.Warehouse;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "BootstrapOverride", "1.0.0", "trev", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BootstrapOverride")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BootstrapOverride")]
[assembly: AssemblyTitle("BootstrapOverride")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BootstrapOverride
{
	public class Core : MelonMod
	{
		public static MelonPreferences_Entry<string> LevelBarcode { get; private set; }

		public static MelonPreferences_Entry<string> LevelName { get; private set; }

		public static SceneBootstrapper_Bonelab Bootstrapper { get; set; }

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			Hooking.OnLevelLoaded += Hooking_OnLevelLoaded;
			Hooking.OnWarehouseReady += Hooking_OnWarehouseReady;
			MelonPreferences_Category val = MelonPreferences.CreateCategory("BootstrapOverride");
			LevelBarcode = val.CreateEntry<string>("LevelBarcode", "c2534c5a-6b79-40ec-8e98-e58c5363656e", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			LevelName = val.CreateEntry<string>("LevelName", "", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MelonPreferences.Save();
		}

		private void Hooking_OnWarehouseReady()
		{
			LevelCrateReference overrideLevel = GetOverrideLevel();
			Bootstrapper.MenuHollowCrateRef = overrideLevel;
			Bootstrapper.VoidG114CrateRef = overrideLevel;
		}

		private void Hooking_OnLevelLoaded(LevelInfo obj)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			((MelonBase)this).LoggerInstance.Msg(":: Loaded Level ::");
			((MelonBase)this).LoggerInstance.Msg(":: Barcode = " + ((ScannableReference)obj.levelReference).Barcode.ID);
			((MelonBase)this).LoggerInstance.Msg(":: Name = " + ((Scannable)((CrateReferenceT<LevelCrate>)(object)obj.levelReference).Crate).Title);
		}

		private static LevelCrateReference GetOverrideLevel()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			if (!string.IsNullOrEmpty(LevelName.Value))
			{
				Crate val = ((IEnumerable<Crate>)AssetWarehouse.Instance.GetCrates().ToArray()).FirstOrDefault((Func<Crate, bool>)((Crate crate) => ((Scannable)crate).Title.ToLower().Contains(LevelName.Value.ToLower())));
				LevelBarcode.Value = (((Object)(object)val == (Object)null) ? "c2534c5a-6b79-40ec-8e98-e58c5363656e" : ((Scannable)val).Barcode.ID);
			}
			if (string.IsNullOrEmpty(LevelBarcode.Value))
			{
				LevelBarcode.Value = "c2534c5a-6b79-40ec-8e98-e58c5363656e";
			}
			LevelName.Value = string.Empty;
			MelonPreferences.Save();
			return new LevelCrateReference(LevelBarcode.Value);
		}
	}
	[HarmonyPatch(typeof(SceneBootstrapper_Bonelab), "Start")]
	public static class BootstrapperPatch
	{
		public static void Prefix(SceneBootstrapper_Bonelab __instance)
		{
			Core.Bootstrapper = __instance;
		}
	}
}