Decompiled source of Map Editing extender v1.0.4
Map_Editing_extender.dll
Decompiled 4 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.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using DM; using HarmonyLib; using InControl; using Landfall.TABS; using Landfall.TABS.GameState; using Landfall.TABS.TeamEdge; using Landfall.TABS.Workshop; using Landfall.TABS_Input; using LevelCreator; using Microsoft.CodeAnalysis; using Pathfinding; using SCPE; using TFBGames; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Mod name")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("made in SFT by FhpSlime")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } public class Item : MonoBehaviour { public enum kind { Weapon, Cloth, Skill, Unit, Projectile, Other } public string name; public kind Kind; } namespace MAPX { public static class ColorPickerLocalization { public static bool IsChinese { get { //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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 try { return typeof(Localizer).GetField("m_locale", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is Language val && (int)val == 7; } catch { return false; } } } public static string GetOpacityText(int percent) { if (!IsChinese) { return $"Opacity: {percent}%"; } return $"不透明度: {percent}%"; } public static string GetEmissionText(int percent) { if (!IsChinese) { return $"Emission: {percent}%"; } return $"发光度: {percent}%"; } public static string GetSmoothnessText(int percent) { if (!IsChinese) { return $"Smoothness: {percent}%"; } return $"平滑度: {percent}%"; } } public class CustomMusicManager : MonoBehaviour { public static CustomMusicManager Instance; public static string MusicBasePath; public List<string> CustomCategories = new List<string>(); public Dictionary<string, AudioClip> PlacementClips = new Dictionary<string, AudioClip>(); public Dictionary<string, AudioClip> BattleClips = new Dictionary<string, AudioClip>(); public string CurrentCustomMusicCategory = string.Empty; public static void Create() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if ((Object)Instance == (Object)null) { GameObject val = new GameObject("CustomMusicManager"); Instance = val.AddComponent<CustomMusicManager>(); Object.DontDestroyOnLoad((Object)val); } } private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0044: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if ((Object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)((Component)this).gameObject); Initialize(); } else if ((Object)Instance != (Object)this) { Object.Destroy((Object)((Component)this).gameObject); } } private void Start() { if (string.IsNullOrEmpty(MusicBasePath)) { Initialize(); } ((MonoBehaviour)this).StartCoroutine(SetupGameStateListenerCoroutine()); } private void Initialize() { MusicBasePath = Path.Combine(Directory.GetParent(Application.dataPath).FullName, "BepInEx", "plugins", "MMusic"); if (!Directory.Exists(MusicBasePath)) { try { Directory.CreateDirectory(MusicBasePath); Debug.Log((object)("[CustomMusicManager] Created music directory at " + MusicBasePath)); } catch (Exception ex) { Debug.LogError((object)("[CustomMusicManager] Failed to create directory: " + ex.Message)); return; } } ((MonoBehaviour)this).StartCoroutine(LoadAllMusic()); } private IEnumerator LoadAllMusic() { if (!Directory.Exists(MusicBasePath)) { yield break; } Debug.Log((object)("[CustomMusicManager] Scanning for music in " + MusicBasePath)); string[] directories = Directory.GetDirectories(MusicBasePath); string[] array = directories; foreach (string text in array) { string categoryName = Path.GetFileName(text); string text2 = Path.Combine(text, "P"); string fDir = Path.Combine(text, "F"); if (!Directory.Exists(text2) || !Directory.Exists(fDir)) { continue; } bool pLoaded = false; bool fLoaded = false; yield return ((MonoBehaviour)this).StartCoroutine(LoadClipFromDir(text2, categoryName, isPlacement: true, delegate(bool success) { pLoaded = success; })); yield return ((MonoBehaviour)this).StartCoroutine(LoadClipFromDir(fDir, categoryName, isPlacement: false, delegate(bool success) { fLoaded = success; })); if (pLoaded && fLoaded) { CustomCategories.Add(categoryName); Debug.Log((object)("[CustomMusicManager] Loaded custom music category: " + categoryName)); MusicHandler service = ServiceLocator.GetService<MusicHandler>(); if ((Object)service != (Object)null) { AddToHandler(service, categoryName); } } } } private IEnumerator LoadClipFromDir(string dir, string category, bool isPlacement, Action<bool> callback) { string text = Directory.GetFiles(dir).FirstOrDefault((string f) => f.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase)); if (text != null) { string url = "file://" + text; AudioType val = (AudioType)0; if (text.EndsWith(".wav", StringComparison.OrdinalIgnoreCase)) { val = (AudioType)20; } else if (text.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase)) { val = (AudioType)14; } else if (text.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase)) { val = (AudioType)13; } UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, val); try { yield return www.SendWebRequest(); if (!www.isNetworkError && !www.isHttpError) { AudioClip content = DownloadHandlerAudioClip.GetContent(www); ((Object)content).name = category + (isPlacement ? "_Placement" : "_Battle"); if (isPlacement) { PlacementClips[category] = content; } else { BattleClips[category] = content; } callback(obj: true); } else { Debug.LogError((object)("[CustomMusicManager] Failed to load audio: " + url + ", Error: " + www.error)); callback(obj: false); } } finally { ((IDisposable)www)?.Dispose(); } } else { callback(obj: false); } } public void AddToHandler(MusicHandler handler, string category) { if (PlacementClips.TryGetValue(category, out var value)) { CreateSongInstance(handler, category + "/Placement", value); } if (BattleClips.TryGetValue(category, out var value2)) { CreateSongInstance(handler, category + "/Battle", value2); } } private void CreateSongInstance(MusicHandler handler, string refKey, AudioClip clip) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!handler.m_songs.ContainsKey(refKey)) { SongInstance val = new SongInstance(); val.clip = clip; val.songRef = refKey; val.positionInSong = 0; val.soundEffectInstance = new SoundEffectInstance(); val.soundEffectInstance.volume = Vector2.one; val.soundEffectInstance.pitch = Vector2.one; val.soundEffectInstance.priority = 128; val.soundEffectInstance.lengthInMeasures = clip.samples; val.soundEffectInstance.transitionMeasures = new int[1]; val.soundEffectInstance.soundRef = refKey; handler.m_songs.Add(refKey, val); } } private IEnumerator SetupGameStateListenerCoroutine() { yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<GameStateManager>() != null)); GameStateManager service = ServiceLocator.GetService<GameStateManager>(); if (service != null) { service.GameStateChanged += OnGameStateChanged; Debug.Log((object)"[CustomMusicManager] Game state listener registered"); } } private void OnGameStateChanged(GameState newGameState) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (string.IsNullOrEmpty(CurrentCustomMusicCategory)) { return; } MusicHandler service = ServiceLocator.GetService<MusicHandler>(); if (!((Object)service == (Object)null)) { string text = (((int)newGameState == 1) ? "/Battle" : "/Placement"); string text2 = CurrentCustomMusicCategory + text; if (service.m_songs.ContainsKey(text2)) { service.PlaySong(text2); Debug.Log((object)("[CustomMusicManager] Switched to " + text.Substring(1) + " music: " + text2)); } } } private void OnDestroy() { GameStateManager service = ServiceLocator.GetService<GameStateManager>(); if (service != null) { service.GameStateChanged -= OnGameStateChanged; } } } internal static class ExternalModelRegistry { [Serializable] private class PrefabData { public string name; public Vector3 position; public Quaternion rotation; public Vector3 scale; public bool active; } [Serializable] private class RegistryState { public List<string> RegisteredIds; public string Timestamp; } private static readonly HashSet<string> s_registeredIds = new HashSet<string>(); private const string Category = "Custom"; private const string Group = "Other"; private const string IdPrefix = "mod.external."; private static readonly Dictionary<string, GameObject> s_externalPrefabs = new Dictionary<string, GameObject>(); private static readonly string SaveModelPath = Path.Combine(Paths.PluginPath, "savemodel"); private static readonly HashSet<string> s_persistentRegisteredIds = new HashSet<string>(); private static readonly string RegistryStatePath = Path.Combine(Paths.PluginPath, "external_models_registry.json"); private static readonly HashSet<string> s_negativeCache = new HashSet<string>(); private static readonly Dictionary<string, string> s_pathCache = new Dictionary<string, string>(); private static readonly HashSet<string> s_pathNotFoundCache = new HashSet<string>(); private static GameObject s_hiddenHolder; private static AssetBundle s_cachedEmbeddedBundle = null; private static DMEditorObjectTable s_cachedEmbeddedTable = null; private static string MakeId(string bundlePath, string prefabName) { string text = Path.GetFileNameWithoutExtension(bundlePath)?.ToLowerInvariant() ?? "bundle"; string text2 = prefabName?.ToLowerInvariant() ?? "unnamed"; return "mod.external." + text + "." + text2; } private static string MakeRadialPath(string displayName) { string text = Sanitize(displayName); return "Custom/Other/" + text; } private static string Sanitize(string name) { if (string.IsNullOrWhiteSpace(name)) { return "Item"; } char[] invalid = Path.GetInvalidFileNameChars(); return new string(name.Select((char c) => (!invalid.Contains(c)) ? c : '_').ToArray()).Replace('/', '_').Replace('\\', '_').Trim(); } private static IEnumerable<(string, GameObject)> LoadExternalPrefabs() { string path = Path.Combine(Paths.PluginPath, "newmodel"); if (!Directory.Exists(path)) { yield break; } string[] source = new string[3] { ".bundle", ".ab", ".assetbundle" }; List<(string, GameObject)> results = new List<(string, GameObject)>(); foreach (string item in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)) { string text = Path.GetExtension(item).ToLowerInvariant(); if (source.Contains(text)) { AssetBundle val = null; try { val = AssetBundle.LoadFromFile(item); if ((Object)val == (Object)null) { Debug.LogWarning((object)("[ExternalModelRegistry] Failed to load AssetBundle: " + item)); continue; } GameObject[] array = val.LoadAllAssets<GameObject>(); if (array == null) { continue; } GameObject[] array2 = array; foreach (GameObject val2 in array2) { if ((Object)val2 != (Object)null) { results.Add((item, val2)); } } } finally { if ((Object)val != (Object)null) { val.Unload(false); } } continue; } if (text == ".obj") { GameObject val3 = TryLoadObjAsGameObject(item); if ((Object)val3 != (Object)null) { results.Add((item, val3)); } } if (text == ".fbx") { GameObject val4 = TryLoadFbxAsGameObject(item); if ((Object)val4 != (Object)null) { results.Add((item, val4)); } } } for (int j = 0; j < results.Count; j++) { yield return results[j]; } } private static void SetIfExists(object obj, string member, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { try { property.SetValue(obj, value); return; } catch { } } FieldInfo field = type.GetField(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { try { field.SetValue(obj, value); } catch { } } } private static Sprite CreatePlaceholderSprite() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown try { Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] pixels = Enumerable.Repeat<Color32>(new Color32((byte)200, (byte)200, (byte)220, byte.MaxValue), 4096).ToArray(); val.SetPixels32(pixels); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); } catch { return null; } } private static GameObject TryLoadObjAsGameObject(string objPath) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown try { Type type; if ((type = Type.GetType("Dummiesman.OBJLoader, Assembly-CSharp")) == null) { type = (from a in AppDomain.CurrentDomain.GetAssemblies() select a.GetType("Dummiesman.OBJLoader")).FirstOrDefault((Type t) => t != null); } Type type2 = type; if (type2 == null) { Debug.LogWarning((object)("[ExternalModelRegistry] OBJLoader not found, skip .obj: " + objPath)); return null; } object obj = Activator.CreateInstance(type2); string text = Path.Combine(Path.GetDirectoryName(objPath) ?? string.Empty, Path.GetFileNameWithoutExtension(objPath) + ".mtl"); GameObject val = null; if (!string.IsNullOrEmpty(text) && File.Exists(text)) { MethodInfo method = type2.GetMethod("Load", BindingFlags.Instance | BindingFlags.Public, null, new Type[2] { typeof(string), typeof(string) }, null); if (method != null) { object obj2 = method.Invoke(obj, new object[2] { objPath, text }); val = (GameObject)((obj2 is GameObject) ? obj2 : null); } } if ((Object)val == (Object)null) { MethodInfo method2 = type2.GetMethod("Load", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); object obj3 = ((method2 != null) ? method2.Invoke(obj, new object[1] { objPath }) : null); val = (GameObject)((obj3 is GameObject) ? obj3 : null); } if ((Object)val == (Object)null) { return null; } AddCollidersToAllMeshes(val); val.transform.SetParent(GetHiddenHolder().transform); return val; } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] OBJ load error: " + objPath + " :: " + ex)); return null; } } public static int RegisterIntoEditor(DMEditor editor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Expected O, but got Unknown if ((Object)editor == (Object)null || (Object)editor.editorObjectTable == (Object)null) { Debug.LogError((object)"[ExternalModelRegistry] Editor or editorObjectTable is null"); return 0; } int num = MergeEmbeddedTableIntoEditor(editor); RestoreEmbeddedModelReferences(editor); LoadPersistentRegistryState(); int num2 = 0; int num3 = 0; int num4 = 0; HashSet<string> hashSet = new HashSet<string>(); foreach (string s_persistentRegisteredId in s_persistentRegisteredIds) { DMEditorObjectRow rowValue = ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).GetRowValue(s_persistentRegisteredId); if (rowValue == null) { if (!FileExistsForId(s_persistentRegisteredId)) { hashSet.Add(s_persistentRegisteredId); num4++; continue; } GameObject val = LoadPrefabFromFile(s_persistentRegisteredId); if ((Object)val != (Object)null) { string originalModelPath = GetOriginalModelPath(s_persistentRegisteredId); string displayName = ((!string.IsNullOrEmpty(originalModelPath)) ? Path.GetFileNameWithoutExtension(originalModelPath) : ((Object)val).name); DMEditorObjectRow val2 = CreateRow(val, displayName, s_persistentRegisteredId, originalModelPath); if (val2 != null) { ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).AddRow(s_persistentRegisteredId, val2); s_registeredIds.Add(s_persistentRegisteredId); s_externalPrefabs[s_persistentRegisteredId] = val; num3++; } } else { hashSet.Add(s_persistentRegisteredId); num4++; } continue; } if (!s_registeredIds.Contains(s_persistentRegisteredId)) { s_registeredIds.Add(s_persistentRegisteredId); } if (!((Object)rowValue.EditorObject == (Object)null) && !((Object)rowValue.GameObject == (Object)null)) { continue; } if (!FileExistsForId(s_persistentRegisteredId)) { hashSet.Add(s_persistentRegisteredId); num4++; continue; } GameObject val3 = LoadPrefabFromFile(s_persistentRegisteredId); if ((Object)val3 != (Object)null) { string originalModelPath2 = GetOriginalModelPath(s_persistentRegisteredId); string displayName2 = ((!string.IsNullOrEmpty(originalModelPath2)) ? Path.GetFileNameWithoutExtension(originalModelPath2) : ((Object)val3).name); DMEditorObjectRow val4 = CreateRow(val3, displayName2, s_persistentRegisteredId, originalModelPath2); if (val4 != null) { rowValue.EditorObject = val4.EditorObject; rowValue.GameObject = val4.GameObject; rowValue.Thumbnail = val4.Thumbnail; rowValue.ObjectName = val4.ObjectName; s_externalPrefabs[s_persistentRegisteredId] = val3; } } else { hashSet.Add(s_persistentRegisteredId); num4++; } } foreach (string item in hashSet) { s_persistentRegisteredIds.Remove(item); } foreach (var item2 in LoadExternalPrefabs()) { try { string text = MakeId(item2.Item1, ((Object)item2.Item2).name); DMEditorObjectRow rowValue2 = ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).GetRowValue(text); if (!s_registeredIds.Contains(text) && rowValue2 == null) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item2.Item1); DMEditorObjectRow val5 = CreateRow(item2.Item2, fileNameWithoutExtension, text, item2.Item1); if (val5 != null) { ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).AddRow(text, val5); s_registeredIds.Add(text); s_persistentRegisteredIds.Add(text); s_externalPrefabs[text] = item2.Item2; SavePrefabToFile(text, item2.Item2); num2++; } } else { if (rowValue2 == null) { continue; } if (!s_registeredIds.Contains(text)) { s_registeredIds.Add(text); } if ((Object)rowValue2.EditorObject == (Object)null || (Object)rowValue2.GameObject == (Object)null) { string originalModelPath3 = GetOriginalModelPath(text); string text2 = ((!string.IsNullOrEmpty(originalModelPath3)) ? Path.GetFileNameWithoutExtension(originalModelPath3) : ((Object)item2.Item2).name); DMEditorObjectRow val6 = CreateRow(item2.Item2, text2, text, item2.Item1); if (val6 != null) { rowValue2.EditorObject = val6.EditorObject; rowValue2.GameObject = val6.GameObject; rowValue2.Thumbnail = val6.Thumbnail; rowValue2.ObjectName = val6.ObjectName; s_externalPrefabs[text] = item2.Item2; Debug.Log((object)("[ExternalModelRegistry] 恢复外部模型引用: " + text + " - " + text2)); } } continue; } } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] Failed to register prefab into editor: " + ex)); } } if (hashSet.Count > 0) { SavePersistentRegistryState(); } if (num2 > 0 || num3 > 0 || num4 > 0 || num > 0) { Debug.Log((object)$"[ExternalModelRegistry] Registered {num2} new, restored {num3} missing, removed {num4} invalid external prefabs, merged {num} embedded objects"); } return num2 + num3 + num; } public static int RegisterIntoSpawnLevel(SpawnLevel spawnLevel) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown if ((Object)spawnLevel == (Object)null) { return 0; } FieldInfo field = typeof(SpawnLevel).GetField("editorObjectTable", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Debug.LogError((object)"[ExternalModelRegistry] Could not find SpawnLevel.editorObjectTable field"); return 0; } DMEditorObjectTable dMEditorObjectTable = null; ref DMEditorObjectTable reference = ref dMEditorObjectTable; object value = field.GetValue(spawnLevel); reference = (DMEditorObjectTable)((value is DMEditorObjectTable) ? value : null); if ((Object)dMEditorObjectTable == (Object)null) { Debug.LogError((object)"[ExternalModelRegistry] SpawnLevel.editorObjectTable is null"); return 0; } int embeddedCount = 0; try { DMEditorObjectTable val = LoadEmbeddedObjectTable(); if ((Object)val != (Object)null) { ((DataTable<DMEditorObjectRow>)(object)val).ForEachRow((Action<string, DMEditorObjectRow>)delegate(string key, DMEditorObjectRow row) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown try { DMEditorObjectRow rowValue = ((DataTable<DMEditorObjectRow>)(object)dMEditorObjectTable).GetRowValue(key); if (rowValue == null) { ((DataTable<DMEditorObjectRow>)(object)dMEditorObjectTable).AddRow(key, row); embeddedCount++; Debug.Log((object)("[ExternalModelRegistry] 合并嵌入式对象到SpawnLevel: " + key + " - " + row.ObjectName)); } else if (((Object)rowValue.EditorObject == (Object)null || (Object)rowValue.GameObject == (Object)null) && (Object)row.EditorObject != (Object)null && (Object)row.GameObject != (Object)null) { rowValue.EditorObject = row.EditorObject; rowValue.GameObject = row.GameObject; embeddedCount++; Debug.Log((object)("[ExternalModelRegistry] 恢复SpawnLevel中嵌入式对象的引用: " + key)); } } catch (Exception arg2) { Debug.LogError((object)$"[ExternalModelRegistry] 合并嵌入式对象到SpawnLevel失败 {key}: {arg2}"); } }); } } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] 合并嵌入式表格到SpawnLevel失败: {arg}"); } int num = 0; foreach (var item in LoadExternalPrefabs()) { try { string text = MakeId(item.Item1, ((Object)item.Item2).name); MethodInfo method = typeof(DMEditorObjectTable).GetMethod("GetRowValue", BindingFlags.Instance | BindingFlags.Public); if (((method != null) ? method.Invoke(dMEditorObjectTable, new object[1] { text }) : null) == null) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item.Item1); DMEditorObjectRow val2 = CreateRowForSpawnLevel(item.Item2, fileNameWithoutExtension, text); if (val2 != null) { ((DataTable<DMEditorObjectRow>)(object)dMEditorObjectTable).AddRow(text, val2); s_registeredIds.Add(text); s_externalPrefabs[text] = item.Item2; Debug.Log((object)("[ExternalModelRegistry] Stored prefab reference for id: " + text + ", prefab: " + fileNameWithoutExtension)); num++; } } } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] Failed to register prefab into SpawnLevel: " + ex)); } } Debug.Log((object)$"[ExternalModelRegistry] Registered {num} external prefabs, merged {embeddedCount} embedded objects into SpawnLevel table"); return num + embeddedCount; } private static DMEditorObjectRow CreateRowForSpawnLevel(GameObject prefab, string displayName, string id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0066: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown try { if ((Object)prefab == (Object)null) { return null; } string text = displayName; if (!string.IsNullOrWhiteSpace(text)) { if (text.Contains(".")) { text = Path.GetFileNameWithoutExtension(text); } } else { text = ((Object)prefab).name; if (text.Contains(".")) { text = Path.GetFileNameWithoutExtension(text); } } string text2 = Sanitize(text); if (string.IsNullOrWhiteSpace(text2)) { return null; } return new DMEditorObjectRow { ObjectName = text2, RadialMenuTheme = (RadialThemes)0, RadialMenuGroup = "Other", RadialMenuSlotName = text2, EditorObject = null, GameObject = null, Thumbnail = CreatePlaceholderSprite(), NormalizedSize = 1f, PivotOffset = Vector3.zero, InitialScale = 1f, InitialRotation = Vector3.zero, defaultSlopeAngle = 0f, IsEffect = false, CanSimulatePhysics = false }; } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] Failed to create DMEditorObjectRow for SpawnLevel: " + ex)); return null; } } public static bool IsExternalModelId(string id) { if (string.IsNullOrEmpty(id)) { return false; } if (!id.StartsWith("mod.external.")) { return false; } if (s_negativeCache.Contains(id)) { return false; } bool flag = s_registeredIds.Contains(id); if (!flag) { flag = s_persistentRegisteredIds.Contains(id); if (flag) { s_registeredIds.Add(id); } else { s_negativeCache.Add(id); } } return flag; } public static GameObject GetExternalPrefabById(string id) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (s_externalPrefabs.TryGetValue(id, out var value) && (Object)value != (Object)null) { return value; } value = LoadPrefabFromFile(id); if ((Object)value != (Object)null) { s_externalPrefabs[id] = value; return value; } return null; } private static void SavePrefabToFile(string id, GameObject prefab) { try { if (!Directory.Exists(SaveModelPath)) { Directory.CreateDirectory(SaveModelPath); } string path = id + ".prefab"; Path.Combine(SaveModelPath, path); Debug.Log((object)("[ExternalModelRegistry] Saved prefab reference to memory for id: " + id)); } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] Failed to save prefab to file: {arg}"); } } private static GameObject LoadPrefabFromFile(string id) { try { string originalModelPath = GetOriginalModelPath(id); if (string.IsNullOrEmpty(originalModelPath)) { return null; } string text = Path.GetExtension(originalModelPath).ToLowerInvariant(); if (text == ".fbx") { return TryLoadFbxAsGameObject(originalModelPath); } if (text == ".obj") { return TryLoadObjAsGameObject(originalModelPath); } return null; } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] Failed to load prefab from file: {arg}"); return null; } } private static string GetOriginalModelPath(string id) { if (!id.StartsWith("mod.external.")) { return null; } if (s_pathNotFoundCache.Contains(id)) { return null; } if (s_pathCache.TryGetValue(id, out var value)) { return value; } string[] array = id.Substring("mod.external.".Length).Split(new char[1] { '.' }); if (array.Length >= 2) { string text = array[0]; string[] array2 = new string[5] { ".obj", ".fbx", ".bundle", ".ab", ".assetbundle" }; foreach (string text2 in array2) { string text3 = Path.Combine(Paths.PluginPath, "newmodel", text + text2); if (File.Exists(text3)) { s_pathCache[id] = text3; return text3; } } } s_pathNotFoundCache.Add(id); return null; } private static void SavePersistentRegistryState() { try { string contents = JsonUtility.ToJson((object)new RegistryState { RegisteredIds = s_persistentRegisteredIds.ToList(), Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, true); File.WriteAllText(RegistryStatePath, contents); Debug.Log((object)$"[ExternalModelRegistry] Saved persistent registry state with {s_persistentRegisteredIds.Count} entries"); } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] Failed to save persistent registry state: {arg}"); } } private static void LoadPersistentRegistryState() { try { if (!File.Exists(RegistryStatePath)) { Debug.Log((object)"[ExternalModelRegistry] No persistent registry state file found"); return; } RegistryState registryState = JsonUtility.FromJson<RegistryState>(File.ReadAllText(RegistryStatePath)); if (registryState?.RegisteredIds == null) { return; } s_persistentRegisteredIds.Clear(); foreach (string registeredId in registryState.RegisteredIds) { s_persistentRegisteredIds.Add(registeredId); } Debug.Log((object)$"[ExternalModelRegistry] Loaded persistent registry state with {s_persistentRegisteredIds.Count} entries from {registryState.Timestamp}"); } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] Failed to load persistent registry state: {arg}"); } } private static bool FileExistsForId(string id) { try { string originalModelPath = GetOriginalModelPath(id); return !string.IsNullOrEmpty(originalModelPath) && File.Exists(originalModelPath); } catch { return false; } } private static GameObject GetHiddenHolder() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if ((Object)s_hiddenHolder == (Object)null) { s_hiddenHolder = new GameObject("ExternalModelHolder"); s_hiddenHolder.SetActive(false); Object.DontDestroyOnLoad((Object)s_hiddenHolder); } return s_hiddenHolder; } public static void ClearRegisteredIds() { s_registeredIds.Clear(); Debug.Log((object)"[ExternalModelRegistry] Cleared registered session IDs cache"); } private static DMEditorObjectRow CreateRow(GameObject prefab, string displayName, string id, string modelFilePath = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown try { if ((Object)prefab == (Object)null) { return null; } string text = displayName; if (!string.IsNullOrWhiteSpace(text)) { if (text.Contains(".")) { text = Path.GetFileNameWithoutExtension(text); } } else { text = ((Object)prefab).name; if (text.Contains(".")) { text = Path.GetFileNameWithoutExtension(text); } } string text2 = Sanitize(text); if (string.IsNullOrWhiteSpace(text2)) { return null; } Sprite val = LoadThumbnailFromPng(modelFilePath); if ((Object)val == (Object)null) { val = CreatePlaceholderSprite(); } return new DMEditorObjectRow { ObjectName = text2, RadialMenuTheme = (RadialThemes)0, RadialMenuGroup = "Other", RadialMenuSlotName = text2, EditorObject = prefab, GameObject = prefab, Thumbnail = val, NormalizedSize = 1f, PivotOffset = Vector3.zero, InitialScale = 1f, InitialRotation = Vector3.zero, defaultSlopeAngle = 0f, IsEffect = false, CanSimulatePhysics = false }; } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] Failed to create DMEditorObjectRow: " + ex)); return null; } } private static Sprite LoadThumbnailFromPng(string modelFilePath) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown if (string.IsNullOrEmpty(modelFilePath) || !File.Exists(modelFilePath)) { return null; } try { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(modelFilePath); if (string.IsNullOrEmpty(fileNameWithoutExtension)) { return null; } string directoryName = Path.GetDirectoryName(modelFilePath); if (string.IsNullOrEmpty(directoryName) || !Directory.Exists(directoryName)) { return null; } string text = Path.Combine(directoryName, fileNameWithoutExtension + ".png"); if (!File.Exists(text)) { string[] files = Directory.GetFiles(directoryName, "*.png", SearchOption.TopDirectoryOnly); foreach (string text2 in files) { if (string.Equals(Path.GetFileNameWithoutExtension(text2), fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) { text = text2; break; } } if (!File.Exists(text)) { return null; } } byte[] array = File.ReadAllBytes(text); if (array == null || array.Length == 0) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { Object.Destroy((Object)val); return null; } Sprite result = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); Debug.Log((object)("[ExternalModelRegistry] Loaded thumbnail from PNG: " + text)); return result; } catch (Exception ex) { Debug.LogWarning((object)("[ExternalModelRegistry] Failed to load thumbnail PNG for " + modelFilePath + ": " + ex.Message)); return null; } } private static GameObject TryLoadFbxAsGameObject(string fbxPath) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown try { GameObject val = TryLoadFbxWithAssetDatabase(fbxPath); if ((Object)val != (Object)null) { Debug.Log((object)("[ExternalModelRegistry] Successfully loaded FBX using AssetDatabase: " + fbxPath)); AddCollidersToAllMeshes(val); val.transform.SetParent(GetHiddenHolder().transform); return val; } val = TryLoadFbxWithReflection(fbxPath); if ((Object)val != (Object)null) { Debug.Log((object)("[ExternalModelRegistry] Successfully loaded FBX using reflection: " + fbxPath)); AddCollidersToAllMeshes(val); val.transform.SetParent(GetHiddenHolder().transform); return val; } Debug.LogWarning((object)("[ExternalModelRegistry] FBX文件无法在运行时直接加载。\n原因:Unity需要先将FBX文件通过导入管道处理才能使用,而导入管道只在编辑器中可用。\n解决方案(任选其一):\n1. 将FBX转换为AssetBundle格式:在Unity编辑器中导出为 .bundle/.ab/.assetbundle 文件\n2. 将FBX转换为OBJ格式:使用Blender、3ds Max等工具导出为 .obj 文件\n文件路径: " + fbxPath)); return null; } catch (Exception ex) { Debug.LogError((object)("[ExternalModelRegistry] FBX load error: " + fbxPath + " :: " + ex)); return null; } } private static GameObject TryLoadFbxWithAssetDatabase(string fbxPath) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown try { Type type = Type.GetType("UnityEditor.AssetDatabase, UnityEditor"); if (type == null) { return null; } MethodInfo method = type.GetMethod("LoadAssetAtPath", new Type[2] { typeof(string), typeof(Type) }); if (method == null) { return null; } string text = fbxPath; if (fbxPath.Contains("Assets")) { int startIndex = fbxPath.IndexOf("Assets"); text = fbxPath.Substring(startIndex); } else { string pluginPath = Paths.PluginPath; if (fbxPath.StartsWith(pluginPath)) { DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(fbxPath)); while (directoryInfo != null && directoryInfo.Exists) { DirectoryInfo directoryInfo2 = directoryInfo.GetDirectories("Assets").FirstOrDefault(); if (directoryInfo2 != null) { text = "Assets" + fbxPath.Substring(directoryInfo2.Parent.FullName.Length).Replace('\\', '/'); break; } directoryInfo = directoryInfo.Parent; } } } object obj = method.Invoke(null, new object[2] { text, typeof(GameObject) }); return (GameObject)((obj is GameObject) ? obj : null); } catch (Exception) { return null; } } private static GameObject TryLoadFbxWithReflection(string fbxPath) { try { _ = (from a in AppDomain.CurrentDomain.GetAssemblies() select a.GetType("UnityEditor.ModelImporter", throwOnError: false)).FirstOrDefault((Type t) => t != null) == null; return null; } catch { return null; } } private static void AddCollidersToAllMeshes(GameObject root) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if ((Object)root == (Object)null) { return; } MeshFilter[] componentsInChildren = root.GetComponentsInChildren<MeshFilter>(true); int num = 0; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { if (!((Object)val == (Object)null) && !((Object)val.sharedMesh == (Object)null) && !((Object)((Component)val).GetComponent<Collider>() != (Object)null)) { MeshCollider obj = ((Component)val).gameObject.AddComponent<MeshCollider>(); obj.sharedMesh = val.sharedMesh; obj.convex = false; num++; } } if (num > 0) { Debug.Log((object)$"[ExternalModelRegistry] Added {num} MeshColliders to {((Object)root).name} and its children"); } } private static DMEditorObjectTable LoadEmbeddedObjectTable() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown if ((Object)s_cachedEmbeddedTable != (Object)null) { Debug.Log((object)"[ExternalModelRegistry] 使用缓存的嵌入式DMEditorObjectTable"); return s_cachedEmbeddedTable; } try { if ((Object)s_cachedEmbeddedBundle != (Object)null) { DMEditorObjectTable val = s_cachedEmbeddedBundle.LoadAsset<DMEditorObjectTable>("newmodel"); if ((Object)val == (Object)null) { val = s_cachedEmbeddedBundle.LoadAsset<DMEditorObjectTable>("newmodel.asset"); if ((Object)val == (Object)null) { DMEditorObjectTable[] array = s_cachedEmbeddedBundle.LoadAllAssets<DMEditorObjectTable>(); if (array != null && array.Length != 0) { val = array[0]; } } } if ((Object)val != (Object)null) { s_cachedEmbeddedTable = val; Debug.Log((object)"[ExternalModelRegistry] 从缓存的AssetBundle加载嵌入式DMEditorObjectTable"); return val; } } using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("model"); if (stream == null) { Debug.LogWarning((object)"[ExternalModelRegistry] 找不到嵌入式资源: model"); return null; } byte[] array2 = new byte[stream.Length]; stream.Read(array2, 0, array2.Length); AssetBundle val2 = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle b) => ((Object)b).name == "Memory" || ((Object)b).name == "")); if ((Object)val2 != (Object)null) { Debug.Log((object)"[ExternalModelRegistry] 检测到已加载的AssetBundle,尝试重用"); s_cachedEmbeddedBundle = val2; } else { AssetBundle val3 = AssetBundle.LoadFromMemory(array2); if ((Object)val3 == (Object)null) { Debug.LogError((object)"[ExternalModelRegistry] 无法从嵌入式资源加载AssetBundle: model"); return null; } s_cachedEmbeddedBundle = val3; } DMEditorObjectTable val4 = s_cachedEmbeddedBundle.LoadAsset<DMEditorObjectTable>("newmodel"); if ((Object)val4 == (Object)null) { val4 = s_cachedEmbeddedBundle.LoadAsset<DMEditorObjectTable>("newmodel.asset"); if ((Object)val4 == (Object)null) { DMEditorObjectTable[] array3 = s_cachedEmbeddedBundle.LoadAllAssets<DMEditorObjectTable>(); if (array3 != null && array3.Length != 0) { val4 = array3[0]; Debug.Log((object)$"[ExternalModelRegistry] 找到 {array3.Length} 个DMEditorObjectTable,使用第一个"); } } } if ((Object)val4 != (Object)null) { s_cachedEmbeddedTable = val4; Debug.Log((object)"[ExternalModelRegistry] 成功加载并缓存嵌入式DMEditorObjectTable: newmodel"); } else { Debug.LogWarning((object)"[ExternalModelRegistry] AssetBundle中未找到DMEditorObjectTable资源: newmodel"); string[] allAssetNames = s_cachedEmbeddedBundle.GetAllAssetNames(); Debug.Log((object)("[ExternalModelRegistry] AssetBundle包含的资源: " + string.Join(", ", allAssetNames))); } return s_cachedEmbeddedTable; } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] 加载嵌入式资源失败: {arg}"); return null; } } private static int MergeEmbeddedTableIntoEditor(DMEditor editor) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown int mergedCount = 0; int restoredCount = 0; try { DMEditorObjectTable val = LoadEmbeddedObjectTable(); if ((Object)val == (Object)null) { return 0; } ((DataTable<DMEditorObjectRow>)(object)val).ForEachRow((Action<string, DMEditorObjectRow>)delegate(string key, DMEditorObjectRow row) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown try { DMEditorObjectRow rowValue = ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).GetRowValue(key); if (rowValue == null) { ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).AddRow(key, row); if (!s_registeredIds.Contains(key)) { s_registeredIds.Add(key); } mergedCount++; Debug.Log((object)("[ExternalModelRegistry] 合并嵌入式对象: " + key + " - " + row.ObjectName)); } else { if (!s_registeredIds.Contains(key)) { s_registeredIds.Add(key); } if ((Object)rowValue.EditorObject == (Object)null || (Object)rowValue.GameObject == (Object)null) { if ((Object)row.EditorObject != (Object)null && (Object)row.GameObject != (Object)null) { rowValue.EditorObject = row.EditorObject; rowValue.GameObject = row.GameObject; restoredCount++; Debug.Log((object)("[ExternalModelRegistry] 恢复嵌入式对象的EditorObject引用: " + key + " - " + row.ObjectName)); } else { Debug.LogWarning((object)("[ExternalModelRegistry] 嵌入式对象 " + key + " 的EditorObject引用为null,无法恢复")); } } } } catch (Exception arg2) { Debug.LogError((object)$"[ExternalModelRegistry] 合并对象失败 {key}: {arg2}"); } }); if (mergedCount > 0 || restoredCount > 0) { Debug.Log((object)$"[ExternalModelRegistry] 成功合并 {mergedCount} 个嵌入式对象,恢复 {restoredCount} 个对象的引用到编辑器表格"); } } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] 合并嵌入式表格失败: {arg}"); } return mergedCount + restoredCount; } public static int RestoreEmbeddedModelReferences(DMEditor editor) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown int restoredCount = 0; try { DMEditorObjectTable embeddedTable = LoadEmbeddedObjectTable(); if ((Object)embeddedTable == (Object)null) { Debug.LogWarning((object)"[ExternalModelRegistry] 无法加载嵌入式表格,无法恢复引用"); return 0; } HashSet<string> embeddedKeys = new HashSet<string>(); ((DataTable<DMEditorObjectRow>)(object)embeddedTable).ForEachRow((Action<string, DMEditorObjectRow>)delegate(string key, DMEditorObjectRow row) { embeddedKeys.Add(key); }); ((DataTable<DMEditorObjectRow>)(object)editor.editorObjectTable).ForEachRow((Action<string, DMEditorObjectRow>)delegate(string key, DMEditorObjectRow row) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown if (embeddedKeys.Contains(key) && ((Object)row.EditorObject == (Object)null || (Object)row.GameObject == (Object)null)) { DMEditorObjectRow rowValue = ((DataTable<DMEditorObjectRow>)(object)embeddedTable).GetRowValue(key); if (rowValue != null && (Object)rowValue.EditorObject != (Object)null && (Object)rowValue.GameObject != (Object)null) { row.EditorObject = rowValue.EditorObject; row.GameObject = rowValue.GameObject; restoredCount++; Debug.Log((object)("[ExternalModelRegistry] 恢复嵌入式模型引用: " + key + " - " + row.ObjectName)); } else { Debug.LogWarning((object)("[ExternalModelRegistry] 无法恢复嵌入式模型引用,嵌入式表格中的引用也为null: " + key)); } } }); if (restoredCount > 0) { Debug.Log((object)$"[ExternalModelRegistry] 成功恢复 {restoredCount} 个嵌入式模型的EditorObject引用"); } } catch (Exception arg) { Debug.LogError((object)$"[ExternalModelRegistry] 恢复嵌入式模型引用失败: {arg}"); } return restoredCount; } } public static class ExternalWeatherManager { private static Dictionary<string, GameObject> s_externalWeatherPrefabs = new Dictionary<string, GameObject>(); private static List<GameObject> s_loadedExternalWeathers = new List<GameObject>(); private static bool s_isInitialized = false; private static AssetBundle s_weatherAssetBundle = null; public static void Initialize() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (s_isInitialized) { return; } s_externalWeatherPrefabs.Clear(); if (!LoadFromEmbeddedResources("Mod_Name.weather")) { GameObject[] array = Resources.LoadAll<GameObject>("weather"); foreach (GameObject val in array) { if ((Object)val != (Object)null) { s_externalWeatherPrefabs[((Object)val).name] = val; } } } s_isInitialized = true; } public static List<string> GetExternalWeatherNames() { Initialize(); return new List<string>(s_externalWeatherPrefabs.Keys); } public static void InstantiateExternalWeathers(Transform weatherParent) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown Initialize(); foreach (GameObject s_loadedExternalWeather in s_loadedExternalWeathers) { if ((Object)s_loadedExternalWeather != (Object)null) { Object.Destroy((Object)s_loadedExternalWeather); } } s_loadedExternalWeathers.Clear(); foreach (KeyValuePair<string, GameObject> s_externalWeatherPrefab in s_externalWeatherPrefabs) { GameObject val = Object.Instantiate<GameObject>(s_externalWeatherPrefab.Value, weatherParent); ((Object)val).name = s_externalWeatherPrefab.Key; val.SetActive(false); s_loadedExternalWeathers.Add(val); } } public static bool HasExternalWeathers() { Initialize(); return s_externalWeatherPrefabs.Count > 0; } public static int GetExternalWeatherCount() { Initialize(); return s_externalWeatherPrefabs.Count; } private static bool LoadFromEmbeddedResources(string resourceName) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(resourceName); if (manifestResourceStream == null) { string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.Contains("weather") || text.EndsWith(".weather") || text.EndsWith("weather")) { manifestResourceStream = executingAssembly.GetManifestResourceStream(text); if (manifestResourceStream != null) { resourceName = text; break; } } } } if (manifestResourceStream != null) { using (manifestResourceStream) { byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); s_weatherAssetBundle = AssetBundle.LoadFromMemory(array); if ((Object)s_weatherAssetBundle != (Object)null) { GameObject[] array2 = s_weatherAssetBundle.LoadAllAssets<GameObject>(); foreach (GameObject val in array2) { if ((Object)val != (Object)null) { s_externalWeatherPrefabs[((Object)val).name] = val; } } return true; } } } } catch (Exception ex) { Debug.LogWarning((object)("[ExternalWeatherManager] 从DLL内部资源加载失败: " + ex.Message)); } return false; } public static void Cleanup() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)s_weatherAssetBundle != (Object)null) { s_weatherAssetBundle.Unload(false); s_weatherAssetBundle = null; } s_externalWeatherPrefabs.Clear(); s_isInitialized = false; } } public class FilterListItem : MonoBehaviour { private PostProcessProfile m_profile; private FilterMenu m_menu; private Button m_button; private Text m_nameText; public void Initialize(PostProcessProfile profile, FilterMenu menu) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown m_profile = profile; m_menu = menu; m_button = ((Component)this).GetComponent<Button>(); if ((Object)m_button == (Object)null) { m_button = ((Component)this).gameObject.AddComponent<Button>(); } ((UnityEvent)m_button.onClick).AddListener(new UnityAction(OnItemClicked)); m_nameText = ((Component)this).GetComponentInChildren<Text>(); if ((Object)m_nameText == (Object)null) { GameObject val = new GameObject("Text"); val.transform.SetParent(((Component)this).transform, false); m_nameText = val.AddComponent<Text>(); m_nameText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); m_nameText.fontSize = 14; } if ((Object)m_nameText != (Object)null) { m_nameText.text = (((Object)profile != (Object)null) ? ((Object)profile).name : "未知滤镜"); } } private void OnItemClicked() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if ((Object)m_menu != (Object)null && (Object)m_profile != (Object)null) { m_menu.SwitchFilter(m_profile); } } } public static class FilterLocalization { public static bool IsChinese { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0048: Invalid comparison between Unknown and I4 try { return (Object)Localizer.GetCurrentFont(0) != (Object)null && typeof(Localizer).GetField("m_locale", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is Language val && (int)val == 7; } catch { return false; } } } public static string FilterTool { get { if (!IsChinese) { return "Filter Tool"; } return "滤镜工具"; } } public static string ReplaceFilter { get { if (!IsChinese) { return "Replace Filter"; } return "替换滤镜"; } } public static string ResetFilter { get { if (!IsChinese) { return "Reset Filter"; } return "还原滤镜"; } } public static string Close { get { if (!IsChinese) { return "Close"; } return "关闭"; } } public static string CurrentFilter { get { if (!IsChinese) { return "Current Filter"; } return "当前滤镜"; } } public static string None { get { if (!IsChinese) { return "None"; } return "无"; } } public static string SelectFilter { get { if (!IsChinese) { return "Select Filter"; } return "选择滤镜"; } } public static string ColorGrading { get { if (!IsChinese) { return "Color Grading"; } return "颜色分级"; } } public static string AutoExposure { get { if (!IsChinese) { return "Auto Exposure"; } return "自动曝光"; } } public static string Vignette { get { if (!IsChinese) { return "Vignette"; } return "暗角"; } } public static string MotionBlur { get { if (!IsChinese) { return "Motion Blur"; } return "运动模糊"; } } public static string AmbientOcclusion { get { if (!IsChinese) { return "Ambient Occlusion"; } return "环境光遮蔽"; } } public static string Bloom { get { if (!IsChinese) { return "Bloom"; } return "泛光"; } } public static string DepthOfField { get { if (!IsChinese) { return "Depth of Field"; } return "景深"; } } public static string ScreenSpaceReflections { get { if (!IsChinese) { return "Screen Space Reflections"; } return "屏幕空间反射"; } } public static string Fog { get { if (!IsChinese) { return "Fog"; } return "雾效"; } } public static string TeamEdge { get { if (!IsChinese) { return "Team Edge"; } return "团队边缘"; } } public static string Saturation { get { if (!IsChinese) { return "Saturation"; } return "饱和度"; } } public static string Brightness { get { if (!IsChinese) { return "Brightness"; } return "亮度"; } } public static string Contrast { get { if (!IsChinese) { return "Contrast"; } return "对比度"; } } public static string Temperature { get { if (!IsChinese) { return "Temperature"; } return "色温"; } } public static string Tint { get { if (!IsChinese) { return "Tint"; } return "色调"; } } public static string HueShift { get { if (!IsChinese) { return "Hue Shift"; } return "色相偏移"; } } public static string MinLuminance { get { if (!IsChinese) { return "Min Luminance (EV)"; } return "最小亮度(EV)"; } } public static string MaxLuminance { get { if (!IsChinese) { return "Max Luminance (EV)"; } return "最大亮度(EV)"; } } public static string ExposureCompensation { get { if (!IsChinese) { return "Exposure Compensation"; } return "曝光补偿"; } } public static string SpeedUp { get { if (!IsChinese) { return "Speed Up"; } return "适应速度(亮)"; } } public static string SpeedDown { get { if (!IsChinese) { return "Speed Down"; } return "适应速度(暗)"; } } public static string Intensity { get { if (!IsChinese) { return "Intensity"; } return "强度"; } } public static string Smoothness { get { if (!IsChinese) { return "Smoothness"; } return "平滑度"; } } public static string Roundness { get { if (!IsChinese) { return "Roundness"; } return "圆度"; } } public static string Opacity { get { if (!IsChinese) { return "Opacity"; } return "不透明度"; } } public static string ShutterAngle { get { if (!IsChinese) { return "Shutter Angle"; } return "快门角度"; } } public static string SampleCount { get { if (!IsChinese) { return "Sample Count"; } return "采样数"; } } public static string ThicknessModifier { get { if (!IsChinese) { return "Thickness Modifier"; } return "厚度修正"; } } public static string Threshold { get { if (!IsChinese) { return "Threshold"; } return "阈值"; } } public static string SoftKnee { get { if (!IsChinese) { return "Soft Knee"; } return "软膝"; } } public static string Diffusion { get { if (!IsChinese) { return "Diffusion"; } return "扩散"; } } public static string AnamorphicRatio { get { if (!IsChinese) { return "Anamorphic Ratio"; } return "各向异性比"; } } public static string DirtIntensity { get { if (!IsChinese) { return "Dirt Intensity"; } return "污垢强度"; } } public static string FocusDistance { get { if (!IsChinese) { return "Focus Distance"; } return "焦点距离"; } } public static string Aperture { get { if (!IsChinese) { return "Aperture"; } return "光圈"; } } public static string FocalLength { get { if (!IsChinese) { return "Focal Length"; } return "焦距"; } } public static string MaximumIterationCount { get { if (!IsChinese) { return "Maximum Iteration Count"; } return "最大迭代数"; } } public static string Thickness { get { if (!IsChinese) { return "Thickness"; } return "厚度"; } } public static string MaximumMarchDistance { get { if (!IsChinese) { return "Maximum March Distance"; } return "最大距离"; } } public static string DistanceFade { get { if (!IsChinese) { return "Distance Fade"; } return "距离衰减"; } } public static string VignetteSSR { get { if (!IsChinese) { return "Vignette"; } return "边缘衰减"; } } public static string GlobalDensity { get { if (!IsChinese) { return "Global Density"; } return "全局密度"; } } public static string FogStartDistance { get { if (!IsChinese) { return "Fog Start Distance"; } return "雾起始距离"; } } public static string FogEndDistance { get { if (!IsChinese) { return "Fog End Distance"; } return "雾结束距离"; } } public static string DistanceDensity { get { if (!IsChinese) { return "Distance Density"; } return "距离密度"; } } public static string SkyboxInfluence { get { if (!IsChinese) { return "Skybox Influence"; } return "天空盒影响"; } } public static string Height { get { if (!IsChinese) { return "Height"; } return "高度"; } } public static string HeightDensity { get { if (!IsChinese) { return "Height Density"; } return "高度密度"; } } public static string HeightNoiseSize { get { if (!IsChinese) { return "Height Noise Size"; } return "高度噪声大小"; } } public static string HeightNoiseStrength { get { if (!IsChinese) { return "Height Noise Strength"; } return "高度噪声强度"; } } public static string HeightNoiseSpeed { get { if (!IsChinese) { return "Height Noise Speed"; } return "高度噪声速度"; } } public static string ScatterIntensity { get { if (!IsChinese) { return "Scatter Intensity"; } return "散射强度"; } } public static string ScatterThreshold { get { if (!IsChinese) { return "Scatter Threshold"; } return "散射阈值"; } } public static string ScatterDiffusion { get { if (!IsChinese) { return "Scatter Diffusion"; } return "散射扩散"; } } public static string ScatterSoftKnee { get { if (!IsChinese) { return "Scatter Soft Knee"; } return "散射平滑度"; } } public static string GetEnableEffect(string effectName) { if (!IsChinese) { return "Enable " + effectName; } return "启用 " + effectName; } } public class FilterMenu : DMUIPanel { [Serializable] private class FilterData { public List<EffectSettingData> settings; public string originalProfileName; } [Serializable] private class EffectSettingData { public string typeName; public bool enabled; public List<ParameterData> parameters = new List<ParameterData>(); } [Serializable] private class ParameterData { public string name; public string valueType; public string value; } private static FilterMenu s_instance; [Header("效果调整面板")] [SerializeField] private RectTransform m_effectAdjustPanel; [SerializeField] private GameObject m_effectTogglePrefab; [SerializeField] private GameObject m_effectSliderPrefab; [Header("当前滤镜信息")] [SerializeField] private Text m_currentFilterNameText; public PostProcessProfile m_currentProfile; public List<PostProcessProfile> m_availableProfiles = new List<PostProcessProfile>(); private Dictionary<string, GameObject> m_effectUIElements = new Dictionary<string, GameObject>(); private RectTransform m_mainPanelRect; private Vector2 m_dragOffset; private bool m_isDragging; private Dictionary<string, GameObject> m_effectButtons = new Dictionary<string, GameObject>(); private Dictionary<string, GameObject> m_effectDetailPanels = new Dictionary<string, GameObject>(); private string m_currentExpandedEffect; public PostProcessProfile m_customLevelProfile; private static Dictionary<string, string> s_levelFilterData = new Dictionary<string, string>(); internal static string s_pendingFilterData = null; internal static Dictionary<string, PostProcessProfile> s_originalProfileCache = new Dictionary<string, PostProcessProfile>(); internal static List<LevelPresetData> s_presetDataCache = new List<LevelPresetData>(); private static Dictionary<string, PostProcessProfile> s_backupProfiles = new Dictionary<string, PostProcessProfile>(); public static FilterMenu Create() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) if ((Object)s_instance != (Object)null) { if ((Object)((Component)s_instance).gameObject != (Object)null) { return s_instance; } Debug.LogWarning((object)"[FilterMenu] Create: 检测到无效的 FilterMenu 实例,清除引用"); s_instance = null; } try { GameObject val = GameObject.Find("FilterMenu"); if ((Object)val == (Object)null) { val = new GameObject("FilterMenu"); Object.DontDestroyOnLoad((Object)val); if ((Object)DMUIManager.Instance != (Object)null) { Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 1000; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); val.AddComponent<GraphicRaycaster>(); Debug.Log((object)"[FilterMenu] Create: 已创建独立的 FilterMenu GameObject(根对象,使用 DontDestroyOnLoad)"); } else { Debug.Log((object)"[FilterMenu] Create: 已创建 FilterMenu GameObject(游玩模式,使用 DontDestroyOnLoad)"); } } else if ((Object)val.transform.parent != (Object)null) { Debug.LogWarning((object)"[FilterMenu] Create: 发现 FilterMenu GameObject 有父对象,将其设置为根对象"); val.transform.SetParent((Transform)null); Object.DontDestroyOnLoad((Object)val); } if ((Object)val == (Object)null) { Debug.LogError((object)"[FilterMenu] Create: 无法创建 FilterMenu GameObject"); return null; } FilterMenu filterMenu = val.GetComponent<FilterMenu>(); if ((Object)filterMenu == (Object)null) { filterMenu = val.AddComponent<FilterMenu>(); } if ((Object)val.GetComponent<Canvas>() == (Object)null && (Object)DMUIManager.Instance != (Object)null) { Canvas obj3 = val.AddComponent<Canvas>(); obj3.renderMode = (RenderMode)0; obj3.sortingOrder = 1000; CanvasScaler obj4 = val.AddComponent<CanvasScaler>(); obj4.uiScaleMode = (ScaleMode)1; obj4.referenceResolution = new Vector2(1920f, 1080f); val.AddComponent<GraphicRaycaster>(); Debug.Log((object)"[FilterMenu] Create: 已重新创建 Canvas 组件(场景切换后恢复)"); } s_instance = filterMenu; return filterMenu; } catch (Exception ex) { Debug.LogError((object)("[FilterMenu] Create: 创建 FilterMenu 时发生异常: " + ex.Message)); Debug.LogException(ex); return null; } } protected override void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown try { ((DMUIPanel)this).Awake(); } catch (Exception ex) { Debug.LogWarning((object)("[FilterMenu] base.Awake()失败: " + ex.Message)); } if ((Object)s_instance == (Object)null) { s_instance = this; } try { FieldInfo field = typeof(DMUIPanel).GetField("m_panelType", BindingFlags.Instance | BindingFlags.Public); if (field != null) { object value = Enum.Parse(typeof(UIPanels), "SliderMenu"); field.SetValue(this, value); } } catch (Exception ex2) { Debug.LogWarning((object)("[FilterMenu] 设置面板类型失败: " + ex2.Message)); } try { if (base.m_inputState == null) { base.m_inputState = new InputState("FilterMenu"); if (PlayerActions.Instance != null) { base.m_inputState.AddOnKeyDownListener(PlayerActions.Instance.m_menu, (UnityAction)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ((DMUIPanel)this).OnClose(); ((Component)this).gameObject.SetActive(false); if ((Object)DMEditor.Instance != (Object)null) { DMEditor.Instance.HideCursor(); } }); } } } catch (Exception ex3) { Debug.LogWarning((object)("[FilterMenu] 初始化输入状态失败: " + ex3.Message)); } ((Component)this).gameObject.SetActive(false); } public override void OnOpen() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Expected O, but got Unknown //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Expected O, but got Unknown //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Expected O, but got Unknown //IL_03b5: Expected O, but got Unknown //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Expected O, but got Unknown //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown try { ((DMUIPanel)this).OnOpen(); } catch (Exception ex) { Debug.LogWarning((object)("[FilterMenu] base.OnOpen() 失败: " + ex.Message)); } if (!((Component)this).gameObject.activeSelf) { ((Component)this).gameObject.SetActive(true); } if ((Object)m_effectAdjustPanel == (Object)null) { try { CreateUI(); Debug.Log((object)"[FilterMenu] OnOpen: 已创建UI元素"); } catch (Exception ex2) { Debug.LogError((object)("[FilterMenu] OnOpen: 创建UI失败: " + ex2.Message)); Debug.LogException(ex2); } } if (m_availableProfiles.Count == 0) { try { LoadAvailableFilters(); Debug.Log((object)$"[FilterMenu] OnOpen: 已加载 {m_availableProfiles.Count} 个可用滤镜"); } catch (Exception ex3) { Debug.LogWarning((object)("[FilterMenu] 加载滤镜资源时出错: " + ex3.Message)); } } RefreshCurrentFilterInfo(); if ((Object)DMEditor.Instance != (Object)null && (Object)DMEditor.Instance.postProcessVolume != (Object)null) { PostProcessProfile sharedProfile = DMEditor.Instance.postProcessVolume.sharedProfile; string currentLevelPath = GetCurrentLevelPath(); bool flag = false; string text = null; if (!string.IsNullOrEmpty(currentLevelPath) && s_levelFilterData.ContainsKey(currentLevelPath)) { text = s_levelFilterData[currentLevelPath]; flag = !string.IsNullOrEmpty(text); Debug.Log((object)$"[FilterMenu] OnOpen: 检测到保存的滤镜数据 (路径: {currentLevelPath}, 长度: {text?.Length ?? 0})"); } else if (!string.IsNullOrEmpty(s_pendingFilterData)) { text = s_pendingFilterData; flag = true; Debug.Log((object)$"[FilterMenu] OnOpen: 检测到临时存储的滤镜数据 (长度: {text.Length})"); } if (flag && !string.IsNullOrEmpty(text)) { Debug.Log((object)"[FilterMenu] OnOpen: 发现保存的滤镜数据,开始加载并应用..."); try { FilterData filterData = ManualParseFilterData(text); if (filterData != null && !string.IsNullOrEmpty(filterData.originalProfileName)) { PostProcessProfile originalProfile = GetOriginalProfile(filterData.originalProfileName); if ((Object)originalProfile == (Object)null || originalProfile.settings == null || originalProfile.settings.Count == 0) { Debug.LogWarning((object)("[FilterMenu] OnOpen: 无法找到原始滤镜 " + filterData.originalProfileName + ",尝试重新加载资源")); LoadAvailableFilters(); originalProfile = GetOriginalProfile(filterData.originalProfileName); } if ((Object)originalProfile != (Object)null && originalProfile.settings != null && originalProfile.settings.Count > 0) { PostProcessProfile val = DeserializeProfileFromJson(text); if ((Object)val != (Object)null) { DMEditor.Instance.postProcessVolume.sharedProfile = val; m_customLevelProfile = val; m_currentProfile = val; Debug.Log((object)("[FilterMenu] OnOpen: 成功加载并应用保存的滤镜: " + ((Object)val).name)); } else { Debug.LogWarning((object)("[FilterMenu] OnOpen: 反序列化滤镜失败,使用原始滤镜: " + ((Object)originalProfile).name)); DMEditor.Instance.postProcessVolume.sharedProfile = originalProfile; } } else { Debug.LogError((object)("[FilterMenu] OnOpen: 无法恢复原始滤镜 " + filterData.originalProfileName + ",滤镜数据将无法应用")); } } else { Debug.LogWarning((object)"[FilterMenu] OnOpen: 滤镜数据解析失败,无法提取 originalProfileName"); } } catch (Exception ex4) { Debug.LogError((object)("[FilterMenu] OnOpen: 加载保存的滤镜数据时出错: " + ex4.Message)); Debug.LogException(ex4); } } else if ((Object)sharedProfile != (Object)null && !((Object)sharedProfile).name.Contains("_Copy")) { LevelPresetData[] allPresets = LevelPresetData.GetAllPresets(); bool flag2 = false; LevelPresetData[] array = allPresets; foreach (LevelPresetData val2 in array) { if ((Object)val2 != (Object)null && (Object)val2.PostProcessProfile != (Object)null && (Object)val2.PostProcessProfile == (Object)sharedProfile) { flag2 = true; break; } } if (flag2) { Debug.Log((object)("[FilterMenu] OnOpen: 检测到原版预设滤镜 " + ((Object)sharedProfile).name + "(不创建副本,除非用户修改)")); if (sharedProfile.settings == null || sharedProfile.settings.Count == 0) { Debug.LogWarning((object)("[FilterMenu] OnOpen: 原版滤镜引用已失效,尝试恢复: " + ((Object)sharedProfile).name)); PostProcessProfile originalProfile2 = GetOriginalProfile(((Object)sharedProfile).name); if ((Object)originalProfile2 != (Object)null && originalProfile2.settings != null && originalProfile2.settings.Count > 0) { DMEditor.Instance.postProcessVolume.sharedProfile = originalProfile2; Debug.Log((object)("[FilterMenu] OnOpen: 已恢复原版滤镜: " + ((Object)originalProfile2).name)); } } } } RefreshCurrentFilterInfo(); } RefreshEffectButtons(); } public override void OnClose() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown ((DMUIPanel)this).OnClose(); if ((Object)DMEditor.Instance != (Object)null) { DMEditor.Instance.HideCursor(); } } internal void LoadAvailableFilters() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown List<PostProcessProfile> list = new List<PostProcessProfile>(); foreach (PostProcessProfile availableProfile in m_availableProfiles) { if ((Object)availableProfile != (Object)null) { try { _ = ((Object)availableProfile).name; list.Add(availableProfile); } catch { } } } m_availableProfiles.Clear(); m_availableProfiles.AddRange(list); if (list.Count > 0) { Debug.Log((object)$"[FilterMenu] LoadAvailableFilters: 保留了 {list.Count} 个仍然有效的滤镜资源"); } try { PostProcessProfile[] array = Resources.LoadAll<PostProcessProfile>(""); if (array != null && array.Length != 0) { int num = 0; PostProcessProfile[] array2 = array; foreach (PostProcessProfile val in array2) { if ((Object)val != (Object)null && !m_availableProfiles.Contains(val)) { m_availableProfiles.Add(val); num++; } } if (num > 0) { Debug.Log((object)$"[FilterMenu] 从Resources加载了 {num} 个PostProcessProfile"); } } } catch (Exception ex) { Debug.LogWarning((object)("[FilterMenu] 从Resources加载PostProcessProfile失败: " + ex.Message)); } try { LoadFiltersFromAssetBundle("render"); } catch (Exception ex2) { Debug.LogWarning((object)("[FilterMenu] 从AssetBundle加载PostProcessProfile失败: " + ex2.Message)); } try { LevelPresetData[] allPresets = LevelPresetData.GetAllPresets(); int num2 = 0; int num3 = 0; LevelPresetData[] array3 = allPresets; foreach (LevelPresetData val2 in array3) { if (!((Object)val2 != (Object)null) || !((Object)val2.PostProcessProfile != (Object)null)) { continue; } string name = ((Object)val2.PostProcessProfile).name; if (!s_backupProfiles.ContainsKey(name)) { try { PostProcessProfile val3 = CreateProfileCopy(val2.PostProcessProfile); if ((Object)val3 != (Object)null) { ((Object)val3).name = name + "_Backup"; s_backupProfiles[name] = val3; num3++; if (!m_availableProfiles.Contains(val3)) { m_availableProfiles.Add(val3); } Debug.Log((object)("[FilterMenu] 已创建原版预设滤镜的备份副本: " + name + " -> " + ((Object)val3).name)); } } catch (Exception ex3) { Debug.LogWarning((object)("[FilterMenu] 创建备份副本失败 (" + name + "): " + ex3.Message)); } } if (!s_originalProfileCache.ContainsKey(name)) { s_originalProfileCache[name] = val2.PostProcessProfile; } if (!s_presetDataCache.Contains(val2)) { s_presetDataCache.Add(val2); } if (!m_availableProfiles.Contains(val2.PostProcessProfile)) { m_availableProfiles.Add(val2.PostProcessProfile); num2++; } } if (num2 > 0) { Debug.Log((object)$"[FilterMenu] 从LevelPresetData加载了 {num2} 个预设"); } if (num3 > 0) { Debug.Log((object)$"[FilterMenu] 已创建 {num3} 个原版预设滤镜的备份副本"); } } catch (Exception ex4) { Debug.LogWarning((object)("[FilterMenu] 从LevelPresetData加载失败: " + ex4.Message)); } try { int num4 = 0; foreach (PostProcessProfile availableProfile2 in m_availableProfiles) { if (!((Object)availableProfile2 != (Object)null) || ((Object)availableProfile2).name.Contains("_Copy") || ((Object)availableProfile2).name.Contains("_Backup")) { continue; } string name2 = ((Object)availableProfile2).name; if (s_backupProfiles.ContainsKey(name2)) { continue; } bool flag = false; LevelPresetData[] array3 = LevelPresetData.GetAllPresets(); foreach (LevelPresetData val4 in array3) { if ((Object)val4 != (Object)null && (Object)val4.PostProcessProfile != (Object)null && ((Object)val4.PostProcessProfile).name == name2) { flag = true; break; } } if (flag) { continue; } try { PostProcessProfile val5 = CreateProfileCopy(availableProfile2); if ((Object)val5 != (Object)null) { ((Object)val5).name = name2 + "_Backup"; s_backupProfiles[name2] = val5; num4++; if (!m_availableProfiles.Contains(val5)) { m_availableProfiles.Add(val5); } Debug.Log((object)("[FilterMenu] 已创建滤镜的备份副本: " + name2 + " -> " + ((Object)val5).name)); } } catch (Exception ex5) { Debug.LogWarning((object)("[FilterMenu] 创建备份副本失败 (" + name2 + "): " + ex5.Message)); } } if (num4 > 0) { Debug.Log((object)$"[FilterMenu] 已创建 {num4} 个其他滤镜的备份副本"); } } catch (Exception ex6) { Debug.LogWarning((object)("[FilterMenu] 备份其他滤镜失败: " + ex6.Message)); } Debug.Log((object)$"[FilterMenu] 总共加载了 {m_availableProfiles.Count} 个可用滤镜"); } private void LoadFiltersFromAssetBundle(string bundleName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown try { if ((Object)LevelEditorPatches.s_renderAssetBundle == (Object)null) { LevelEditorPatches.LoadRenderAssetBundle(); } if ((Object)LevelEditorPatches.s_renderAssetBundle != (Object)null) { LoadProfilesFromBundle(LevelEditorPatches.s_renderAssetBundle); Debug.Log((object)"[FilterMenu] 使用LevelEditorPatches中已加载的render资源包(嵌入式资源)"); return; } } catch (Exception ex) { Debug.LogWarning((object)("[FilterMenu] 从LevelEditorPatches获取render资源包失败: " + ex.Message)); } try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream stream = null; stream = executingAssembly.GetManifestResourceStream("Mod_Name.render"); if (stream == null) { string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.Contains("render") || text.Contains("Render") || text.EndsWith(".render") || text.ToLower().Contains("render")) { stream = executingAssembly.GetManifestResourceStream(text); if (stream != null) { Debug.Log((object)("[FilterMenu] 找到render嵌入式资源: " + text)); break; } } } } if (stream != null) { using (stream) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); AssetBundle val = AssetBundle.LoadFromMemory(array); if ((Object)val != (Object)null) { LoadProfilesFromBundle(val); Debug.Log((object)"[FilterMenu] 从嵌入式资源直接加载render资源包"); return; } } } } catch (Exception ex2) { Debug.LogWarning((object)("[FilterMenu] 从嵌入式资源加载失败: " + ex2.Message)); } Debug.LogWarning((object)"[FilterMenu] 无法加载render资源包"); } private void LoadProfilesFromBundle(AssetBundle bundle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)bundle == (Object)null) { Debug.LogWarning((object)"[FilterMenu] AssetBundle为null,无法加载PostProcessProfile"); return; } try { string[] allAssetNames = bund