Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ThatGuyNic MoreHead v1.1.0
MoreHead/MoreHead.dll
Decompiled a year agousing 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using MenuLib.Structs; using Microsoft.CodeAnalysis; using MoreHead; using Newtonsoft.Json; using Photon.Pun; using TMPro; using UnityEngine; [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 = "")] [assembly: AssemblyCompany("YMC_MHZ")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyDescription("一个简单好玩的装饰模组,提供unitypackage,供玩家自行导入模型。")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("MoreHead")] [assembly: AssemblyTitle("MoreHead")] [assembly: AssemblyVersion("1.3.0.0")] 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; } } } [BepInPlugin("Mhz.REPOMoreHead", "MoreHead", "1.3.0")] public class Morehead : BaseUnityPlugin { private const string PluginGuid = "Mhz.REPOMoreHead"; private const string PluginName = "MoreHead"; private const string PluginVersion = "1.3.0"; public static ManualLogSource? Logger; public static Morehead? Instance { get; private set; } public static string GetPluginVersion() { return "1.3.0"; } private void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; try { Harmony val = new Harmony("Mhz.REPOMoreHead"); val.PatchAll(typeof(PlayerAvatarVisualsPatch)); val.PatchAll(typeof(PlayerUpdatePatch)); val.PatchAll(typeof(PlayerAvatarAwakePatch)); val.PatchAll(typeof(GameDirectorUpdatePatch)); val.PatchAll(typeof(PlayerRevivePatch)); val.PatchAll(typeof(MenuManagerStartPatch)); string text = "\n\n ███▄ ▄███▓ ▒█████ ██▀███ ▓█████ ██░ ██ ▓█████ ▄▄▄ ▓█████▄ \n▓██▒▀█▀ ██▒▒██▒ ██▒▓██ ▒ ██▒▓█ ▀ ▓██░ ██▒▓█ ▀▒████▄ ▒██▀ ██▌\n▓██ ▓██░▒██░ ██▒▓██ ░▄█ ▒▒███ ▒██▀███░▒███ ▒██ ▀█▄ ░██ █▌\n▒██ ▒██ ▒██ ██░▒███▀█▄ ▒▓█ ▄ ░▓█ ░██ ▒▓█ ▄░██▄▄▄▄██ ░▓█▄ ▌\n▒██▒ ░██▒░ ████▓▒░░██▓ ▒██▒░▒████▒░▓█▒░██▓░▒████▒▓█ ▓██▒░▒████▓ v1.3.0\n░ ▒░ ░ ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░░ ▒░ ░ ▒ ░░▒░▒░░ ▒░ ░▒▒ ▓▒█░ ▒▒▓ ▒ \n░ ░ ░ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ░ ░ ▒ ░▒░ ░ ░ ░ ░ ▒ ▒▒ ░ ░ ▒ ▒ \n░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░ ░ \n ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ \n"; ManualLogSource? logger = Logger; if (logger != null) { logger.LogMessage((object)text); } HeadDecorationManager.Initialize(); ConfigManager.Initialize(); } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("Harmony补丁应用失败: " + ex.Message)); } } } private void OnApplicationQuit() { ConfigManager.SaveConfig(); } public static bool GetDecorationState(string? name) { return HeadDecorationManager.GetDecorationState(name); } } [HarmonyPatch(typeof(MenuManager))] [HarmonyPatch("Start")] internal class MenuManagerStartPatch { [HarmonyPostfix] private static void Postfix() { try { if ((Object)(object)MenuManager.instance != (Object)null && MenuManager.instance.menuPages != null && MenuManager.instance.menuPages.Count > 0) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogInfo((object)"MenuManager已初始化,正在初始化MoreHeadUI..."); } MoreHeadUI.Initialize(); } else { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)"MenuManager未准备好,无法初始化UI"); } } } catch (Exception arg) { ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogError((object)$"在MenuManager.Start补丁中初始化UI时出错: {arg}"); } } } } [HarmonyPatch(typeof(PlayerAvatar))] [HarmonyPatch("Update")] internal class PlayerUpdatePatch { private static void Postfix(PlayerAvatar __instance) { if (__instance.photonView.IsMine && GameManager.Multiplayer() && PhotonNetwork.LocalPlayer != null) { } } public static void UpdatePlayerDecorations(PlayerAvatar playerAvatar) { try { if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null) { return; } Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)playerAvatar.playerAvatarVisuals).transform); if (decorationParentNodes.Count == 0) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogWarning((object)"找不到任何装饰物父级节点"); } return; } DecorationUtils.EnsureDecorationContainers(decorationParentNodes); foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value)) { Transform val = value.Find("HeadDecorations"); if ((Object)(object)val != (Object)null) { DecorationUtils.UpdateDecoration(val, decoration.Name ?? string.Empty, decoration.IsVisible); } } else { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)("找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag)); } } } } catch (Exception ex) { ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogError((object)("更新玩家装饰物时出错: " + ex.Message)); } } } public static void UpdateMenuPlayerDecorations() { try { PlayerAvatarVisuals val = FindMenuPlayerVisuals(); if ((Object)(object)val == (Object)null) { return; } Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)val).transform); if (decorationParentNodes.Count == 0) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点"); } return; } DecorationUtils.EnsureDecorationContainers(decorationParentNodes); foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value)) { Transform val2 = value.Find("HeadDecorations"); if ((Object)(object)val2 != (Object)null) { Transform val3 = val2.Find(decoration.Name); if ((Object)(object)val3 == (Object)null) { AddMenuDecoration(val2, decoration.Name); } else { DecorationUtils.UpdateDecoration(val2, decoration.Name ?? string.Empty, decoration.IsVisible); } } } else { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)("找不到菜单角色装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag)); } } } } catch (Exception ex) { ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogError((object)("更新菜单角色装饰物状态失败: " + ex.Message)); } } } private static PlayerAvatarVisuals? FindMenuPlayerVisuals() { if ((Object)(object)PlayerAvatarMenu.instance == (Object)null) { return null; } return ((Component)PlayerAvatarMenu.instance).GetComponentInChildren<PlayerAvatarVisuals>(); } public static void AddMenuDecoration(Transform parent, string? decorationName) { string decorationName2 = decorationName; try { Transform val = parent.Find(decorationName2); if ((Object)(object)val != (Object)null) { bool decorationState = Morehead.GetDecorationState(decorationName2); ((Component)val).gameObject.SetActive(decorationState); return; } DecorationInfo decorationInfo = HeadDecorationManager.Decorations.Find((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase)); if (decorationInfo != null && (Object)(object)decorationInfo.Prefab != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(decorationInfo.Prefab, parent); ((Object)val2).name = decorationName2; val2.SetActive(decorationInfo.IsVisible); return; } ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogWarning((object)("AddMenuDecoration: 找不到装饰物 " + decorationName2 + " 或其预制体为空")); } } catch (Exception ex) { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogError((object)("为菜单角色添加装饰物时出错: " + ex.Message)); } } } } [HarmonyPatch(typeof(PlayerAvatar))] [HarmonyPatch("Awake")] internal class PlayerAvatarAwakePatch { private static void Postfix(PlayerAvatar __instance) { ((Component)__instance).gameObject.AddComponent<HeadDecorationSync>(); } } public class HeadDecorationSync : MonoBehaviourPun { public void SyncAllDecorations() { try { string[] array = new string[HeadDecorationManager.Decorations.Count]; bool[] array2 = new bool[HeadDecorationManager.Decorations.Count]; string[] array3 = new string[HeadDecorationManager.Decorations.Count]; for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++) { DecorationInfo decorationInfo = HeadDecorationManager.Decorations[i]; array[i] = decorationInfo.Name; array2[i] = decorationInfo.IsVisible; array3[i] = decorationInfo.ParentTag; } ((MonoBehaviourPun)this).photonView.RPC("UpdateAllDecorations", (RpcTarget)1, new object[3] { array, array2, array3 }); } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("同步所有装饰物状态失败: " + ex.Message)); } } } [PunRPC] private void UpdateAllDecorations(string[] names, bool[] states, string[] parentTags) { try { PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>(); if ((Object)(object)component == (Object)null || (Object)(object)component.playerAvatarVisuals == (Object)null) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogWarning((object)"找不到PlayerAvatar或PlayerAvatarVisuals组件"); } return; } Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)component.playerAvatarVisuals).transform); if (decorationParentNodes.Count == 0) { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)"找不到任何装饰物父级节点"); } return; } DecorationUtils.EnsureDecorationContainers(decorationParentNodes); for (int i = 0; i < names.Length; i++) { string decorationName = names[i]; bool showDecoration = states[i]; string key = parentTags[i]; if (decorationParentNodes.TryGetValue(key, out var value)) { Transform val = value.Find("HeadDecorations"); if ((Object)(object)val != (Object)null) { DecorationUtils.UpdateDecoration(val, decorationName, showDecoration); } } } } catch (Exception ex) { ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message)); } } } } [HarmonyPatch(typeof(PlayerAvatarVisuals))] [HarmonyPatch("Start")] internal class PlayerAvatarVisualsPatch { private static void Postfix(PlayerAvatarVisuals __instance) { try { Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)__instance).transform); if (decorationParentNodes.Count == 0) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogWarning((object)$"找不到任何装饰物父级节点 (isMenuAvatar: {__instance.isMenuAvatar})"); } return; } DecorationUtils.EnsureDecorationContainers(decorationParentNodes); if (__instance.isMenuAvatar) { foreach (KeyValuePair<string, Transform> item in decorationParentNodes) { string key = item.Key; Transform value = item.Value; Transform val = value.Find("HeadDecorations"); if ((Object)(object)val != (Object)null) { foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { if (decoration.ParentTag == key) { PlayerUpdatePatch.AddMenuDecoration(val, decoration.Name); } } } } return; } foreach (DecorationInfo decoration2 in HeadDecorationManager.Decorations) { if (decorationParentNodes.TryGetValue(decoration2.ParentTag ?? string.Empty, out var value2)) { Transform val2 = value2.Find("HeadDecorations"); if ((Object)(object)val2 != (Object)null) { AddNewDecoration(val2, decoration2, __instance); } } else { ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration2.DisplayName + " 的父级节点: " + decoration2.ParentTag)); } } } if (!GameManager.Multiplayer() || !((Object)(object)__instance.playerAvatar != (Object)null) || !((Object)(object)__instance.playerAvatar.photonView != (Object)null) || !__instance.playerAvatar.photonView.IsMine) { return; } try { HeadDecorationSync component = ((Component)__instance.playerAvatar).GetComponent<HeadDecorationSync>(); if ((Object)(object)component != (Object)null) { component.SyncAllDecorations(); return; } ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogWarning((object)"找不到HeadDecorationSync组件,无法同步初始状态"); } } catch (Exception ex) { ManualLogSource? logger4 = Morehead.Logger; if (logger4 != null) { logger4.LogError((object)("同步初始装饰物状态失败: " + ex.Message)); } } } catch (Exception ex2) { ManualLogSource? logger5 = Morehead.Logger; if (logger5 != null) { logger5.LogError((object)$"添加装饰物失败: {ex2.Message} (isMenuAvatar: {__instance.isMenuAvatar})"); } } } private static void AddNewDecoration(Transform parent, DecorationInfo decoration, PlayerAvatarVisuals __instance) { Transform val = parent.Find(decoration.Name); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(decoration.IsVisible); return; } if ((Object)(object)decoration.Prefab != (Object)null) { try { GameObject val2 = Object.Instantiate<GameObject>(decoration.Prefab, parent); ((Object)val2).name = decoration.Name; val2.SetActive(decoration.IsVisible); return; } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("实例化预制体时出错: " + ex.Message)); } return; } } ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)("AddNewDecoration: 装饰物 " + decoration.DisplayName + " 的预制体为空")); } } } [HarmonyPatch(typeof(GameDirector))] [HarmonyPatch("Update")] internal class GameDirectorUpdatePatch { private static gameState previousState; private static void Postfix(GameDirector __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) try { if ((int)previousState != 2 && (int)__instance.currentState == 2) { SyncAllPlayersDecorations(); } previousState = __instance.currentState; } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("监听游戏状态变化时出错: " + ex.Message)); } } } private static void SyncAllPlayersDecorations() { try { PlayerAvatar val = FindLocalPlayer(); if ((Object)(object)val != (Object)null) { PlayerUpdatePatch.UpdatePlayerDecorations(val); HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>(); if ((Object)(object)component != (Object)null) { component.SyncAllDecorations(); } } } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("同步所有玩家装饰物状态时出错: " + ex.Message)); } } } private static PlayerAvatar? FindLocalPlayer() { try { PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); PlayerAvatar[] array2 = array; foreach (PlayerAvatar val in array2) { if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine) { return val; } } } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("查找本地玩家时出错: " + ex.Message)); } } return null; } } [HarmonyPatch(typeof(PlayerAvatar))] [HarmonyPatch("ReviveRPC")] internal class PlayerRevivePatch { private static void Postfix(PlayerAvatar __instance) { try { if (__instance.photonView.IsMine) { ((MonoBehaviour)__instance).StartCoroutine(DelayedSync(__instance)); } } catch (Exception ex) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("玩家复活时同步装饰物状态失败: " + ex.Message)); } } } private static IEnumerator DelayedSync(PlayerAvatar playerAvatar) { yield return null; yield return (object)new WaitForSeconds(0.2f); try { PlayerUpdatePatch.UpdatePlayerDecorations(playerAvatar); } catch (Exception e2) { ManualLogSource? logger = Morehead.Logger; if (logger != null) { logger.LogError((object)("更新玩家装饰物状态失败: " + e2.Message)); } } yield return (object)new WaitForSeconds(0.1f); try { HeadDecorationSync syncComponent = ((Component)playerAvatar).GetComponent<HeadDecorationSync>(); if ((Object)(object)syncComponent != (Object)null) { syncComponent.SyncAllDecorations(); yield break; } ManualLogSource? logger2 = Morehead.Logger; if (logger2 != null) { logger2.LogWarning((object)"玩家复活后找不到HeadDecorationSync组件"); } } catch (Exception e) { ManualLogSource? logger3 = Morehead.Logger; if (logger3 != null) { logger3.LogError((object)("同步装饰物状态失败: " + e.Message)); } } } } namespace MoreHead { public static class ConfigManager { private const string MOD_DATA_FOLDER = "REPOModData"; private const string MOD_FOLDER = "MoreHead"; private const string CONFIG_FILENAME = "MoreHeadConfig.json"; private static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>(); private static ManualLogSource? Logger => Morehead.Logger; private static string NewConfigFilePath => Path.Combine(Application.persistentDataPath, "REPOModData", "MoreHead", "MoreHeadConfig.json"); private static string BepInExConfigFilePath => Path.Combine(Paths.ConfigPath, "MoreHeadConfig.json"); private static string OldConfigFilePath { get { Morehead? instance = Morehead.Instance; return Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null) ?? string.Empty, "MoreHeadConfig.txt"); } } public static void Initialize() { try { EnsureModDataDirectoryExists(); LoadConfig(); ApplySavedStates(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("初始化配置管理器时出错: " + ex.Message)); } } } private static void EnsureModDataDirectoryExists() { try { string text = Path.Combine(Application.persistentDataPath, "REPOModData"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)("已创建MOD数据总文件夹: " + text)); } } string text2 = Path.Combine(text, "MoreHead"); if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("已创建MOD特定文件夹: " + text2)); } } } catch (Exception ex) { ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogError((object)("创建MOD数据目录时出错: " + ex.Message)); } } } private static void LoadConfig() { try { _decorationStates.Clear(); if (File.Exists(NewConfigFilePath) && LoadJsonConfig(NewConfigFilePath)) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)("已从Unity存档位置加载配置: " + NewConfigFilePath)); } return; } if (File.Exists(BepInExConfigFilePath) && LoadJsonConfig(BepInExConfigFilePath)) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("已从BepInEx配置目录加载配置: " + BepInExConfigFilePath)); } SaveConfigWithoutUpdate(); ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)("已将配置从BepInEx目录迁移到Unity存档位置: " + NewConfigFilePath)); } try { File.Delete(BepInExConfigFilePath); ManualLogSource? logger4 = Logger; if (logger4 != null) { logger4.LogInfo((object)("已删除BepInEx配置文件: " + BepInExConfigFilePath)); } return; } catch (Exception ex) { ManualLogSource? logger5 = Logger; if (logger5 != null) { logger5.LogWarning((object)("删除BepInEx配置文件失败: " + ex.Message)); } return; } } if (!File.Exists(OldConfigFilePath)) { return; } try { string[] array = File.ReadAllLines(OldConfigFilePath); string[] array2 = array; foreach (string text in array2) { if (!string.IsNullOrWhiteSpace(text)) { string[] array3 = text.Split('='); if (array3.Length == 2) { string key = array3[0].Trim(); bool value = array3[1].Trim().Equals("1", StringComparison.OrdinalIgnoreCase); _decorationStates[key] = value; } } } if (_decorationStates.Count <= 0) { return; } ManualLogSource? logger6 = Logger; if (logger6 != null) { logger6.LogInfo((object)$"已从旧文本格式加载配置,包含 {_decorationStates.Count} 个装饰物状态"); } SaveConfigWithoutUpdate(); ManualLogSource? logger7 = Logger; if (logger7 != null) { logger7.LogInfo((object)("已将旧文本格式配置迁移到新的JSON格式: " + NewConfigFilePath)); } try { File.Delete(OldConfigFilePath); ManualLogSource? logger8 = Logger; if (logger8 != null) { logger8.LogInfo((object)("已删除旧文本配置文件: " + OldConfigFilePath)); } } catch (Exception ex2) { ManualLogSource? logger9 = Logger; if (logger9 != null) { logger9.LogWarning((object)("删除旧文本配置文件失败: " + ex2.Message)); } } } catch (Exception ex3) { ManualLogSource? logger10 = Logger; if (logger10 != null) { logger10.LogError((object)("从旧文本格式加载配置时出错: " + ex3.Message)); } } } catch (Exception ex4) { ManualLogSource? logger11 = Logger; if (logger11 != null) { logger11.LogError((object)("加载配置时出错: " + ex4.Message)); } _decorationStates.Clear(); } } private static bool LoadJsonConfig(string filePath) { //IL_0095: Expected O, but got Unknown try { string text = File.ReadAllText(filePath); Dictionary<string, bool> dictionary = JsonConvert.DeserializeObject<Dictionary<string, bool>>(text); if (dictionary != null) { foreach (KeyValuePair<string, bool> item in dictionary) { _decorationStates[item.Key] = item.Value; } ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)$"已从JSON加载配置,包含 {_decorationStates.Count} 个装饰物状态"); } return true; } } catch (JsonException val) { JsonException val2 = val; ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("解析JSON配置文件时出错: " + ((Exception)(object)val2).Message)); } } catch (Exception ex) { ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogError((object)("加载JSON配置文件时出错: " + ex.Message)); } } return false; } public static void SaveConfig() { try { UpdateConfigData(); SaveToFile(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("保存配置时出错: " + ex.Message)); } } } private static void SaveConfigWithoutUpdate() { try { SaveToFile(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("保存配置时出错: " + ex.Message)); } } } private static void SaveToFile() { try { EnsureModDataDirectoryExists(); string contents = JsonConvert.SerializeObject((object)_decorationStates, (Formatting)1); File.WriteAllText(NewConfigFilePath, contents); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("写入配置文件时出错: " + ex.Message)); } } } private static void UpdateConfigData() { _decorationStates.Clear(); foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { _decorationStates[decoration.Name] = decoration.IsVisible; } } public static void ApplySavedStates() { try { int num = 0; foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { if (_decorationStates.TryGetValue(decoration.Name, out var value)) { decoration.IsVisible = value; num++; } } if (num > 0) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)$"已应用 {num} 个已保存的装饰物状态"); } } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("应用已保存的装饰物状态时出错: " + ex.Message)); } } } } public static class DecorationUtils { private const string HEAD_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top"; private const string NECK_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side"; private const string BODY_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE"; private const string HIP_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT"; public static Dictionary<string, Transform> GetDecorationParentNodes(Transform rootTransform) { //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); Transform val = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top"); if ((Object)(object)val != (Object)null) { dictionary["head"] = val; } Transform val2 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side"); if ((Object)(object)val2 != (Object)null) { dictionary["neck"] = val2; } Transform val3 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE"); if ((Object)(object)val3 != (Object)null) { dictionary["body"] = val3; } Transform val4 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT"); if ((Object)(object)val4 != (Object)null) { dictionary["hip"] = val4; } if ((Object)(object)rootTransform != (Object)null) { bool flag = false; PlayerAvatar componentInChildren = ((Component)rootTransform.parent).GetComponentInChildren<PlayerAvatar>(); if ((Object)(object)componentInChildren != (Object)null) { flag = !SemiFunc.IsMultiplayer() || ((Object)(object)componentInChildren.photonView != (Object)null && componentInChildren.photonView.IsMine); } Transform val5 = rootTransform.Find("WorldDecorationFollower"); if ((Object)(object)val5 != (Object)null) { if (flag) { ((Component)val5).gameObject.SetActive(false); } else { ((Component)val5).gameObject.SetActive(true); } dictionary["world"] = val5; } else { GameObject val6 = new GameObject("WorldDecorationFollower"); val6.transform.SetParent(rootTransform, false); val6.transform.localPosition = Vector3.zero; val6.transform.localRotation = Quaternion.identity; val6.transform.localScale = Vector3.one; val6.AddComponent<WorldSpaceFollower>(); if (flag) { val6.SetActive(false); } else { val6.SetActive(true); } dictionary["world"] = val6.transform; } } return dictionary; } public static void EnsureDecorationContainers(Dictionary<string, Transform> parentNodes) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<string, Transform> parentNode in parentNodes) { Transform value = parentNode.Value; Transform val = value.Find("HeadDecorations"); if ((Object)(object)val == (Object)null) { val = new GameObject("HeadDecorations").transform; val.SetParent(value, false); val.localPosition = Vector3.zero; val.localRotation = Quaternion.identity; val.localScale = Vector3.one; } } } public static void UpdateDecoration(Transform parent, string decorationName, bool showDecoration) { Transform val = parent.Find(decorationName); if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf != showDecoration) { ((Component)val).gameObject.SetActive(showDecoration); } } } public class WorldSpaceFollower : MonoBehaviour { private Transform? _rootTransform; private Vector3 _initialOffset; private void Start() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) _rootTransform = ((Component)this).transform.parent; if ((Object)(object)_rootTransform != (Object)null) { _initialOffset = ((Component)this).transform.position - _rootTransform.position; ((Component)this).transform.rotation = Quaternion.identity; ((Component)this).transform.localScale = Vector3.one; } } private void LateUpdate() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0054: 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) if ((Object)(object)_rootTransform != (Object)null) { ((Component)this).transform.position = _rootTransform.position + _initialOffset; ((Component)this).transform.rotation = Quaternion.Euler(0f, _rootTransform.eulerAngles.y, 0f); ((Component)this).transform.localScale = Vector3.one; } } } public class DecorationInfo { public string? Name { get; set; } public string? DisplayName { get; set; } public bool IsVisible { get; set; } public GameObject? Prefab { get; set; } public string? ParentTag { get; set; } public string? BundlePath { get; set; } } public static class HeadDecorationManager { private static Dictionary<string?, string> parentPathMap = new Dictionary<string, string> { { "head", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top" }, { "neck", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side" }, { "body", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE" }, { "hip", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT" }, { "world", "" } }; private static Dictionary<string, List<DecorationInfo>> externalDecorations = new Dictionary<string, List<DecorationInfo>>(); private static ManualLogSource? Logger => Morehead.Logger; public static List<DecorationInfo> Decorations { get; private set; } = new List<DecorationInfo>(); public static void Initialize() { try { ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)"正在初始化装饰物管理器..."); } Decorations.Clear(); LoadAllDecorations(); ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)$"装饰物管理器初始化完成,共加载了 {Decorations.Count} 个装饰物"); } } catch (Exception ex) { ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogError((object)("初始化装饰物管理器时出错: " + ex.Message)); } } } private static void LoadAllDecorations() { try { Morehead? instance = Morehead.Instance; string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null); if (string.IsNullOrEmpty(directoryName)) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)"无法获取MOD所在目录"); } return; } string text = Path.Combine(directoryName, "Decorations"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("已创建装饰物目录: " + text)); } } List<string> list = new List<string>(); string[] files = Directory.GetFiles(text, "*.hhh"); list.AddRange(files); try { string pluginPath = Paths.PluginPath; if (!string.IsNullOrEmpty(pluginPath) && Directory.Exists(pluginPath)) { string[] files2 = Directory.GetFiles(pluginPath, "*.hhh", SearchOption.AllDirectories); list.AddRange(files2); ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件"); } } else { ManualLogSource? logger4 = Logger; if (logger4 != null) { logger4.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物"); } } } catch (Exception ex) { ManualLogSource? logger5 = Logger; if (logger5 != null) { logger5.LogError((object)("搜索plugins目录时出错: " + ex.Message)); } } list = list.Distinct().ToList(); if (list.Count == 0) { ManualLogSource? logger6 = Logger; if (logger6 != null) { logger6.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置"); } } else { ManualLogSource? logger7 = Logger; if (logger7 != null) { logger7.LogInfo((object)$"找到 {list.Count} 个装饰物包文件"); } if (files.Length != 0) { ManualLogSource? logger8 = Logger; if (logger8 != null) { logger8.LogInfo((object)$"- Decorations目录: {files.Length} 个文件"); } } } foreach (string item in list) { LoadDecorationBundle(item); } } catch (Exception ex2) { ManualLogSource? logger9 = Logger; if (logger9 != null) { logger9.LogError((object)("加载装饰物时出错: " + ex2.Message)); } } } private static void LoadDecorationBundle(string bundlePath) { AssetBundle val = null; try { if (!File.Exists(bundlePath)) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("文件不存在: " + bundlePath)); } return; } FileInfo fileInfo = new FileInfo(bundlePath); if (fileInfo.Length < 1024) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogWarning((object)$"文件过小,可能不是有效的AssetBundle: {bundlePath}, 大小: {fileInfo.Length} 字节"); } return; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(bundlePath); string parentTag = "head"; string text = fileNameWithoutExtension; if (fileNameWithoutExtension.Contains("_")) { string[] array = fileNameWithoutExtension.Split('_'); if (array.Length >= 2) { string text2 = array[^1].ToLower(); if (parentPathMap.ContainsKey(text2)) { parentTag = text2; text = string.Join("_", array, 0, array.Length - 1); } } } string text3 = EnsureUniqueName(text); if (text3 != text) { ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogWarning((object)("检测到重名,将基础名称从 " + text + " 修改为 " + text3)); } text = text3; } try { val = AssetBundle.LoadFromFile(bundlePath); if ((Object)(object)val == (Object)null) { ManualLogSource? logger4 = Logger; if (logger4 != null) { logger4.LogError((object)("无法加载AssetBundle,文件可能已损坏或不是有效的AssetBundle: " + bundlePath)); } return; } } catch (Exception ex) { ManualLogSource? logger5 = Logger; if (logger5 != null) { logger5.LogError((object)("加载AssetBundle时出错,文件可能不是有效的AssetBundle: " + bundlePath + ", 错误: " + ex.Message)); } return; } try { string[] allAssetNames; try { allAssetNames = val.GetAllAssetNames(); } catch (Exception ex2) { ManualLogSource? logger6 = Logger; if (logger6 != null) { logger6.LogError((object)("获取AssetBundle资源名称时出错: " + bundlePath + ", 错误: " + ex2.Message)); } val.Unload(true); return; } if (allAssetNames.Length == 0) { ManualLogSource? logger7 = Logger; if (logger7 != null) { logger7.LogWarning((object)("AssetBundle不包含任何资源: " + bundlePath)); } val.Unload(true); return; } bool flag = false; GameObject val2 = null; string[] array2 = allAssetNames; foreach (string text4 in array2) { try { val2 = val.LoadAsset<GameObject>(text4); if ((Object)(object)val2 != (Object)null) { flag = true; break; } } catch (Exception ex3) { ManualLogSource? logger8 = Logger; if (logger8 != null) { logger8.LogWarning((object)("加载资源 " + text4 + " 时出错: " + ex3.Message)); } } } if (!flag || (Object)(object)val2 == (Object)null) { ManualLogSource? logger9 = Logger; if (logger9 != null) { logger9.LogWarning((object)("AssetBundle不包含有效的GameObject资源: " + bundlePath)); } val.Unload(true); return; } string text5 = ((Object)val2).name; string text6 = EnsureUniqueDisplayName(text5); if (text6 != text5) { ManualLogSource? logger10 = Logger; if (logger10 != null) { logger10.LogWarning((object)("检测到显示名称重复,将显示名称从 " + text5 + " 修改为 " + text6)); } text5 = text6; } DecorationInfo decorationInfo = new DecorationInfo { Name = text, DisplayName = text5, IsVisible = false, Prefab = val2, ParentTag = parentTag, BundlePath = bundlePath }; Decorations.Add(decorationInfo); ManualLogSource? logger11 = Logger; if (logger11 != null) { logger11.LogInfo((object)("成功加载装饰物: " + decorationInfo.DisplayName + ", 标签: " + decorationInfo.ParentTag)); } val.Unload(false); } catch (Exception ex4) { ManualLogSource? logger12 = Logger; if (logger12 != null) { logger12.LogError((object)("处理AssetBundle时出错: " + ex4.Message)); } if ((Object)(object)val != (Object)null) { val.Unload(true); } } } catch (Exception ex5) { ManualLogSource? logger13 = Logger; if (logger13 != null) { logger13.LogError((object)("加载装饰物包时出错: " + ex5.Message + ", 路径: " + bundlePath)); } if ((Object)(object)val != (Object)null) { val.Unload(true); } } } private static string EnsureUniqueName(string baseName) { string name = baseName; int num = 1; while (Decorations.Any((DecorationInfo d) => d.Name != null && d.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) { name = $"{baseName}({num})"; num++; } return name; } private static string EnsureUniqueDisplayName(string baseDisplayName) { string displayName = baseDisplayName; int num = 1; while (Decorations.Any((DecorationInfo d) => d.DisplayName != null && d.DisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase))) { displayName = $"{baseDisplayName}({num})"; num++; } return displayName; } private static string? GetParentTagFromPrefab(GameObject prefab) { string text = ((Object)prefab).name.ToLower(); foreach (string key in parentPathMap.Keys) { if (key != null && text.Contains(key)) { return key; } } return null; } public static bool GetDecorationState(string? name) { string name2 = name; DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase)); if (decorationInfo == null) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("GetDecorationState: 找不到装饰物 " + name2)); } } return decorationInfo?.IsVisible ?? false; } public static void SetDecorationState(string name, bool isVisible) { string name2 = name; DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase)); if (decorationInfo != null) { decorationInfo.IsVisible = isVisible; ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)$"设置装饰物 {decorationInfo.DisplayName} 显示状态为: {isVisible}"); } } else { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogWarning((object)("SetDecorationState: 找不到装饰物 " + name2)); } } } public static bool ToggleDecorationState(string? name) { string name2 = name; DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase)); if (decorationInfo != null) { decorationInfo.IsVisible = !decorationInfo.IsVisible; return decorationInfo.IsVisible; } ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("ToggleDecorationState: 找不到装饰物 " + name2)); } return false; } public static string GetParentPath(string parentTag) { if (parentPathMap.TryGetValue(parentTag.ToLower(), out string value)) { return value; } return parentPathMap["head"]; } public static void DisableAllDecorations() { try { int num = 0; foreach (DecorationInfo decoration in Decorations) { if (decoration.IsVisible) { decoration.IsVisible = false; num++; } } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message)); } } } public static bool LoadExternalAssetBundle(byte[] bundleData, string resourceName) { try { string text = Path.Combine(Path.GetTempPath(), resourceName); File.WriteAllBytes(text, bundleData); LoadDecorationBundle(text); try { File.Delete(text); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("清理临时文件失败: " + ex.Message)); } } return true; } catch (Exception ex2) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("加载外部AB包失败: " + ex2.Message)); } return false; } } public static void LoadExternalAssetBundlesFromAssembly(Assembly assembly) { try { int num = 0; string name2 = assembly.GetName().Name; if (!externalDecorations.ContainsKey(name2)) { externalDecorations[name2] = new List<DecorationInfo>(); } else { externalDecorations[name2].Clear(); } int count = Decorations.Count; string[] manifestResourceNames = assembly.GetManifestResourceNames(); IEnumerable<string> enumerable = manifestResourceNames.Where((string name) => name.EndsWith(".hhh", StringComparison.OrdinalIgnoreCase)); if (!enumerable.Any()) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("在DLL " + name2 + " 中未找到.hhh资源")); } return; } ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)$"在DLL {name2} 中找到 {enumerable.Count()} 个.hhh资源"); } foreach (string item in enumerable) { try { string text = item.Substring(0, item.Length - 4); string text2 = ((!text.Contains(".")) ? text : text.Split('.').Last()); ManualLogSource? logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)("处理资源: " + item + ", 提取文件名: " + text2)); } byte[] array; using (Stream stream = assembly.GetManifestResourceStream(item)) { if (stream == null) { continue; } array = new byte[stream.Length]; stream.Read(array, 0, array.Length); goto IL_01ab; } IL_01ab: if (LoadExternalAssetBundle(array, text2 + ".hhh")) { num++; } } catch (Exception ex) { ManualLogSource? logger4 = Logger; if (logger4 != null) { logger4.LogError((object)("加载资源 " + item + " 失败: " + ex.Message)); } } } if (num > 0) { for (int i = count; i < Decorations.Count; i++) { externalDecorations[name2].Add(Decorations[i]); } ManualLogSource? logger5 = Logger; if (logger5 != null) { logger5.LogInfo((object)$"成功从DLL {name2} 加载了 {num} 个资源,已保存到外部装饰物记录中"); } ConfigManager.ApplySavedStates(); } } catch (Exception ex2) { ManualLogSource? logger6 = Logger; if (logger6 != null) { logger6.LogError((object)("从DLL加载资源失败: " + ex2.Message)); } } } public static List<DecorationInfo> GetDecorationsFromAssembly(Assembly assembly) { string name = assembly.GetName().Name; if (externalDecorations.TryGetValue(name, out List<DecorationInfo> value)) { return value; } return new List<DecorationInfo>(); } public static List<GameObject> GetDecorationGameObjectsFromAssembly(Assembly assembly) { List<GameObject> list = new List<GameObject>(); foreach (DecorationInfo item in GetDecorationsFromAssembly(assembly)) { if ((Object)(object)item.Prefab != (Object)null) { list.Add(item.Prefab); } } return list; } public static DecorationInfo GetDecorationByName(Assembly assembly, string decorationName) { string decorationName2 = decorationName; List<DecorationInfo> decorationsFromAssembly = GetDecorationsFromAssembly(assembly); return decorationsFromAssembly.FirstOrDefault((DecorationInfo d) => (d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase)) || (d.DisplayName != null && d.DisplayName.Equals(decorationName2, StringComparison.OrdinalIgnoreCase))); } public static List<DecorationInfo> FindDecorationsByPartialName(Assembly assembly, string partialName) { string partialName2 = partialName; if (string.IsNullOrEmpty(partialName2)) { return new List<DecorationInfo>(); } List<DecorationInfo> decorationsFromAssembly = GetDecorationsFromAssembly(assembly); return decorationsFromAssembly.Where((DecorationInfo d) => (d.Name != null && d.Name.IndexOf(partialName2, StringComparison.OrdinalIgnoreCase) >= 0) || (d.DisplayName != null && d.DisplayName.IndexOf(partialName2, StringComparison.OrdinalIgnoreCase) >= 0)).ToList(); } public static void RecreateUI() { try { MoreHeadUI.RecreateUI(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("重新创建UI时出错: " + ex.Message)); } } } } public static class MoreHeadUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static BuilderDelegate <>9__13_0; public static Action <>9__18_1; public static BuilderDelegate <>9__18_0; public static BuilderDelegate <>9__30_0; public static Func<DecorationInfo, bool> <>9__34_0; public static Func<DecorationInfo, string> <>9__34_1; public static Func<DecorationInfo, bool> <>9__34_2; public static Func<DecorationInfo, string> <>9__34_3; public static BuilderDelegate <>9__36_0; public static BuilderDelegate <>9__36_1; internal void <Initialize>b__13_0(Transform parent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick, parent, Vector2.zero); } internal void <AddAuthorCredit>b__18_0(Transform parent) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate { }, parent, new Vector2(300f, 329f)); } internal void <AddAuthorCredit>b__18_1() { } internal void <CreateAvatarPreview>b__30_0(Transform parent) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) avatarPreview = MenuAPI.CreateREPOAvatarPreview(parent, new Vector2(420f, 10f), false, (Color?)null); } internal bool <CreateAllDecorationButtons>b__34_0(DecorationInfo decoration) { return IsBuiltInDecoration(decoration); } internal string <CreateAllDecorationButtons>b__34_1(DecorationInfo decoration) { return decoration.DisplayName; } internal bool <CreateAllDecorationButtons>b__34_2(DecorationInfo decoration) { return !IsBuiltInDecoration(decoration); } internal string <CreateAllDecorationButtons>b__34_3(DecorationInfo decoration) { return decoration.DisplayName; } internal void <AddActionButtons>b__36_0(Transform parent) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick, parent, new Vector2(301f, 0f)); } internal void <AddActionButtons>b__36_1(Transform parent) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=18><color=#FFAA00>CLEAR ALL</color></size>", (Action)OnDisableAllButtonClick, parent, new Vector2(401f, 0f)); } } private static REPOPopupPage? decorationsPage; private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>(); private static Dictionary<string, List<REPOScrollViewElement>> tagScrollViewElements = new Dictionary<string, List<REPOScrollViewElement>>(); private static string currentTagFilter = "ALL"; private static Dictionary<string, REPOButton> tagFilterButtons = new Dictionary<string, REPOButton>(); private static Dictionary<string, List<DecorationInfo>> decorationDataCache = new Dictionary<string, List<DecorationInfo>>(); private static Dictionary<string, Dictionary<string, string>> buttonTextCache = new Dictionary<string, Dictionary<string, string>>(); private static REPOAvatarPreview? avatarPreview; private const string BUTTON_NAME = "<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>"; private static readonly string PAGE_TITLE = "Rotate robot: A/D <size=12><color=#AAAAAA>v" + Morehead.GetPluginVersion() + "</color></size>"; private static readonly string[] ALL_TAGS = new string[6] { "ALL", "HEAD", "NECK", "BODY", "HIP", "WORLD" }; private static ManualLogSource? Logger => Morehead.Logger; public static void Initialize() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown try { object obj = <>c.<>9__13_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick, parent, Vector2.zero); }; <>c.<>9__13_0 = val; obj = (object)val; } MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj); InitializeDataCache(); ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)"MoreHead UI已初始化"); } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("初始化UI时出错: " + ex.Message)); } } } private static void InitializeDataCache() { try { decorationDataCache.Clear(); buttonTextCache.Clear(); string[] aLL_TAGS = ALL_TAGS; foreach (string tag in aLL_TAGS) { List<DecorationInfo> list = HeadDecorationManager.Decorations.Where((DecorationInfo decoration) => tag == "ALL" || decoration.ParentTag?.ToLower() == tag.ToLower()).ToList(); decorationDataCache[tag] = list; buttonTextCache[tag] = new Dictionary<string, string>(); foreach (DecorationInfo item in list) { string buttonText = GetButtonText(item, item.IsVisible); buttonTextCache[tag][item.Name ?? string.Empty] = buttonText; } } ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)"数据缓存初始化完成"); } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("初始化数据缓存时出错: " + ex.Message)); } } } private static void OnMenuButtonClick() { try { MenuManager.instance.PageCloseAll(); MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>(); if (obj != null) { obj.StartCoroutine(DelayedOpenMoreHeadUI()); } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("打开设置页面时出错: " + ex.Message)); } } } private static IEnumerator DelayedOpenMoreHeadUI() { yield return null; try { if ((Object)(object)decorationsPage == (Object)null) { decorationsPage = MenuAPI.CreateREPOPopupPage(PAGE_TITLE, true, true, 0f, (Vector2?)new Vector2(-299f, 10f)); SetupPopupPage(decorationsPage); CreateAllDecorationButtons(decorationsPage); CreateTagFilterButtons(decorationsPage); AddAuthorCredit(decorationsPage); AddActionButtons(decorationsPage); } decorationsPage.OpenPage(false); MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>(); if (obj != null) { obj.StartCoroutine(DelayedShowTagDecorations(currentTagFilter)); } UpdateAvatarPreview(); UpdateButtonStates(); } catch (Exception e) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("延迟打开设置页面时出错: " + e.Message)); } } } private static void SetupPopupPage(REPOPopupPage page) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)((Component)page).gameObject != (Object)null) { ((Object)((Component)page).gameObject).name = "MoreHead_Page"; } page.pageDimmerVisibility = true; page.maskPadding = new Padding(10f, 10f, 20f, 10f); ((Transform)((TMP_Text)page.headerTMP).rectTransform).position = new Vector3(170f, 344f, 0f); page.pageDimmerOpacity = 0.85f; page.scrollView.scrollSpeed = 4f; } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("设置弹出页面属性时出错: " + ex.Message)); } } } private static void AddAuthorCredit(REPOPopupPage page) { //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_0022: Expected O, but got Unknown try { object obj = <>c.<>9__18_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate { }, parent, new Vector2(300f, 329f)); }; <>c.<>9__18_0 = val; obj = (object)val; } page.AddElement((BuilderDelegate)obj); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("添加作者标记时出错: " + ex.Message)); } } } private static bool IsBuiltInDecoration(DecorationInfo decoration) { string bundlePath = decoration.BundlePath; if (string.IsNullOrEmpty(bundlePath)) { return false; } Morehead? instance = Morehead.Instance; string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null); if (string.IsNullOrEmpty(directoryName)) { return false; } string value = Path.Combine(directoryName, "Decorations"); return bundlePath.StartsWith(value); } private static void CreateTagFilterButtons(REPOPopupPage? page) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown try { tagFilterButtons.Clear(); for (int i = 0; i < ALL_TAGS.Length; i++) { string text = ALL_TAGS[i]; string text2 = text.ToLower(); int num = i; if (1 == 0) { } string text3 = text2 switch { "head" => "#00AAFF", "neck" => "#AA00FF", "body" => "#FFAA00", "hip" => "#FF00AA", "world" => "#00FFAA", _ => "#FFFFFF", }; if (1 == 0) { } string text4 = text3; string buttonText = ((text2 == currentTagFilter.ToLower()) ? ("<size=14><b><color=" + text4 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text4 + "50>" + text + "</color></size>")); string tagForCallback = ((text2 == "all") ? "ALL" : text); int xPosition = 70 + i * 40; if (page == null) { continue; } page.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) REPOButton value = MenuAPI.CreateREPOButton(buttonText, (Action)delegate { OnTagFilterButtonClick(tagForCallback); }, parent, new Vector2((float)xPosition, 20f)); tagFilterButtons[tagForCallback] = value; }); } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("创建标签筛选按钮时出错: " + ex.Message)); } } } private static void OnTagFilterButtonClick(string tag) { try { if (tag == currentTagFilter) { REPOPopupPage? obj = decorationsPage; if (obj != null) { obj.scrollView.SetScrollPosition(0f); } } else { ShowTagDecorations(tag); UpdateTagButtonHighlights(); } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("切换标签筛选时出错: " + ex.Message)); } } } private static void UpdateButtonStates() { try { if (decorationButtons.Count == 0) { return; } if (decorationDataCache.TryGetValue(currentTagFilter, out List<DecorationInfo> value)) { foreach (DecorationInfo item in value) { if (!decorationButtons.TryGetValue(item.Name ?? string.Empty, out REPOButton value2)) { continue; } if (!buttonTextCache.TryGetValue(currentTagFilter, out Dictionary<string, string> value3) || !value3.TryGetValue(item.Name ?? string.Empty, out var value4)) { value4 = GetButtonText(item, item.IsVisible); if (buttonTextCache.TryGetValue(currentTagFilter, out value3)) { value3[item.Name ?? string.Empty] = value4; } } ((TMP_Text)value2.labelTMP).text = value4; } } UpdateTagButtonHighlights(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("更新按钮状态时出错: " + ex.Message)); } } } private static void UpdateTagButtonHighlights() { try { string[] aLL_TAGS = ALL_TAGS; foreach (string text in aLL_TAGS) { string text2 = ((text == "ALL") ? "ALL" : text); if (tagFilterButtons.TryGetValue(text2, out REPOButton value)) { string text3 = text.ToLower(); if (1 == 0) { } string text4 = text3 switch { "head" => "#00AAFF", "neck" => "#AA00FF", "body" => "#FFAA00", "hip" => "#FF00AA", "world" => "#00FFAA", _ => "#FFFFFF", }; if (1 == 0) { } string text5 = text4; string text6 = ((text2 == currentTagFilter) ? ("<size=14><b><color=" + text5 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text5 + "50>" + text + "</color></size>")); ((TMP_Text)value.labelTMP).text = text6; } } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("更新标签按钮高亮状态时出错: " + ex.Message)); } } } private static void OnDecorationButtonClick(string? decorationName) { string decorationName2 = decorationName; try { DecorationInfo decorationInfo = HeadDecorationManager.Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase)); if (decorationInfo == null) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物: " + decorationName2)); } return; } bool isEnabled = HeadDecorationManager.ToggleDecorationState(decorationName2); string buttonText = GetButtonText(decorationInfo, isEnabled); string[] aLL_TAGS = ALL_TAGS; foreach (string text in aLL_TAGS) { if ((text == "ALL" || decorationInfo.ParentTag?.ToLower() == text.ToLower()) && buttonTextCache.TryGetValue(text, out Dictionary<string, string> value)) { value[decorationName2 ?? string.Empty] = buttonText; } } if (decorationButtons.TryGetValue(decorationName2 ?? string.Empty, out REPOButton value2)) { ((TMP_Text)value2.labelTMP).text = buttonText; } UpdateDecorations(); ConfigManager.SaveConfig(); } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message)); } } } private static string GetButtonText(DecorationInfo decoration, bool isEnabled) { string text = decoration.DisplayName?.ToUpper() ?? "UNKNOWN"; string text2 = decoration.ParentTag ?? "unknown"; string text3 = text2.ToLower(); if (1 == 0) { } string text4 = text3 switch { "head" => "#00AAFF", "neck" => "#AA00FF", "body" => "#FFAA00", "hip" => "#FF00AA", "world" => "#00FFAA", _ => "#AAAAAA", }; if (1 == 0) { } string text5 = text4; return "<size=16>" + (isEnabled ? "<color=#00FF00>[+]</color>" : "<color=#FF0000>[-]</color>") + " <color=" + text5 + "><size=12>(" + text2 + ")</size></color> " + text + "</size>"; } private static void OnCloseButtonClick() { try { MenuManager.instance.PageCloseAll(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("关闭页面时出错: " + ex.Message)); } } } private static void UpdateDecorations() { try { PlayerAvatar val = FindLocalPlayer(); if ((Object)(object)val != (Object)null) { PlayerUpdatePatch.UpdatePlayerDecorations(val); HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>(); if ((Object)(object)component != (Object)null) { component.SyncAllDecorations(); } } PlayerUpdatePatch.UpdateMenuPlayerDecorations(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("更新装饰物状态时出错: " + ex.Message)); } } } private static PlayerAvatar? FindLocalPlayer() { try { PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); PlayerAvatar[] array2 = array; foreach (PlayerAvatar val in array2) { if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine) { return val; } } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("查找本地玩家时出错: " + ex.Message)); } } return null; } private static void UpdateAvatarPreview() { try { if (!((Object)(object)decorationsPage == (Object)null)) { if ((Object)(object)avatarPreview != (Object)null) { SafeDestroyAvatar(); } CreateAvatarPreview(decorationsPage); } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("更新头像预览时出错: " + ex.Message)); } } } private static void CreateAvatarPreview(REPOPopupPage page) { //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_0022: Expected O, but got Unknown try { object obj = <>c.<>9__30_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) avatarPreview = MenuAPI.CreateREPOAvatarPreview(parent, new Vector2(420f, 10f), false, (Color?)null); }; <>c.<>9__30_0 = val; obj = (object)val; } page.AddElement((BuilderDelegate)obj); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("创建头像预览时出错: " + ex.Message)); } } } private static void SafeDestroyAvatar() { try { if ((Object)(object)avatarPreview != (Object)null) { if ((Object)(object)((Component)avatarPreview).transform != (Object)null && (Object)(object)((Component)avatarPreview).transform.parent != (Object)null) { ((Component)avatarPreview).transform.SetParent((Transform)null, false); } PlayerAvatarVisuals playerAvatarVisuals = avatarPreview.playerAvatarVisuals; if ((Object)(object)playerAvatarVisuals != (Object)null) { } if ((Object)(object)((Component)avatarPreview).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)avatarPreview).gameObject); } avatarPreview = null; } } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)("安全销毁头像预览时出错,但这不影响功能: " + ex.Message)); } avatarPreview = null; } } private static void OnDisableAllButtonClick() { try { HeadDecorationManager.DisableAllDecorations(); string[] aLL_TAGS = ALL_TAGS; foreach (string text in aLL_TAGS) { if (!buttonTextCache.TryGetValue(text, out Dictionary<string, string> value)) { continue; } foreach (DecorationInfo decoration in HeadDecorationManager.Decorations) { if (text == "ALL" || decoration.ParentTag?.ToLower() == text.ToLower()) { string buttonText = GetButtonText(decoration, isEnabled: false); value[decoration.Name ?? string.Empty] = buttonText; } } } foreach (DecorationInfo decoration2 in HeadDecorationManager.Decorations) { if (decorationButtons.TryGetValue(decoration2.Name ?? string.Empty, out REPOButton value2)) { ((TMP_Text)value2.labelTMP).text = GetButtonText(decoration2, isEnabled: false); } } UpdateDecorations(); ConfigManager.SaveConfig(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message)); } } } public static void RecreateUI() { try { decorationDataCache.Clear(); buttonTextCache.Clear(); decorationButtons.Clear(); tagScrollViewElements.Clear(); if ((Object)(object)decorationsPage != (Object)null && (Object)(object)((Component)decorationsPage).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)decorationsPage).gameObject); decorationsPage = null; } SafeDestroyAvatar(); InitializeDataCache(); ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)"UI已重新初始化,缓存已重置"); } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("重新创建UI时出错: " + ex.Message)); } } } private static void CreateAllDecorationButtons(REPOPopupPage page) { try { decorationButtons.Clear(); tagScrollViewElements.Clear(); string[] aLL_TAGS = ALL_TAGS; foreach (string key in aLL_TAGS) { tagScrollViewElements[key] = new List<REPOScrollViewElement>(); } List<DecorationInfo> source = HeadDecorationManager.Decorations.ToList(); List<DecorationInfo> list = (from decoration in source where IsBuiltInDecoration(decoration) orderby decoration.DisplayName select decoration).ToList(); List<DecorationInfo> list2 = (from decoration in source where !IsBuiltInDecoration(decoration) orderby decoration.DisplayName select decoration).ToList(); foreach (DecorationInfo item in list) { CreateDecorationButton(page, item); } foreach (DecorationInfo item2 in list2) { CreateDecorationButton(page, item2); } ManualLogSource? logger = Logger; if (logger != null) { logger.LogInfo((object)$"创建了所有装饰物按钮,总共 {decorationButtons.Count} 个"); } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("创建装饰物按钮时出错: " + ex.Message)); } } } private static void CreateDecorationButton(REPOPopupPage page, DecorationInfo decoration) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown try { string decorationName = decoration.Name; string parentTag = decoration.ParentTag; if (string.IsNullOrEmpty(decorationName) || string.IsNullOrEmpty(parentTag)) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogWarning((object)"跳过创建按钮:装饰物名称或标签为空"); } return; } string buttonText = GetButtonText(decoration, decoration.IsVisible); string[] aLL_TAGS = ALL_TAGS; foreach (string text in aLL_TAGS) { if (text == "ALL" || parentTag.ToLower() == text.ToLower()) { if (!buttonTextCache.TryGetValue(text, out Dictionary<string, string> value)) { buttonTextCache[text] = new Dictionary<string, string>(); value = buttonTextCache[text]; } value[decorationName] = buttonText; } } REPOButton repoButton = null; page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) repoButton = MenuAPI.CreateREPOButton(buttonText, (Action)delegate { OnDecorationButtonClick(decorationName); }, scrollView, default(Vector2)); return ((REPOElement)repoButton).rectTransform; }, 0f, 0f); if ((Object)(object)repoButton != (Object)null) { decorationButtons[decorationName] = repoButton; ((REPOElement)repoButton).repoScrollViewElement.visibility = false; tagScrollViewElements["ALL"].Add(((REPOElement)repoButton).repoScrollViewElement); if (tagScrollViewElements.TryGetValue(parentTag.ToUpper(), out List<REPOScrollViewElement> value2)) { value2.Add(((REPOElement)repoButton).repoScrollViewElement); } } } catch (Exception ex) { ManualLogSource? logger2 = Logger; if (logger2 != null) { logger2.LogError((object)("创建装饰物按钮时出错: " + ex.Message)); } } } private static void AddActionButtons(REPOPopupPage page) { //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_0022: 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_0048: Expected O, but got Unknown try { object obj = <>c.<>9__36_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick, parent, new Vector2(301f, 0f)); }; <>c.<>9__36_0 = val; obj = (object)val; } page.AddElement((BuilderDelegate)obj); object obj2 = <>c.<>9__36_1; if (obj2 == null) { BuilderDelegate val2 = delegate(Transform parent) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("<size=18><color=#FFAA00>CLEAR ALL</color></size>", (Action)OnDisableAllButtonClick, parent, new Vector2(401f, 0f)); }; <>c.<>9__36_1 = val2; obj2 = (object)val2; } page.AddElement((BuilderDelegate)obj2); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("添加操作按钮时出错: " + ex.Message)); } } } private static void ShowTagDecorations(string tag) { try { if ((Object)(object)decorationsPage == (Object)null) { return; } if (!string.IsNullOrEmpty(currentTagFilter) && tagScrollViewElements.TryGetValue(currentTagFilter, out List<REPOScrollViewElement> value)) { foreach (REPOScrollViewElement item in value) { if ((Object)(object)item != (Object)null) { item.visibility = false; } } } if (!string.IsNullOrEmpty(tag) && tagScrollViewElements.TryGetValue(tag, out List<REPOScrollViewElement> value2)) { foreach (REPOScrollViewElement item2 in value2) { if ((Object)(object)item2 != (Object)null) { item2.visibility = true; } } } currentTagFilter = tag; decorationsPage.scrollView.SetScrollPosition(0f); decorationsPage.scrollView.UpdateElements(); } catch (Exception ex) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("显示标签 " + tag + " 的装饰物时出错: " + ex.Message)); } } } private static IEnumerator DelayedShowTagDecorations(string tag) { yield return null; try { ShowTagDecorations(tag); } catch (Exception e) { ManualLogSource? logger = Logger; if (logger != null) { logger.LogError((object)("延迟显示标签装饰物时出错: " + e.Message)); } } } } }