Decompiled source of AlwaysMist v0.1.29

AlwaysMist.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AlwaysMist.Behaviour;
using AlwaysMist.Datas;
using AlwaysMist.Extensions;
using AlwaysMist.Proxy;
using BepInEx;
using BepInEx.Configuration;
using BepInExUtils.Attributes;
using BepInExUtils.Extensions;
using BepInExUtils.Interfaces;
using BepInExUtils.Logging;
using BepInExUtils.Proxy;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TeamCherry.SharedUtils;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AlwaysMist")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d69756569b627b2d0e211a9ca559bf464726f86c")]
[assembly: AssemblyProduct("AlwaysMist")]
[assembly: AssemblyTitle("AlwaysMist")]
[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.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;
		}
	}
}
namespace AlwaysMist
{
	[BepInUtils("io.github.ykysnk.AlwaysMist", "Always Mist", "0.1.29")]
	[BepInDependency("io.github.ykysnk.BepinExUtils", "1.0.0")]
	[BepInProcess("Hollow Knight Silksong.exe")]
	[ConfigBind<bool>("ResetMazeSaveData", "Options", false, "Always reset maze save data when enter even if you're not dead.")]
	[ConfigBind<bool>("RandomNeededCorrectDoors", "Options", false, "Random the correct doors are needed when enter every single time.")]
	[ConfigBind<int>("MaxRandomNeededCorrectDoors", "Options", 10, "The max value of random the correct doors needed.", 2, 100)]
	[ConfigBind<int>("MinRandomNeededCorrectDoors", "Options", 2, "The min value of random the correct doors needed.", 2, 100)]
	[ConfigBind<bool>("TrueAlwaysMist", "Options", false, "Always enter the mist maze first when entering any rooms or any doors.")]
	[ConfigBind<bool>("RestBenchInMist", "Options", false, "Turn on the rest bench in the mist maze.")]
	[BepInPlugin("io.github.ykysnk.AlwaysMist", "Always Mist", "0.1.29")]
	public class Main : BaseUnityPlugin, IBepInUtils
	{
		private const string SectionOptions = "Options";

		private const string Version = "0.1.29";

		private static Main? _instance;

		private readonly Harmony _harmony = new Harmony("io.github.ykysnk.AlwaysMist");

		private void Awake()
		{
			//IL_0005: 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)
			//IL_0016: Expected O, but got Unknown
			GameObject val = new GameObject("AlwaysMistController");
			val.AddComponent<AlwaysMistController>();
			Object.DontDestroyOnLoad((Object)val);
		}

		public void Init()
		{
		}

