Decompiled source of Radiance v0.1.0

Radiance.dll

Decompiled 3 days 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 System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using GlobalEnums;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using Radiance.Behaviours.Common;
using Radiance.Managers;
using Radiance.Patches;
using Radiance.Tools;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Radiance")]
[assembly: AssemblyConfiguration("debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+b096460ed9ee5d84154f6cf5e5ed6e529bfff55f")]
[assembly: AssemblyProduct("Radiance")]
[assembly: AssemblyTitle("Radiance")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xieedechunniunai/Radiance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Radiance
{
	[BepInPlugin("io.github.xieedechunniunai.radiance", "Radiance", "0.1.0")]
	public class RadiancePlugin : BaseUnityPlugin
	{
		private Harmony? _harmony;

		private GameObject? _radianceManager;

		public const string Id = "io.github.xieedechunniunai.radiance";

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

		public static string Name => "Radiance";

		public static string Version => "0.1.0";

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			_harmony = new Harmony("io.github.xieedechunniunai.radiance");
			_harmony.PatchAll(typeof(FsmFixPatches));
			_harmony.PatchAll(typeof(GodfinderIconPatches));
			_harmony.PatchAll(typeof(RadiancePatches));
			_harmony.PatchAll(typeof(MemoryScenePatches));
			_harmony.PatchAll(typeof(SceneTransitionPatches));
			Log.Info("Harmony 补丁已应用");
			SceneManager.activeSceneChanged += OnSceneChange;
			Log.Info("Plugin " + Name + " (io.github.xieedechunniunai.radiance) has loaded!");
		}

		private void OnSceneChange(Scene oldScene, Scene newScene)
		{
			if (((Scene)(ref oldScene)).name == "Menu_Title")
			{
				CreateManager();
			}
		}

		private void CreateManager()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			_radianceManager = GameObject.Find("RadianceManager");
			if ((Object)(object)_radianceManager == (Object)null)
			{
				_radianceManager = new GameObject("RadianceManager");
				Object.DontDestroyOnLoad((Object)(object)_radianceManager);
				AssetManager assetManager = _radianceManager.AddComponent<AssetManager>();
				_radianceManager.AddComponent<RadianceSceneManager>();
				Log.Info("创建持久化管理器");
				((MonoBehaviour)this).StartCoroutine(assetManager.PreloadAllAssets());
			}
			else
			{
				Log.Info("找到已存在的持久化管理器");
			}
		}

		private void OnDestroy()
		{
			SceneManager.activeSceneChanged -= OnSceneChange;
		}
	}
}
namespace Radiance.Tools
{
	public static class FsmAnalyzer
	{
		private static readonly string DefaultOutputDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BepInEx", "plugins", "Radiance", "temp");

