Decompiled source of LevelLoadingOptimization v0.0.2

BepInEx/plugins/LevelLoadingOptimizer.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BuildingPlus.Patches;
using HarmonyLib;
using LevelLoadingOptimizer;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LevelLoadingOptimizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LevelLoadingOptimizer")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5272c5ad-cb2f-4ab0-8282-d3d174b00d9f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BuildingPlus.Patches
{
	internal class PlaceablePlacePatch
	{
		public static void ApplyPatch(Harmony harmony)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(Placeable), "Place", new Type[3]
			{
				typeof(int),
				typeof(bool),
				typeof(bool)
			}, (Type[])null);
			if (methodInfo != null)
			{
				MethodInfo methodInfo2 = AccessTools.Method(typeof(PlaceablePlacePatch), "PlacePrefix", (Type[])null, (Type[])null);
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				LevelLoadingOptimizerPlugin.LogInfo("Patched Placeable.Place successfully");
			}
			else
			{
				LevelLoadingOptimizerPlugin.LogError("Failed to find Placeable.Place");
			}
		}

		public static void PlacePrefix(Placeable __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance.UsefulName != null)
			{
				Debug.unityLogger.logEnabled = false;
			}
		}
	}
}
namespace LevelLoadingOptimizer
{
	[BepInPlugin("LevelLoadingOptimizer", "LevelLoadingOptimizer", "0.0.2")]
	public class LevelLoadingOptimizerPlugin : BaseUnityPlugin
	{
		private Harmony harmony;

		internal static LevelLoadingOptimizerPlugin Instance { get; private set; }

		internal static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger;

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Instance = this;
			harmony = new Harmony("LevelLoadingOptimizer");
			PlaceablePlacePatch.ApplyPatch(harmony);
			LogInfo("Plugin loaded.");
		}

		public static void LogInfo(string message)
		{
			LoggerInstance.LogInfo((object)("[LevelLoadingOptimizer] " + message));
		}

		public static void LogWarning(string message)
		{
			LoggerInstance.LogWarning((object)("[LevelLoadingOptimizer] " + message));
		}

		public static void LogError(string message)
		{
			LoggerInstance.LogError((object)("[LevelLoadingOptimizer] " + message));
		}
	}
}