		public Main()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0047: Expected O, but got Unknown
			//IL_005c: 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_0077: Expected O, but got Unknown
			//IL_0077: Expected O, but got Unknown
			//IL_008c: 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_00af: Expected O, but got Unknown
			//IL_00af: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00e6: Expected O, but got Unknown
			//IL_00fb: 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_0116: Expected O, but got Unknown
			//IL_0116: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0146: Expected O, but got Unknown
			_instance = this;
			Configs._ResetMazeSaveData = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "ResetMazeSaveData"), false, new ConfigDescription("Always reset maze save data when enter even if you're not dead.", (AcceptableValueBase)null, Array.Empty<object>()));
			Configs._RandomNeededCorrectDoors = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "RandomNeededCorrectDoors"), false, new ConfigDescription("Random the correct doors are needed when enter every single time.", (AcceptableValueBase)null, Array.Empty<object>()));
			Configs._MaxRandomNeededCorrectDoors = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("Options", "MaxRandomNeededCorrectDoors"), 10, new ConfigDescription("The max value of random the correct doors needed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 100), Array.Empty<object>()));
			Configs._MinRandomNeededCorrectDoors = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("Options", "MinRandomNeededCorrectDoors"), 2, new ConfigDescription("The min value of random the correct doors needed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 100), Array.Empty<object>()));
			Configs._TrueAlwaysMist = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "TrueAlwaysMist"), false, new ConfigDescription("Always enter the mist maze first when entering any rooms or any doors.", (AcceptableValueBase)null, Array.Empty<object>()));
			Configs._RestBenchInMist = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "RestBenchInMist"), false, new ConfigDescription("Turn on the rest bench in the mist maze.", (AcceptableValueBase)null, Array.Empty<object>()));
			Configs.Init();
			Utils.Logger.Info((object)"Plugin Always Mist is loaded, version 0.1.29");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Init();
		}
	}
	public static class Utils
	{
		internal const string FolderName = "AlwaysMist";

		internal const string GameName = "Hollow Knight Silksong.exe";

		internal const string Guid = "io.github.ykysnk.AlwaysMist";

		internal const string Name = "Always Mist";

		internal const string Version = "0.1.29";

		private static Logger? _logger;

		public static Logger Logger
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Expected O, but got Unknown
				object obj = _logger;
				if (obj == null)
				{
					Logger val = new Logger("Always Mist");
					_logger = val;
					obj = (object)val;
				}
				return (Logger)obj;
			}
		}

		public static string? GetDoorDir(string doorName)
		{
			if (doorName.StartsWith("left"))
			{
				return "left";
			}
			if (doorName.StartsWith("right"))
			{
				return "right";
			}
			if (doorName.StartsWith("top"))
			{
				return "top";
			}
			if (!doorName.StartsWith("bot"))
			{
				return null;
			}
			return "bot";
		}

		public static string? GetDoorDirMatch(string doorName)
		{
			string doorDir = GetDoorDir(doorName);
			if (doorDir == null)
			{
				return null;
			}
			return doorDir switch
			{
				"left" => "right", 
				"right" => "left", 
				"top" => "bot", 
				"bot" => "top", 
				_ => null, 
			};
		}

		public static string? GetEntryDoorDir(string doorName)
		{
			string doorDir = GetDoorDir(doorName);
			if (doorDir == null)
			{
				return null;
			}
			return doorDir switch
			{
				"left" => "left", 
				"right" => "right", 
				"top" => "left", 
				"bot" => "right", 
				_ => null, 
			};
		}
	}
	public static class Configs
	{
		public delegate void OnResetMazeSaveDataValueChangedEvent(bool oldValue, bool newValue);

		public delegate void OnRandomNeededCorrectDoorsValueChangedEvent(bool oldValue, bool newValue);

		public delegate void OnMaxRandomNeededCorrectDoorsValueChangedEvent(int oldValue, int newValue);

		public delegate void OnMinRandomNeededCorrectDoorsValueChangedEvent(int oldValue, int newValue);

		public delegate void OnTrueAlwaysMistValueChangedEvent(bool oldValue, bool newValue);

		public delegate void OnRestBenchInMistValueChangedEvent(bool oldValue, bool newValue);

		internal static ConfigEntry<bool>? _ResetMazeSaveData;

		internal static ConfigEntry<bool>? _RandomNeededCorrectDoors;

		internal static ConfigEntry<int>? _MaxRandomNeededCorrectDoors;

		internal static ConfigEntry<int>? _MinRandomNeededCorrectDoors;

		internal static ConfigEntry<bool>? _TrueAlwaysMist;

		internal static ConfigEntry<bool>? _RestBenchInMist;

		private static bool? _oldResetMazeSaveData;

		private static bool? _oldRandomNeededCorrectDoors;

		private static int? _oldMaxRandomNeededCorrectDoors;

		private static int? _oldMinRandomNeededCorrectDoors;

		private static bool? _oldTrueAlwaysMist;

		private static bool? _oldRestBenchInMist;

		public static bool ResetMazeSaveData
		{
			get
			{
				return _ResetMazeSaveData?.Value ?? false;
			}
			set
			{
				if (_ResetMazeSaveData != null)
				{
					_ResetMazeSaveData.Value = value;
				}
			}
		}

		public static bool RandomNeededCorrectDoors
		{
			get
			{
				return _RandomNeededCorrectDoors?.Value ?? false;
			}
			set
			{
				if (_RandomNeededCorrectDoors != null)
				{
					_RandomNeededCorrectDoors.Value = value;
				}
			}
		}

		public static int MaxRandomNeededCorrectDoors
		{
			get
			{
				return _MaxRandomNeededCorrectDoors?.Value ?? 0;
			}
			set
			{
				if (_MaxRandomNeededCorrectDoors != null)
				{
					_MaxRandomNeededCorrectDoors.Value = value;
				}
			}
		}

		public static int MinRandomNeededCorrectDoors
		{
			get
			{
				return _MinRandomNeededCorrectDoors?.Value ?? 0;
			}
			set
			{
				if (_MinRandomNeededCorrectDoors != null)
				{
					_MinRandomNeededCorrectDoors.Value = value;
				}
			}
		}

		public static bool TrueAlwaysMist
		{
			get
			{
				return _TrueAlwaysMist?.Value ?? false;
			}
			set
			{
				if (_TrueAlwaysMist != null)
				{
					_TrueAlwaysMist.Value = value;
				}
			}
		}

		public static bool RestBenchInMist
		{
			get
			{
				return _RestBenchInMist?.Value ?? false;
			}
			set
			{
				if (_RestBenchInMist != null)
				{
					_RestBenchInMist.Value = value;
				}
			}
		}

		public static event OnResetMazeSaveDataValueChangedEvent? OnResetMazeSaveDataValueChanged;

		public static event OnRandomNeededCorrectDoorsValueChangedEvent? OnRandomNeededCorrectDoorsValueChanged;

		public static event OnMaxRandomNeededCorrectDoorsValueChangedEvent? OnMaxRandomNeededCorrectDoorsValueChanged;

		public static event OnMinRandomNeededCorrectDoorsValueChangedEvent? OnMinRandomNeededCorrectDoorsValueChanged;

		public static event OnTrueAlwaysMistValueChangedEvent? OnTrueAlwaysMistValueChanged;

		public static event OnRestBenchInMistValueChangedEvent? OnRestBenchInMistValueChanged;

		internal static void Init()
		{
			_oldResetMazeSaveData = _ResetMazeSaveData?.Value;
			ConfigEntry<bool>? resetMazeSaveData = _ResetMazeSaveData;
			if (resetMazeSaveData != null)
			{
				resetMazeSaveData.SettingChanged += delegate
				{
					Configs.OnResetMazeSaveDataValueChanged?.Invoke(_oldResetMazeSaveData.GetValueOrDefault(), _ResetMazeSaveData.Value);
					_oldResetMazeSaveData = _ResetMazeSaveData.Value;
				};
			}
			_oldRandomNeededCorrectDoors = _RandomNeededCorrectDoors?.Value;
			ConfigEntry<bool>? randomNeededCorrectDoors = _RandomNeededCorrectDoors;
			if (randomNeededCorrectDoors != null)
			{
				randomNeededCorrectDoors.SettingChanged += delegate
				{
					Configs.OnRandomNeededCorrectDoorsValueChanged?.Invoke(_oldRandomNeededCorrectDoors.GetValueOrDefault(), _RandomNeededCorrectDoors.Value);
					_oldRandomNeededCorrectDoors = _RandomNeededCorrectDoors.Value;
				};
			}
			_oldMaxRandomNeededCorrectDoors = _MaxRandomNeededCorrectDoors?.Value;
			ConfigEntry<int>? maxRandomNeededCorrectDoors = _MaxRandomNeededCorrectDoors;
			if (maxRandomNeededCorrectDoors != null)
			{
				maxRandomNeededCorrectDoors.SettingChanged += delegate
				{
					Configs.OnMaxRandomNeededCorrectDoorsValueChanged?.Invoke(_oldMaxRandomNeededCorrectDoors.GetValueOrDefault(), _MaxRandomNeededCorrectDoors.Value);
					_oldMaxRandomNeededCorrectDoors = _MaxRandomNeededCorrectDoors.Value;
				};
			}
			_oldMinRandomNeededCorrectDoors = _MinRandomNeededCorrectDoors?.Value;
			ConfigEntry<int>? minRandomNeededCorrectDoors = _MinRandomNeededCorrectDoors;
			if (minRandomNeededCorrectDoors != null)
			{
				minRandomNeededCorrectDoors.SettingChanged += delegate
				{
					Configs.OnMinRandomNeededCorrectDoorsValueChanged?.Invoke(_oldMinRandomNeededCorrectDoors.GetValueOrDefault(), _MinRandomNeededCorrectDoors.Value);
					_oldMinRandomNeededCorrectDoors = _MinRandomNeededCorrectDoors.Value;
				};
			}
			_oldTrueAlwaysMist = _TrueAlwaysMist?.Value;
			ConfigEntry<bool>? trueAlwaysMist = _TrueAlwaysMist;
			if (trueAlwaysMist != null)
			{
				trueAlwaysMist.SettingChanged += delegate
				{
					Configs.OnTrueAlwaysMistValueChanged?.Invoke(_oldTrueAlwaysMist.GetValueOrDefault(), _TrueAlwaysMist.Value);
					_oldTrueAlwaysMist = _TrueAlwaysMist.Value;
				};
			}
			_oldRestBenchInMist = _RestBenchInMist?.Value;
			ConfigEntry<bool>? restBenchInMist = _RestBenchInMist;
			if (restBenchInMist != null)
			{
				restBenchInMist.SettingChanged += delegate
				{
					Configs.OnRestBenchInMistValueChanged?.Invoke(_oldRestBenchInMist.GetValueOrDefault(), _RestBenchInMist.Value);
					_oldRestBenchInMist = _RestBenchInMist.Value;
				};
			}
		}
	}
}
namespace AlwaysMist.Proxy
{
	[PublicAPI]
	public class MazeControllerEntryMatchProxy : ClassProxy
	{
		private const string ClassName = "MazeController+EntryMatch";