		public static void AnalyzeAllFsms(GameObject gameObject, string? outputDir = null)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				Log.Error("[FsmAnalyzer] GameObject 为空");
				return;
			}
			string text = outputDir ?? DefaultOutputDir;
			Directory.CreateDirectory(text);
			PlayMakerFSM[] components = gameObject.GetComponents<PlayMakerFSM>();
			Log.Info($"[FsmAnalyzer] 开始分析 {((Object)gameObject).name} 的 {components.Length} 个 FSM");
			string text2 = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
			string text3 = SanitizeFileName(((Object)gameObject).name);
			PlayMakerFSM[] array = components;
			foreach (PlayMakerFSM val in array)
			{
				string text4 = SanitizeFileName(val.FsmName);
				string text5 = text3 + "_" + text4 + "_" + text2 + ".txt";
				string outputPath = Path.Combine(text, text5);
				WriteFsmReport(val, outputPath);
				Log.Info("[FsmAnalyzer] 已输出: " + text5);
			}
			string outputPath2 = Path.Combine(text, text3 + "_Summary_" + text2 + ".txt");
			WriteSummaryReport(gameObject, components, outputPath2);
			Log.Info("[FsmAnalyzer] 已输出汇总: " + text3 + "_Summary_" + text2 + ".txt");
		}

		public static void WriteFsmReport(PlayMakerFSM fsm, string outputPath)
		{
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fsm == (Object)null)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("================================================================================");
			stringBuilder.AppendLine("FSM 报告: " + fsm.FsmName);
			stringBuilder.AppendLine("GameObject: " + ((Object)((Component)fsm).gameObject).name);
			stringBuilder.AppendLine("路径: " + GetGameObjectPath(((Component)fsm).gameObject));
			stringBuilder.AppendLine($"生成时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
			stringBuilder.AppendLine("================================================================================");
			stringBuilder.AppendLine("当前状态: " + fsm.ActiveStateName);
			stringBuilder.AppendLine("起始状态: " + fsm.Fsm.StartState);
			FsmState[] fsmStates = fsm.FsmStates;
			stringBuilder.AppendLine($"\n--- 所有状态 ({fsmStates.Length}个) ---");
			FsmState[] array = fsmStates;
			foreach (FsmState val in array)
			{
				stringBuilder.AppendLine("  - " + val.Name);
			}
			FsmEvent[] fsmEvents = fsm.FsmEvents;
			stringBuilder.AppendLine($"\n--- 所有事件 ({fsmEvents.Length}个) ---");
			FsmEvent[] array2 = fsmEvents;
			foreach (FsmEvent val2 in array2)
			{
				stringBuilder.AppendLine($"  - {val2.Name} (IsGlobal: {val2.IsGlobal})");
			}
			FsmTransition[] fsmGlobalTransitions = fsm.FsmGlobalTransitions;
			stringBuilder.AppendLine($"\n--- 全局转换 ({fsmGlobalTransitions.Length}个) ---");
			FsmTransition[] array3 = fsmGlobalTransitions;
			foreach (FsmTransition val3 in array3)
			{
				FsmEvent fsmEvent = val3.FsmEvent;
				stringBuilder.AppendLine("  " + ((fsmEvent != null) ? fsmEvent.Name : null) + " -> " + val3.toState);
			}
			stringBuilder.AppendLine("\n================================================================================");
			stringBuilder.AppendLine("各状态详情");
			stringBuilder.AppendLine("================================================================================");
			FsmState[] array4 = fsmStates;
			foreach (FsmState val4 in array4)
			{
				stringBuilder.AppendLine("\n【状态: " + val4.Name + "】");
				stringBuilder.AppendLine("  转换:");
				if (val4.Transitions != null && val4.Transitions.Length != 0)
				{
					FsmTransition[] transitions = val4.Transitions;
					foreach (FsmTransition val5 in transitions)
					{
						FsmEvent fsmEvent2 = val5.FsmEvent;
						stringBuilder.AppendLine("    " + (((fsmEvent2 != null) ? fsmEvent2.Name : null) ?? "(null)") + " -> " + val5.toState);
					}
				}
				else
				{
					stringBuilder.AppendLine("    (无转换)");
				}
				FsmStateAction[] actions = val4.Actions;
				stringBuilder.AppendLine($"  动作 ({((actions != null) ? actions.Length : 0)}个):");
				if (val4.Actions != null && val4.Actions.Length != 0)
				{
					for (int n = 0; n < val4.Actions.Length; n++)
					{
						FsmStateAction val6 = val4.Actions[n];
						if (val6 == null)
						{
							stringBuilder.AppendLine($"    [{n}] (null)");
							continue;
						}
						stringBuilder.AppendLine($"    [{n}] {((object)val6).GetType().Name}");
						AnalyzeActionVariables(stringBuilder, val6, n);
					}
				}
				else
				{
					stringBuilder.AppendLine("    (无动作)");
				}
			}
			FsmVariables fsmVariables = fsm.FsmVariables;
			stringBuilder.AppendLine("\n================================================================================");
			stringBuilder.AppendLine("FSM 变量");
			stringBuilder.AppendLine("================================================================================");
			stringBuilder.AppendLine($"Bool: {fsmVariables.BoolVariables.Length}, Int: {fsmVariables.IntVariables.Length}, Float: {fsmVariables.FloatVariables.Length}, String: {fsmVariables.StringVariables.Length}");
			stringBuilder.AppendLine($"GameObject: {fsmVariables.GameObjectVariables.Length}, Object: {fsmVariables.ObjectVariables.Length}, Vector3: {fsmVariables.Vector3Variables.Length}");
			stringBuilder.AppendLine("\n  Float 变量:");
			FsmFloat[] floatVariables = fsmVariables.FloatVariables;
			foreach (FsmFloat val7 in floatVariables)
			{
				stringBuilder.AppendLine($"    {((NamedVariable)val7).Name} = {val7.Value}");
			}
			stringBuilder.AppendLine("\n  Bool 变量:");
			FsmBool[] boolVariables = fsmVariables.BoolVariables;
			foreach (FsmBool val8 in boolVariables)
			{
				stringBuilder.AppendLine($"    {((NamedVariable)val8).Name} = {val8.Value}");
			}
			stringBuilder.AppendLine("\n  Int 变量:");
			FsmInt[] intVariables = fsmVariables.IntVariables;
			foreach (FsmInt val9 in intVariables)
			{
				stringBuilder.AppendLine($"    {((NamedVariable)val9).Name} = {val9.Value}");
			}
			stringBuilder.AppendLine("\n  String 变量:");
			FsmString[] stringVariables = fsmVariables.StringVariables;
			foreach (FsmString val10 in stringVariables)
			{
				stringBuilder.AppendLine("    " + ((NamedVariable)val10).Name + " = \"" + val10.Value + "\"");
			}
			stringBuilder.AppendLine("\n  GameObject 变量:");
			FsmGameObject[] gameObjectVariables = fsmVariables.GameObjectVariables;
			foreach (FsmGameObject val11 in gameObjectVariables)
			{
				string text = (((Object)(object)val11.Value != (Object)null) ? ((Object)val11.Value).name : "(null)");
				stringBuilder.AppendLine("    " + ((NamedVariable)val11).Name + " = " + text);
			}
			stringBuilder.AppendLine("\n  Vector3 变量:");
			FsmVector3[] vector3Variables = fsmVariables.Vector3Variables;
			foreach (FsmVector3 val12 in vector3Variables)
			{
				stringBuilder.AppendLine($"    {((NamedVariable)val12).Name} = {val12.Value}");
			}
			Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? ".");
			File.WriteAllText(outputPath, stringBuilder.ToString(), Encoding.UTF8);
		}

		private static void WriteSummaryReport(GameObject gameObject, PlayMakerFSM[] fsms, string outputPath)
		{
			GameObject gameObject2 = gameObject;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("================================================================================");
			stringBuilder.AppendLine("FSM 汇总报告: " + ((Object)gameObject2).name);
			stringBuilder.AppendLine("路径: " + GetGameObjectPath(gameObject2));
			stringBuilder.AppendLine($"生成时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
			stringBuilder.AppendLine($"FSM 数量: {fsms.Length}");
			stringBuilder.AppendLine("================================================================================");
			foreach (PlayMakerFSM val in fsms)
			{
				stringBuilder.AppendLine("\n【" + val.FsmName + "】");
				stringBuilder.AppendLine($"  状态数: {val.FsmStates.Length}");
				stringBuilder.AppendLine($"  事件数: {val.FsmEvents.Length}");
				stringBuilder.AppendLine("  起始状态: " + val.Fsm.StartState);
				stringBuilder.AppendLine("  状态列表:");
				FsmState[] fsmStates = val.FsmStates;
				foreach (FsmState val2 in fsmStates)
				{
					FsmStateAction[] actions = val2.Actions;
					int num = ((actions != null) ? actions.Length : 0);
					FsmTransition[] transitions = val2.Transitions;
					int num2 = ((transitions != null) ? transitions.Length : 0);
					stringBuilder.AppendLine($"    - {val2.Name} ({num} actions, {num2} transitions)");
				}
			}
			stringBuilder.AppendLine("\n================================================================================");
			stringBuilder.AppendLine("子对象 FSM");
			stringBuilder.AppendLine("================================================================================");
			PlayMakerFSM[] componentsInChildren = gameObject2.GetComponentsInChildren<PlayMakerFSM>(true);
			PlayMakerFSM[] array = componentsInChildren.Where((PlayMakerFSM f) => (Object)(object)((Component)f).gameObject != (Object)(object)gameObject2).ToArray();
			stringBuilder.AppendLine($"子对象 FSM 数量: {array.Length}");
			PlayMakerFSM[] array2 = array;
			foreach (PlayMakerFSM val3 in array2)
			{
				stringBuilder.AppendLine($"  {GetGameObjectPath(((Component)val3).gameObject)} -> {val3.FsmName} ({val3.FsmStates.Length} states)");
			}
			Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? ".");
			File.WriteAllText(outputPath, stringBuilder.ToString(), Encoding.UTF8);
		}

		private static void AnalyzeActionVariables(StringBuilder sb, FsmStateAction action, int actionIndex)
		{
			try
			{
				Type type = ((object)action).GetType();
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
				FieldInfo[] array = fields;
				foreach (FieldInfo fieldInfo in array)
				{
					object value = fieldInfo.GetValue(action);
					if (value != null)
					{
						string text = FormatValue(value, action);
						sb.AppendLine("        " + fieldInfo.Name + ": " + text);
					}
				}
			}
			catch (Exception ex)
			{
				sb.AppendLine("        (分析变量时出错: " + ex.Message + ")");
			}
		}

		private static string FormatValue(object value, FsmStateAction action)
		{
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			FsmFloat val = (FsmFloat)((value is FsmFloat) ? value : null);
			string result;
			if (val == null)
			{
				FsmInt val2 = (FsmInt)((value is FsmInt) ? value : null);
				if (val2 == null)
				{
					FsmBool val3 = (FsmBool)((value is FsmBool) ? value : null);
					if (val3 == null)
					{
						FsmString val4 = (FsmString)((value is FsmString) ? value : null);
						if (val4 == null)
						{
							FsmEvent val5 = (FsmEvent)((value is FsmEvent) ? value : null);
							if (val5 == null)
							{
								FsmGameObject val6 = (FsmGameObject)((value is FsmGameObject) ? value : null);
								if (val6 == null)
								{
									FsmOwnerDefault val7 = (FsmOwnerDefault)((value is FsmOwnerDefault) ? value : null);
									if (val7 == null)
									{
										FsmColor val8 = (FsmColor)((value is FsmColor) ? value : null);
										if (val8 == null)
										{
											FsmVector3 val9 = (FsmVector3)((value is FsmVector3) ? value : null);
											if (val9 == null)
											{
												FsmObject val10 = (FsmObject)((value is FsmObject) ? value : null);
												if (val10 == null)
												{
													GameObject val11 = (GameObject)((value is GameObject) ? value : null);
													result = ((val11 == null) ? $"{value} ({value.GetType().Name})" : ("GO:" + ((Object)val11).name));
												}
												else
												{
													result = (((NamedVariable)val10).UseVariable ? ("[Obj变量:" + ((NamedVariable)val10).Name + "]") : ("Obj:" + (((object)val10.Value)?.GetType().Name ?? "(null)")));
												}
											}
											else
											{
												result = (((NamedVariable)val9).UseVariable ? ("[V3变量:" + ((NamedVariable)val9).Name + "]") : $"({val9.Value.x:F2},{val9.Value.y:F2},{val9.Value.z:F2})");
											}
										}
										else
										{
											result = (((NamedVariable)val8).UseVariable ? ("[Color变量:" + ((NamedVariable)val8).Name + "]") : $"RGBA({val8.Value.r:F2},{val8.Value.g:F2},{val8.Value.b:F2},{val8.Value.a:F2})");
										}
									}
									else
									{
										result = FormatOwnerDefault(val7, action);
									}
								}
								else
								{
									result = (((NamedVariable)val6).UseVariable ? ("[GO变量:" + ((NamedVariable)val6).Name + "]") : (((Object)(object)val6.Value != (Object)null) ? ("GO:" + ((Object)val6.Value).name) : "GO:(null)"));
								}
							}
							else
							{
								result = "[Event:" + val5.Name + "]";
							}
						}
						else
						{
							result = (((NamedVariable)val4).UseVariable ? ("[String变量:" + ((NamedVariable)val4).Name + "]") : ("\"" + val4.Value + "\""));
						}
					}
					else
					{
						result = (((NamedVariable)val3).UseVariable ? ("[Bool变量:" + ((NamedVariable)val3).Name + "]") : $"{val3.Value}");
					}
				}
				else
				{
					result = (((NamedVariable)val2).UseVariable ? ("[Int变量:" + ((NamedVariable)val2).Name + "]") : $"{val2.Value}");
				}
			}
			else
			{
				result = (((NamedVariable)val).UseVariable ? ("[Float变量:" + ((NamedVariable)val).Name + "]") : $"{val.Value}");
			}
			if (1 == 0)
			{
			}
			return result;
		}

		private static string FormatOwnerDefault(FsmOwnerDefault od, FsmStateAction action)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			try
			{
				OwnerDefaultOption ownerOption = od.OwnerOption;
				if ((int)ownerOption == 0)
				{
					return "[Owner]";
				}
				if (od.GameObject != null && (Object)(object)od.GameObject.Value != (Object)null)
				{
					return "GO:" + ((Object)od.GameObject.Value).name;
				}
				if (od.GameObject != null && ((NamedVariable)od.GameObject).UseVariable)
				{
					return "[GO变量:" + ((NamedVariable)od.GameObject).Name + "]";
				}
			}
			catch
			{
			}
			return "[OwnerDefault]";
		}

		private static string GetGameObjectPath(GameObject obj)
		{
			if ((Object)(object)obj == (Object)null)
			{
				return "(null)";
			}
			string text = ((Object)obj).name;
			Transform parent = obj.transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private static string SanitizeFileName(string name)
		{
			char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
			return string.Join("_", name.Split(invalidFileNameChars, StringSplitOptions.RemoveEmptyEntries));
		}
	}
	public static class FsmStateBuilder
	{
		public struct StateDefinition
		{
			public string Name;

			public string Description;

			public StateDefinition(string name, string description = "")
			{
				Name = name;
				Description = description;
			}
		}

		public static FsmState CreateState(Fsm fsm, string name, string description = "")
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return new FsmState(fsm)
			{
				Name = name,
				Description = description
			};
		}

		public static FsmState CreateState(PlayMakerFSM pmFsm, string name, string description = "")
		{
			return CreateState(pmFsm.Fsm, name, description);
		}

		public static FsmState CreateAndAddState(PlayMakerFSM pmFsm, string name, string description = "")
		{
			FsmState val = CreateState(pmFsm.Fsm, name, description);
			AddStateToFsm(pmFsm, val);
			return val;
		}

		public static void AddStateToFsm(PlayMakerFSM pmFsm, FsmState state)
		{
			List<FsmState> list = pmFsm.Fsm.States.ToList();
			list.Add(state);
			pmFsm.Fsm.States = list.ToArray();
		}

		public static void AddStatesToFsm(PlayMakerFSM pmFsm, params FsmState[] statesToAdd)
		{
			List<FsmState> list = pmFsm.Fsm.States.ToList();
			list.AddRange(statesToAdd);
			pmFsm.Fsm.States = list.ToArray();
		}

		public static FsmState[] CreateStates(Fsm fsm, params StateDefinition[] definitions)
		{
			FsmState[] array = (FsmState[])(object)new FsmState[definitions.Length];
			for (int i = 0; i < definitions.Length; i++)
			{
				array[i] = CreateState(fsm, definitions[i].Name, definitions[i].Description);
			}
			return array;
		}

		public static FsmState[] CreateStates(Fsm fsm, params (string name, string description)[] definitions)
		{
			FsmState[] array = (FsmState[])(object)new FsmState[definitions.Length];
			for (int i = 0; i < definitions.Length; i++)
			{
				array[i] = CreateState(fsm, definitions[i].name, definitions[i].description);
			}
			return array;
		}

		public static FsmState[] CreateAndAddStates(PlayMakerFSM pmFsm, params (string name, string description)[] definitions)
		{
			FsmState[] array = CreateStates(pmFsm.Fsm, definitions);
			AddStatesToFsm(pmFsm, array);
			return array;
		}

		public static FsmState? FindState(PlayMakerFSM pmFsm, string stateName)
		{
			string stateName2 = stateName;
			return ((IEnumerable<FsmState>)pmFsm.FsmStates).FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.Name == stateName2));
		}

		public static bool StateExists(PlayMakerFSM pmFsm, string stateName)
		{
			string stateName2 = stateName;
			return pmFsm.FsmStates.Any((FsmState s) => s.Name == stateName2);
		}

		public static FsmState GetOrCreateState(PlayMakerFSM pmFsm, string name, string description = "")
		{
			FsmState val = FindState(pmFsm, name);
			if (val != null)
			{
				return val;
			}
			return CreateAndAddState(pmFsm, name, description);
		}

		public static FsmTransition CreateFinishedTransition(FsmState targetState)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return new FsmTransition
			{
				FsmEvent = FsmEvent.Finished,
				toState = targetState.Name,
				toFsmState = targetState
			};
		}

		public static FsmTransition CreateTransition(FsmEvent fsmEvent, FsmState targetState)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			return new FsmTransition
			{
				FsmEvent = fsmEvent,
				toState = targetState.Name,
				toFsmState = targetState
			};
		}

		public static void SetFinishedTransition(FsmState state, FsmState targetState)
		{
			state.Transitions = (FsmTransition[])(object)new FsmTransition[1] { CreateFinishedTransition(targetState) };
		}

		public static void AddTransition(FsmState state, FsmTransition transition)
		{
			List<FsmTransition> list = state.Transitions?.ToList() ?? new List<FsmTransition>();
			list.Add(transition);
			state.Transitions = list.ToArray();
		}

		public static FsmEvent GetOrCreateEvent(PlayMakerFSM pmFsm, string eventName)
		{
			FsmEvent fsmEvent = FsmEvent.GetFsmEvent(eventName);
			List<FsmEvent> list = pmFsm.Fsm.Events.ToList();
			if (!list.Contains(fsmEvent))
			{
				list.Add(fsmEvent);
				pmFsm.Fsm.Events = list.ToArray();
			}
			return fsmEvent;
		}

		public static FsmEvent[] RegisterEvents(PlayMakerFSM pmFsm, params string[] eventNames)
		{
			List<FsmEvent> list = pmFsm.Fsm.Events.ToList();
			FsmEvent[] array = (FsmEvent[])(object)new FsmEvent[eventNames.Length];
			for (int i = 0; i < eventNames.Length; i++)
			{
				array[i] = FsmEvent.GetFsmEvent(eventNames[i]);
				if (!list.Contains(array[i]))
				{
					list.Add(array[i]);
				}
			}
			pmFsm.Fsm.Events = list.ToArray();
			return array;
		}

		public static void ReinitializeFsm(PlayMakerFSM pmFsm)
		{
		}

		public static void ReinitializeFsmVariables(PlayMakerFSM pmFsm)
		{
			pmFsm.FsmVariables.Init();
		}
	}
	internal static class Log
	{
		private static ManualLogSource? _logSource;

		private static string LogPrefix => $"[{Assembly.GetExecutingAssembly().GetName().Version}] ";

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object debug)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogDebug((object)(LogPrefix + debug));
			}
		}

		internal static void Info(object info)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogInfo((object)(LogPrefix + info));
			}
		}

		internal static void Warn(object warning)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogWarning((object)(LogPrefix + warning));
			}
		}

		internal static void Error(object error)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogError((object)(LogPrefix + error));
			}
		}
	}
}
namespace Radiance.Patches
{
	[HarmonyPatch]
	internal static class FsmFixPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayMakerFSM), "OnEnable")]
		private static void FixFsmEventHandlersOnEnable(PlayMakerFSM __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			try
			{
				Fsm fsm = __instance.Fsm;
				if (fsm == null || fsm.States == null)
				{
					return;
				}
				FsmState[] states = fsm.States;
				foreach (FsmState val in states)
				{
					if (((val != null) ? val.Actions : null) == null)
					{
						continue;
					}
					FsmStateAction[] actions = val.Actions;
					foreach (FsmStateAction val2 in actions)
					{
						if (val2 != null)
						{
							try
							{
								val2.OnPreprocess();
							}
							catch
							{
							}
						}
					}
				}
				__instance.AddEventHandlerComponents();
			}
			catch (Exception ex)
			{
				Log.Debug("[FsmFixPatch] 修复 FSM 事件处理组件失败: " + ((Object)((Component)__instance).gameObject).name + "/" + __instance.FsmName + " - " + ex.Message);
			}
		}
	}
	[HarmonyPatch]
	internal static class GodfinderIconPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShowGodfinderIcon), "OnEnter")]
		private static bool SkipShowGodfinderIcon()
		{
			return !RadianceSceneManager.IsInCustomScene;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GodfinderIcon), "Show")]
		private static bool SkipHideGodfinderIcon()
		{
			return !RadianceSceneManager.IsInCustomScene;
		}
	}
	[HarmonyPatch]
	internal static class MemoryScenePatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameManager), "IsMemoryScene", new Type[] { })]
		private static void ForceMemoryInCustomScene(ref bool __result)
		{
			if (RadianceSceneManager.IsInCustomScene)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch]
	internal static class RadiancePatches
	{
		public delegate void FsmHandler(PlayMakerFSM fsm);

		private const string TargetGameObjectName = "Absolute Radiance";

		public static bool EnableFsmAnalysis = true;

		private static readonly HashSet<int> AnalyzedInstances = new HashSet<int>();

		private static readonly Dictionary<string, FsmHandler> FsmHandlers = new Dictionary<string, FsmHandler> { { "Control", HandleControlFsm } };

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayMakerFSM), "Start")]
		private static void MountRadianceBehaviours(PlayMakerFSM __instance)
		{
			if ((Object)(object)__instance == (Object)null || ((Object)((Component)__instance).gameObject).name != "Absolute Radiance" || !FsmHandlers.TryGetValue(__instance.FsmName, out FsmHandler value))
			{
				return;
			}
			Log.Info("[RadiancePatch] 发现目标 FSM: Absolute Radiance/" + __instance.FsmName);
			try
			{
				value(__instance);
			}
			catch (Exception ex)
			{
				Log.Error("[RadiancePatch] 处理 FSM [" + __instance.FsmName + "] 失败: " + ex.Message);
			}
		}

		private static void HandleControlFsm(PlayMakerFSM fsm)
		{
			PlayMakerFSM fsm2 = fsm;
			MountBehaviour(fsm2, delegate(RadianceReturnOnDialogueBehavior b)
			{
				b.Initialize(fsm2);
			});
		}

		private static T MountBehaviour<T>(PlayMakerFSM fsm, Action<T>? initializer = null) where T : MonoBehaviour
		{
			T val = ((Component)fsm).gameObject.GetComponent<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)fsm).gameObject.AddComponent<T>();
				Log.Info("[RadiancePatch] 已挂载 " + typeof(T).Name + " 组件");
			}
			initializer?.Invoke(val);
			return val;
		}

		public static void RegisterFsmHandler(string fsmName, FsmHandler handler)
		{
			if (FsmHandlers.ContainsKey(fsmName))
			{
				Log.Warn("[RadiancePatch] FSM 处理器 [" + fsmName + "] 已存在,将被覆盖");
			}
			FsmHandlers[fsmName] = handler;
			Log.Info("[RadiancePatch] 已注册 FSM 处理器: " + fsmName);
		}

		public static void UnregisterFsmHandler(string fsmName)
		{
			if (FsmHandlers.Remove(fsmName))
			{
				Log.Info("[RadiancePatch] 已注销 FSM 处理器: " + fsmName);
			}
		}
	}
	[HarmonyPatch]
	internal static class SceneTransitionPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameManager), "BeginSceneTransition")]
		private static bool InterceptSceneTransition(SceneLoadInfo info)
		{
			if (!RadianceSceneManager.IsInCustomScene && info.SceneName == "GG_Radiance")
			{
				RadianceSceneManager instance = RadianceSceneManager.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					Log.Info("[SceneTransitionPatch] 拦截 TransitionPoint 入场: GG_Radiance,转为 AssetBundle 加载");
					instance.EnterViaTransitionPoint();
					return false;
				}
			}
			if (RadianceSceneManager.IsInCustomScene)
			{
				RadianceSceneManager instance2 = RadianceSceneManager.Instance;
				if ((Object)(object)instance2 != (Object)null)
				{
					Log.Info("[SceneTransitionPatch] 自定义场景内场景转换: " + info.SceneName + ",执行清理");
					instance2.CleanupCustomScene();
				}
			}
			return true;
		}
	}
}
namespace Radiance.Managers
{
	internal sealed class AssetManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <EnsureBundleLoadedAsync>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetManager <>4__this;

