Decompiled source of 8 3 DISINTEGRATION LOOP Door thing v1.1.3

plugins/8-3 DISINTEGRATION LOOP.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
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("8-3--Disintergarion loop--")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("8-3--Disintergarion loop--")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3bcc4deb-c0fa-470b-b82e-4f014385a809")]
[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")]
[BepInPlugin("com.Monkey199.doorto83", "8-3 DISINTEGRATION LOOP Door thing", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DoorDetector : BaseUnityPlugin
{
	public static ManualLogSource Log;

	public static BoolField modEnabled;

	public static IntField rollChance;

	public static StringField targetLevel;

	public static BoolField randomLevel;

	public static BoolField showRollText;

	public static StringField luckyText;

	public static List<string> discoveredLevels = new List<string>();

	private static readonly HashSet<string> blockedLevels = new HashSet<string> { "Level 9-1", "Level 9-2" };

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Expected O, but got Unknown
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Expected O, but got Unknown
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		PluginConfigurator val = PluginConfigurator.Create("8-3 DISINTEGRATION LOOP Door thing", "com.Monkey199.doorto83");
		new ConfigHeader(val.rootPanel, "Settings", 24);
		modEnabled = new BoolField(val.rootPanel, "Mod Enabled", "mod_enabled", true);
		rollChance = new IntField(val.rootPanel, "Chance (1 in X)", "roll_chance", 100);
		rollChance.minimumValue = 1;
		rollChance.maximumValue = 10000;
		rollChance.setToNearestValidValueOnUnvalidInput = true;
		targetLevel = new StringField(val.rootPanel, "Target Level (ignored if Random)", "target_level", "Level 8-3");
		targetLevel.allowEmptyValues = false;
		randomLevel = new BoolField(val.rootPanel, "Random Level", "random_level", false);
		showRollText = new BoolField(val.rootPanel, "Show Roll Text", "show_roll_text", true);
		luckyText = new StringField(val.rootPanel, "Lucky Text", "lucky_text", "Lucky :3");
		luckyText.allowEmptyValues = false;
		new ConfigHeader(val.rootPanel, "--- Available Levels ---", 24);
		for (int i = 0; i < 50; i++)
		{
			try
			{
				string sceneName = GetMissionName.GetSceneName(i);
				if (!string.IsNullOrEmpty(sceneName))
				{
					string text = sceneName.ToLower();
					if (!text.Contains("menu") && !text.Contains("intro") && !text.Contains("bootstrap") && !text.Contains("custom") && !blockedLevels.Contains(sceneName))
					{
						discoveredLevels.Add(sceneName);
						new ConfigHeader(val.rootPanel, sceneName, 24);
					}
				}
			}
			catch
			{
			}
		}
		Harmony val2 = new Harmony("com.Monkey199.doorto83");
		val2.PatchAll(Assembly.GetExecutingAssembly());
	}
}
[HarmonyPatch(typeof(Door), "Open", new Type[]
{
	typeof(bool),
	typeof(bool)
})]
internal class DoorOpenPatch
{
	private static void Postfix(Door __instance)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		if (!DoorDetector.modEnabled.value)
		{
			return;
		}
		int num = Random.Range(0, DoorDetector.rollChance.value);
		LevelNamePopup instance = MonoSingleton<LevelNamePopup>.Instance;
		if ((Object)instance == (Object)null)
		{
			return;
		}
		if (num == 0)
		{
			string text;
			if (DoorDetector.randomLevel.value && DoorDetector.discoveredLevels.Count > 0)
			{
				text = DoorDetector.discoveredLevels[Random.Range(0, DoorDetector.discoveredLevels.Count)];
				if (DoorDetector.showRollText.value)
				{
					instance.CustomNameAppear("random level!!", text);
				}
			}
			else
			{
				text = DoorDetector.targetLevel.value;
				if (DoorDetector.showRollText.value)
				{
					instance.CustomNameAppear("oh very unlucky", text + "!!");
				}
			}
			SceneHelper.LoadScene(text, false);
		}
		else if (DoorDetector.showRollText.value)
		{
			instance.CustomNameAppear($"{num}", DoorDetector.luckyText.value);
		}
	}
}