		public string EntryScene
		{
			get
			{
				return ObjectExtensions.GetFieldValue<string>(((ClassProxy)this).Native, "EntryScene");
			}
			set
			{
				ObjectExtensions.SetFieldValue<string>(((ClassProxy)this).Native, "EntryScene", value);
			}
		}

		public string EntryDoorDir
		{
			get
			{
				return ObjectExtensions.GetFieldValue<string>(((ClassProxy)this).Native, "EntryDoorDir");
			}
			set
			{
				ObjectExtensions.SetFieldValue<string>(((ClassProxy)this).Native, "EntryDoorDir", value);
			}
		}

		public string ExitDoorDir
		{
			get
			{
				return ObjectExtensions.GetFieldValue<string>(((ClassProxy)this).Native, "ExitDoorDir");
			}
			set
			{
				ObjectExtensions.SetFieldValue<string>(((ClassProxy)this).Native, "ExitDoorDir", value);
			}
		}

		public MinMaxFloat FogRotationRange
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return ObjectExtensions.GetFieldValue<MinMaxFloat>(((ClassProxy)this).Native, "FogRotationRange");
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				ObjectExtensions.SetFieldValue<MinMaxFloat>(((ClassProxy)this).Native, "FogRotationRange", value);
			}
		}

		public MazeControllerEntryMatchProxy()
			: base("MazeController+EntryMatch")
		{
		}

		public MazeControllerEntryMatchProxy(object obj)
			: base(obj, "MazeController+EntryMatch")
		{
		}
	}
}
namespace AlwaysMist.Patches
{
	[HarmonyPatch(typeof(DesktopPlatform))]
	internal class DesktopPlatformPatches
	{
		private const string SaveFileName = "saveData{0}.json";

		private const string SaveFileBackupName = "saveData{0}.json.bak";

		private const string SaveFileNewName = "saveData{0}.json.new";