			private AssetBundleCreateRequest <req>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)<>4__this._bundle != (Object)null)
					{
						if (string.IsNullOrEmpty(<>4__this._scenePathInBundle))
						{
							<>4__this.ResolveScenePath();
						}
						return false;
					}
					if (<>4__this._bundleBytes == null)
					{
						<>4__this._bundleBytes = <>4__this.GetEmbeddedBundleBytes();
					}
					if (<>4__this._bundleBytes == null)
					{
						Log.Error("[AssetManager] 无法获取嵌入的 radiance.bundle 字节数据");
						return false;
					}
					<req>5__1 = AssetBundle.LoadFromMemoryAsync(<>4__this._bundleBytes);
					<>2__current = <req>5__1;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this._bundle = <req>5__1.assetBundle;
					if ((Object)(object)<>4__this._bundle == (Object)null)
					{
						Log.Error("[AssetManager] AssetBundle.LoadFromMemoryAsync 失败");
						return false;
					}
					<>4__this.ResolveScenePath();
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadRadianceSceneSingleAsync>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetManager <>4__this;

			private AsyncOperation <op>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = <>4__this.EnsureBundleLoadedAsync();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (string.IsNullOrEmpty(<>4__this._scenePathInBundle))
					{
						Log.Error("[AssetManager] scenePath 为空,无法加载 GG_Radiance 场景");
						return false;
					}
					Log.Info("[AssetManager] 加载场景(Single):" + <>4__this._scenePathInBundle);
					<op>5__1 = SceneManager.LoadSceneAsync(<>4__this._scenePathInBundle, (LoadSceneMode)0);
					if (<op>5__1 == null)
					{
						Log.Error("[AssetManager] SceneManager.LoadSceneAsync 返回 null");
						return false;
					}
					<>2__current = <op>5__1;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <PreloadAllAssets>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetManager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this._isPreloaded || <>4__this._isPreloading)
					{
						goto IL_0064;
					}
					<>4__this._isPreloading = true;
					<>2__current = <>4__this.EnsureBundleLoadedAsync();
					<>1__state = 2;
					return true;
				case 1:
					<>1__state = -1;
					goto IL_0064;
				case 2:
					{
						<>1__state = -1;
						<>4__this._isPreloaded = true;
						<>4__this._isPreloading = false;
						Log.Info("[AssetManager] 预加载完成");
						return false;
					}
					IL_0064:
					if (<>4__this._isPreloading)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					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 EmbeddedBundleName = "Radiance.Asset.radiance.bundle";

		private const string EmbeddedBundleSuffix = ".radiance.bundle";

		private byte[]? _bundleBytes;

		private AssetBundle? _bundle;

		private string? _scenePathInBundle;

		private bool _isPreloaded;

		private bool _isPreloading;

		public bool IsBundleLoaded => (Object)(object)_bundle != (Object)null;

		public bool IsPreloaded => _isPreloaded;

		private void Awake()
		{
			Log.Info("[AssetManager] 已初始化(Scene bundle 模式)");
		}

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

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

		public void UnloadBundleKeepLoadedAssets()
		{
			if (!((Object)(object)_bundle == (Object)null))
			{
				_bundle.Unload(false);
				Resources.UnloadUnusedAssets();
				_bundle = null;
			}
		}

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

		private void ResolveScenePath()
		{
			if ((Object)(object)_bundle == (Object)null)
			{
				return;
			}
			string[] allScenePaths = _bundle.GetAllScenePaths();
			if (allScenePaths == null || allScenePaths.Length == 0)
			{
				Log.Error("[AssetManager] radiance.bundle 内没有 Scene。请确认打包的是 Scene bundle(包含 GG_Radiance.unity)");
				return;
			}
			_scenePathInBundle = allScenePaths.FirstOrDefault((string p) => p.IndexOf("gg_radiance", StringComparison.OrdinalIgnoreCase) >= 0) ?? allScenePaths[0];
			Log.Info("[AssetManager] ScenePaths: " + string.Join(", ", allScenePaths));
			Log.Info("[AssetManager] 选用 scenePath: " + _scenePathInBundle);
		}

		private byte[]? GetEmbeddedBundleBytes()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("Radiance.Asset.radiance.bundle");
				if (manifestResourceStream == null)
				{
					string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
					string text = manifestResourceNames.FirstOrDefault((string n) => n.EndsWith(".radiance.bundle", StringComparison.OrdinalIgnoreCase));
					if (string.IsNullOrEmpty(text))
					{
						Log.Error("[AssetManager] 未找到嵌入资源:Radiance.Asset.radiance.bundle(也没有匹配 .radiance.bundle 的资源)");
						Log.Debug("[AssetManager] 可用嵌入资源:" + string.Join(", ", manifestResourceNames));
						return null;
					}
					manifestResourceStream = executingAssembly.GetManifestResourceStream(text);
					Log.Warn("[AssetManager] EmbeddedBundleName 不匹配,使用兜底资源名:" + text);
				}
				using (manifestResourceStream)
				{
					using MemoryStream memoryStream = new MemoryStream();
					manifestResourceStream.CopyTo(memoryStream);
					return memoryStream.ToArray();
				}
			}
			catch (Exception ex)
			{
				Log.Error("[AssetManager] 读取嵌入 bundle 失败:" + ex.Message);
				return null;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bundle != (Object)null)
			{
				_bundle.Unload(false);
				_bundle = null;
			}
			_bundleBytes = null;
		}
	}
	public class RadianceSceneManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <EnsureCustomSceneAudioState>d__46 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RadianceSceneManager <>4__this;

			private GameManager <gm>5__1;

			private CustomSceneManager <sm>5__2;

			private CameraController <cameraController>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<gm>5__1 = null;
				<sm>5__2 = null;
				<cameraController>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<gm>5__1 = GameManager._instance;
					GameManager obj = <gm>5__1;
					<sm>5__2 = ((obj != null) ? obj.sm : null);
					<cameraController>5__3 = GameCameras.instance?.cameraController;
					if ((Object)(object)<cameraController>5__3 != (Object)null)
					{
						<cameraController>5__3.PositionToHero(true);
						<>2__current = (object)new WaitForSecondsRealtime(0.15f);
						<>1__state = 1;
						return true;
					}
					goto IL_00aa;
				}
				case 1:
					<>1__state = -1;
					goto IL_00aa;
				case 2:
					{
						<>1__state = -1;
						break;
					}
					IL_00aa:
					if ((Object)(object)<gm>5__1 == (Object)null || (Object)(object)<sm>5__2 == (Object)null || (Object)(object)<gm>5__1.AudioManager == (Object)null)
					{
						return false;
					}
					if (<sm>5__2.IsAudioSnapshotsApplied)
					{
						return false;
					}
					if (!HasCustomSceneAudioConfig(<sm>5__2))
					{
						<gm>5__1.AudioManager.StopAndClearMusic();
						<gm>5__1.AudioManager.StopAndClearAtmos();
						AudioManager.CustomSceneManagerReady();
						Log.Info("[RadianceSceneManager] 未检测到场景音频配置,已清理旧场景音乐/氛围");
						return false;
					}
					if ((Object)(object)<cameraController>5__3 != (Object)null)
					{
						<cameraController>5__3.PositionToHero(true);
						<>2__current = (object)new WaitForSecondsRealtime(0.15f);
						<>1__state = 2;
						return true;
					}
					break;
				}
				if (!<sm>5__2.IsAudioSnapshotsApplied)
				{
					AudioManager.CustomSceneManagerReady();
					Log.Warn("[RadianceSceneManager] 场景音频回调未触发,已执行 Ready 兜底");
				}
				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();
			}
		}

		[CompilerGenerated]
		private sealed class <EnterCustomSceneRoutine>d__36 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string customSceneName;

			public Vector3 spawnPosition;

			public string targetSceneName;

			public RadianceSceneManager <>4__this;

			private HeroController <hero>5__1;

			private AssetManager <assetManager>5__2;

			private Exception <ex>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<hero>5__1 = null;
				<assetManager>5__2 = null;
				<ex>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Expected O, but got Unknown
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0203: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Unknown result type (might be due to invalid IL or missing references)
				//IL_021a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0225: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_023f: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Log.Info("[RadianceSceneManager] 开始进入自定义场景: " + customSceneName);
					<hero>5__1 = HeroController.instance;
					if ((Object)(object)<hero>5__1 == (Object)null || (Object)(object)GameManager._instance == (Object)null)
					{
						Log.Error("[RadianceSceneManager] HeroController 或 GameManager 为空");
						return false;
					}
					<>4__this._targetSceneName = (string.IsNullOrEmpty(targetSceneName) ? "GG_Radiance" : targetSceneName);
					<>4__this.SaveReturnInfo();
					<>4__this.DisablePlayerControl();
					<>2__current = <>4__this.PlayEnterAnimation(<hero>5__1);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this._pendingCustomSceneName = customSceneName;
					if (<>4__this._targetSceneName == "GG_Radiance")
					{
						<assetManager>5__2 = ((Component)<>4__this).GetComponent<AssetManager>();
						if ((Object)(object)<assetManager>5__2 == (Object)null)
						{
							Log.Error("[RadianceSceneManager] AssetManager 未找到");
							<>4__this._pendingCustomSceneName = null;
							<>4__this.EnablePlayerControl();
							return false;
						}
						try
						{
							GameManager instance = GameManager._instance;
							if (instance != null)
							{
								PlayMakerFSM screenFader_fsm = instance.screenFader_fsm;
								if (screenFader_fsm != null)
								{
									screenFader_fsm.SendEvent("SCENE FADE OUT");
								}
							}
						}
						catch
						{
						}
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 2;
						return true;
					}
					try
					{
						GameManager._instance.BeginSceneTransition(new SceneLoadInfo
						{
							SceneName = <>4__this._targetSceneName,
							EntryGateName = "",
							HeroLeaveDirection = (GatePosition)5,
							EntryDelay = 0f,
							WaitForSceneTransitionCameraFade = true,
							Visualization = (SceneLoadVisualizations)0,
							AlwaysUnloadUnusedAssets = false
						});
						Log.Info("[RadianceSceneManager] 传送到: " + <>4__this._targetSceneName);
					}
					catch (Exception ex)
					{
						<ex>5__3 = ex;
						Log.Error("[RadianceSceneManager] 传送失败: " + <ex>5__3.Message);
						<>4__this._pendingCustomSceneName = null;
						<>4__this._targetSceneName = "";
						<>4__this.EnablePlayerControl();
					}
					break;
				case 2:
					<>1__state = -1;
					<>2__current = <assetManager>5__2.LoadRadianceSceneSingleAsync();
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					Log.Info("[RadianceSceneManager] 加载 GG_Radiance 成功");
					<assetManager>5__2 = null;
					break;
				}
				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();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadFromTransitionPointRoutine>d__38 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RadianceSceneManager <>4__this;

			private AssetManager <assetManager>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<assetManager>5__1 = ((Component)<>4__this).GetComponent<AssetManager>();
					if ((Object)(object)<assetManager>5__1 == (Object)null)
					{
						Log.Error("[RadianceSceneManager] AssetManager 未找到");
						<>4__this._pendingCustomSceneName = null;
						<>4__this._targetSceneName = "";
						<>4__this.EnablePlayerControl();
						return false;
					}
					if (!<assetManager>5__1.IsPreloaded)
					{
						Log.Info("[RadianceSceneManager] 等待资源预加载...");
						goto IL_00c4;
					}
					goto IL_0130;
				case 1:
					<>1__state = -1;
					goto IL_00c4;
				case 2:
					{
						<>1__state = -1;
						Log.Info("[RadianceSceneManager] TransitionPoint 触发: GG_Radiance 加载成功");
						return false;
					}
					IL_00c4:
					if ((Object)(object)<assetManager>5__1 != (Object)null && !<assetManager>5__1.IsPreloaded)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)<assetManager>5__1 == (Object)null)
					{
						Log.Error("[RadianceSceneManager] AssetManager 在等待预加载期间被销毁");
						<>4__this._pendingCustomSceneName = null;
						<>4__this._targetSceneName = "";
						<>4__this.EnablePlayerControl();
						return false;
					}
					goto IL_0130;
					IL_0130:
					<>2__current = <assetManager>5__1.LoadRadianceSceneSingleAsync();
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnEnterTargetScene>d__39 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RadianceSceneManager <>4__this;

			private TransitionPoint <existingTP>5__1;

			private Exception <ex>5__2;

			private PlayerData <pd>5__3;

			private Exception <ex>5__4;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<existingTP>5__1 = null;
				<ex>5__2 = null;
				<pd>5__3 = null;
				<ex>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.HandleProblematicComponents();
					<>4__this.RemapAudioMixerGroups();
					<>4__this.CreateMinimalSceneManager();
					<>4__this.RefreshCustomSceneVisualState();
					<>4__this.SavePreMemoryState();
					<existingTP>5__1 = Object.FindAnyObjectByType<TransitionPoint>();
					if ((Object)(object)<existingTP>5__1 != (Object)null)
					{
						<existingTP>5__1.isInactive = true;
						((InteractableBase)<existingTP>5__1).Deactivate(false);
						Log.Info("[RadianceSceneManager] 已禁用 TransitionPoint 交互: " + ((Object)((Component)<existingTP>5__1).gameObject).name);
					}
					<>4__this.DisableInterferingRenderers();
					<>4__this.InitializeHeroAndCameraForCustomEntry();
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.FixHK1LocalizationTexts();
					<>4__this.RefreshCustomSceneVisualState();
					<>2__current = <>4__this.EnsureCustomSceneAudioState();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.ForceApplyInitialCameraLocks();
					<>4__this.FadeSceneIn();
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.EnablePlayerControl();
					try
					{
						GameManager instance = GameManager._instance;
						if (instance != null)
						{
							instance.FinishedEnteringScene();
						}
					}
					catch (Exception ex)
					{
						<ex>5__2 = ex;
						Log.Warn("[RadianceSceneManager] FinishedEnteringScene 失败: " + <ex>5__2.Message);
					}
					try
					{
						<pd>5__3 = PlayerData.instance;
						if (<pd>5__3 != null)
						{
							<pd>5__3.disablePause = false;
							<pd>5__3.isInvincible = false;
						}
						<pd>5__3 = null;
					}
					catch (Exception ex)
					{
						<ex>5__4 = ex;
						Log.Warn("[RadianceSceneManager] 重置 PlayerData 状态失败: " + <ex>5__4.Message);
					}
					Log.Info("[RadianceSceneManager] 自定义场景设置完成");
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <OnReturnToOriginalScene>d__49 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RadianceSceneManager <>4__this;

			private GameManager <gm>5__1;

			private float <timeout>5__2;

			private Exception <ex>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<gm>5__1 = null;
				<ex>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					<gm>5__1 = GameManager._instance;
					if (!((Object)(object)<gm>5__1 != (Object)null))
					{
						goto IL_0097;
					}
					<timeout>5__2 = 5f;
				}
				if (!<gm>5__1.hasFinishedEnteringScene && <timeout>5__2 > 0f)
				{
					<timeout>5__2 -= Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				goto IL_0097;
				IL_0097:
				try
				{
					GameCameras instance = GameCameras.instance;
					if (instance != null)
					{
						instance.HUDIn();
					}
				}
				catch (Exception ex)
				{
					<ex>5__3 = ex;
					Log.Warn("[RadianceSceneManager] HUDIn 失败: " + <ex>5__3.Message);
				}
				<>4__this._hasSavedReturnInfo = false;
				Log.Info("[RadianceSceneManager] 已返回原场景");
				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();
			}
		}

		[CompilerGenerated]
		private sealed class <PlayEnterAnimation>d__56 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public HeroController hero;

			public RadianceSceneManager <>4__this;

			private tk2dSpriteAnimator <tk2dAnimator>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Expected O, but got Unknown
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Expected O, but got Unknown
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<tk2dAnimator>5__1 = ((Component)hero).GetComponent<tk2dSpriteAnimator>();
					if ((Object)(object)<tk2dAnimator>5__1 != (Object)null)
					{
						<tk2dAnimator>5__1.Play("Abyss Kneel");
						<>2__current = (object)new WaitForSeconds(0.8f);
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForSeconds(1.8f);
					<>1__state = 3;
					return true;
				case 1:
					<>1__state = -1;
					<tk2dAnimator>5__1.Play("Kneel To Prostrate");
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					break;
				case 3:
					<>1__state = -1;
					break;
				}
				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 string _returnSceneName = "";

		private Vector3 _returnPosition;

		private bool _hasSavedReturnInfo;

		private string _targetSceneName = "";

		private string? _pendingCustomSceneName;

		private readonly List<TransitionPoint> _disabledTransitionPoints = new List<TransitionPoint>();

		private static readonly string[] GlobalRenderersToDisable = new string[1] { "_GameCameras/CameraParent/tk2dCamera/Masker Blackout" };

		private static readonly Dictionary<string, (string zh, string fallback)> HK1TextMap = new Dictionary<string, (string, string)>
		{
			{
				"!!Titles/ABSOLUTE_RADIANCE_MAIN!!",
				("无上辐光", "Radiance")
			},
			{
				"!!Titles/ABSOLUTE_RADIANCE_SUPER!!",
				("", "Absolute")
			}
		};

		private static readonly BindingFlags PrivateInstanceFlags = BindingFlags.Instance | BindingFlags.NonPublic;

		private static readonly FieldInfo? MusicCueField = typeof(CustomSceneManager).GetField("musicCue", PrivateInstanceFlags);

		private static readonly FieldInfo? AtmosCueField = typeof(CustomSceneManager).GetField("atmosCue", PrivateInstanceFlags);

		private static readonly FieldInfo? MusicSnapshotField = typeof(CustomSceneManager).GetField("musicSnapshot", PrivateInstanceFlags);

		private static readonly FieldInfo? OverrideColorSettingsField = typeof(CustomSceneManager).GetField("overrideColorSettings", PrivateInstanceFlags);

		private static readonly HashSet<string> BossLeftoverNames = new HashSet<string> { "Radiant Nail Comb(Clone)", "Radiant Beam R(Clone)", "Radiant Beam L(Clone)", "Radiant Nail(Clone)" };

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

		public static bool IsInCustomScene { get; private set; }

		public static string? CurrentCustomSceneName { get; private set; }

		public string ReturnSceneName => _returnSceneName;

		public bool HasReturnInfo => _hasSavedReturnInfo;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				SceneManager.activeSceneChanged += OnSceneChanged;
				Log.Info("[RadianceSceneManager] 初始化完成");
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}

		private void OnDestroy()
		{
			SceneManager.activeSceneChanged -= OnSceneChanged;
			Instance = null;
		}

		private void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			if (((Scene)(ref newScene)).name == "Menu_Title" || ((Scene)(ref newScene)).name == "Quit_To_Menu")
			{
				ResetState();
				return;
			}
			if (!string.IsNullOrEmpty(_pendingCustomSceneName) && !string.IsNullOrEmpty(_targetSceneName) && ((Scene)(ref newScene)).name == _targetSceneName)
			{
				IsInCustomScene = true;
				CurrentCustomSceneName = _pendingCustomSceneName;
				_pendingCustomSceneName = null;
				Log.Info("[RadianceSceneManager] 已进入目标场景: " + ((Scene)(ref newScene)).name);
				((MonoBehaviour)this).StartCoroutine(OnEnterTargetScene());
				return;
			}
			if (_hasSavedReturnInfo && ((Scene)(ref newScene)).name == _returnSceneName && !IsInCustomScene)
			{
				Log.Info("[RadianceSceneManager] 返回原场景: " + ((Scene)(ref newScene)).name);
				((MonoBehaviour)this).StartCoroutine(OnReturnToOriginalScene());
			}
			if (((Scene)(ref newScene)).name == "Belltown")
			{
				CreateBelltownTransitionPoint();
			}
		}

		private void ResetState()
		{
			IsInCustomScene = false;
			CurrentCustomSceneName = null;
			_pendingCustomSceneName = null;
			_hasSavedReturnInfo = false;
			_disabledTransitionPoints.Clear();
			Log.Info("[RadianceSceneManager] 状态已重置");
		}

		private void CreateBelltownTransitionPoint()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0091: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("door_radiance");
			val.SetActive(false);
			val.transform.position = new Vector3(50f, 40.7f, 0f);
			BoxCollider2D val2 = val.AddComponent<BoxCollider2D>();
			val2.size = new Vector2(2.13f, 0.2258f);
			((Collider2D)val2).isTrigger = true;
			TransitionPoint val3 = val.AddComponent<TransitionPoint>();
			val3.isADoor = true;
			val3.targetScene = "GG_Radiance";
			val3.entryPoint = "door_radiance";
			val3.nonHazardGate = true;
			val3.OnDoorEnter = new UnityEvent();
			((InteractableBase)val3).interactLabel = (PromptLabels)8;
			typeof(TransitionPoint).GetField("skipSceneMapCheck", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val3, true);
			SceneManager.MoveGameObjectToScene(val, SceneManager.GetActiveScene());
			val.SetActive(true);
			Log.Info("[RadianceSceneManager] 已在 Belltown 创建传送点 door_radiance");
			((InteractableBase)val3).interactLabel = (PromptLabels)8;
			SetupBelltownTransitionDecor();
		}

		private void SetupBelltownTransitionDecor()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Hornet House States/Full/bg_bell_hang (1)/background_bell_generic_upright_after");
			if ((Object)(object)val == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] 未找到房屋背景源对象,跳过装饰创建");
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).name = "radiance_transition_decor";
			val2.transform.SetParent((Transform)null);
			val2.transform.position = new Vector3(50.0918f, 42.4555f, 0.1f);
			val2.transform.localScale = new Vector3(1f, 1f, 1f);
			SpriteRenderer component = val2.GetComponent<SpriteRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				component.color = new Color(1f, 0.7f, 0.2f, 1f);
			}
			SceneManager.MoveGameObjectToScene(val2, SceneManager.GetActiveScene());
			Log.Info("[RadianceSceneManager] 已创建传送点装饰: radiance_transition_decor");
		}

		public void EnterCustomScene(string customSceneName, Vector3 spawnPosition, string targetSceneName)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (IsInCustomScene || !string.IsNullOrEmpty(_pendingCustomSceneName))
			{
				Log.Warn("[RadianceSceneManager] 已在自定义场景中或正在进入");
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(EnterCustomSceneRoutine(customSceneName, spawnPosition, targetSceneName));
			}
		}

		[IteratorStateMachine(typeof(<EnterCustomSceneRoutine>d__36))]
		private IEnumerator EnterCustomSceneRoutine(string customSceneName, Vector3 spawnPosition, string targetSceneName)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EnterCustomSceneRoutine>d__36(0)
			{
				<>4__this = this,
				customSceneName = customSceneName,
				spawnPosition = spawnPosition,
				targetSceneName = targetSceneName
			};
		}

		public void EnterViaTransitionPoint()
		{
			if (IsInCustomScene || !string.IsNullOrEmpty(_pendingCustomSceneName))
			{
				Log.Warn("[RadianceSceneManager] 已在自定义场景中或正在进入");
				return;
			}
			SaveReturnInfo();
			_targetSceneName = "GG_Radiance";
			_pendingCustomSceneName = "GG_Radiance";
			((MonoBehaviour)this).StartCoroutine(LoadFromTransitionPointRoutine());
		}

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

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

		private void HandleProblematicComponents()
		{
			BossSceneController val = Object.FindAnyObjectByType<BossSceneController>();
			if ((Object)(object)val != (Object)null)
			{
				typeof(BossSceneController).GetField("restoreBindingsOnDestroy", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val, false);
				Log.Info("[RadianceSceneManager] 已禁用 BossSceneController(保留 door_dreamEnter)");
			}
		}

		private void FixHK1LocalizationTexts()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (int)Language.CurrentLanguage() == 199;
			int num = 0;
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				Component[] componentsInChildren = val.GetComponentsInChildren<Component>(true);
				foreach (Component val2 in componentsInChildren)
				{
					if ((Object)(object)val2 == (Object)null || ((object)val2).GetType().Name != "TextMeshPro")
					{
						continue;
					}
					PropertyInfo property = ((object)val2).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public);
					if (!(property == null) && property.GetValue(val2) is string text && !string.IsNullOrEmpty(text) && HK1TextMap.TryGetValue(text, out (string, string) value))
					{
						string text2;
						if (flag)
						{
							(text2, _) = value;
						}
						else
						{
							text2 = value.Item2;
						}
						string text3 = text2;
						property.SetValue(val2, text3);
						num++;
						Log.Info("[RadianceSceneManager] 已修复 HK1 本地化文本: \"" + text + "\" → \"" + text3 + "\" (on " + ((Object)val2.gameObject).name + ")");
					}
				}
			}
			if (num == 0)
			{
				Log.Warn("[RadianceSceneManager] 未找到需要修复的 HK1 本地化文本");
			}
		}

		private void RemapAudioMixerGroups()
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			GameManager instance = GameManager._instance;
			if ((Object)(object)instance == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] GameManager 为空,跳过 AudioMixer 重映射");
				return;
			}
			Dictionary<string, AudioMixer> dictionary = new Dictionary<string, AudioMixer>();
			AudioMixerSnapshot[] array = (AudioMixerSnapshot[])(object)new AudioMixerSnapshot[6] { instance.actorSnapshotUnpaused, instance.actorSnapshotPaused, instance.silentSnapshot, instance.noMusicSnapshot, instance.noAtmosSnapshot, instance.soundOptionsDefaultSnaphot };
			AudioMixerSnapshot[] array2 = array;
			foreach (AudioMixerSnapshot val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.audioMixer == (Object)null))
				{
					AudioMixer audioMixer = val.audioMixer;
					dictionary.TryAdd(((Object)audioMixer).name, audioMixer);
				}
			}
			if (dictionary.Count == 0)
			{
				Log.Warn("[RadianceSceneManager] 未发现任何二代 AudioMixer,跳过重映射");
				return;
			}
			HashSet<AudioMixer> hashSet = new HashSet<AudioMixer>(dictionary.Values);
			HashSet<AudioMixer> hashSet2 = new HashSet<AudioMixer>();
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			foreach (GameObject val2 in rootGameObjects)
			{
				AudioSource[] componentsInChildren = val2.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val3 in componentsInChildren)
				{
					if (!((Object)(object)val3.outputAudioMixerGroup == (Object)null))
					{
						AudioMixer audioMixer2 = val3.outputAudioMixerGroup.audioMixer;
						if ((Object)(object)audioMixer2 != (Object)null && !hashSet.Contains(audioMixer2))
						{
							hashSet2.Add(audioMixer2);
						}
					}
				}
			}
			if (hashSet2.Count == 0)
			{
				Log.Info("[RadianceSceneManager] 未发现一代 AudioMixer,无需重映射");
				return;
			}
			int num = 0;
			foreach (AudioMixer item in hashSet2)
			{
				if (!dictionary.TryGetValue(((Object)item).name, out var value))
				{
					Log.Warn("[RadianceSceneManager] 一代 Mixer '" + ((Object)item).name + "' 在二代中找不到同名 Mixer");
					continue;
				}
				AudioMixerGroup val4 = (item.outputAudioMixerGroup = value.outputAudioMixerGroup);
				num++;
				object obj;
				if (!((Object)(object)val4 != (Object)null))
				{
					obj = "null (root)";
				}
				else
				{
					string[] obj2 = new string[5]
					{
						"'",
						((Object)val4).name,
						"' (Mixer: '",
						null,
						null
					};
					AudioMixer audioMixer3 = val4.audioMixer;
					obj2[3] = ((audioMixer3 != null) ? ((Object)audioMixer3).name : null);
					obj2[4] = "')";
					obj = string.Concat(obj2);
				}
				string text = (string)obj;
				Log.Info("[RadianceSceneManager] Mixer 嫁接: '" + ((Object)item).name + "' → " + text);
			}
			Log.Info($"[RadianceSceneManager] AudioMixer 重映射完成: 嫁接={num} 个 Mixer");
		}

		private void CreateMinimalSceneManager()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00db: 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)
			//IL_0107: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			GameManager instance = GameManager._instance;
			if ((Object)(object)instance == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] GameManager 不存在,无法创建 SceneManager");
				return;
			}
			CustomSceneManager val = Object.FindAnyObjectByType<CustomSceneManager>();
			if ((Object)(object)val != (Object)null)
			{
				val.mapZone = (MapZone)33;
				val.sceneType = (SceneType)0;
				instance.sm = val;
				Log.Info("[RadianceSceneManager] 使用场景内已有的 CustomSceneManager,已设置为 MEMORY");
				return;
			}
			GameObject val2 = new GameObject("_SceneManager (Radiance)");
			val2.tag = "SceneManager";
			val2.SetActive(false);
			CustomSceneManager val3 = val2.AddComponent<CustomSceneManager>();
			val3.scenePools = (SceneObjectPool[])(object)new SceneObjectPool[0];
			val3.sceneBordersMask = 0;
			GameObject val4 = new GameObject("_DummyBorder");
			val4.SetActive(false);
			val4.transform.SetParent(val2.transform);
			val3.borderPrefab = val4;
			val3.defaultColor = Color32.op_Implicit(new Color32((byte)193, (byte)166, (byte)126, byte.MaxValue));
			val3.defaultIntensity = 1f;
			val3.heroLightColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)227, (byte)185, (byte)28));
			val3.saturation = 0.9f;
			val3.redChannel = AnimationCurve.Linear(0f, 0f, 1f, 1f);
			val3.greenChannel = AnimationCurve.Linear(0f, 0f, 1f, 1f);
			val3.blueChannel = AnimationCurve.Linear(0f, 0f, 1f, 1f);
			val3.darknessLevel = -1;
			val3.environmentType = (EnvironmentTypes)0;
			val3.isWindy = false;
			val3.blurPlaneVibranceOffset = 0f;
			OverrideColorSettingsField?.SetValue(val3, true);
			val3.mapZone = (MapZone)33;
			val3.sceneType = (SceneType)0;
			instance.sm = val3;
			SceneManager.MoveGameObjectToScene(val2, SceneManager.GetActiveScene());
			val2.SetActive(true);
			Log.Info("[RadianceSceneManager] 已创建最小化 CustomSceneManager (mapZone=MEMORY)");
		}

		private void RefreshCustomSceneVisualState()
		{
			GameManager instance = GameManager._instance;
			CustomSceneManager val = ((instance != null) ? instance.sm : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			try
			{
				val.UpdateScene();
			}
			catch (Exception ex)
			{
				Log.Warn("[RadianceSceneManager] 刷新场景视觉状态失败: " + ex.Message);
			}
		}

		private static bool HasCustomSceneAudioConfig(CustomSceneManager sm)
		{
			if ((Object)(object)sm.atmosSnapshot != (Object)null || (Object)(object)sm.enviroSnapshot != (Object)null || (Object)(object)sm.actorSnapshot != (Object)null || (Object)(object)sm.shadeSnapshot != (Object)null)
			{
				return true;
			}
			return MusicCueField?.GetValue(sm) != null || AtmosCueField?.GetValue(sm) != null || MusicSnapshotField?.GetValue(sm) != null;
		}

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

		public void CleanupCustomScene()
		{
			if (IsInCustomScene)
			{
				Log.Info("[RadianceSceneManager] 执行自定义场景清理");
				IsInCustomScene = false;
				CurrentCustomSceneName = null;
				EnableInterferingRenderers();
				DestroyBossLeftovers();
			}
		}

		public void ExitCustomScene()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			if (!IsInCustomScene)
			{
				Log.Warn("[RadianceSceneManager] 不在自定义场景中");
				return;
			}
			if (!_hasSavedReturnInfo || (Object)(object)GameManager._instance == (Object)null)
			{
				Log.Error("[RadianceSceneManager] 无返回信息或 GameManager 为空");
				return;
			}
			Log.Info("[RadianceSceneManager] 退出自定义场景,目标: " + _returnSceneName);
			try
			{
				GameManager._instance.BeginSceneTransition(new SceneLoadInfo
				{
					SceneName = _returnSceneName,
					EntryGateName = "door_radiance",
					HeroLeaveDirection = (GatePosition)5,
					EntryDelay = 0f,
					WaitForSceneTransitionCameraFade = true,
					Visualization = (SceneLoadVisualizations)0,
					AlwaysUnloadUnusedAssets = false
				});
			}
			catch (Exception ex)
			{
				Log.Error("[RadianceSceneManager] 退出失败: " + ex.Message);
			}
		}

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

		private void DestroyBossLeftovers()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Scene scene = ((Component)this).gameObject.scene;
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			int num = 0;
			GameObject[] array = rootGameObjects;
			foreach (GameObject val in array)
			{
				if (BossLeftoverNames.Contains(((Object)val).name))
				{
					Object.Destroy((Object)(object)val);
					num++;
				}
			}
			if (num > 0)
			{
				Log.Info($"[RadianceSceneManager] 已清理 {num} 个 Boss 残留对象");
			}
		}

		private void SaveReturnInfo()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			_returnSceneName = ((Scene)(ref activeScene)).name;
			HeroController instance = HeroController.instance;
			if ((Object)(object)instance != (Object)null)
			{
				_returnPosition = instance.transform.position;
			}
			_hasSavedReturnInfo = true;
			Log.Info($"[RadianceSceneManager] 保存返回信息: {_returnSceneName} at {_returnPosition}");
		}

		private void SavePreMemoryState()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			HeroController instance = HeroController.instance;
			PlayerData instance2 = PlayerData.instance;
			if (!((Object)(object)instance == (Object)null) && instance2 != null && !instance2.HasStoredMemoryState)
			{
				instance2.PreMemoryState = HeroItemsState.Record(instance);
				instance2.HasStoredMemoryState = true;
				instance2.CaptureToolAmountsOverride();
				EventRegister.SendEvent("END FOLLOWERS INSTANT", (GameObject)null);
				instance.MaxHealthKeepBlue();
				Log.Info("[RadianceSceneManager] 已保存 PreMemoryState");
			}
		}

		private void DisablePlayerControl()
		{
			HeroController instance = HeroController.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			GameManager instance2 = GameManager._instance;
			if (instance2 != null)
			{
				InputHandler inputHandler = instance2.inputHandler;
				if (inputHandler != null)
				{
					inputHandler.StopAcceptingInput();
				}
			}
			instance.RelinquishControl();
			instance.StopAnimationControl();
		}

		private void EnablePlayerControl()
		{
			HeroController instance = HeroController.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			GameManager instance2 = GameManager._instance;
			if (instance2 != null)
			{
				InputHandler inputHandler = instance2.inputHandler;
				if (inputHandler != null)
				{
					inputHandler.StartAcceptingInput();
				}
			}
			instance.RegainControl();
			instance.StartAnimationControl();
		}

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

		private void FadeSceneIn()
		{
			try
			{
				GameManager instance = GameManager._instance;
				if (instance != null)
				{
					PlayMakerFSM screenFader_fsm = instance.screenFader_fsm;
					if (screenFader_fsm != null)
					{
						screenFader_fsm.SendEvent("SCENE FADE IN");
					}
				}
			}
			catch (Exception ex)
			{
				Log.Error("[RadianceSceneManager] 屏幕淡入失败: " + ex.Message);
			}
		}

		private void InitializeHeroAndCameraForCustomEntry()
		{
			HeroController instance = HeroController.instance;
			if ((Object)(object)instance == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] HeroController 不存在,跳过开场镜头初始化");
				return;
			}
			instance.SceneInit();
			GameCameras instance2 = GameCameras.instance;
			if ((Object)(object)instance2 == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] GameCameras 不存在,无法同步开场镜头");
				return;
			}
			instance2.SceneInit();
			CameraController cameraController = instance2.cameraController;
			if ((Object)(object)cameraController == (Object)null)
			{
				Log.Warn("[RadianceSceneManager] CameraController 不存在,无法同步开场镜头");
				return;
			}
			cameraController.ResetStartTimer();
			cameraController.PositionToHero(true);
		}

		private void ForceApplyInitialCameraLocks()
		{
			//IL_003e: 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)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			HeroController instance = HeroController.instance;
			CameraController val = GameCameras.instance?.cameraController;
			if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null)
			{
				return;
			}
			Vector2 val2 = Vector2.op_Implicit(instance.transform.position);
			CameraLockArea[] array = Object.FindObjectsByType<CameraLockArea>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			int num = 0;
			CameraLockArea[] array2 = array;
			foreach (CameraLockArea val3 in array2)
			{
				if (!((Object)(object)val3 == (Object)null) && ((Behaviour)val3).isActiveAndEnabled)
				{
					Collider2D component = ((Component)val3).GetComponent<Collider2D>();
					if (!((Object)(object)component == (Object)null) && ((Behaviour)component).enabled && component.OverlapPoint(val2))
					{
						val.LockToArea(val3);
						num++;
					}
				}
			}
			if (num > 0)
			{
				Log.Info($"[RadianceSceneManager] 开场强制应用 CameraLockArea: {num}");
			}
		}

		private void SetRendererEnabled(string path, bool enabled)
		{
			GameObject val = GameObject.Find(path);
			if (!((Object)(object)val == (Object)null))
			{
				Renderer component = val.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.enabled = enabled;
				}
			}
		}

		private void DisableInterferingRenderers()
		{
			string[] globalRenderersToDisable = GlobalRenderersToDisable;
			foreach (string path in globalRenderersToDisable)
			{
				SetRendererEnabled(path, enabled: false);
			}
		}

		private void EnableInterferingRenderers()
		{
			string[] globalRenderersToDisable = GlobalRenderersToDisable;
			foreach (string path in globalRenderersToDisable)
			{
				SetRendererEnabled(path, enabled: true);
			}
		}
	}
}
namespace Radiance.Behaviours.Common
{
	public class RadianceReturnOnDialogueBehavior : MonoBehaviour
	{
		private const string TargetStateName = "Godseeker Dialogue";

