using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using Microsoft.CodeAnalysis;
using MoreHead;
using Photon.Pun;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreHead")]
[assembly: AssemblyTitle("MoreHead")]
[assembly: AssemblyVersion("1.0.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.0.0")]
public class Morehead : BaseUnityPlugin
{
public static ManualLogSource? Logger;
public static Morehead? Instance { get; private set; }
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(MenuPlayerVisualsPatch));
val.PatchAll(typeof(GameDirectorUpdatePatch));
val.PatchAll(typeof(PlayerRevivePatch));
Logger.LogInfo((object)"MoreHead 已加载");
HeadDecorationManager.Initialize();
ConfigManager.Initialize();
MoreHeadUI.Initialize();
}
catch (Exception ex)
{
Logger.LogError((object)("Harmony补丁应用失败: " + ex.Message));
}
}
private void OnApplicationQuit()
{
ConfigManager.SaveConfig();
}
public static bool GetDecorationState(string? name)
{
return HeadDecorationManager.GetDecorationState(name);
}
}
[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)
{
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null)
{
return;
}
Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
Transform val = ((Component)playerAvatar.playerAvatarVisuals).transform.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 = ((Component)playerAvatar.playerAvatarVisuals).transform.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 = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
if ((Object)(object)val3 != (Object)null)
{
dictionary["body"] = val3;
}
if (dictionary.Count == 0)
{
ManualLogSource? logger = Morehead.Logger;
if (logger != null)
{
logger.LogWarning((object)"找不到任何装饰物父级节点");
}
return;
}
foreach (KeyValuePair<string, Transform> item in dictionary)
{
string key = item.Key;
Transform value = item.Value;
Transform val4 = value.Find("HeadDecorations");
if ((Object)(object)val4 == (Object)null)
{
val4 = new GameObject("HeadDecorations").transform;
val4.SetParent(value, false);
val4.localPosition = Vector3.zero;
val4.localRotation = Quaternion.identity;
val4.localScale = Vector3.one;
}
}
foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
{
if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
{
Transform val5 = value2.Find("HeadDecorations");
if ((Object)(object)val5 != (Object)null)
{
UpdateDecoration(val5, decoration.Name, 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 void UpdateDecoration(Transform parent, string? decorationName, bool showDecoration)
{
Transform val = parent.Find(decorationName);
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(showDecoration);
}
}
public static void UpdateMenuPlayerDecorations()
{
//IL_011f: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
try
{
PlayerAvatarVisuals val = FindMenuPlayerVisuals();
if ((Object)(object)val == (Object)null)
{
return;
}
Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
Transform val2 = ((Component)val).transform.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)val2 != (Object)null)
{
dictionary["head"] = val2;
}
Transform val3 = ((Component)val).transform.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)val3 != (Object)null)
{
dictionary["neck"] = val3;
}
Transform val4 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
if ((Object)(object)val4 != (Object)null)
{
dictionary["body"] = val4;
}
if (dictionary.Count == 0)
{
ManualLogSource? logger = Morehead.Logger;
if (logger != null)
{
logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
}
return;
}
foreach (KeyValuePair<string, Transform> item in dictionary)
{
string key = item.Key;
Transform value = item.Value;
Transform val5 = value.Find("HeadDecorations");
if ((Object)(object)val5 == (Object)null)
{
val5 = new GameObject("HeadDecorations").transform;
val5.SetParent(value, false);
val5.localPosition = Vector3.zero;
val5.localRotation = Quaternion.identity;
val5.localScale = Vector3.one;
}
}
foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
{
if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
{
Transform val6 = value2.Find("HeadDecorations");
if ((Object)(object)val6 != (Object)null)
{
Transform val7 = val6.Find(decoration.Name);
if ((Object)(object)val7 == (Object)null)
{
AddMenuDecoration(val6, decoration.Name);
}
else
{
((Component)val7).gameObject.SetActive(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()
{
GameObject val = GameObject.Find("PlayerAvatarMenu");
if ((Object)(object)val == (Object)null)
{
return null;
}
return val.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> dictionary = new Dictionary<string, Transform>();
Transform val = ((Component)component.playerAvatarVisuals).transform.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 = ((Component)component.playerAvatarVisuals).transform.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 = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
if ((Object)(object)val3 != (Object)null)
{
dictionary["body"] = val3;
}
for (int i = 0; i < names.Length; i++)
{
string decorationName = names[i];
bool showDecoration = states[i];
string key = parentTags[i];
if (dictionary.TryGetValue(key, out var value))
{
Transform val4 = value.Find("HeadDecorations");
if ((Object)(object)val4 != (Object)null)
{
UpdateDecoration(val4, decorationName, showDecoration);
}
}
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Morehead.Logger;
if (logger2 != null)
{
logger2.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message));
}
}
}
private void UpdateDecoration(Transform parent, string decorationName, bool showDecoration)
{
Transform val = parent.Find(decorationName);
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(showDecoration);
}
}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class PlayerAvatarVisualsPatch
{
private static void Postfix(PlayerAvatarVisuals __instance)
{
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
try
{
Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
Transform val = ((Component)__instance).transform.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 = ((Component)__instance).transform.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 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
if ((Object)(object)val3 != (Object)null)
{
dictionary["body"] = val3;
}
if (dictionary.Count == 0)
{
ManualLogSource? logger = Morehead.Logger;
if (logger != null)
{
logger.LogError((object)"找不到任何装饰物父级节点");
}
return;
}
foreach (KeyValuePair<string, Transform> item in dictionary)
{
string key = item.Key;
Transform value = item.Value;
Transform val4 = value.Find("HeadDecorations");
if ((Object)(object)val4 == (Object)null)
{
val4 = new GameObject("HeadDecorations").transform;
val4.SetParent(value, false);
val4.localPosition = Vector3.zero;
val4.localRotation = Quaternion.identity;
val4.localScale = Vector3.one;
}
}
foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
{
if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
{
Transform val5 = value2.Find("HeadDecorations");
if ((Object)(object)val5 != (Object)null)
{
AddNewDecoration(val5, decoration, __instance);
}
}
else
{
ManualLogSource? logger2 = Morehead.Logger;
if (logger2 != null)
{
logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.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));
}
}
}
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(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class MenuPlayerVisualsPatch
{
private static void Postfix(PlayerAvatarVisuals __instance)
{
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!__instance.isMenuAvatar)
{
return;
}
Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
Transform val = ((Component)__instance).transform.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 = ((Component)__instance).transform.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 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
if ((Object)(object)val3 != (Object)null)
{
dictionary["body"] = val3;
}
if (dictionary.Count == 0)
{
ManualLogSource? logger = Morehead.Logger;
if (logger != null)
{
logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
}
return;
}
foreach (KeyValuePair<string, Transform> item in dictionary)
{
string key = item.Key;
Transform value = item.Value;
Transform val4 = value.Find("HeadDecorations");
if ((Object)(object)val4 == (Object)null)
{
val4 = new GameObject("HeadDecorations").transform;
val4.SetParent(value, false);
val4.localPosition = Vector3.zero;
val4.localRotation = Quaternion.identity;
val4.localScale = Vector3.one;
}
foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
{
if (decoration.ParentTag == key)
{
PlayerUpdatePatch.AddMenuDecoration(val4, decoration.Name);
}
}
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Morehead.Logger;
if (logger2 != null)
{
logger2.LogError((object)("初始化菜单角色装饰物失败: " + ex.Message));
}
}
}
}
[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 static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>();
private static ManualLogSource? Logger => Morehead.Logger;
private static string ConfigFilePath
{
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
{
LoadConfig();
ApplySavedStates();
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("初始化配置管理器时出错: " + ex.Message));
}
}
}
private static void LoadConfig()
{
try
{
_decorationStates.Clear();
if (!File.Exists(ConfigFilePath))
{
return;
}
string[] array = File.ReadAllLines(ConfigFilePath);
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)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogInfo((object)$"已加载配置,包含 {_decorationStates.Count} 个装饰物状态");
}
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("加载配置时出错: " + ex.Message));
}
_decorationStates.Clear();
}
}
public static void SaveConfig()
{
try
{
UpdateConfigData();
List<string> list = new List<string>();
foreach (KeyValuePair<string, bool> decorationState in _decorationStates)
{
list.Add(decorationState.Key + "=" + (decorationState.Value ? "1" : "0"));
}
File.WriteAllLines(ConfigFilePath, list);
}
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;
}
}
private 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 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" }
};
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 text2 = FindPluginsDirectory(directoryName);
if (!string.IsNullOrEmpty(text2) && Directory.Exists(text2))
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogInfo((object)("找到BepInEx/plugins目录: " + text2));
}
string[] files2 = Directory.GetFiles(text2, "*.hhh", SearchOption.AllDirectories);
list.AddRange(files2);
ManualLogSource? logger4 = Logger;
if (logger4 != null)
{
logger4.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件");
}
}
else
{
ManualLogSource? logger5 = Logger;
if (logger5 != null)
{
logger5.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物");
}
}
}
catch (Exception ex)
{
ManualLogSource? logger6 = Logger;
if (logger6 != null)
{
logger6.LogError((object)("搜索plugins目录时出错: " + ex.Message));
}
}
list = list.Distinct().ToList();
if (list.Count == 0)
{
ManualLogSource? logger7 = Logger;
if (logger7 != null)
{
logger7.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置");
}
}
else
{
ManualLogSource? logger8 = Logger;
if (logger8 != null)
{
logger8.LogInfo((object)$"找到 {list.Count} 个装饰物包文件");
}
if (files.Length != 0)
{
ManualLogSource? logger9 = Logger;
if (logger9 != null)
{
logger9.LogInfo((object)$"- Decorations目录: {files.Length} 个文件");
}
}
}
foreach (string item in list)
{
LoadDecorationBundle(item);
}
}
catch (Exception ex2)
{
ManualLogSource? logger10 = Logger;
if (logger10 != null)
{
logger10.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"];
}
private static string? FindPluginsDirectory(string startDirectory)
{
try
{
string text = startDirectory;
for (int i = 0; i < 5; i++)
{
string fileName = Path.GetFileName(text);
if (string.Equals(fileName, "plugins", StringComparison.OrdinalIgnoreCase))
{
string directoryName = Path.GetDirectoryName(text);
if (directoryName != null)
{
string fileName2 = Path.GetFileName(directoryName);
if (string.Equals(fileName2, "BepInEx", StringComparison.OrdinalIgnoreCase))
{
return text;
}
}
}
string text2 = Path.Combine(text, "BepInEx", "plugins");
if (Directory.Exists(text2))
{
return text2;
}
string directoryName2 = Path.GetDirectoryName(text);
if (string.IsNullOrEmpty(directoryName2) || directoryName2 == text)
{
break;
}
text = directoryName2;
}
string pathRoot = Path.GetPathRoot(startDirectory);
if (!string.IsNullOrEmpty(pathRoot))
{
string text3 = Path.Combine(pathRoot, "REPO", "BepInEx", "plugins");
if (Directory.Exists(text3))
{
return text3;
}
string[] array = new string[4]
{
Path.Combine(pathRoot, "Program Files (x86)", "Steam", "steamapps", "common", "REPO"),
Path.Combine(pathRoot, "Program Files", "Steam", "steamapps", "common", "REPO"),
Path.Combine(pathRoot, "SteamLibrary", "steamapps", "common", "REPO"),
Path.Combine(pathRoot, "Games", "REPO")
};
string[] array2 = array;
foreach (string path in array2)
{
string text4 = Path.Combine(path, "BepInEx", "plugins");
if (Directory.Exists(text4))
{
return text4;
}
}
}
return null;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("查找plugins目录时出错: " + ex.Message));
}
return null;
}
}
}
public static class MoreHeadUI
{
private static REPOButton? menuButton;
private static REPOPopupPage? decorationsPage;
private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>();
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 const string PAGE_TITLE = "Rotate robot: A/D";
private static ManualLogSource? Logger => Morehead.Logger;
public static void Initialize()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
try
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogInfo((object)"正在初始化MoreHead UI...");
}
menuButton = new REPOButton("<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);
MenuAPI.AddElementToEscapeMenu((REPOElement)(object)menuButton, new Vector2(0f, 0f));
decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
CreatePageContent();
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogInfo((object)"MoreHead UI初始化完成");
}
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("初始化UI时出错: " + ex.Message));
}
}
}
private static void SetupPopupPage(REPOPopupPage page)
{
//IL_000d: 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)
try
{
page.SetSize(new Vector2(300f, 350f));
page.SetBackgroundDimming(true);
page.SetMaskPadding((Padding?)new Padding(10f, 20f, 20f, 10f));
AddAuthorCredit(page);
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 AddAuthorCredit(REPOPopupPage page)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
try
{
REPOButton val = new REPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate
{
});
((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val, new Vector2(300f, 345f));
try
{
MenuManager obj = Object.FindObjectOfType<MenuManager>();
if (obj != null)
{
((MonoBehaviour)obj).StartCoroutine(DelayedStyleAuthorCredit(val));
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)("无法修改作者标记样式: " + ex.Message));
}
}
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogInfo((object)"添加作者标记完成");
}
}
catch (Exception ex2)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("添加作者标记时出错: " + ex2.Message));
}
}
}
private static IEnumerator DelayedStyleAuthorCredit(REPOButton button)
{
yield return null;
try
{
GameObject buttonObj = null;
Button[] allButtons = Object.FindObjectsOfType<Button>();
Button[] array = allButtons;
foreach (Button btn in array)
{
if (((Object)btn).name.Contains("Masaicker") && ((Object)btn).name.Contains("Yuriscat"))
{
buttonObj = ((Component)btn).gameObject;
break;
}
}
if (!((Object)(object)buttonObj != (Object)null))
{
yield break;
}
Button buttonComponent = buttonObj.GetComponent<Button>();
if (!((Object)(object)buttonComponent != (Object)null))
{
yield break;
}
((Selectable)buttonComponent).interactable = false;
Image[] images = buttonObj.GetComponentsInChildren<Image>();
Image[] array2 = images;
foreach (Image image in array2)
{
if ((Object)(object)((Component)image).gameObject != (Object)(object)((Component)buttonComponent).gameObject)
{
((Behaviour)image).enabled = false;
}
}
}
catch (Exception e)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)("修改作者标记样式失败: " + e.Message));
}
}
}
private static void OnMenuButtonClick()
{
try
{
UpdateButtonStates();
REPOPopupPage? obj = decorationsPage;
if (obj != null)
{
((REPOSimplePage)obj).OpenPage(false);
}
SetHeaderPosition();
MovePlayerAvatarToFront();
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("打开设置页面时出错: " + ex.Message));
}
}
}
private static void SetHeaderPosition()
{
try
{
MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
if (obj != null)
{
obj.StartCoroutine(DelayedSetHeaderPosition());
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("设置标题位置时出错: " + ex.Message));
}
}
}
private static IEnumerator DelayedSetHeaderPosition()
{
yield return null;
try
{
FieldInfo headerTransformField = typeof(REPOPopupPage).GetField("headerTransform", BindingFlags.Instance | BindingFlags.NonPublic);
if (headerTransformField != null)
{
object? value = headerTransformField.GetValue(decorationsPage);
RectTransform headerTransform = (RectTransform)((value is RectTransform) ? value : null);
if ((Object)(object)headerTransform != (Object)null)
{
((Transform)headerTransform).localPosition = new Vector3(185.5049f, 368.9677f, 0f);
yield break;
}
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"headerTransform为空");
}
}
else
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"找不到headerTransform字段");
}
}
}
catch (Exception e)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("延迟设置标题位置时出错: " + e.Message));
}
}
}
private static void AdjustBoolSettingPosition()
{
try
{
MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
if (obj != null)
{
obj.StartCoroutine(DelayedAdjustBoolSettingPosition());
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("调整Bool Setting位置时出错: " + ex.Message));
}
}
}
private static IEnumerator DelayedAdjustBoolSettingPosition()
{
yield return null;
try
{
object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
MenuPage menuPage = (MenuPage)((value is MenuPage) ? value : null);
if (!((Object)(object)menuPage != (Object)null))
{
yield break;
}
Transform boolSetting = null;
foreach (Transform item in ((Component)menuPage).transform)
{
Transform child = item;
if ((Object)(object)child != (Object)null && ((Object)child).name.Contains("Bool Setting"))
{
boolSetting = child;
break;
}
}
if ((Object)(object)boolSetting != (Object)null)
{
RectTransform rectTransform = ((Component)boolSetting).GetComponent<RectTransform>();
if ((Object)(object)rectTransform != (Object)null)
{
((Transform)rectTransform).localPosition = new Vector3(70f, 202.5f, 0f);
}
}
else
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"找不到Bool Setting - (Clone)对象");
}
}
}
catch (Exception e)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("延迟调整Bool Setting位置时出错: " + e.Message));
}
}
}
private static void CreatePageContent()
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00e8: 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_005a: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
try
{
for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
{
DecorationInfo decoration = HeadDecorationManager.Decorations[i];
REPOButton val = new REPOButton(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible), (Action)delegate
{
OnDecorationButtonClick(decoration.Name);
});
int num = -(i * 20);
REPOPopupPage? obj = decorationsPage;
if (obj != null)
{
obj.AddElementToScrollView((REPOElement)(object)val, new Vector2(0f, (float)num));
}
decorationButtons[decoration.Name ?? string.Empty] = val;
}
REPOButton val2 = new REPOButton("<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);
REPOPopupPage? obj2 = decorationsPage;
if (obj2 != null)
{
((REPOSimplePage)obj2).AddElementToPage((REPOElement)(object)val2, new Vector2(301f, 0f));
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("创建页面内容时出错: " + ex.Message));
}
}
}
private static void UpdateButtonStates()
{
try
{
foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
{
if (decorationButtons.TryGetValue(decoration.Name ?? string.Empty, out REPOButton value))
{
value.SetText(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible));
}
}
}
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);
if (decorationButtons.TryGetValue(decorationName2, out REPOButton value))
{
value.SetText(GetButtonText(decorationInfo.DisplayName?.ToUpper(), isEnabled));
}
else
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物 " + decorationName2 + " 的按钮"));
}
}
UpdateDecorations();
ConfigManager.SaveConfig();
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message));
}
}
}
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 string GetButtonText(string? name, bool isEnabled)
{
return "<size=16>" + name + ": " + (isEnabled ? "ON" : "OFF") + "</size>";
}
private static void MovePlayerAvatarToFront()
{
try
{
MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
if (obj != null)
{
obj.StartCoroutine(DelayedMovePlayerAvatarToFront());
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("移动玩家模型时出错: " + ex.Message));
}
}
}
private static IEnumerator DelayedMovePlayerAvatarToFront()
{
yield return null;
try
{
PlayerAvatarMenuHover playerAvatarHover = Object.FindObjectOfType<PlayerAvatarMenuHover>();
if ((Object)(object)playerAvatarHover != (Object)null)
{
GameObject playerAvatarObj2 = ((Component)((Component)playerAvatarHover).transform.parent).gameObject;
object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
MenuPage menuPage2 = (MenuPage)((value is MenuPage) ? value : null);
if ((Object)(object)menuPage2 != (Object)null)
{
playerAvatarObj2.transform.SetParent(((Component)menuPage2).transform, true);
playerAvatarObj2.transform.SetAsLastSibling();
playerAvatarObj2.transform.localPosition = new Vector3(-76f, -30f, 0f);
}
yield break;
}
GameObject playerAvatarObj = GameObject.Find("Menu Element Player Avatar");
if ((Object)(object)playerAvatarObj != (Object)null)
{
object? value2 = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
MenuPage menuPage = (MenuPage)((value2 is MenuPage) ? value2 : null);
if ((Object)(object)menuPage != (Object)null)
{
playerAvatarObj.transform.SetParent(((Component)menuPage).transform, true);
playerAvatarObj.transform.SetAsLastSibling();
playerAvatarObj.transform.localPosition = new Vector3(-76f, -30f, 0f);
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogInfo((object)"已通过名称查找将玩家模型移动到前面,并设置坐标为(-76, -30, 0)");
}
}
}
else
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"找不到玩家模型对象");
}
}
}
catch (Exception e)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("延迟移动玩家模型时出错: " + e.Message));
}
}
}
}
}