		[HarmonyPatch("WriteSaveSlot")]
		[HarmonyPostfix]
		private static void WriteSaveSlot(DesktopPlatform __instance, int slotIndex, byte[] bytes, Action<bool> callback)
		{
			Utils.Logger.Debug((object)$"DesktopPlatform.WriteSaveSlot: {slotIndex}");
			AlwaysMistController instance = AlwaysMistController.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || !instance.SaveDatas.TryGetValue(slotIndex, out AlwaysMistData data))
			{
				return;
			}
			string savePath = __instance.GetSavePath();
			string filePath = Path.Combine(savePath, $"saveData{slotIndex}.json");
			string newFilePath = Path.Combine(savePath, $"saveData{slotIndex}.json.new");
			string backupFilePath = Path.Combine(savePath, $"saveData{slotIndex}.json.bak");
			CoreLoop.InvokeNext((Action)delegate
			{
				SaveDataUtility.SerializeToJsonAsync<AlwaysMistData>(data, (Action<bool, string>)delegate(bool success, string result)
				{
					if (!success)
					{
						return;
					}
					try
					{
						File.WriteAllText(newFilePath, result);
					}
					catch (Exception ex)
					{
						Utils.Logger.Error((object)ex);
					}
					try
					{
						if (File.Exists(filePath))
						{
							File.Replace(newFilePath, filePath, backupFilePath);
						}
						else
						{
							File.Move(newFilePath, filePath);
						}
					}
					catch (Exception ex2)
					{
						Utils.Logger.Error((object)ex2);
					}
				});
			});
		}