		private const string ReturnMethodName = "TriggerReturnToOriginalScene";

		private bool _hasTriggeredReturn = false;

		private bool _isInitialized = false;

		public void Initialize(PlayMakerFSM fsm)
		{
			if (_isInitialized)
			{
				Log.Debug("[RadianceReturnBehavior] 已初始化,跳过");
				return;
			}
			InjectCallMethodToState(fsm);
			_isInitialized = true;
		}

		private void InjectCallMethodToState(PlayMakerFSM fsm)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			FsmState val = fsm.FsmStates?.FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.Name == "Godseeker Dialogue"));
			if (val == null)
			{
				Log.Warn("[RadianceReturnBehavior] 未找到状态: Godseeker Dialogue");
				return;
			}
			if (val.Actions != null && val.Actions.Length == 1)
			{
				FsmStateAction val2 = val.Actions[0];
				CallMethod val3 = (CallMethod)(object)((val2 is CallMethod) ? val2 : null);
				if (val3 != null)
				{
					FsmString methodName = val3.methodName;
					if (((methodName != null) ? methodName.Value : null) == "TriggerReturnToOriginalScene")
					{
						Log.Debug("[RadianceReturnBehavior] CallMethod 已存在,跳过注入");
						return;
					}
				}
			}
			FsmStateAction[] actions = val.Actions;
			int num = ((actions != null) ? actions.Length : 0);
			CallMethod val4 = new CallMethod();
			val4.behaviour = new FsmObject
			{
				Value = (Object)(object)this
			};
			val4.methodName = new FsmString("TriggerReturnToOriginalScene")
			{
				Value = "TriggerReturnToOriginalScene"
			};
			val4.parameters = (FsmVar[])(object)new FsmVar[0];
			val4.everyFrame = false;
			CallMethod val5 = val4;
			val.Actions = (FsmStateAction[])(object)new FsmStateAction[1] { (FsmStateAction)val5 };
			val.Transitions = (FsmTransition[])(object)new FsmTransition[0];
			fsm.Fsm.InitData();
			Log.Info(string.Format("[RadianceReturnBehavior] 已替换 [{0}] 状态(移除 {1} 个原有 Action)", "Godseeker Dialogue", num));
		}

		public void TriggerReturnToOriginalScene()
		{
			if (_hasTriggeredReturn)
			{
				Log.Debug("[RadianceReturnBehavior] 已触发过返回,跳过重复调用");
				return;
			}
			if (!RadianceSceneManager.IsInCustomScene)
			{
				Log.Debug("[RadianceReturnBehavior] 不在自定义场景中,跳过返回");
				return;
			}
			_hasTriggeredReturn = true;
			Log.Info("[RadianceReturnBehavior] 触发返回原场景");
			RadianceSceneManager.Instance?.ExitCustomScene();
		}

		public void ResetTriggerState()
		{
			_hasTriggeredReturn = false;
			_isInitialized = false;
		}

		private void OnDestroy()
		{
			_hasTriggeredReturn = false;
			_isInitialized = false;
		}
	}
}