Decompiled source of AnySilkBoss v0.2.0
AnySilkBoss/AnySilkBoss/AnySilkBoss.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
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 AnySilkBoss.Source.Actions; using AnySilkBoss.Source.Behaviours.Common; using AnySilkBoss.Source.Behaviours.Memory; using AnySilkBoss.Source.Behaviours.Normal; using AnySilkBoss.Source.Handlers; using AnySilkBoss.Source.Managers; using AnySilkBoss.Source.Patches; using AnySilkBoss.Source.Tools; using BepInEx; using BepInEx.Logging; using GlobalEnums; using GlobalSettings; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using TMProOld; using TeamCherry.Localization; using TeamCherry.SharedUtils; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("AnySilkBoss")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.2.0")] [assembly: AssemblyInformationalVersion("0.1.2+87458fadabf8955f9ee8d1e41aa8e2c570e02aca")] [assembly: AssemblyProduct("AnySilkBoss")] [assembly: AssemblyTitle("AnySilkBoss")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.2.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 AnySilkBoss { public static class MyPluginInfo { public const string PLUGIN_GUID = "AnySilkBoss"; public const string PLUGIN_NAME = "AnySilkBoss"; public const string PLUGIN_VERSION = "0.1.2"; } } namespace AnySilkBoss.Source { [BepInPlugin("AnySilkBoss", "AnySilkBoss", "0.1.2")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <DelayedPatchApplication>d__27 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Exception <ex>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedPatchApplication>d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <ex>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; try { _harmony = new Harmony("AnySilkBoss"); _harmony.PatchAll(typeof(BossPatches)); _harmony.PatchAll(typeof(I18nPatches)); _harmony.PatchAll(typeof(DamageReductionPatches)); _harmony.PatchAll(typeof(MemorySceneTransitionPatch)); _harmony.PatchAll(typeof(MemoryClashTinkPatch)); _harmony.PatchAll(typeof(MemoryParryDownspikePatch)); _harmony.PatchAll(typeof(HeroDamageStackPatch)); _harmony.PatchAll(typeof(HeroControllerDeathPatches)); _harmony.PatchAll(typeof(GameManagerRespawnPatches)); _harmony.PatchAll(typeof(ToolItemPatches)); AudioHandler.Initialize(); AudioHandler.ApplyPatches(_harmony); Log.Info("Harmony patches applied successfully"); } catch (Exception ex) { <ex>5__1 = ex; Log.Error("Failed to apply Harmony patches: " + <ex>5__1.Message); Log.Error("Stack trace: " + <ex>5__1.StackTrace); } 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 <ReinitializeSilkBallManagerDelayed>d__29 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private SilkBallManager <silkBallManager>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReinitializeSilkBallManagerDelayed>d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <silkBallManager>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject anySilkBossManager = <>4__this.AnySilkBossManager; <silkBallManager>5__1 = ((anySilkBossManager != null) ? anySilkBossManager.GetComponent<SilkBallManager>() : null); if ((Object)(object)<silkBallManager>5__1 != (Object)null) { <silkBallManager>5__1.ReinitializeOnEnterGame(); } 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 <ResetBossPlatformsDelay>d__31 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetBossPlatformsDelay>d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2.5f); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.ResetBossPlatforms(); 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 static Harmony _harmony; private GameObject AnySilkBossManager = null; public static Plugin Instance { get; private set; } public static bool IsBossSaveLoaded { get; set; } public static string OriginalSaveBackupPath { get; set; } public static bool IsInBossRoom { get; set; } public static string CurrentSaveFileName { get; set; } public static Texture2D? BoulderTexture { get; private set; } private void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); Instance = this; LoadEmbeddedTextures(); SceneManager.activeSceneChanged += OnSceneChange; ((MonoBehaviour)this).StartCoroutine(DelayedPatchApplication()); Log.Info("AnySilkBoss plugin loaded!"); } [IteratorStateMachine(typeof(<DelayedPatchApplication>d__27))] private IEnumerator DelayedPatchApplication() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedPatchApplication>d__27(0) { <>4__this = this }; } private void OnSceneChange(Scene oldScene, Scene newScene) { IsInBossRoom = ((Scene)(ref newScene)).name == "Cradle_03"; if (((Scene)(ref newScene)).name == "Menu_Title") { Log.Info("[Plugin] 切换到主菜单,清空丝球池和缓存..."); GameObject anySilkBossManager = AnySilkBossManager; SilkBallManager silkBallManager = ((anySilkBossManager != null) ? anySilkBossManager.GetComponent<SilkBallManager>() : null); if ((Object)(object)silkBallManager != (Object)null) { silkBallManager.ResetOnReturnToMenu(); } return; } if (((Scene)(ref newScene)).name == "Cradle_03") { ((MonoBehaviour)this).StartCoroutine(ResetBossPlatformsDelay()); DamageStackManager.Reset(); } if (((Scene)(ref oldScene)).name == "Menu_Title") { CreateManager(); ((MonoBehaviour)this).StartCoroutine(ReinitializeSilkBallManagerDelayed()); } } [IteratorStateMachine(typeof(<ReinitializeSilkBallManagerDelayed>d__29))] private IEnumerator ReinitializeSilkBallManagerDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReinitializeSilkBallManagerDelayed>d__29(0) { <>4__this = this }; } private void CreateManager() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown AnySilkBossManager = GameObject.Find("AnySilkBossManager"); if ((Object)(object)AnySilkBossManager == (Object)null) { AnySilkBossManager = new GameObject("AnySilkBossManager"); Object.DontDestroyOnLoad((Object)(object)AnySilkBossManager); AssetManager assetManager = AnySilkBossManager.AddComponent<AssetManager>(); AnySilkBossManager.AddComponent<DamageHeroEventManager>(); AnySilkBossManager.AddComponent<SilkBallManager>(); AnySilkBossManager.AddComponent<BigSilkBallManager>(); AnySilkBossManager.AddComponent<MemoryManager>(); AnySilkBossManager.AddComponent<DeathManager>(); AnySilkBossManager.AddComponent<SingleWebManager>(); AnySilkBossManager.AddComponent<FWPinManager>(); AnySilkBossManager.AddComponent<FWBlastManager>(); AnySilkBossManager.AddComponent<LaceCircleSlashManager>(); Log.Info("创建持久化管理器和所有组件"); ((MonoBehaviour)this).StartCoroutine(assetManager.PreloadAllExternalAssets()); } else { Log.Info("找到已存在的持久化管理器"); } } [IteratorStateMachine(typeof(<ResetBossPlatformsDelay>d__31))] private IEnumerator ResetBossPlatformsDelay() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetBossPlatformsDelay>d__31(0) { <>4__this = this }; } private void ResetBossPlatforms() { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_02d5: Unknown result type (might be due to invalid IL or missing references) try { if (IsInBossRoom) { GameObject[] source = Resources.FindObjectsOfTypeAll<GameObject>(); List<GameObject> list = source.Where((GameObject x) => ((Object)x).name.Contains("cradle_plat") && !((Object)x).name.Contains("spike")).ToList(); List<GameObject> list2 = source.Where((GameObject x) => ((Object)x).name.Contains("cradle_spike_plat")).ToList(); foreach (GameObject item in list) { Transform val = item.transform.Find("crank_hit"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } switch (((Object)item).name) { case "cradle_plat (6)": item.transform.position = new Vector3(39.81f, 58.35f, -0.2602f); Log.Info("重置 " + ((Object)item).name + " 的位置"); break; case "cradle_plat (1)": item.transform.position = new Vector3(49.01f, 64.94f, -0.2602f); Log.Info("重置 " + ((Object)item).name + " 的位置"); break; case "cradle_plat (7)": item.transform.position = new Vector3(31.81f, 80.87f, -0.2602f); Log.Info("重置 " + ((Object)item).name + " 的位置"); break; case "cradle_plat (8)": item.transform.position = new Vector3(48.9f, 93.74f, -0.2602f); Log.Info("重置 " + ((Object)item).name + " 的位置"); break; case "cradle_plat": item.transform.position = new Vector3(31.27f, 108.25f, -0.2602f); Log.Info("重置 " + ((Object)item).name + " 的位置"); break; } } foreach (GameObject item2 in list2) { Transform val2 = item2.transform.Find("spikes hit"); if ((Object)(object)val2 != (Object)null) { DamageHero component = ((Component)val2).GetComponent<DamageHero>(); if ((Object)(object)component != (Object)null) { component.damageDealt = 2; component.hazardType = (HazardType)0; } } else { Log.Warn(((Object)item2).name + " 没有找到子物品 spikes hit"); } } } if ((Object)(object)GameManager.instance == (Object)null) { Log.Warn("GameManager.instance 为 null,无法重置平台"); return; } SceneData sceneData = GameManager.instance.sceneData; if (sceneData == null) { Log.Warn("sceneData 为 null,无法重置平台"); return; } if (sceneData.persistentBools == null) { Log.Warn("persistentBools 为 null,无法重置平台"); return; } if (((PersistentItemDataCollection<bool, SerializableBoolData>)(object)sceneData.persistentBools).serializedList == null) { Log.Warn("serializedList 为 null,无法重置平台"); return; } List<SerializableBoolData> list3 = ((PersistentItemDataCollection<bool, SerializableBoolData>)(object)sceneData.persistentBools).serializedList.FindAll((SerializableBoolData x) => ((SerializableItemData<bool>)(object)x).SceneName == "Cradle_03" && ((SerializableItemData<bool>)(object)x).ID.Contains("plat")); if (list3.Count == 0) { return; } int num = 0; foreach (SerializableBoolData item3 in list3) { bool value = ((SerializableItemData<bool>)(object)item3).Value; ((SerializableItemData<bool>)(object)item3).Value = false; num++; } } catch (Exception ex) { Log.Error("重置平台失败: " + ex.Message); Log.Error("堆栈跟踪: " + ex.StackTrace); } } private void LoadEmbeddedTextures() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream != null && text.Contains("SLIK")) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); BoulderTexture = new Texture2D(2, 2); ImageConversion.LoadImage(BoulderTexture, array); ((Texture)BoulderTexture).filterMode = (FilterMode)0; ((Texture)BoulderTexture).wrapMode = (TextureWrapMode)1; Log.Info("成功加载 Boulder 贴图: " + text); } } } private void OnDestroy() { _harmony.UnpatchSelf(); } } } namespace AnySilkBoss.Source.Tools { internal static class FsmAnalyzer { public static void WriteFsmReport(PlayMakerFSM fsm, string outputPath) { if ((Object)(object)fsm == (Object)null) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== FSM 报告: " + fsm.FsmName + " ==="); stringBuilder.AppendLine("当前状态: " + fsm.ActiveStateName); 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); } 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--- 各状态转换与动作 ---"); FsmState[] array4 = fsmStates; foreach (FsmState val4 in array4) { stringBuilder.AppendLine("状态 " + val4.Name + " 的转换:"); 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) + " -> " + val5.toState); } } else { stringBuilder.AppendLine(" (无转换)"); } if (val4.Actions != null && val4.Actions.Length != 0) { stringBuilder.AppendLine($"动作 ({val4.Actions.Length}个):"); for (int n = 0; n < val4.Actions.Length; n++) { FsmStateAction val6 = val4.Actions[n]; stringBuilder.AppendLine($" [{n}] {((object)val6).GetType().Name}"); AnalyzeActionVariables(stringBuilder, val6, n); } } else { stringBuilder.AppendLine("动作: 无"); } } FsmVariables fsmVariables = fsm.FsmVariables; stringBuilder.AppendLine("\n--- 变量 ---"); stringBuilder.AppendLine($"Bool: {fsmVariables.BoolVariables.Length}, Int: {fsmVariables.IntVariables.Length}, Float: {fsmVariables.FloatVariables.Length}, String: {fsmVariables.StringVariables.Length}"); FsmFloat[] floatVariables = fsmVariables.FloatVariables; foreach (FsmFloat val7 in floatVariables) { stringBuilder.AppendLine($"Float {((NamedVariable)val7).Name} = {val7.Value}"); } FsmBool[] boolVariables = fsmVariables.BoolVariables; foreach (FsmBool val8 in boolVariables) { stringBuilder.AppendLine($"Bool {((NamedVariable)val8).Name} = {val8.Value}"); } FsmInt[] intVariables = fsmVariables.IntVariables; foreach (FsmInt val9 in intVariables) { stringBuilder.AppendLine($"Int {((NamedVariable)val9).Name} = {val9.Value}"); } FsmString[] stringVariables = fsmVariables.StringVariables; foreach (FsmString val10 in stringVariables) { stringBuilder.AppendLine("String " + ((NamedVariable)val10).Name + " = " + val10.Value); } 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); sb.AppendLine($" 行为 {actionIndex} 的变量:"); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object value = fieldInfo.GetValue(action); if (value == null) { continue; } sb.AppendLine($" {fieldInfo.Name}: {value} ({value.GetType().Name})"); FsmFloat val = (FsmFloat)((value is FsmFloat) ? value : null); if (val != null) { sb.AppendLine($" -> FsmFloat值: {val.Value}"); if (((NamedVariable)val).UseVariable && ((NamedVariable)val).Name != null) { sb.AppendLine(" -> 使用变量: " + ((NamedVariable)val).Name); } continue; } FsmString val2 = (FsmString)((value is FsmString) ? value : null); if (val2 != null) { sb.AppendLine(" -> FsmString值: " + val2.Value); if (((NamedVariable)val2).UseVariable && ((NamedVariable)val2).Name != null) { sb.AppendLine(" -> 使用变量: " + ((NamedVariable)val2).Name); } continue; } FsmBool val3 = (FsmBool)((value is FsmBool) ? value : null); if (val3 != null) { sb.AppendLine($" -> FsmBool值: {val3.Value}"); if (((NamedVariable)val3).UseVariable && ((NamedVariable)val3).Name != null) { sb.AppendLine(" -> 使用变量: " + ((NamedVariable)val3).Name); } continue; } FsmInt val4 = (FsmInt)((value is FsmInt) ? value : null); if (val4 != null) { sb.AppendLine($" -> FsmInt值: {val4.Value}"); if (((NamedVariable)val4).UseVariable && ((NamedVariable)val4).Name != null) { sb.AppendLine(" -> 使用变量: " + ((NamedVariable)val4).Name); } continue; } FsmGameObject val5 = (FsmGameObject)((value is FsmGameObject) ? value : null); if (val5 != null) { AnalyzeFsmGameObject(sb, val5, action); continue; } FsmOwnerDefault val6 = (FsmOwnerDefault)((value is FsmOwnerDefault) ? value : null); if (val6 != null) { AnalyzeFsmOwnerDefault(sb, val6, action); continue; } FsmEvent val7 = (FsmEvent)((value is FsmEvent) ? value : null); if (val7 != null) { sb.AppendLine(" -> FsmEvent: " + val7.Name); continue; } GameObject val8 = (GameObject)((value is GameObject) ? value : null); if (val8 != null) { sb.AppendLine(" -> GameObject名称: " + ((Object)val8).name); sb.AppendLine(" -> GameObject路径: " + GetGameObjectPath(val8)); } } } catch (Exception ex) { sb.AppendLine($" 分析行为 {actionIndex} 变量时出错: {ex.Message}"); } } private static void AnalyzeFsmGameObject(StringBuilder sb, FsmGameObject fsmGameObject, FsmStateAction action) { sb.AppendLine(" -> FsmGameObject详情:"); if (((NamedVariable)fsmGameObject).UseVariable) { sb.AppendLine(" 使用变量: " + ((NamedVariable)fsmGameObject).Name); } GameObject value = fsmGameObject.Value; if ((Object)(object)value != (Object)null) { sb.AppendLine(" GameObject名称: " + ((Object)value).name); sb.AppendLine(" GameObject路径: " + GetGameObjectPath(value)); sb.AppendLine($" 是否激活: {value.activeSelf}"); Component[] components = value.GetComponents<Component>(); if (components.Length != 0) { sb.AppendLine(" 组件列表: " + string.Join(", ", components.Select((Component c) => ((object)c).GetType().Name))); } } else { sb.AppendLine(" GameObject值: null (可能在运行时设置)"); } } private static void AnalyzeFsmOwnerDefault(StringBuilder sb, FsmOwnerDefault fsmOwnerDefault, FsmStateAction action) { sb.AppendLine(" -> FsmOwnerDefault详情:"); try { FieldInfo field = ((object)fsmOwnerDefault).GetType().GetField("OwnerOption"); if (field != null) { object value = field.GetValue(fsmOwnerDefault); sb.AppendLine($" OwnerOption: {value}"); } } catch { } try { PropertyInfo property = ((object)fsmOwnerDefault).GetType().GetProperty("GameObject"); if (property != null) { object? value2 = property.GetValue(fsmOwnerDefault); FsmGameObject val = (FsmGameObject)((value2 is FsmGameObject) ? value2 : null); if (val != null && (Object)(object)val.Value != (Object)null) { sb.AppendLine(" 指定GameObject名称: " + ((Object)val.Value).name); sb.AppendLine(" 指定GameObject路径: " + GetGameObjectPath(val.Value)); } } } catch { } if (action.Fsm != null && (Object)(object)action.Fsm.GameObject != (Object)null) { sb.AppendLine(" Owner(FSM宿主)名称: " + ((Object)action.Fsm.GameObject).name); sb.AppendLine(" Owner(FSM宿主)路径: " + GetGameObjectPath(action.Fsm.GameObject)); } } 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; } } 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 Error(object error) { ManualLogSource? logSource = _logSource; if (logSource != null) { logSource.LogError((object)(LogPrefix + error)); } } internal static void Fatal(object fatal) { ManualLogSource? logSource = _logSource; if (logSource != null) { logSource.LogFatal((object)(LogPrefix + fatal)); } } internal static void Info(object info) { ManualLogSource? logSource = _logSource; if (logSource != null) { logSource.LogInfo((object)(LogPrefix + info)); } } internal static void Message(object message) { ManualLogSource? logSource = _logSource; if (logSource != null) { logSource.LogMessage((object)(LogPrefix + message)); } } internal static void Warn(object warning) { ManualLogSource? logSource = _logSource; if (logSource != null) { logSource.LogWarning((object)(LogPrefix + warning)); } } } } namespace AnySilkBoss.Source.Patches { internal static class BossPatches { [HarmonyPrefix] [HarmonyPatch(typeof(PlayMakerFSM), "Start")] private static void ModifyBoss(PlayMakerFSM __instance) { if (((Object)__instance).name == "Silk Boss" && __instance.FsmName == "Control") { HandleBossControl(__instance); } else if (((Object)__instance).name == "Silk Boss" && __instance.FsmName == "Stun Control") { HandleStunControl(__instance); } else if (((Object)__instance).name == "Silk Boss" && __instance.FsmName == "Phase Control") { HandlePhaseControl(__instance); } else if (((Object)__instance).name == "Silk Boss" && __instance.FsmName == "Attack Control") { HandleAttackControl(__instance); } else if ((((Object)__instance).name == "Rubble Field M" || ((Object)__instance).name == "Rubble Field L" || ((Object)__instance).name == "Rubble Field R") && __instance.FsmName == "FSM") { HandleRubbleField(__instance); } else if (((Object)__instance).name.Contains("Silk Boulder") && __instance.FsmName == "Control") { HandleSilkBoulder(__instance); } } private static void HandleBossControl(PlayMakerFSM __instance) { if (MemoryManager.IsInMemoryMode) { BossBehavior component = ((Component)__instance).gameObject.GetComponent<BossBehavior>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); Log.Info("[Memory模式] 移除普通BossBehavior组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<MemoryBossBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<MemoryBossBehavior>(); Log.Info("[Memory模式] 添加梦境版 MemoryBossBehavior 组件"); } DamageReductionManager component2 = ((Component)__instance).gameObject.GetComponent<DamageReductionManager>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); Log.Info("[Memory模式] 移除普通DamageReductionManager组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<MemoryDamageReductionManager>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<MemoryDamageReductionManager>(); Log.Info("[Memory模式] 添加梦境版 MemoryDamageReductionManager 组件"); } } else { MemoryBossBehavior component3 = ((Component)__instance).gameObject.GetComponent<MemoryBossBehavior>(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); Log.Info("[普通模式] 移除梦境版 MemoryBossBehavior 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<BossBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<BossBehavior>(); Log.Info("检测到没有BossBehavior组件,添加BossBehavior组件"); } MemoryDamageReductionManager component4 = ((Component)__instance).gameObject.GetComponent<MemoryDamageReductionManager>(); if ((Object)(object)component4 != (Object)null) { Object.Destroy((Object)(object)component4); Log.Info("[普通模式] 移除梦境版 MemoryDamageReductionManager 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<DamageReductionManager>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DamageReductionManager>(); Log.Info("添加DamageReductionManager组件,启用动态减伤系统"); } } } private static void HandleStunControl(PlayMakerFSM __instance) { if (MemoryManager.IsInMemoryMode) { StunControlBehavior component = ((Component)__instance).gameObject.GetComponent<StunControlBehavior>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); Log.Info("[Memory模式] 移除普通StunControlBehavior组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<MemoryStunControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<MemoryStunControlBehavior>(); Log.Info("[Memory模式] 添加梦境版 MemoryStunControlBehavior 组件"); } } else { MemoryStunControlBehavior component2 = ((Component)__instance).gameObject.GetComponent<MemoryStunControlBehavior>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); Log.Info("[普通模式] 移除梦境版 MemoryStunControlBehavior 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<StunControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<StunControlBehavior>(); Log.Info("检测到没有StunControlBehavior组件,添加StunControlBehavior组件"); } } } private static void HandlePhaseControl(PlayMakerFSM __instance) { if (MemoryManager.IsInMemoryMode) { PhaseControlBehavior component = ((Component)__instance).gameObject.GetComponent<PhaseControlBehavior>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); Log.Info("[Memory模式] 移除普通 PhaseControlBehavior 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<MemoryPhaseControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<MemoryPhaseControlBehavior>(); Log.Info("[Memory模式] 添加梦境版 MemoryPhaseControl 组件"); } } else { MemoryPhaseControlBehavior component2 = ((Component)__instance).gameObject.GetComponent<MemoryPhaseControlBehavior>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); Log.Info("[普通模式] 移除梦境版 MemoryPhaseControl 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<PhaseControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<PhaseControlBehavior>(); Log.Info("[普通模式] 添加 PhaseControlBehavior 组件"); } } } private static void HandleAttackControl(PlayMakerFSM __instance) { if (MemoryManager.IsInMemoryMode) { AttackControlBehavior component = ((Component)__instance).gameObject.GetComponent<AttackControlBehavior>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); Log.Info("[Memory模式] 移除普通 AttackControlBehavior 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<MemoryAttackControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<MemoryAttackControlBehavior>(); Log.Info("[Memory模式] 添加梦境版 MemoryAttackControlBehavior 组件"); } } else { MemoryAttackControlBehavior component2 = ((Component)__instance).gameObject.GetComponent<MemoryAttackControlBehavior>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); Log.Info("[普通模式] 移除梦境版 MemoryAttackControlBehavior 组件"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<AttackControlBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<AttackControlBehavior>(); Log.Info("检测到没有AttackControlBehavior组件,添加AttackControlBehavior组件"); } } } private static void HandleRubbleField(PlayMakerFSM __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent<RubbleFieldBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<RubbleFieldBehavior>(); Log.Info("检测到没有RubbleFieldBehavior组件,添加RubbleFieldBehavior组件"); } } private static void HandleSilkBoulder(PlayMakerFSM __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent<RubbleRockBehavior>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<RubbleRockBehavior>(); } } } internal static class DamageReductionPatches { [HarmonyPrefix] [HarmonyPatch(typeof(HealthManager), "TakeDamage")] public static void Prefix(HealthManager __instance, ref HitInstance hitInstance) { if (((Object)((Component)__instance).gameObject).name != "Silk Boss") { return; } DamageReductionManager component = ((Component)__instance).GetComponent<DamageReductionManager>(); if ((Object)(object)component == (Object)null) { Log.Error("[减伤系统] ❌ 未找到DamageReductionManager组件!"); return; } int damageDealt = hitInstance.DamageDealt; float num = component.CalculateReductionForIncomingDamage(damageDealt); if (num <= 0f) { component.RecordReducedDamage(damageDealt); return; } float num2 = DamageReductionManager.ApplyReductionRatio(damageDealt, num); int num3 = (hitInstance.DamageDealt = Mathf.Max(1, Mathf.RoundToInt(num2))); component.RecordReducedDamage(num3); Log.Info($"[减伤系统] 原始伤害: {damageDealt} → 减伤后: {num3} (减伤率: {num:P0})"); } } [HarmonyPatch(typeof(HeroController))] internal static class HeroControllerDeathPatches { [HarmonyPostfix] [HarmonyPatch("Die")] private static void OnPlayerDiePostfix(bool nonLethal) { try { if ((Object)(object)DeathManager.Instance != (Object)null && MemoryManager.IsInMemoryMode) { Log.Info($"[DeathManager] 梦境中死亡,nonLethal={nonLethal},设置等待重生标志"); DeathManager.Instance.SetWaitingForMemoryRespawn(); } } catch (Exception ex) { Log.Error("[DeathManager] Die 补丁失败: " + ex.Message); } } } [HarmonyPatch(typeof(GameManager))] internal static class GameManagerRespawnPatches { [HarmonyPostfix] [HarmonyPatch("GetRespawnInfo")] private static void OnGetRespawnInfoPostfix(ref string scene, ref string marker) { try { if (MemoryManager.IsInMemoryMode) { string text = scene; string text2 = marker; scene = "Cradle_03"; marker = "MemoryRespawnMarker"; Log.Info("[DeathManager] 梦境模式修改重生信息: " + text + "/" + text2 + " → " + scene + "/" + marker); } } catch (Exception ex) { Log.Error("[DeathManager] GetRespawnInfo 补丁失败: " + ex.Message); } } } internal static class I18nPatches { [HarmonyPostfix] [HarmonyPatch(typeof(Language), "Get", new Type[] { typeof(string), typeof(string) })] private static void ChangeBossTitle(string key, string sheetTitle, ref string __result) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Invalid comparison between Unknown and I4 //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 try { if (new Func<LanguageCode>(Language.CurrentLanguage) == null || !Plugin.IsInBossRoom) { return; } string text2; if (MemoryManager.IsInMemoryMode) { if (1 == 0) { } if (!(key == "SILK_SUPER")) { if (key == "SILK_MAIN") { LanguageCode val = Language.CurrentLanguage(); if (1 == 0) { } string text = (((int)val == 44) ? "Dawn" : (((int)val != 199) ? __result : "破晓")); if (1 == 0) { } text2 = text; } else { text2 = __result; } } else { LanguageCode val2 = Language.CurrentLanguage(); if (1 == 0) { } string text = (((int)val2 == 44) ? "Astral Oblivion" : (((int)val2 != 199) ? __result : "苍耀归墟")); if (1 == 0) { } text2 = text; } if (1 == 0) { } __result = text2; return; } if (1 == 0) { } if (!(key == "SILK_SUPER")) { if (key == "SILK_MAIN") { LanguageCode val3 = Language.CurrentLanguage(); if (1 == 0) { } string text = (((int)val3 == 44) ? "Silk" : (((int)val3 != 199) ? __result : "灵丝")); if (1 == 0) { } text2 = text; } else { text2 = __result; } } else { LanguageCode val4 = Language.CurrentLanguage(); if (1 == 0) { } string text = (((int)val4 == 44) ? "Loombinder Matriarch" : (((int)val4 != 199) ? __result : "织狱圣母")); if (1 == 0) { } text2 = text; } if (1 == 0) { } __result = text2; } catch (Exception ex) { Log.Error("Language.Get补丁执行失败: " + ex.Message); } } } [HarmonyPatch(typeof(GameManager))] internal static class MemorySceneTransitionPatch { private const string TARGET_SCENE = "Cradle_03"; private const string TRIGGER_SCENE = "Cradle_03_Destroyed"; [HarmonyPrefix] [HarmonyPatch("BeginSceneTransition")] private static bool OnBeginSceneTransition(GameManager __instance, SceneLoadInfo info) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!MemoryManager.IsInMemoryMode) { return true; } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (name != "Cradle_03") { return true; } if (info.SceneName == "Menu_Title" || info.SceneName == "Quit_To_Menu" || info.SceneName == "PermaDeath" || string.IsNullOrEmpty(info.SceneName)) { return true; } if (info.SceneName == "Cradle_03_Destroyed") { return true; } if (info.SceneName == name) { Log.Info("[MemoryPatch] 允许同场景重生: " + name); return true; } Log.Info("[MemoryPatch] 拦截梦境中的场景切换: " + name + " → " + info.SceneName + ",改为退出梦境"); MemoryManager.Instance?.TriggerExitMemory(); return false; } } [HarmonyPatch(typeof(DamageEnemies), "HasBeenDamaged", new Type[] { typeof(IHitResponder) })] internal static class MemoryClashTinkPatch { [HarmonyPrefix] private static bool Prefix(DamageEnemies __instance, IHitResponder hitResponder, ref bool __result) { if (!MemoryManager.IsInMemoryMode) { return true; } HealthManager val = (HealthManager)(object)((hitResponder is HealthManager) ? hitResponder : null); if ((Object)(object)val == (Object)null) { return true; } if (((Object)((Component)val).gameObject).name != "Silk Boss") { return true; } __result = false; return false; } } [HarmonyPatch(typeof(HeroController), "NailParryRecover")] internal static class MemoryParryDownspikePatch { [HarmonyPostfix] private static void Postfix(HeroController __instance) { if (MemoryManager.IsInMemoryMode) { FieldInfo field = typeof(HeroController).GetField("allowAttackCancellingDownspikeRecovery", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(__instance, true); Log.Info("[MemoryParryDownspikePatch] 梦境模式下拼刀刷新下劈"); } } } } [HarmonyPatch(typeof(HeroController), "TakeDamage", new Type[] { typeof(GameObject), typeof(CollisionSide), typeof(int), typeof(HazardType), typeof(DamagePropertyFlags) })] internal static class HeroDamageStackPatch { [HarmonyPrefix] private static void Prefix(GameObject go, CollisionSide damageSide, ref int damageAmount, HazardType hazardType, DamagePropertyFlags damagePropertyFlags) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if (MemoryManager.IsInMemoryMode && (int)hazardType == 1 && !((Object)(object)go == (Object)null)) { DamageStackManager.DamageSourceType damageSourceType = DamageStackManager.IdentifyDamageSource(go); if (damageSourceType != 0) { int damageMultiplier = DamageStackManager.GetDamageMultiplier(damageSourceType); int num = damageAmount * damageMultiplier; DamageStackManager.RecordDamage(damageSourceType); damageAmount = num; } } } } [HarmonyPatch(typeof(ToolItemManager))] internal static class ToolItemPatches { [HarmonyPatch("SetEquippedCrest")] [HarmonyPostfix] private static void SetEquippedCrest_Postfix(string crestId) { Log.Info("[ToolItemPatches] 护符装备状态已改变: " + crestId); SilkBallManager.UpdateReaperCrestState(); } [HarmonyPatch("RefreshEquippedState")] [HarmonyPostfix] private static void RefreshEquippedState_Postfix() { Log.Info("[ToolItemPatches] 护符装备状态已刷新"); SilkBallManager.UpdateReaperCrestState(); } [HarmonyPatch("SendEquippedChangedEvent")] [HarmonyPostfix] private static void SendEquippedChangedEvent_Postfix(bool force) { Log.Info("[ToolItemPatches] 护符装备变更事件已发送"); SilkBallManager.UpdateReaperCrestState(); } } } namespace AnySilkBoss.Source.Managers { internal sealed class AssetManager : MonoBehaviour { private class AssetConfig { public string? BundleName { get; set; } public string? ObjectPath { get; set; } } [CompilerGenerated] private sealed class <LoadAssetAsync>d__26 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string assetName; public AssetManager <>4__this; private AssetConfig <config>5__1; private Object <cached>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAssetAsync>d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <config>5__1 = null; <cached>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (string.IsNullOrEmpty(assetName)) { Log.Error("[AssetManager] 资源名称不能为空"); return false; } if (!_assetConfig.TryGetValue(assetName, out <config>5__1)) { Log.Error("[AssetManager] 未配置的资源: '" + assetName + "'。请在 AssetManager._assetConfig 中显式声明。"); return false; } if (<config>5__1.BundleName == null) { Log.Debug("[AssetManager] '" + assetName + "' 是全局资源,直接同步获取"); return false; } if (<>4__this._externalAssetCache.TryGetValue(assetName, out <cached>5__2) && <cached>5__2 != (Object)null) { Log.Debug("[AssetManager] 资源 '" + assetName + "' 已在缓存中"); return false; } if (<>4__this._loadingAssets.Contains(assetName)) { Log.Debug("[AssetManager] 资源 '" + assetName + "' 正在加载中,等待完成..."); goto IL_0166; } <>4__this._loadingAssets.Add(assetName); if (<config>5__1.ObjectPath == null) { <>2__current = <>4__this.LoadFromExternalBundle(assetName, <config>5__1.BundleName); <>1__state = 2; return true; } <>2__current = <>4__this.LoadFromSceneBundle(assetName, <config>5__1.BundleName, <config>5__1.ObjectPath); <>1__state = 3; return true; case 1: <>1__state = -1; goto IL_0166; case 2: <>1__state = -1; break; case 3: { <>1__state = -1; break; } IL_0166: if (<>4__this._loadingAssets.Contains(assetName)) { <>2__current = null; <>1__state = 1; return true; } return false; } <>4__this._loadingAssets.Remove(assetName); 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 <LoadAssetsAsync>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string[] assetNames; public AssetManager <>4__this; private Dictionary<string, List<string>> <groupedByBundle>5__1; private string[] <>s__2; private int <>s__3; private string <assetName>5__4; private AssetConfig <config>5__5; private Dictionary<string, List<string>>.Enumerator <>s__6; private KeyValuePair<string, List<string>> <group>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAssetsAsync>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <groupedByBundle>5__1 = null; <>s__2 = null; <assetName>5__4 = null; <config>5__5 = null; <>s__6 = default(Dictionary<string, List<string>>.Enumerator); <group>5__7 = default(KeyValuePair<string, List<string>>); <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <groupedByBundle>5__1 = new Dictionary<string, List<string>>(); <>s__2 = assetNames; for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++) { <assetName>5__4 = <>s__2[<>s__3]; if (_assetConfig.TryGetValue(<assetName>5__4, out <config>5__5) && <config>5__5.BundleName != null && !<>4__this.IsAssetLoaded(<assetName>5__4) && !<>4__this.IsAssetLoading(<assetName>5__4)) { if (!<groupedByBundle>5__1.ContainsKey(<config>5__5.BundleName)) { <groupedByBundle>5__1[<config>5__5.BundleName] = new List<string>(); } <groupedByBundle>5__1[<config>5__5.BundleName].Add(<assetName>5__4); <config>5__5 = null; <assetName>5__4 = null; } } <>s__2 = null; <>s__6 = <groupedByBundle>5__1.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <group>5__7 = default(KeyValuePair<string, List<string>>); break; } if (<>s__6.MoveNext()) { <group>5__7 = <>s__6.Current; <>2__current = <>4__this.LoadFromBundleBatch(<group>5__7.Key, <group>5__7.Value); <>1__state = 1; return true; } <>m__Finally1(); <>s__6 = default(Dictionary<string, List<string>>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__6).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadFromBundleBatch>d__34 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string bundleName; public List<string> assetNames; public AssetManager <>4__this; private List<string> <exactMatchAssets>5__1; private List<string> <scenePathAssets>5__2; private string <bundlePath>5__3; private AssetBundle <bundle>5__4; private List<string>.Enumerator <>s__5; private string <name>5__6; private List<string>.Enumerator <>s__7; private string <assetName>5__8; private AssetConfig <config>5__9; private List<string>.Enumerator <>s__10; private string <name>5__11; private List<string>.Enumerator <>s__12; private string <name>5__13; private string[] <bundleAssetPaths>5__14; private List<string>.Enumerator <>s__15; private string <assetName>5__16; private string[] <>s__17; private int <>s__18; private string <assetPath>5__19; private string <currentAssetName>5__20; private Object <asset>5__21; private GameObject <go>5__22; private bool <wasActive>5__23; private GameObject <copy>5__24; private string <sceneName>5__25; private string[] <scenePaths>5__26; private string <sceneToLoad>5__27; private GameObject <tempCamera>5__28; private AsyncOperation <loadOp>5__29; private Scene <scene>5__30; private AsyncOperation <unloadOp>5__31; private List<string>.Enumerator <>s__32; private string <assetName>5__33; private AssetConfig <config>5__34; private GameObject <sourceObject>5__35; private GameObject <copy>5__36; private List<string>.Enumerator <>s__37; private string <name>5__38; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadFromBundleBatch>d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <exactMatchAssets>5__1 = null; <scenePathAssets>5__2 = null; <bundlePath>5__3 = null; <bundle>5__4 = null; <>s__5 = default(List<string>.Enumerator); <name>5__6 = null; <>s__7 = default(List<string>.Enumerator); <assetName>5__8 = null; <config>5__9 = null; <>s__10 = default(List<string>.Enumerator); <name>5__11 = null; <>s__12 = default(List<string>.Enumerator); <name>5__13 = null; <bundleAssetPaths>5__14 = null; <>s__15 = default(List<string>.Enumerator); <assetName>5__16 = null; <>s__17 = null; <assetPath>5__19 = null; <currentAssetName>5__20 = null; <asset>5__21 = null; <go>5__22 = null; <copy>5__24 = null; <sceneName>5__25 = null; <scenePaths>5__26 = null; <sceneToLoad>5__27 = null; <tempCamera>5__28 = null; <loadOp>5__29 = null; <unloadOp>5__31 = null; <>s__32 = default(List<string>.Enumerator); <assetName>5__33 = null; <config>5__34 = null; <sourceObject>5__35 = null; <copy>5__36 = null; <>s__37 = default(List<string>.Enumerator); <name>5__38 = null; <>1__state = -2; } private bool MoveNext() { //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__5 = assetNames.GetEnumerator(); try { while (<>s__5.MoveNext()) { <name>5__6 = <>s__5.Current; <>4__this._loadingAssets.Add(<name>5__6); <name>5__6 = null; } } finally { ((IDisposable)<>s__5).Dispose(); } <>s__5 = default(List<string>.Enumerator); <exactMatchAssets>5__1 = new List<string>(); <scenePathAssets>5__2 = new List<string>(); <>s__7 = assetNames.GetEnumerator(); try { while (<>s__7.MoveNext()) { <assetName>5__8 = <>s__7.Current; <config>5__9 = _assetConfig[<assetName>5__8]; if (<config>5__9.ObjectPath == null) { <exactMatchAssets>5__1.Add(<assetName>5__8); } else { <scenePathAssets>5__2.Add(<assetName>5__8); } <config>5__9 = null; <assetName>5__8 = null; } } finally { ((IDisposable)<>s__7).Dispose(); } <>s__7 = default(List<string>.Enumerator); <bundlePath>5__3 = Path.Combine(BundleRootFolder, bundleName); if (!File.Exists(<bundlePath>5__3)) { Log.Error("[AssetManager] Bundle 文件不存在: " + <bundlePath>5__3); <>s__10 = assetNames.GetEnumerator(); try { while (<>s__10.MoveNext()) { <name>5__11 = <>s__10.Current; <>4__this._loadingAssets.Remove(<name>5__11); <name>5__11 = null; } } finally { ((IDisposable)<>s__10).Dispose(); } <>s__10 = default(List<string>.Enumerator); return false; } <bundle>5__4 = AssetBundle.LoadFromFile(<bundlePath>5__3); if ((Object)(object)<bundle>5__4 == (Object)null) { Log.Error("[AssetManager] 无法加载 Bundle: " + <bundlePath>5__3); <>s__12 = assetNames.GetEnumerator(); try { while (<>s__12.MoveNext()) { <name>5__13 = <>s__12.Current; <>4__this._loadingAssets.Remove(<name>5__13); <name>5__13 = null; } } finally { ((IDisposable)<>s__12).Dispose(); } <>s__12 = default(List<string>.Enumerator); return false; } if (<exactMatchAssets>5__1.Count > 0) { Log.Info($"[AssetManager] 从 Bundle '{bundleName}' 批量加载 {<exactMatchAssets>5__1.Count} 个精确匹配资源..."); <bundleAssetPaths>5__14 = <bundle>5__4.GetAllAssetNames(); <>s__15 = <exactMatchAssets>5__1.GetEnumerator(); try { while (<>s__15.MoveNext()) { <assetName>5__16 = <>s__15.Current; <>s__17 = <bundleAssetPaths>5__14; for (<>s__18 = 0; <>s__18 < <>s__17.Length; <>s__18++) { <assetPath>5__19 = <>s__17[<>s__18]; <currentAssetName>5__20 = Path.GetFileNameWithoutExtension(<assetPath>5__19); if (<currentAssetName>5__20.Equals(<assetName>5__16, StringComparison.OrdinalIgnoreCase)) { <asset>5__21 = <bundle>5__4.LoadAsset<Object>(<assetPath>5__19); if (<asset>5__21 != (Object)null) { ref GameObject reference = ref <go>5__22; Object obj = <asset>5__21; reference = (GameObject)(object)((obj is GameObject) ? obj : null); if (<go>5__22 != null && (Object)(object)<>4__this._assetPool != (Object)null) { <wasActive>5__23 = <go>5__22.activeSelf; <go>5__22.SetActive(false); <copy>5__24 = Object.Instantiate<GameObject>(<go>5__22); ((Object)<copy>5__24).name = <assetName>5__16 + " (Prefab)"; <go>5__22.SetActive(<wasActive>5__23); <>4__this.DisableAutoDestructComponents(<copy>5__24); <copy>5__24.transform.SetParent(<>4__this._assetPool.transform); <>4__this._externalAssetCache[<assetName>5__16] = (Object)(object)<copy>5__24; <copy>5__24 = null; } else { <>4__this._externalAssetCache[<assetName>5__16] = <asset>5__21; } Log.Info("[AssetManager] 资源 '" + <assetName>5__16 + "' 加载成功"); <go>5__22 = null; } break; } <currentAssetName>5__20 = null; <assetPath>5__19 = null; } <>s__17 = null; <assetName>5__16 = null; } } finally { ((IDisposable)<>s__15).Dispose(); } <>s__15 = default(List<string>.Enumerator); <bundleAssetPaths>5__14 = null; } if (<scenePathAssets>5__2.Count > 0) { Log.Info($"[AssetManager] 从场景 Bundle '{bundleName}' 批量加载 {<scenePathAssets>5__2.Count} 个场景对象..."); <sceneName>5__25 = Path.GetFileNameWithoutExtension(bundleName); <scenePaths>5__26 = <bundle>5__4.GetAllScenePaths(); <sceneToLoad>5__27 = <sceneName>5__25; if (<scenePaths>5__26.Length != 0) { <sceneToLoad>5__27 = <scenePaths>5__26[0]; } <tempCamera>5__28 = <>4__this.CreateTempCamera(); <loadOp>5__29 = SceneManager.LoadSceneAsync(<sceneToLoad>5__27, (LoadSceneMode)1); <>2__current = <loadOp>5__29; <>1__state = 1; return true; } break; case 1: <>1__state = -1; <scene>5__30 = SceneManager.GetSceneByPath(<sceneToLoad>5__27); if (!((Scene)(ref <scene>5__30)).IsValid()) { <scene>5__30 = SceneManager.GetSceneByName(Path.GetFileNameWithoutExtension(<sceneToLoad>5__27)); } if (!((Scene)(ref <scene>5__30)).isLoaded) { Log.Error("[AssetManager] 场景加载失败: " + <sceneToLoad>5__27); if ((Object)(object)<tempCamera>5__28 != (Object)null) { Object.Destroy((Object)(object)<tempCamera>5__28); } goto IL_08f0; } <>4__this.DisableProblematicComponents(<scene>5__30); <>s__32 = <scenePathAssets>5__2.GetEnumerator(); try { while (<>s__32.MoveNext()) { <assetName>5__33 = <>s__32.Current; <config>5__34 = _assetConfig[<assetName>5__33]; <sourceObject>5__35 = <>4__this.FindObjectInScene(<scene>5__30, <config>5__34.ObjectPath); if ((Object)(object)<sourceObject>5__35 == (Object)null) { Log.Error("[AssetManager] 在场景 '" + <sceneName>5__25 + "' 中未找到对象 '" + <config>5__34.ObjectPath + "'"); continue; } <copy>5__36 = Object.Instantiate<GameObject>(<sourceObject>5__35); ((Object)<copy>5__36).name = <assetName>5__33 + " (Prefab)"; <copy>5__36.SetActive(false); if ((Object)(object)<>4__this._assetPool != (Object)null) { <copy>5__36.transform.SetParent(<>4__this._assetPool.transform); } <>4__this._externalAssetCache[<assetName>5__33] = (Object)(object)<copy>5__36; Log.Info("[AssetManager] 场景对象 '" + <assetName>5__33 + "' 加载成功"); <config>5__34 = null; <sourceObject>5__35 = null; <copy>5__36 = null; <assetName>5__33 = null; } } finally { ((IDisposable)<>s__32).Dispose(); } <>s__32 = default(List<string>.Enumerator); <unloadOp>5__31 = SceneManager.UnloadSceneAsync(((Scene)(ref <scene>5__30)).name); <>2__current = <unloadOp>5__31; <>1__state = 2; return true; case 2: { <>1__state = -1; if ((Object)(object)<tempCamera>5__28 != (Object)null) { Object.Destroy((Object)(object)<tempCamera>5__28); } <unloadOp>5__31 = null; goto IL_08f0; } IL_08f0: <sceneName>5__25 = null; <scenePaths>5__26 = null; <sceneToLoad>5__27 = null; <tempCamera>5__28 = null; <loadOp>5__29 = null; break; } <bundle>5__4.Unload(false); <>s__37 = assetNames.GetEnumerator(); try { while (<>s__37.MoveNext()) { <name>5__38 = <>s__37.Current; <>4__this._loadingAssets.Remove(<name>5__38); <name>5__38 = null; } } finally { ((IDisposable)<>s__37).Dispose(); } <>s__37 = default(List<string>.Enumerator); Log.Info("[AssetManager] Bundle '" + bundleName + "' 批量加载完成"); 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 <LoadFromExternalBundle>d__32 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string assetName; public string bundleName; public AssetManager <>4__this; private string <bundlePath>5__1; private AssetBundle <bundle>5__2; private string[] <assetPaths>5__3; private string[] <>s__4; private int <>s__5; private string <assetPath>5__6; private string <currentAssetName>5__7; private Object <asset>5__8; private GameObject <go>5__9; private bool <wasActive>5__10; private GameObject <copy>5__11; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadFromExternalBundle>d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <bundlePath>5__1 = null; <bundle>5__2 = null; <assetPaths>5__3 = null; <>s__4 = null; <assetPath>5__6 = null; <currentAssetName>5__7 = null; <asset>5__8 = null; <go>5__9 = null; <copy>5__11 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; Log.Info("[AssetManager] 从 Bundle '" + bundleName + "' 加载资源: " + assetName); <bundlePath>5__1 = Path.Combine(BundleRootFolder, bundleName); if (!File.Exists(<bundlePath>5__1)) { Log.Error("[AssetManager] Bundle 文件不存在: " + <bundlePath>5__1); return false; } <bundle>5__2 = AssetBundle.LoadFromFile(<bundlePath>5__1); if ((Object)(object)<bundle>5__2 == (Object)null) { Log.Error("[AssetManager] 无法加载 Bundle: " + <bundlePath>5__1); return false; } try { <assetPaths>5__3 = <bundle>5__2.GetAllAssetNames(); <>s__4 = <assetPaths>5__3; for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++) { <assetPath>5__6 = <>s__4[<>s__5]; <currentAssetName>5__7 = Path.GetFileNameWithoutExtension(<assetPath>5__6); if (<currentAssetName>5__7.Equals(assetName, StringComparison.OrdinalIgnoreCase)) { <asset>5__8 = <bundle>5__2.LoadAsset<Object>(<assetPath>5__6); if (<asset>5__8 != (Object)null) { ref GameObject reference = ref <go>5__9; Object obj = <asset>5__8; reference = (GameObject)(object)((obj is GameObject) ? obj : null); if (<go>5__9 != null && (Object)(object)<>4__this._assetPool != (Object)null) { <wasActive>5__10 = <go>5__9.activeSelf; <go>5__9.SetActive(false); <copy>5__11 = Object.Instantiate<GameObject>(<go>5__9); ((Object)<copy>5__11).name = assetName + " (Prefab)"; <go>5__9.SetActive(<wasActive>5__10); <>4__this.DisableAutoDestructComponents(<copy>5__11); <copy>5__11.transform.SetParent(<>4__this._assetPool.transform); <>4__this._externalAssetCache[assetName] = (Object)(object)<copy>5__11; <copy>5__11 = null; } else { <>4__this._externalAssetCache[assetName] = <asset>5__8; } Log.Info("[AssetManager] 资源 '" + assetName + "' 加载成功并已持久化"); break; } <asset>5__8 = null; } <currentAssetName>5__7 = null; <assetPath>5__6 = null; } <>s__4 = null; <assetPaths>5__3 = null; } finally { <bundle>5__2.Unload(false); } <>2__current = null; <>1__state = 1; return true; case 1: <>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 <LoadFromSceneBundle>d__33 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string assetName; public string bundleName; public string objectPath; public AssetManager <>4__this; private string <bundlePath>5__1; private AssetBundle <bundle>5__2; private string <sceneName>5__3; private string[] <scenePaths>5__4; private string <sceneToLoad>5__5; private GameObject <tempCamera>5__6; private AsyncOperation <loadOp>5__7; private Scene <scene>5__8; private GameObject <sourceObject>5__9; private AsyncOperation <unloadOp>5__10; private GameObject <copy>5__11; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadFromSceneBundle>d__33(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <bundlePath>5__1 = null; <bundle>5__2 = null; <sceneName>5__3 = null; <scenePaths>5__4 = null; <sceneToLoad>5__5 = null; <tempCamera>5__6 = null; <loadOp>5__7 = null; <sourceObject>5__9 = null; <unloadOp>5__10 = null; <copy>5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; Log.Info("[AssetManager] 从场景 Bundle '" + bundleName + "' 加载对象: " + assetName + " (路径: " + objectPath + ")"); <bundlePath>5__1 = Path.Combine(BundleRootFolder, bundleName); if (!File.Exists(<bundlePath>5__1)) { Log.Error("[AssetManager] 场景 Bundle 文件不存在: " + <bundlePath>5__1); return false; } <bundle>5__2 = AssetBundle.LoadFromFile(<bundlePath>5__1); if ((Object)(object)<bundle>5__2 == (Object)null) { Log.Error("[AssetManager] 无法加载场景 Bundle: " + <bundlePath>5__1); return false; } <sceneName>5__3 = Path.GetFileNameWithoutExtension(bundleName); <scenePaths>5__4 = <bundle>5__2.GetAllScenePaths(); <sceneToLoad>5__5 = <sceneName>5__3; if (<scenePaths>5__4.Length != 0) { <sceneToLoad>5__5 = <scenePaths>5__4[0]; } <tempCamera>5__6 = <>4__this.CreateTempCamera(); <loadOp>5__7 = SceneManager.LoadSceneAsync(<sceneToLoad>5__5, (LoadSceneMode)1); <>2__current = <loadOp>5__7; <>1__state = 1; return true; case 1: <>1__state = -1; <scene>5__8 = SceneManager.GetSceneByPath(<sceneToLoad>5__5); if (!((Scene)(ref <scene>5__8)).IsValid()) { <scene>5__8 = SceneManager.GetSceneByName(Path.GetFileNameWithoutExtension(<sceneToLoad>5__5)); } if (!((Scene)(ref <scene>5__8)).isLoaded) { Log.Error("[AssetManager] 场景加载失败: " + <sceneToLoad>5__5); <bundle>5__2.Unload(true); if ((Object)(object)<tempCamera>5__6 != (Object)null) { Object.Destroy((Object)(object)<tempCamera>5__6); } return false; } <>4__this.DisableProblematicComponents(<scene>5__8); <sourceObject>5__9 = <>4__this.FindObjectInScene(<scene>5__8, objectPath); if ((Object)(object)<sourceObject>5__9 != (Object)null) { <copy>5__11 = Object.Instantiate<GameObject>(<sourceObject>5__9); ((Object)<copy>5__11).name = assetName + " (Prefab)"; <copy>5__11.SetActive(false); if ((Object)(object)<>4__this._assetPool != (Object)null) { <copy>5__11.transform.SetParent(<>4__this._assetPool.transform); } <>4__this._externalAssetCache[assetName] = (Object)(object)<copy>5__11; Log.Info("[AssetManager] 场景对象 '" + assetName + "' 加载成功并已持久化"); <copy>5__11 = null; } else { Log.Error("[AssetManager] 在场景 '" + <sceneName>5__3 + "' 中未找到对象 '" + objectPath + "'"); } <unloadOp>5__10 = SceneManager.UnloadSceneAsync(((Scene)(ref <scene>5__8)).name); <>2__current = <unloadOp>5__10; <>1__state = 2; return true; case 2: <>1__state = -1; <bundle>5__2.Unload(false); if ((Object)(object)<tempCamera>5__6 != (Object)null) { Object.Destroy((Object)(object)<tempCamera>5__6); } 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 <LoadSceneObjectAsync>d__27 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string assetName; public AssetManager <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSceneObjectAsync>d__27(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; <>2__current = <>4__this.LoadAssetAsync(assetName); <>1__state = 1; return true; case 1: <>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 <LoadSceneObjectsAsync>d__29 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string[] assetNames; public AssetManager <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSceneObjectsAsync>d__29(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; <>2__current = <>4__this.LoadAssetsAsync(assetNames); <>1__state = 1; return true; case 1: <>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 <PreloadAllExternalAssets>d__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AssetManager <>4__this; private List<string> <externalAssets>5__1; private int <loadedCount>5__2; private int <failedCount>5__3; private Dictionary<string, AssetConfig>.Enumerator <>s__4; private KeyValuePair<string, AssetConfig> <kvp>5__5; private List<string>.Enumerator <>s__6; private string <assetName>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PreloadAllExternalAssets>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <externalAssets>5__1 = null; <>s__4 = default(Dictionary<string, AssetConfig>.Enumerator); <kvp>5__5 = default(KeyValuePair<string, AssetConfig>); <>s__6 = default(List<string>.Enumerator); <assetName>5__7 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (<>4__this._externalAssetsPreloaded || <>4__this._preloadingExternalAssets) { Log.Debug("[AssetManager] 外部资源已预加载或正在预加载,跳过"); goto IL_0074; } <>4__this._preloadingExternalAssets = true; Log.Info("[AssetManager] 开始预加载所有外部资源..."); <externalAssets>5__1 = new List<string>(); <>s__4 = _assetConfig.GetEnumerator(); try { while (<>s__4.MoveNext()) { <kvp>5__5 = <>s__4.Current; if (<kvp>5__5.Value.BundleName != null) { <externalAssets>5__1.Add(<kvp>5__5.Key); } <kvp>5__5 = default(KeyValuePair<string, AssetConfig>); } } finally { ((IDisposable)<>s__4).Dispose(); } <>s__4 = default(Dictionary<string, AssetConfig>.Enumerator); if (<externalAssets>5__1.Count == 0) { Log.Info("[AssetManager] 没有需要预加载的外部资源"); <>4__this._externalAssetsPreloaded = true; <>4__this._preloadingExternalAssets = false; return false; } Log.Info(string.Format("[AssetManager] 需要预加载 {0} 个外部资源: {1}", <externalAssets>5__1.Count, string.Join(", ", <externalAssets>5__1))); <>2__current = <>4__this.LoadAssetsAsync(<externalAssets>5__1.ToArray()); <>1__state = 2; return true; case 1: <>1__state = -1; goto IL_0074; case 2: { <>1__state = -1; <loadedCount>5__2 = 0; <failedCount>5__3 = 0; <>s__6 = <externalAssets>5__1.GetEnumerator(); try { while (<>s__6.MoveNext()) { <assetName>5__7 = <>s__6.Current; if (<>4__this.IsAssetLoaded(<assetName>5__7)) { <loadedCount>5__2++; } else { <failedCount>5__3++; Log.Warn("[AssetManager] 预加载失败: " + <assetName>5__7); } <assetName>5__7 = null; } } finally { ((IDisposable)<>s__6).Dispose(); } <>s__6 = default(List<string>.Enumerator); <>4__this._externalAssetsPreloaded = true; <>4__this._preloadingExternalAssets = false; Log.Info($"[AssetManager] 外部资源预加载完成: 成功 {<loadedCount>5__2},失败 {<failedCount>5__3}"); return false; } IL_0074: if (<>4__this._preloadingExternalAssets) { <>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(); } } [CompilerGenerated] private sealed class <WaitForPreload>d__14 : 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 <WaitForPreload>d__14(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; break; case 1: <>1__state = -1; break; } if (!<>4__this._externalAssetsPreloaded) { <>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 static readonly Dictionary<string, AssetConfig> _assetConfig = new Dictionary<string, AssetConfig> { { "Reaper Silk Bundle", new AssetConfig { BundleName = null } }, { "Abyss Bullet", new AssetConfig { BundleName = null } }, { "lace_circle_slash", new AssetConfig { BundleName = "localpoolprefabs_assets_laceboss.bundle" } }, { "First Weaver Anim", new AssetConfig { BundleName = "tk2danimations_assets_areaslab.bundle" } }, { "First Weaver Cln", new AssetConfig { BundleName = "tk2dcollections_assets_areaslab.bundle" } }, { "First Weaver Bomb Blast", new AssetConfig { BundleName = "localpoolprefabs_assets_areaslab.bundle" } }, { "focus_blast_first_weaver", new AssetConfig { BundleName = "animations_assets_areaslab.bundle" } }, { "FW Pin Projectile", new AssetConfig { BundleName = "scenes_scenes_scenes/slab_10b.bundle", ObjectPath = "Boss Scene/Pin Projectiles/FW Pin Projectile (3)" } } }; private static readonly string BundleRootFolder; private readonly Dictionary<(Type, string), Object> _globalBundleCache = new Dictionary<(Type, string), Object>(); private readonly Dictionary<string, Object> _externalAssetCache = new Dictionary<string, Object>(); private GameObject? _assetPool; private bool _initialized = false; private readonly HashSet<string> _loadingAssets = new HashSet<string>(); private bool _externalAssetsPreloaded = false; private bool _preloadingExternalAssets = false; public bool IsExternalAssetsPreloaded => _externalAssetsPreloaded; private void Awake() { CreateAssetPool(); _initialized = true; Log.Info("[AssetManager] 已初始化(统一持久化缓存架构)"); } [IteratorStateMachine(typeof(<PreloadAllExternalAssets>d__13))] public IEnumerator PreloadAllExternalAssets() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PreloadAllExternalAssets>d__13(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<WaitForPreload>d__14))] public IEnumerator WaitForPreload() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPreload>d__14(0) { <>4__this = this }; } private void CreateAssetPool() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)_assetPool == (Object)null) { _assetPool = new GameObject("AssetPool"); _assetPool.transform.SetParent(((Component)this).transform); _assetPool.SetActive(false); Log.Info("[AssetManager] AssetPool 容器已创建"); } } private void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if (_preloadingExternalAssets) { Log.Debug("[AssetManager] 场景切换: " + ((Scene)(ref scene)).name + ",预加载中,跳过缓存清理"); return; } if ((int)mode == 1) { Log.Debug("[AssetManager] 场景切换: " + ((Scene)(ref scene)).name + "(Additive),跳过缓存清理"); return; } Log.Debug("[AssetManager] 场景切换: " + ((Scene)(ref scene)).name + ",检查缓存有效性"); CleanupInvalidCaches(); } private void CleanupInvalidCaches() { List<(Type, string)> list = new List<(Type, string)>(); foreach (KeyValuePair<(Type, string), Object> item in _globalBundleCache) { if (item.Value == (Object)null) { list.Add(item.Key); } } foreach (var item2 in list) { _globalBundleCache.Remove(item2); Log.Debug("[AssetManager] 移除失效的全局缓存: " + item2.Item2); } List<string> list2 = new List<string>(); foreach (KeyValuePair<string, Object> item3 in _externalAssetCache) { if (item3.Value == (Object)null) { list2.Add(item3.Key); } } foreach (string item4 in list2) { _externalAssetCache.Remove(item4); Log.Debug("[AssetManager] 移除失效的外部资源缓存: " + item4); } int num = list.Count + list2.Count; if (num > 0) { Log.Info($"[AssetManager] 清理了 {num} 个失效的缓存引用"); } } public T? Get<T>(string assetName) where T : Object { if (string.IsNullOrEmpty(assetName)) { Log.Error("[AssetManager] 资源名称不能为空"); return default(T); } if (!_assetConfig.TryGetValue(assetName, out AssetConfig value)) { Log.Error("[AssetManager] 未配置的资源: '" + assetName + "'。请在 AssetManager._assetConfig 中显式声明。"); return default(T); } if (value.BundleName == null) { return GetFromGlobalBundle<T>(assetName); } return GetFromExternalCache<T>(assetName); } public GameObject? GetSceneObject(string assetName) { return this.Get<GameObject>(assetName); } public bool IsAssetLoaded(string assetName) { string assetName2 = assetName; if (!_assetConfig.TryGetValue(assetName2, out AssetConfig value)) { return false; } if (value.BundleName == null) { return _globalBundleCache.Keys.Any<(Type, string)>(((Type, string) k) => k.Item2 == assetName2); } Object value2; return _externalAssetCache.TryGetValue(assetName2, out value2) && value2 != (Object)null; } public bool IsSceneObjectLoaded(string assetName) { return IsAssetLoaded(assetName); } public bool IsAssetLoading(string assetName) { return _loadingAssets.Contains(assetName); } public bool IsSceneObjectLoading(string assetName) { return IsAssetLoading(assetName); } [IteratorStateMachine(typeof(<LoadAssetAsync>d__26))] public IEnumerator LoadAssetAsync(string assetName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAssetAsync>d__26(0) { <>4__this = this, assetName = assetName }; } [IteratorStateMachine(typeof(<LoadSceneObjectAsync>d__27))] public IEnumerator LoadSceneObjectAsync(string assetName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSceneObjectAsync>d__27(0) { <>4__this = this, assetName = assetName }; } [IteratorStateMachine(typeof(<LoadAssetsAsync>d__28))] public IEnumerator LoadAssetsAsync(params string[] assetNames) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAssetsAsync>d__28(0) { <>4__this = this, assetNames = assetNames }; } [IteratorStateMachine(typeof(<LoadSceneObjectsAsync>d__29))] public IEnumerator LoadSceneObjectsAsync(params string[] assetNames) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSceneObjectsAsync>d__29(0) { <>4__this = this, assetNames = assetNames }; } private T? GetFromGlobalBundle<T>(string assetName) where T : Object { (Type, string) key = (typeof(T), assetName); if (_globalBundleCache.TryGetValue(key, out Object value)) { if (value != (Object)null) { Log.Debug("[AssetManager] 从全局缓存中找到资源: " + assetName); return (T)(object)((value is T) ? value : null); } _globalBundleCache.Remove(key); } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if ((Object)(object)allLoadedAssetBundle == (Object)null) { continue; } try { string[] allAssetNames = allLoadedAssetBundle.GetAllAssetNames(); string[] array = allAssetNames; foreach (string text in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (fileNameWithoutExtension.Equals(assetName, StringComparison.OrdinalIgnoreCase)) { T val = allLoadedAssetBundle.LoadAsset<T>(text); if ((Object)(object)val != (Object)null) { _globalBundleCache[key] = (Object)(object)val; Log.Info("[AssetManager] 从全局 Bundle '" + ((Object)allLoadedAssetBundle).name + "' 加载资源: " + assetName); return val; } } } } catch (Exception ex) { Log.Error("[AssetManager] 从 Bundle '" + ((Object)allLoadedAssetBundle).name + "' 查找资源时出错: " + ex.Message); } } Log.Error("[AssetManager] 未找到全局资源: '" + assetName + "' (" + typeof(T).Name + ")"); return default(T); } private T? GetFromExternalCache<T>(string assetName) where T : Object { if (_externalAssetCache.TryGetValue(assetName, out Object value) && value != (Object)null) { T val = (T)(object)((value is T) ? value : null); if (val != null) { return val; } Log.Warn("[AssetManager] 资源 '" + assetName + "' 类型不匹配: 期望 " + typeof(T).Name + ",实际 " + ((object)value).GetType().Name); return default(T); } Log.Warn("[AssetManager] 资源 '" + assetName + "' 尚未加载,请先调用 LoadAssetAsync"); return default(T); } [IteratorStateMachine(typeof(<LoadFromExternalBundle>d__32))] private IEnumerator LoadFromExternalBundle(string assetName, string bundleName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadFromExternalBundle>d__32(0) { <>4__this = this, assetName = assetName, bundleName = bundleName }; } [IteratorStateMachine(typeof(<LoadFromSceneBundle>d__33))] private IEnumerator LoadFromSceneBundle(string assetName, string bundleName, string objectPath) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadFromSceneBundle>d__33(0) { <>4__this = this, assetName = assetName, bundleName = bundleName, objectPath = objectPath }; } [IteratorStateMachine(typeof(<LoadFromBundleBatch>d__34))] private IEnumerator LoadFromBundleBatch(string bundleName, List<string> assetNames) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadFromBundleBatch>d__34(0) { <>4__this = this, bundleName = bundleName, assetNames = assetNames }; } private GameObject CreateTempCamera() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown GameObject val = new GameObject("AssetManager_TempCamera") { hideFlags = (HideFlags)61, tag = "MainCamera" }; val.AddComponent<Camera>(); val.AddComponent<AudioListener>(); return val; } private void DisableProblematicComponents(Scene scene) { Behaviour[] array = (from b in ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject o) => o.GetComponentsInChildren<Behaviour>(true)) where (Object)(object)b != (Object)null select b).ToArray(); Behaviour[] array2 = array; foreach (Behaviour val in array2) { string name = ((object)val).GetType().Name; if (val.enabled && (name == "TintRendererGroup" || name == "CustomSceneManager")) { val.enabled = false; } } } private void DisableAutoDestructComponents(GameObject obj) { if ((Object)(object)obj == (Object)null) { return; } HashSet<string> hashSet = new HashSet<string> { "AutoRecycleSelf", "ActiveRecycler", "ObjectBounce", "DropRecycle", "RecycleResetHandler", "EventRegister" }; Component[] componentsInChildren = obj.GetComponentsInChildren<Component>(true); int num = 0; Component[] array = componentsInChildren; foreach (Component val in array) { if ((Object)(object)val == (Object)null) { continue; } string name = ((object)val).GetType().Name; if (hashSet.Contains(name)) { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (val2 != null) { val2.enabled = false; num++; } else { Object.Destroy((Object)(object)val); num++; } } } if (num > 0) { Log.Debug($"[AssetManager] 禁用了 {((Object)obj).name} 的 {num} 个自毁相关组件"); } } public void ClearAssetCache(string assetName) { string assetName2 = assetName; List<(Type, string)> list = _globalBundleCache.Keys.Where<(Type, string)>(((Type, string) k) => k.Item2 == assetName2).ToList(); foreach (var item in list) { _globalBundleCache.Remove(item); } if (_externalAssetCache.TryGetValue(assetName2, out Object value)) { if (value != (Object)null)