		[HarmonyPatch("ReadSaveSlot")]
		[HarmonyPostfix]
		private static void ReadSaveSlot(DesktopPlatform __instance, int slotIndex, Action<byte[]> callback)
		{
			Utils.Logger.Debug((object)$"DesktopPlatform.ReadSaveSlot: {slotIndex}");
			AlwaysMistController controller = AlwaysMistController.Instance;
			if (!Object.op_Implicit((Object)(object)controller))
			{
				return;
			}
			string path = Path.Combine(__instance.GetSavePath(), $"saveData{slotIndex}.json");
			string saveJson = "";
			try
			{
				if (File.Exists(path))
				{
					saveJson = File.ReadAllText(path);
				}
			}
			catch (Exception ex)
			{
				Utils.Logger.Error((object)ex);
			}
			if (!string.IsNullOrEmpty(saveJson))
			{
				CoreLoop.InvokeSafe((Action)delegate
				{
					controller.SaveDatas[slotIndex] = SaveDataUtility.DeserializeSaveData<AlwaysMistData>(saveJson);
				});
			}
		}
	}
	[HarmonyPatch(typeof(MazeController))]
	internal class MazeControllerPatches
	{
		[HarmonyPatch("Activate")]
		[HarmonyPrefix]
		private static void Activate(MazeController __instance)
		{
			MazeController __instance2 = __instance;
			if (MazeControllerExtensions.get_isActive(__instance2))
			{
				return;
			}
			AlwaysMistController instance = AlwaysMistController.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return;
			}
			if (Configs.RandomNeededCorrectDoors || Configs.TrueAlwaysMist)
			{
				if (instance.LastRandomValue < 0)
				{
					instance.LastRandomValue = Random.Range(Configs.MinRandomNeededCorrectDoors, Configs.MaxRandomNeededCorrectDoors);
				}
				MazeControllerExtensions.set_neededCorrectDoors(__instance2, instance.LastRandomValue);
				MazeControllerExtensions.set_restScenePoint(__instance2, (int)Math.Round((float)instance.LastRandomValue / 2f));
			}
			if (instance.CurrentSceneName == "Dust_Maze_Last_Hall" && !string.IsNullOrEmpty(instance.TargetSceneName))
			{
				MazeControllerExtensions.set_exitSceneName(__instance2, instance.TargetSceneName);
			}
			if (!(instance.CurrentSceneName != "Dust_Maze_09_entrance") && Configs.TrueAlwaysMist && !string.IsNullOrEmpty(instance.TargetEntryDoorDir) && !(instance.TargetEntryDoorDir == "left"))
			{
				TransitionPoint val = ((IEnumerable<TransitionPoint>)TransitionPoint.TransitionPoints).FirstOrDefault((Func<TransitionPoint, bool>)((TransitionPoint door) => ((Component)door).gameObject.scene == ((Component)__instance2).gameObject.scene && ((Object)((Component)door).gameObject).name == "right1"));
				if (Object.op_Implicit((Object)(object)val))
				{
					PlayerData instance2 = PlayerData.instance;
					Utils.Logger.Debug((object)("playerData.PreviousMazeTargetDoor: " + instance2.PreviousMazeTargetDoor));
					MazeControllerExtensions.get_entryDoors(__instance2).Clear();
					MazeControllerExtensions.get_entryDoors(__instance2).Add(val);
				}
			}
		}

		[HarmonyPatch("GetExitMatch")]
		[HarmonyPrefix]
		private static bool GetExitMatch(MazeController __instance, ref object __result)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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)
			AlwaysMistController instance = AlwaysMistController.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return true;
			}
			if (!Configs.TrueAlwaysMist)
			{
				return true;
			}
			if (string.IsNullOrEmpty(instance.TargetSceneName))
			{
				return true;
			}
			if (!instance.IsEnteredMaze)
			{
				return true;
			}
			Utils.Logger.Debug((object)"Create Entry Match");
			MazeControllerEntryMatchProxy mazeControllerEntryMatchProxy = new MazeControllerEntryMatchProxy();
			mazeControllerEntryMatchProxy.EntryScene = instance.EnterSceneName;
			mazeControllerEntryMatchProxy.EntryDoorDir = instance.TargetEntryDoorDir;
			mazeControllerEntryMatchProxy.ExitDoorDir = ((instance.CurrentSceneName == "Dust_Maze_Last_Hall") ? instance.TargetExitDoorName : instance.TargetExitDoorDir);
			MazeControllerEntryMatchProxy mazeControllerEntryMatchProxy2 = mazeControllerEntryMatchProxy;
			string targetEntryDoorDir = instance.TargetEntryDoorDir;
			MinMaxFloat fogRotationRange = ((targetEntryDoorDir == "left") ? new MinMaxFloat(0f, 0f) : ((!(targetEntryDoorDir == "right")) ? new MinMaxFloat(0f, 0f) : new MinMaxFloat(0f, 3.1416f)));
			mazeControllerEntryMatchProxy2.FogRotationRange = fogRotationRange;
			object native = ((ClassProxy)mazeControllerEntryMatchProxy).Native;
			Utils.Logger.Debug((object)$"Create Entry Match is {native}");
			__result = native;
			return false;
		}

		[HarmonyPatch("SubscribeDoorEntered")]
		[HarmonyPrefix]
		private static bool SubscribeDoorEntered(MazeController __instance, TransitionPoint door)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			TransitionPoint door2 = door;
			MazeController __instance2 = __instance;
			AlwaysMistController controller = AlwaysMistController.Instance;
			if (!Object.op_Implicit((Object)(object)controller))
			{
				return true;
			}
			if (!Configs.TrueAlwaysMist)
			{
				return true;
			}
			door2.OnBeforeTransition += (BeforeTransitionEvent)delegate
			{
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				PlayerData instance = PlayerData.instance;
				string name = ((Object)door2).name;
				if (!MazeControllerExtensions.get_isCapScene(__instance2))
				{
					if (door2.targetScene == MazeControllerExtensions.get_restSceneName(__instance2))
					{
						instance.EnteredMazeRestScene = true;
						instance.CorrectMazeDoorsEntered = MazeControllerExtensions.get_neededCorrectDoors(__instance2) - MazeControllerExtensions.get_restScenePoint(__instance2);
						instance.IncorrectMazeDoorsEntered = 0;
					}
					else if (instance.PreviousMazeTargetDoor != name)
					{
						if (MazeControllerExtensions.get_correctDoors(__instance2).Contains(door2))
						{
							instance.CorrectMazeDoorsEntered++;
							instance.IncorrectMazeDoorsEntered = 0;
						}
						else
						{
							instance.CorrectMazeDoorsEntered = 0;
							instance.IncorrectMazeDoorsEntered++;
							instance.EnteredMazeRestScene = false;
							bool flag = string.IsNullOrEmpty(controller.TargetEntryDoorDir) || controller.TargetEntryDoorDir == "left";
							if (instance.IncorrectMazeDoorsEntered >= MazeControllerExtensions.get_allowedIncorrectDoors(__instance2) && name.StartsWith(flag ? "right" : "left"))
							{
								door2.SetTargetScene("Dust_Maze_09_entrance");
								door2.entryPoint = (flag ? "left1" : "right1");
							}
						}
					}
				}
				instance.PreviousMazeTargetDoor = door2.entryPoint;
				Scene scene = ((Component)door2).gameObject.scene;
				instance.PreviousMazeScene = ((Scene)(ref scene)).name;
				instance.PreviousMazeDoor = name;
			};
			return false;
		}
	}
	[HarmonyPatch(typeof(TransitionPoint))]
	internal static class TransitionPointPatches
	{
		[HarmonyPatch("DoSceneTransition")]
		[HarmonyPrefix]
		private static void DoSceneTransition(TransitionPoint __instance, bool doFade)
		{
			if (Configs.TrueAlwaysMist)
			{
				AlwaysMistController instance = AlwaysMistController.Instance;
				if (Object.op_Implicit((Object)(object)instance) && instance.IsOutsideMaze && instance.ChangedTransitionPoint.TryGetValue(__instance, out string value))
				{
					instance.TargetSceneName = value;
					instance.TargetEntryDoorDir = Utils.GetEntryDoorDir(((Object)__instance).name) ?? Utils.GetDoorDirMatch(__instance.entryPoint) ?? "left";
					instance.TargetExitDoorDir = Utils.GetDoorDir(__instance.entryPoint) ?? "right";
					instance.TargetExitDoorName = __instance.entryPoint;
					instance.EnterDoorName = ((Object)__instance).name;
					Utils.Logger.Debug((object)("controller.TargetSceneName: " + instance.TargetSceneName));
					Utils.Logger.Debug((object)("controller.TargetEntryDoorDir: " + instance.TargetEntryDoorDir));
					Utils.Logger.Debug((object)("controller.TargetExitDoorDir: " + instance.TargetExitDoorDir));
					Utils.Logger.Debug((object)("controller.TargetExitDoorName: " + instance.TargetExitDoorName));
					Utils.Logger.Debug((object)("controller.EnterDoorName: " + instance.EnterDoorName));
					string targetEntryDoorDir = instance.TargetEntryDoorDir;
					string targetDoor = ((targetEntryDoorDir == "left") ? "right1" : ((!(targetEntryDoorDir == "right")) ? "right1" : "left1"));
					__instance.SetTargetDoor(targetDoor);
				}
			}
		}
	}
}
namespace AlwaysMist.Extensions
{
	[AccessExtensions]
	[AccessInstance<DesktopPlatform>]
	[AccessField<string>("saveDirPath")]
	public static class DesktopPlatformExtensions
	{
		public sealed class <>E__0
		{
			public string GetSavePath()
			{
				throw null;
			}
		}

