using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c59b55aa-6ff3-4d25-9e5a-79bf1fdac330")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace IdleStanceWheelMod;
public static class PluginInfo
{
public const string PLUGIN_ID = "cl.skylin3.idlestancewheel";
public const string PLUGIN_NAME = "Idle Stance Wheel";
public const string PLUGIN_VERSION = "1.0.0";
}
public enum Language
{
English,
French,
Italian,
German,
SpanishSpain,
SpanishLatam,
BRPortuguese,
Russian,
Ukrainian,
SimplifiedChinese,
Japanese,
Korean
}
public static class LanguageData
{
public static readonly Dictionary<Language, string[]> SliceTranslations = new Dictionary<Language, string[]>
{
{
Language.English,
new string[8] { "Confident", "Determined", "Focused", "Observant", "Excited", "Centered", "Hidden Hands", "Prepared" }
},
{
Language.French,
new string[8] { "Confiant", "Déterminé", "Concentré", "Observateur", "Excité", "Centré", "Mains cachées", "Préparé" }
},
{
Language.Italian,
new string[8] { "Fiducioso", "Determinato", "Concentrato", "Osservatore", "Emozionato", "Centrato", "Mani nascoste", "Preparato" }
},
{
Language.German,
new string[8] { "Selbstbewusst", "Entschlossen", "Fokussiert", "Beobachtend", "Aufgeregt", "Zentriert", "Versteckte Hände", "Vorbereitet" }
},
{
Language.SpanishSpain,
new string[8] { "Confianzudo", "Determinado", "Enfocado", "Observador", "Emocionado", "Centrado", "Manos ocultas", "Preparado" }
},
{
Language.SpanishLatam,
new string[8] { "Confiado", "Decidido", "Concentrado", "Atento", "Emocionado", "Centrado", "Manos ocultas", "Listo" }
},
{
Language.BRPortuguese,
new string[8] { "Confiante", "Determinado", "Focado", "Observador", "Animado", "Centrado", "Mãos ocultas", "Preparado" }
},
{
Language.Russian,
new string[8] { "Уверенный", "Решительный", "Сфокусированный", "Наблюдательный", "Взволнованный", "Сосредоточенный", "Скрытые руки", "Подготовленный" }
},
{
Language.Ukrainian,
new string[8] { "Впевнений", "Рішучий", "Зосереджений", "Спостерігач", "Збуджений", "Збалансований", "Приховані руки", "Підготовлений" }
},
{
Language.SimplifiedChinese,
new string[8] { "自信", "坚定", "专注", "观察者", "兴奋", "冷静", "隐藏的手", "准备完毕" }
},
{
Language.Japanese,
new string[8] { "自信家", "決意のある", "集中", "観察者", "興奮", "中心", "隠された手", "準備完了" }
},
{
Language.Korean,
new string[8] { "자신감", "결달력", "집중", "관찰자", "흥망", "중심", "숨겨진 손", "준비 완료" }
}
};
}
[BepInPlugin("cl.skylin3.idlestancewheel", "Idle Stance Wheel", "1.0.0")]
public class MessageWheelMod : BaseUnityPlugin
{
public static class EmoteTriggerFlag
{
public static bool triggerOnce = true;
}
[HarmonyPatch(typeof(RunManager), "Start")]
public class Patch_StartRun
{
private static void Postfix(RunManager __instance)
{
EmoteTriggerFlag.triggerOnce = true;
}
}
[HarmonyPatch(typeof(CharacterInput), "Sample")]
public class Patch_CharacterInput_BlockMenu
{
private static bool Prefix(CharacterInput __instance)
{
if (_showKeybindMenu)
{
AccessTools.Method(typeof(CharacterInput), "ResetInput", (Type[])null, (Type[])null)?.Invoke(__instance, null);
return false;
}
return true;
}
private static void Postfix(CharacterInput __instance)
{
if (EmoteTriggerFlag.triggerOnce)
{
__instance.emoteIsPressed = true;
EmoteTriggerFlag.triggerOnce = false;
}
}
}
[HarmonyPatch(typeof(GUIManager), "UpdateEmoteWheel")]
private class Patch_EmoteUI_Update
{
private static void Postfix(GUIManager __instance)
{
IsWheelActive = __instance.wheelActive;
if (IsIdleWheelActive)
{
PropertyInfo property = typeof(GUIManager).GetProperty("windowBlockingInput", BindingFlags.Instance | BindingFlags.Public);
if (property != null)
{
MethodInfo setMethod = property.GetSetMethod(nonPublic: true);
if (setMethod != null)
{
setMethod.Invoke(__instance, new object[1] { true });
_windowBlockingInput = true;
}
else
{
Log.LogWarning((object)"No se pudo obtener el setter privado de windowBlockingInput");
}
}
else
{
Log.LogWarning((object)"No se encontró la propiedad windowBlockingInput");
}
}
else
{
_windowBlockingInput = __instance.windowBlockingInput;
}
}
}
[HarmonyPatch(typeof(EmoteWheel))]
public static class EmoteWheelPatches
{
[HarmonyPatch("Choose")]
[HarmonyPrefix]
private static bool ChoosePrefix(EmoteWheel __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
if (!IsIdleWheelActive || !_windowBlockingInput || !IsWheelActive)
{
return true;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(EmoteWheel), "chosenEmoteData");
EmoteWheelData val = (EmoteWheelData)fieldInfo.GetValue(__instance);
if ((Object)(object)val != (Object)null)
{
iSelectedIdle = Array.IndexOf(__instance.data, val);
if (iSelectedIdle >= 0 && SliceText[iSelectedIdle] != "")
{
SendChatMessage(SliceText[iSelectedIdle]);
CharacterCustomization localPlayerCharacterCustomization = GetLocalPlayerCharacterCustomization();
if ((Object)(object)localPlayerCharacterCustomization != (Object)null)
{
Log.LogInfo((object)$"Animación idle establecida a: {iSelectedIdle} para jugador local");
localPlayerCharacterCustomization.SetRandomIdle();
}
else
{
Log.LogWarning((object)"No se encontró CharacterCustomization del jugador local.");
}
return false;
}
}
return true;
}
[HarmonyPatch(typeof(CharacterCustomization), "SetRandomIdle")]
[HarmonyPrefix]
private static bool Prefix_SetRandomIdle(CharacterCustomization __instance)
{
PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null && component.IsMine)
{
component.RPC("SetCharacterIdle_RPC", (RpcTarget)3, new object[1] { iSelectedIdle });
return false;
}
return true;
}
private static CharacterCustomization GetLocalPlayerCharacterCustomization()
{
try
{
if ((Object)(object)Character.localCharacter != (Object)null && (Object)(object)Character.localCharacter != (Object)null)
{
CharacterCustomization component = ((Component)Character.localCharacter).GetComponent<CharacterCustomization>();
if ((Object)(object)component != (Object)null)
{
Log.LogInfo((object)"CharacterCustomization encontrado via PlayerManager.localPlayer");
return component;
}
}
Player localPlayer = PhotonNetwork.LocalPlayer;
if (localPlayer != null)
{
CharacterCustomization[] array = Object.FindObjectsByType<CharacterCustomization>((FindObjectsSortMode)0);
CharacterCustomization[] array2 = array;
foreach (CharacterCustomization val in array2)
{
PhotonView component2 = ((Component)val).GetComponent<PhotonView>();
if ((Object)(object)component2 != (Object)null && component2.Owner != null && component2.Owner.ActorNumber == localPlayer.ActorNumber)
{
Log.LogInfo((object)$"CharacterCustomization encontrado via PhotonView para actor {localPlayer.ActorNumber}");
return val;
}
}
}
Player[] array3 = Object.FindObjectsByType<Player>((FindObjectsSortMode)0);
Player[] array4 = array3;
foreach (Player val2 in array4)
{
PhotonView component3 = ((Component)val2).GetComponent<PhotonView>();
if ((Object)(object)component3 != (Object)null && component3.IsMine && (Object)(object)val2.character != (Object)null)
{
CharacterCustomization component4 = ((Component)val2.character).GetComponent<CharacterCustomization>();
if ((Object)(object)component4 != (Object)null)
{
Log.LogInfo((object)"CharacterCustomization encontrado via Player.photonView.IsMine");
return component4;
}
}
}
Log.LogWarning((object)"No se pudo encontrar CharacterCustomization del jugador local");
return null;
}
catch (Exception arg)
{
Log.LogError((object)$"Error al buscar CharacterCustomization local: {arg}");
return null;
}
}
[HarmonyPatch("InitWheel")]
[HarmonyPrefix]
private static void InitWheelPrefix(EmoteWheel __instance)
{
if (IsIdleWheelActive && !_windowBlockingInput && !IsWheelActive)
{
EmoteWheelSlice[] slices = __instance.slices;
EmoteWheelData[] data = __instance.data;
FieldInfo fieldInfo = AccessTools.Field(typeof(EmoteWheel), "chosenEmoteData");
fieldInfo.SetValue(__instance, null);
for (int i = 0; i < slices.Length; i++)
{
slices[i].Init(data[i], __instance);
}
((TMP_Text)__instance.selectedEmoteName).text = "";
}
}
[HarmonyPatch("Hover")]
[HarmonyPrefix]
private static bool HoverPrefix(EmoteWheel __instance, EmoteWheelData emoteWheelData)
{
if (!IsIdleWheelActive || !_windowBlockingInput || !IsWheelActive)
{
return true;
}
try
{
FieldInfo fieldInfo = AccessTools.Field(typeof(EmoteWheel), "chosenEmoteData");
fieldInfo.SetValue(__instance, emoteWheelData);
if ((Object)(object)__instance.selectedEmoteName != (Object)null && (Object)(object)emoteWheelData != (Object)null)
{
int num = Array.IndexOf(__instance.data, emoteWheelData);
if (num >= 0 && SliceText[num] != "")
{
((TMP_Text)__instance.selectedEmoteName).text = SliceText[num];
}
else
{
((TMP_Text)__instance.selectedEmoteName).text = LocalizedText.GetText(emoteWheelData.emoteName, true);
}
}
return false;
}
catch (Exception arg)
{
Log.LogError((object)$"Error en HoverPrefix: {arg}");
return true;
}
}
}
[HarmonyPatch(typeof(EmoteWheelSlice))]
public static class EmoteWheelSlicePatches
{
[HarmonyPatch("Init")]
[HarmonyPostfix]
private static void InitPostfix(EmoteWheelSlice __instance, EmoteWheelData data, EmoteWheel wheel)
{
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
if (!IsIdleWheelActive || _windowBlockingInput || IsWheelActive)
{
return;
}
try
{
if ((Object)(object)data == (Object)null)
{
return;
}
Transform val = ((Component)__instance).transform.Find("CustomMessageText");
if ((Object)(object)val != (Object)null)
{
return;
}
int num = -1;
for (int i = 0; i < wheel.slices.Length; i++)
{
if ((Object)(object)wheel.slices[i] == (Object)(object)__instance)
{
num = i;
break;
}
}
if (num >= 0 && !(SliceText[num] == ""))
{
if ((Object)(object)__instance.image != (Object)null)
{
((Component)__instance.image).gameObject.SetActive(false);
}
GameObject val2 = new GameObject("CustomMessageText");
val2.transform.SetParent(((Component)__instance).transform, false);
TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)val3).text = SliceText[num];
((TMP_Text)val3).fontSize = 26f;
((Graphic)val3).color = Color.white;
((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
((TMP_Text)val3).fontStyle = (FontStyles)1;
((TMP_Text)val3).outlineColor = Color32.op_Implicit(Color.black);
((TMP_Text)val3).outlineWidth = 0.5f;
((TMP_Text)val3).characterSpacing = 0.75f;
((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0;
Material val4 = new Material(((TMP_Text)val3).fontMaterial);
val4.EnableKeyword("OUTLINE_ON");
((TMP_Text)val3).fontMaterial = val4;
RectTransform component = ((Component)val3).GetComponent<RectTransform>();
if ((Object)(object)__instance.image != (Object)null)
{
RectTransform component2 = ((Component)__instance.image).GetComponent<RectTransform>();
component.anchorMin = component2.anchorMin;
component.anchorMax = component2.anchorMax;
component.sizeDelta = new Vector2(component2.sizeDelta.x * 1.2f, component2.sizeDelta.y * 1.2f);
component.anchoredPosition = component2.anchoredPosition;
((Transform)component).localScale = ((Transform)component2).localScale;
((Transform)component).rotation = ((Transform)component2).rotation;
}
else
{
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.sizeDelta = new Vector2(100f, 40f);
component.anchoredPosition = Vector2.zero;
}
}
}
catch (Exception arg)
{
Log.LogError((object)$"Error en InitPostfix del slice: {arg}");
}
}
}
private static string[] SliceText = new string[8];
private ConfigEntry<KeyCode> _wheelKeybind;
private EmoteWheel _emoteWheel = null;
private bool _wheelVisible = false;
public static bool _windowBlockingInput = false;
public static bool IsWheelActive = false;
private static int iSelectedIdle = 0;
private static bool _showKeybindMenu = false;
private bool _awaitingKeyPress = false;
public static ManualLogSource Log { get; private set; }
public static bool IsIdleWheelActive { get; private set; } = false;
private void Awake()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Inicializando Message Wheel Mod...");
_wheelKeybind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "WheelKey", (KeyCode)116, "Tecla para abrir el Idle Emote Wheel (por defecto: P)");
try
{
Harmony val = new Harmony("cl.skylin3.idlestancewheel");
val.PatchAll();
Log.LogInfo((object)"Parches Harmony aplicados correctamente");
}
catch (Exception arg)
{
Log.LogError((object)$"Error al aplicar parches: {arg}");
}
}
private void OnGUI()
{
//IL_0026: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
if (_showKeybindMenu)
{
GUI.Box(new Rect(20f, 20f, 300f, 120f), "Configuración de Message Wheel");
GUI.Label(new Rect(30f, 50f, 200f, 20f), $"Tecla actual: {_wheelKeybind.Value}");
if (_awaitingKeyPress)
{
GUI.Label(new Rect(30f, 70f, 250f, 20f), "Presiona una tecla nueva...");
}
else if (GUI.Button(new Rect(30f, 70f, 150f, 25f), "Cambiar tecla"))
{
_awaitingKeyPress = true;
}
if (GUI.Button(new Rect(200f, 70f, 90f, 25f), "Cerrar"))
{
_showKeybindMenu = false;
}
}
}
private void Update()
{
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Expected I4, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)282))
{
_showKeybindMenu = !_showKeybindMenu;
if (_showKeybindMenu)
{
EnableUIMode();
}
else
{
DisableUIMode();
}
}
if (_showKeybindMenu)
{
BlockGameInput();
}
if (_awaitingKeyPress)
{
foreach (KeyCode value3 in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(value3))
{
_wheelKeybind.Value = value3;
_awaitingKeyPress = false;
Log.LogInfo((object)$"Nueva tecla asignada: {(object)value3}");
((BaseUnityPlugin)this).Config.Save();
break;
}
}
}
if ((Object)(object)_emoteWheel == (Object)null)
{
_emoteWheel = Object.FindFirstObjectByType<EmoteWheel>();
}
if ((Object)(object)_emoteWheel == (Object)null)
{
return;
}
if (Input.GetKeyDown(_wheelKeybind.Value) && !_windowBlockingInput && !IsWheelActive)
{
_wheelVisible = true;
IsIdleWheelActive = true;
SettingsHandler instance = SettingsHandler.Instance;
LanguageSetting val2 = ((instance != null) ? instance.GetSetting<LanguageSetting>() : null);
if (val2 != null)
{
Language value = ((EnumSetting<Language>)(object)val2).Value;
Language val3 = val2.ValueToLanguage((int)value);
Log.LogInfo((object)$"Idioma actual: {val3}");
if (val2 != null)
{
Log.LogInfo((object)$"Idioma actual detectado: {val3}");
if (Enum.TryParse<Language>(((object)(Language)(ref val3)).ToString().Replace(" ", ""), ignoreCase: true, out var result))
{
if (LanguageData.SliceTranslations.TryGetValue(result, out var value2))
{
SliceText = value2;
Log.LogInfo((object)$"Traducciones cargadas para: {result}");
}
else
{
Log.LogWarning((object)$"Idioma no soportado en SliceTranslations: {result}");
}
}
else
{
Log.LogWarning((object)$"Idioma no reconocido: {val3}");
}
}
else
{
Log.LogWarning((object)"No se pudo obtener LanguageSetting.");
}
}
((Component)_emoteWheel).gameObject.SetActive(true);
_emoteWheel.OnEnable();
}
if (Input.GetKeyUp(_wheelKeybind.Value) && _wheelVisible)
{
_emoteWheel.OnDisable();
((Component)_emoteWheel).gameObject.SetActive(false);
RestoreEmoteWheel();
_wheelVisible = false;
IsIdleWheelActive = false;
}
}
private void LateUpdate()
{
if (_showKeybindMenu)
{
BlockGameInput();
}
}
private void EnableUIMode()
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
Log.LogInfo((object)"UI Mode enabled - cursor unlocked");
}
private void DisableUIMode()
{
Log.LogInfo((object)"UI Mode disabled - returning control to game");
}
private void BlockGameInput()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)Cursor.lockState > 0)
{
Cursor.lockState = (CursorLockMode)0;
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
}
private static void SendChatMessage(string message)
{
try
{
Log.LogInfo((object)("[CHAT] Enviando: " + message));
}
catch (Exception arg)
{
Log.LogError((object)$"Error al enviar mensaje: {arg}");
}
}
private void RestoreEmoteWheel()
{
if ((Object)(object)_emoteWheel == (Object)null)
{
return;
}
try
{
if ((Object)(object)_emoteWheel.selectedEmoteName != (Object)null)
{
((TMP_Text)_emoteWheel.selectedEmoteName).text = "";
}
EmoteWheelSlice[] slices = _emoteWheel.slices;
foreach (EmoteWheelSlice val in slices)
{
if (!((Object)(object)val == (Object)null))
{
if ((Object)(object)val.image != (Object)null)
{
((Component)val.image).gameObject.SetActive(true);
}
Transform val2 = ((Component)val).transform.Find("CustomMessageText");
if ((Object)(object)val2 != (Object)null)
{
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
}
}
catch (Exception arg)
{
Log.LogError((object)$"Error al restaurar EmoteWheel: {arg}");
}
}
}