		public sealed class <>E__1
		{
			public string saveDirPath
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}
		}

		[SpecialName]
		public static string GetSavePath(this DesktopPlatform instance)
		{
			string text = Path.Combine(get_saveDirPath(instance), "AlwaysMist");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			return text;
		}

		[SpecialName]
		public static string get_saveDirPath(DesktopPlatform instance)
		{
			return ObjectExtensions.GetFieldValue<string>((object)instance, "saveDirPath");
		}

		[SpecialName]
		public static void set_saveDirPath(DesktopPlatform instance, string value)
		{
			ObjectExtensions.SetFieldValue<string>((object)instance, "saveDirPath", value);
		}
	}
	[AccessExtensions]
	[AccessInstance<MazeController>]
	[AccessField<bool>("isCapScene")]
	[AccessField<List<TransitionPoint>>("entryDoors")]
	[AccessField<string[]>("sceneNames")]
	[AccessField<int>("neededCorrectDoors")]
	[AccessField<int>("allowedIncorrectDoors")]
	[AccessField<int>("restScenePoint")]
	[AccessField<string>("restSceneName")]
	[AccessField<string>("exitSceneName")]
	[AccessField<object[]>("entryMatchExit")]
	[AccessField<bool>("isActive")]
	[AccessField<List<TransitionPoint>>("correctDoors")]
	[PublicAPI]
	public static class MazeControllerExtensions
	{
		public sealed class <>E__0
		{
			public bool isCapScene
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public List<TransitionPoint> entryDoors
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public string[] sceneNames
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public int neededCorrectDoors
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public int allowedIncorrectDoors
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public int restScenePoint
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public string restSceneName
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public string exitSceneName
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public object[] entryMatchExit
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public bool isActive
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}

			public List<TransitionPoint> correctDoors
			{
				get
				{
					throw null;
				}
				set
				{
					throw null;
				}
			}
		}

		[SpecialName]
		public static bool get_isCapScene(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<bool>((object)instance, "isCapScene");
		}

		[SpecialName]
		public static void set_isCapScene(MazeController instance, bool value)
		{
			ObjectExtensions.SetFieldValue<bool>((object)instance, "isCapScene", value);
		}

		[SpecialName]
		public static List<TransitionPoint> get_entryDoors(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<List<TransitionPoint>>((object)instance, "entryDoors");
		}

		[SpecialName]
		public static void set_entryDoors(MazeController instance, List<TransitionPoint> value)
		{
			ObjectExtensions.SetFieldValue<List<TransitionPoint>>((object)instance, "entryDoors", value);
		}

		[SpecialName]
		public static string[] get_sceneNames(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<string[]>((object)instance, "sceneNames");
		}

		[SpecialName]
		public static void set_sceneNames(MazeController instance, string[] value)
		{
			ObjectExtensions.SetFieldValue<string[]>((object)instance, "sceneNames", value);
		}

		[SpecialName]
		public static int get_neededCorrectDoors(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<int>((object)instance, "neededCorrectDoors");
		}

		[SpecialName]
		public static void set_neededCorrectDoors(MazeController instance, int value)
		{
			ObjectExtensions.SetFieldValue<int>((object)instance, "neededCorrectDoors", value);
		}

		[SpecialName]
		public static int get_allowedIncorrectDoors(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<int>((object)instance, "allowedIncorrectDoors");
		}

		[SpecialName]
		public static void set_allowedIncorrectDoors(MazeController instance, int value)
		{
			ObjectExtensions.SetFieldValue<int>((object)instance, "allowedIncorrectDoors", value);
		}

		[SpecialName]
		public static int get_restScenePoint(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<int>((object)instance, "restScenePoint");
		}

		[SpecialName]
		public static void set_restScenePoint(MazeController instance, int value)
		{
			ObjectExtensions.SetFieldValue<int>((object)instance, "restScenePoint", value);
		}

		[SpecialName]
		public static string get_restSceneName(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<string>((object)instance, "restSceneName");
		}

		[SpecialName]
		public static void set_restSceneName(MazeController instance, string value)
		{
			ObjectExtensions.SetFieldValue<string>((object)instance, "restSceneName", value);
		}

		[SpecialName]
		public static string get_exitSceneName(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<string>((object)instance, "exitSceneName");
		}

		[SpecialName]
		public static void set_exitSceneName(MazeController instance, string value)
		{
			ObjectExtensions.SetFieldValue<string>((object)instance, "exitSceneName", value);
		}

		[SpecialName]
		public static object[] get_entryMatchExit(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<object[]>((object)instance, "entryMatchExit");
		}

		[SpecialName]
		public static void set_entryMatchExit(MazeController instance, object[] value)
		{
			ObjectExtensions.SetFieldValue<object[]>((object)instance, "entryMatchExit", value);
		}

		[SpecialName]
		public static bool get_isActive(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<bool>((object)instance, "isActive");
		}

		[SpecialName]
		public static void set_isActive(MazeController instance, bool value)
		{
			ObjectExtensions.SetFieldValue<bool>((object)instance, "isActive", value);
		}

		[SpecialName]
		public static List<TransitionPoint> get_correctDoors(MazeController instance)
		{
			return ObjectExtensions.GetFieldValue<List<TransitionPoint>>((object)instance, "correctDoors");
		}

		[SpecialName]
		public static void set_correctDoors(MazeController instance, List<TransitionPoint> value)
		{
			ObjectExtensions.SetFieldValue<List<TransitionPoint>>((object)instance, "correctDoors", value);
		}
	}
}
namespace AlwaysMist.Datas
{
	[Serializable]
	[JsonObject]
	public class AlwaysMistData
	{
		public string TargetSceneName = "";

		public string TargetEntryDoorDir = "";

		public string TargetExitDoorDir = "";

		public string TargetExitDoorName = "";

		public string EnterSceneName = "";

		public string EnterDoorName = "";

		public bool IsEnteredMaze;

		public int LastRandomValue = -1;
	}
}
namespace AlwaysMist.Behaviour
{
	public class AlwaysMistController : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <OnSceneLoadedDelay>d__49 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public AlwaysMistController <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				AlwaysMistController alwaysMistController = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					alwaysMistController.EnterMazeHandle();
					if (Configs.TrueAlwaysMist)
					{
						if (alwaysMistController.IsOutsideMaze)
						{
							alwaysMistController.EnterSceneName = alwaysMistController.CurrentSceneName;
							alwaysMistController.ChangeAllTransitionScene();
						}
						else
						{
							string currentSceneName = alwaysMistController.CurrentSceneName;
							if (!(currentSceneName == "Dust_Maze_09_entrance"))
							{
								if (currentSceneName == "Dust_Maze_Last_Hall")
								{
									Utils.Logger.Debug((object)("TargetSceneName: " + alwaysMistController.TargetSceneName));
									Utils.Logger.Debug((object)("TargetExitDoorDir: " + alwaysMistController.TargetExitDoorDir));
									if (!string.IsNullOrEmpty(alwaysMistController.TargetSceneName))
									{
										alwaysMistController.FixExitTransition();
									}
								}
							}
							else
							{
								Utils.Logger.Debug((object)("EnterSceneName: " + alwaysMistController.EnterSceneName));
								Utils.Logger.Debug((object)("EnterDoorName: " + alwaysMistController.EnterDoorName));
								string targetEntryDoorDir = alwaysMistController.TargetEntryDoorDir;
								if (!(targetEntryDoorDir == "left"))
								{
									if (targetEntryDoorDir == "right")
									{
										alwaysMistController.ChangeTransitionScene("left1", alwaysMistController.EnterSceneName, alwaysMistController.EnterDoorName);
									}
								}
								else
								{
									alwaysMistController.ChangeTransitionScene("right1", alwaysMistController.EnterSceneName, alwaysMistController.EnterDoorName);
								}
							}
						}
					}
					else
					{
						string currentSceneName = alwaysMistController.CurrentSceneName;
						if ((currentSceneName == "Shadow_04" || currentSceneName == "Dust_05") ? true : false)
						{
							alwaysMistController.EnterSceneName = alwaysMistController.CurrentSceneName;
							alwaysMistController.ChangeTransitionScene("left1");
						}
					}
					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();
			}
		}

		private const string ChangeScene = "Shadow_04";

		private const string ChangeScene2 = "Dust_05";

		public const string LeftTransitionPoint = "left1";

		public const string RightTransitionPoint = "right1";

		internal const string MazeEntranceSceneName = "Dust_Maze_09_entrance";

		internal const string MazeExitSceneName = "Dust_Maze_Last_Hall";

		private const string MazeRestSceneName = "Dust_Maze_crossing";

		private static readonly string[] SceneNames = new string[8] { "Dust_Maze_01", "Dust_Maze_02", "Dust_Maze_03", "Dust_Maze_04", "Dust_Maze_05", "Dust_Maze_06", "Dust_Maze_07", "Dust_Maze_08" };

		public readonly Dictionary<TransitionPoint, string> ChangedTransitionPoint = new Dictionary<TransitionPoint, string>();

		public readonly Dictionary<int, AlwaysMistData> SaveDatas = new Dictionary<int, AlwaysMistData>();

		private Scene _currentScene;

		public static AlwaysMistController? Instance { get; private set; }

		public string CurrentSceneName { get; private set; } = "";


		public string TargetSceneName
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.TargetSceneName;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.TargetSceneName = value;
			}
		}

		public string TargetEntryDoorDir
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.TargetEntryDoorDir;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.TargetEntryDoorDir = value;
			}
		}

		public string TargetExitDoorDir
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.TargetExitDoorDir;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.TargetExitDoorDir = value;
			}
		}

		public string TargetExitDoorName
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.TargetExitDoorName;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.TargetExitDoorName = value;
			}
		}

		public string EnterSceneName
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.EnterSceneName;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.EnterSceneName = value;
			}
		}

		public string EnterDoorName
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.EnterDoorName;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.EnterDoorName = value;
			}
		}

		public bool IsEnteredMaze
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.IsEnteredMaze;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.IsEnteredMaze = value;
			}
		}

		public bool IsOutsideMaze
		{
			get
			{
				if (!IsEnteredMaze && CurrentSceneName != "Dust_Maze_Last_Hall" && CurrentSceneName != "Dust_Maze_crossing")
				{
					return !SceneNames.Contains(CurrentSceneName);
				}
				return false;
			}
		}

		public int LastRandomValue
		{
			get
			{
				GetSaveData(out AlwaysMistData data);
				return data.LastRandomValue;
			}
			set
			{
				GetSaveData(out AlwaysMistData data);
				data.LastRandomValue = value;
			}
		}

		private void Awake()
		{
			Instance = this;
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		public void GetSaveData(out AlwaysMistData data)
		{
			GameManager instance = GameManager.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				data = new AlwaysMistData();
				return;
			}
			if (!SaveDatas.ContainsKey(instance.profileID))
			{
				SaveDatas.Add(instance.profileID, new AlwaysMistData());
			}
			data = SaveDatas[instance.profileID];
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0029: 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)
			Utils.Logger.Debug((object)("OnSceneLoaded: " + ((Scene)(ref scene)).name));
			CurrentSceneName = ((Scene)(ref scene)).name;
			_currentScene = scene;
			TurnOnRestBench();
			((MonoBehaviour)this).StartCoroutine(OnSceneLoadedDelay());
		}

		[IteratorStateMachine(typeof(<OnSceneLoadedDelay>d__49))]
		private IEnumerator OnSceneLoadedDelay()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnSceneLoadedDelay>d__49(0)
			{
				<>4__this = this
			};
		}

		private void TurnOnRestBench()
		{
			if (CurrentSceneName != "Dust_Maze_09_entrance" || (!Configs.RestBenchInMist && !Configs.TrueAlwaysMist))
			{
				return;
			}
			RestBench[] array = Object.FindObjectsByType<RestBench>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			Utils.Logger.Debug((object)$"Find RestBenchs: {array}");
			RestBench[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				GameObject gameObject = ((Component)array2[i]).gameObject;
				if (!(gameObject.tag != "RespawnPoint"))
				{
					Utils.Logger.Debug((object)$"Got RestBench: {gameObject}");
					if (Object.op_Implicit((Object)(object)gameObject) && !gameObject.activeSelf)
					{
						gameObject.SetActive(true);
					}
				}
			}
		}

		private void EnterMazeHandle()
		{
			if (CurrentSceneName == "Dust_Maze_09_entrance")
			{
				IsEnteredMaze = true;
			}
			else if (IsEnteredMaze && !SceneNames.Contains(CurrentSceneName) && !(CurrentSceneName == "Dust_Maze_09_entrance") && !(CurrentSceneName == "Dust_Maze_Last_Hall") && !(CurrentSceneName == "Dust_Maze_crossing"))
			{
				IsEnteredMaze = false;
				LastRandomValue = -1;
				TargetSceneName = "";
				TargetEntryDoorDir = "";
				TargetExitDoorDir = "";
			}
		}

		private void ChangeTransitionScene(string doorName, string changeScene = "Dust_Maze_09_entrance", string? exitDoorName = null)
		{
			string doorName2 = doorName;
			TransitionPoint val = ((IEnumerable<TransitionPoint>)TransitionPoint.TransitionPoints).FirstOrDefault((Func<TransitionPoint, bool>)((TransitionPoint door) => ((Component)door).gameObject.scene == _currentScene && ((Object)((Component)door).gameObject).name == doorName2));
			if (Object.op_Implicit((Object)(object)val))
			{
				string targetScene = val.targetScene;
				Utils.Logger.Info((object)("Target Scene: " + targetScene));
				if (targetScene != changeScene)
				{
					Utils.Logger.Info((object)("Change target scene to: " + changeScene));
					val.SetTargetScene(changeScene);
				}
				if (!string.IsNullOrEmpty(exitDoorName) && val.entryPoint != exitDoorName)
				{
					val.SetTargetDoor(exitDoorName);
				}
				if (Configs.ResetMazeSaveData || Configs.TrueAlwaysMist)
				{
					MazeController.ResetSaveData();
				}
			}
		}

		private void FixExitTransition()
		{
			TransitionPoint val = ((IEnumerable<TransitionPoint>)TransitionPoint.TransitionPoints).FirstOrDefault((Func<TransitionPoint, bool>)((TransitionPoint door) => ((Component)door).gameObject.scene == _currentScene && door.targetScene == TargetSceneName));
			if (Object.op_Implicit((Object)(object)val))
			{
				val.SetTargetDoor(TargetExitDoorName);
			}
		}

		private void ChangeAllTransitionScene()
		{
			List<TransitionPoint> list = TransitionPoint.TransitionPoints.Where((TransitionPoint door) => ((Component)door).gameObject.scene == _currentScene).ToList();
			if (list.Count < 1)
			{
				return;
			}
			foreach (TransitionPoint item in list)
			{
				string targetScene = item.targetScene;
				Utils.Logger.Info((object)("Target Scene: " + targetScene));
				if ((!(targetScene == "Dust_Maze_09_entrance") && !(targetScene == "Dust_Maze_Last_Hall")) || 1 == 0)
				{
					Utils.Logger.Info((object)"Change target scene to: Dust_Maze_09_entrance");
					item.SetTargetScene("Dust_Maze_09_entrance");
					if (!ChangedTransitionPoint.ContainsKey(item))
					{
						ChangedTransitionPoint.Add(item, targetScene);
					}
				}
			}
			if (Configs.ResetMazeSaveData || Configs.TrueAlwaysMist)
			{
				MazeController.ResetSaveData();
			}
		}
	}
}