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 ExpressionSaver v1.1.0
ExpressionSaver.dll
Decompiled 3 days 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExpressionSaver")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("ExpressionSaver")] [assembly: AssemblyTitle("ExpressionSaver")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExpressionSaver { internal class FirstHint : MonoBehaviour { public static bool Visible; private const float ShowDelay = 1f; private const float CloseHold = 0.5f; private float _showAt = -1f; private float _holdStart = -1f; private static Texture2D _panelTex; private static Texture2D _okTex; private static Texture2D _okHoverTex; private static Texture2D _white; private GUIStyle _panel; private GUIStyle _line1; private GUIStyle _line2; private GUIStyle _ok; private int _styleHeight; private void Update() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) try { if (SavedExpression.HintShown || !Plugin.EnableWheel.Value) { Visible = false; return; } if (!Game.PlayerSpawned() || (Object)(object)Game.LocalExpression() == (Object)null) { Visible = false; _showAt = -1f; _holdStart = -1f; return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (!Visible) { if (_showAt < 0f) { _showAt = realtimeSinceStartup + 1f; return; } if (realtimeSinceStartup < _showAt) { return; } Visible = true; _holdStart = -1f; } KeyCode val = (KeyCode)Plugin.OpenKey.Value; if ((int)val != 0 && Input.GetKey(val)) { if (_holdStart < 0f) { _holdStart = realtimeSinceStartup; } if (realtimeSinceStartup - _holdStart >= 0.5f) { Close(); } } else { _holdStart = -1f; } } catch (Exception ex) { Plugin.Log.LogError((object)ex); Visible = false; } } private void Close() { Visible = false; SavedExpression.HintShown = true; SavedExpression.Save(); Plugin.Log.LogInfo((object)"Wheel hint closed - it will not be shown again."); } private void OnDisable() { Visible = false; } private void OnGUI() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) if (!Visible) { return; } try { MakeTextures(); float num = (float)Screen.height / 1080f; MakeStyles(num); GUI.depth = -1000; string text = SavedWheel.KeyName(Plugin.OpenKey.Value).ToUpperInvariant(); string text2 = "Hold <color=#FF8C00>" + text + "</color> to open the expression wheel and save or pick your expressions"; string text3 = "Hold <color=#FF8C00>" + text + "</color> to close this message"; float num2 = 20f * num; float num3 = Mathf.Min((float)Screen.width - 40f, 1040f * num); float num4 = num3 - num2 * 2f; float num5 = _line1.CalcHeight(new GUIContent(text2), num4); float num6 = _line2.CalcHeight(new GUIContent(text3), num4); float num7 = 38f * num; float num8 = num2 + num5 + 6f * num + num6 + 14f * num + num7 + num2; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num3) / 2f, 40f * num, num3, num8); GUI.Box(val, GUIContent.none, _panel); float num9 = ((Rect)(ref val)).y + num2; GUI.Label(new Rect(((Rect)(ref val)).x + num2, num9, num4, num5), text2, _line1); num9 += num5 + 6f * num; GUI.Label(new Rect(((Rect)(ref val)).x + num2, num9, num4, num6), text3, _line2); num9 += num6 + 14f * num; float num10 = 260f * num; float num11 = 100f * num; float num12 = 18f * num; float num13 = ((Rect)(ref val)).center.x - (num10 + num12 + num11) / 2f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num13, num9 + num7 / 2f - 4f * num, num10, Mathf.Max(3f, 8f * num)); GUI.color = new Color(1f, 1f, 1f, 0.2f); GUI.DrawTexture(val2, (Texture)(object)_white); float num14 = ((_holdStart < 0f) ? 0f : Mathf.Clamp01((Time.realtimeSinceStartup - _holdStart) / 0.5f)); GUI.color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue)); GUI.DrawTexture(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width * num14, ((Rect)(ref val2)).height), (Texture)(object)_white); GUI.color = Color.white; if (GUI.Button(new Rect(num13 + num10 + num12, num9, num11, num7), "OK", _ok)) { Close(); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); Visible = false; } } private void MakeStyles(float s) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003d: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_015f: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) int height = Screen.height; if (_panel == null || height != _styleHeight) { _styleHeight = height; _panel = new GUIStyle { border = new RectOffset(18, 18, 18, 18) }; _panel.normal.background = _panelTex; _line1 = new GUIStyle(GUI.skin.label) { fontSize = Mathf.Max(10, Mathf.RoundToInt(21f * s)), fontStyle = (FontStyle)1, alignment = (TextAnchor)4, wordWrap = true, richText = true }; _line1.normal.textColor = Color.white; _line2 = new GUIStyle(_line1) { fontSize = Mathf.Max(9, Mathf.RoundToInt(17f * s)), fontStyle = (FontStyle)0 }; _line2.normal.textColor = Color32.op_Implicit(new Color32((byte)200, (byte)205, (byte)220, byte.MaxValue)); _ok = new GUIStyle(GUI.skin.button) { fontSize = Mathf.Max(10, Mathf.RoundToInt(18f * s)), fontStyle = (FontStyle)1, alignment = (TextAnchor)4, border = new RectOffset(12, 12, 12, 12) }; _ok.normal.background = _okTex; _ok.hover.background = _okHoverTex; _ok.active.background = _okTex; _ok.focused.background = _okTex; Color32 val = default(Color32); ((Color32)(ref val))..ctor((byte)24, (byte)26, (byte)34, byte.MaxValue); _ok.normal.textColor = Color32.op_Implicit(val); _ok.hover.textColor = Color32.op_Implicit(val); _ok.active.textColor = Color32.op_Implicit(val); _ok.focused.textColor = Color32.op_Implicit(val); } } private static void MakeTextures() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_panelTex != (Object)null)) { _panelTex = Rounded(64, 14f, 3f, Color32.op_Implicit(new Color32((byte)24, (byte)26, (byte)34, (byte)240)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue))); _okTex = Rounded(48, 10f, 0f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue))); _okHoverTex = Rounded(48, 10f, 0f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)170, (byte)60, byte.MaxValue)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)170, (byte)60, byte.MaxValue))); _white = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _white.SetPixel(0, 0, Color.white); _white.Apply(); } } private static Texture2D Rounded(int size, float radius, float borderWidth, Color fill, Color border) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size / 2f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Mathf.Abs((float)j + 0.5f - num) - (num - radius); float num3 = Mathf.Abs((float)i + 0.5f - num) - (num - radius); Vector2 val2 = new Vector2(Mathf.Max(num2, 0f), Mathf.Max(num3, 0f)); float num4 = ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(num2, num3), 0f); float num5 = radius - num4; if (num5 <= -0.5f) { array[i * size + j] = Color.clear; continue; } Color val3 = ((borderWidth > 0f) ? Color.Lerp(border, fill, Mathf.Clamp01(num5 - borderWidth + 0.5f)) : fill); val3.a *= Mathf.Clamp01(num5 + 0.5f); array[i * size + j] = val3; } } val.SetPixels(array); val.Apply(false, true); return val; } } public enum WheelKey { None = 0, Backspace = 8, Tab = 9, Return = 13, Escape = 27, Space = 32, Quote = 39, Comma = 44, Minus = 45, Period = 46, Slash = 47, Alpha0 = 48, Alpha1 = 49, Alpha2 = 50, Alpha3 = 51, Alpha4 = 52, Alpha5 = 53, Alpha6 = 54, Alpha7 = 55, Alpha8 = 56, Alpha9 = 57, Semicolon = 59, Equals = 61, LeftBracket = 91, Backslash = 92, RightBracket = 93, BackQuote = 96, A = 97, B = 98, C = 99, D = 100, E = 101, F = 102, G = 103, H = 104, I = 105, J = 106, K = 107, L = 108, M = 109, N = 110, O = 111, P = 112, Q = 113, R = 114, S = 115, T = 116, U = 117, V = 118, W = 119, X = 120, Y = 121, Z = 122, Delete = 127, Keypad0 = 256, Keypad1 = 257, Keypad2 = 258, Keypad3 = 259, Keypad4 = 260, Keypad5 = 261, Keypad6 = 262, Keypad7 = 263, Keypad8 = 264, Keypad9 = 265, KeypadPeriod = 266, KeypadDivide = 267, KeypadMultiply = 268, KeypadMinus = 269, KeypadPlus = 270, KeypadEnter = 271, UpArrow = 273, DownArrow = 274, RightArrow = 275, LeftArrow = 276, Insert = 277, Home = 278, End = 279, PageUp = 280, PageDown = 281, F1 = 282, F2 = 283, F3 = 284, F4 = 285, F5 = 286, F6 = 287, F7 = 288, F8 = 289, F9 = 290, F10 = 291, F11 = 292, F12 = 293, CapsLock = 301, RightShift = 303, LeftShift = 304, RightControl = 305, LeftControl = 306, RightAlt = 307, LeftAlt = 308, MouseLeft = 323, MouseRight = 324, MouseMiddle = 325, MouseBack = 326, MouseForward = 327 } [BepInPlugin("purtzel_hd.expressionsaver", "ExpressionSaver", "1.1.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; public const int SlotCount = 8; internal static ConfigEntry<bool> SaveExpression; internal static ConfigEntry<bool> EnableWheel; internal static ConfigEntry<WheelKey> OpenKey; internal static ConfigEntry<WheelKey> SaveKey; internal static ConfigEntry<int> ClearHoldTime; internal static ConfigEntry<WheelKey> ClearKey; internal static ConfigEntry<float> WheelSensitivity; internal static ConfigEntry<string>[] SlotNames = new ConfigEntry<string>[8]; private void Awake() { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; SavedExpression.Load(); SaveExpression = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Save Expression", true, "Remember your face expression and put it back after every level, lobby change and game restart."); EnableWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Wheel", true, "Enable the wheel for your saved expressions."); OpenKey = ((BaseUnityPlugin)this).Config.Bind<WheelKey>("Wheel", "Open Key", WheelKey.MouseMiddle, "Hold to open the wheel. MouseMiddle = wheel click, MouseBack / MouseForward = the two thumb buttons."); SaveKey = ((BaseUnityPlugin)this).Config.Bind<WheelKey>("Wheel", "Save Key", WheelKey.MouseRight, "Press while pointing at a slot to save your current face there."); ClearHoldTime = ((BaseUnityPlugin)this).Config.Bind<int>("Wheel", "Clear Hold Time", 800, new ConfigDescription("How long (in ms) you have to hold the Clear Key to clear a slot. 0 = instantly.", (AcceptableValueBase)(object)new AcceptableValueList<int>((from i in Enumerable.Range(0, 41) select i * 50).ToArray()), Array.Empty<object>())); ClearKey = ((BaseUnityPlugin)this).Config.Bind<WheelKey>("Wheel", "Clear Key", WheelKey.MouseRight, "Hold while pointing at a saved slot to clear it. A saved slot must be cleared before you can save a new face on it."); WheelSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Wheel", "Sensitivity", 1f, new ConfigDescription("How fast the selection follows your mouse.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>())); for (int num = 0; num < 8; num++) { SlotNames[num] = ((BaseUnityPlugin)this).Config.Bind<string>("Wheel Slots", $"Slot {num + 1} Name", "", $"Name shown in the wheel for slot {num + 1}. Empty = \"No name\"."); } try { Harmony val = new Harmony("purtzel_hd.expressionsaver"); Type type = AccessTools.TypeByName("InputManager"); string[] array = new string[2] { "GetMouseX", "GetMouseY" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(type, text, (Type[])null, (Type[])null); if (methodInfo != null) { val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(WheelPatches), "NoLookFloat", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } MethodInfo methodInfo2 = AccessTools.Method(type, "GetRawMouseDelta", (Type[])null, (Type[])null); if (methodInfo2 != null) { val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(WheelPatches), "NoLookVector", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo3 = AccessTools.Method(type, "ExpressionWheelControlReserved", (Type[])null, (Type[])null); if (methodInfo3 != null) { val.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(WheelPatches), "ControlReservedPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception arg) { Log.LogError((object)$"Patching failed: {arg}"); } GameObject val2 = new GameObject("ExpressionSaver"); Object.DontDestroyOnLoad((Object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.AddComponent<ExpressionKeeper>(); val2.AddComponent<SavedWheel>(); val2.AddComponent<FirstHint>(); Log.LogInfo((object)("ExpressionSaver loaded. Saved: " + SavedExpression.Describe())); } } internal static class SavedExpression { public static List<int> Wheel = new List<int>(); public static List<int> Toggles = new List<int>(); public static string[] Slots = Enumerable.Repeat("", 8).ToArray(); public static bool HintShown; private static string FilePath => Path.Combine(Paths.ConfigPath, "purtzel_hd.expressionsaver.txt"); public static string Describe() { return "wheel [" + string.Join(",", Wheel) + "], keys [" + string.Join(",", Toggles) + "]"; } public static void Load() { try { if (!File.Exists(FilePath)) { return; } string[] array = File.ReadAllLines(FilePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.StartsWith("wheel=")) { Wheel = Parse(text.Substring(6)); } else if (text.StartsWith("keys=")) { Toggles = Parse(text.Substring(5)); } else if (text.StartsWith("hint=")) { HintShown = text.Substring(5).Trim() == "1"; } else if (text.StartsWith("slot") && text.Contains("=")) { int num = text.IndexOf('='); if (int.TryParse(text.Substring(4, num - 4), out var result) && result >= 1 && result <= 8) { Slots[result - 1] = text.Substring(num + 1).Trim(); } } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Loading failed: {arg}"); } } public static void Save() { try { List<string> list = new List<string> { "# ExpressionSaver - last used face expression", "wheel=" + string.Join(",", Wheel), "keys=" + string.Join(",", Toggles), "hint=" + (HintShown ? "1" : "0"), "# Wheel slots (0 = neutral face)" }; for (int i = 0; i < Slots.Length; i++) { list.Add($"slot{i + 1}=" + Slots[i]); } File.WriteAllLines(FilePath, list); } catch (Exception arg) { Plugin.Log.LogError((object)$"Saving failed: {arg}"); } } internal static List<int> Parse(string s) { int result; return (from x in (s ?? "").Split(',') select (!int.TryParse(x.Trim(), out result)) ? (-1) : result into i where i >= 0 select i).ToList(); } } internal static class Game { private const BindingFlags All = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags AllStatic = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static bool _ready; private static FieldInfo _gdInstance; private static FieldInfo _gdPlayerList; private static FieldInfo _paLocal; private static FieldInfo _paExpression; private static FieldInfo _peWheel; private static FieldInfo _peToggles; private static FieldInfo _peExpressions; private static FieldInfo _tiIndex; private static FieldInfo _tiActive; private static FieldInfo _esName; private static FieldInfo _imInstance; private static FieldInfo _imActions; private static FieldInfo _uiInstance; private static FieldInfo _uiWheel; private static FieldInfo _lgInstance; private static FieldInfo _lgGenerated; private static FieldInfo _gdState; private static FieldInfo _loadingInstance; private static MethodInfo _peWheelSet; private static MethodInfo _imWheelAllowed; private static MethodInfo _menuLevel; private static PropertyInfo _wheelVisible; public static FieldInfo TogglesField { get { Init(); return _peToggles; } } public static FieldInfo ToggleIndex { get { Init(); return _tiIndex; } } public static FieldInfo ToggleActive { get { Init(); return _tiActive; } } private static void Init() { if (!_ready) { _ready = true; Type type = AccessTools.TypeByName("GameDirector"); _gdInstance = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _gdPlayerList = type.GetField("PlayerList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type2 = AccessTools.TypeByName("PlayerAvatar"); _paLocal = type2.GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _paExpression = type2.GetField("playerExpression", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type3 = AccessTools.TypeByName("PlayerExpression"); _peWheel = type3.GetField("wheelExpressions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _peToggles = type3.GetField("inputToggleList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _peExpressions = type3.GetField("expressions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _peWheelSet = AccessTools.Method(type3, "WheelExpressionsSet", (Type[])null, (Type[])null); Type type4 = AccessTools.TypeByName("ToggleExpressionInput"); _tiIndex = type4.GetField("index", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _tiActive = type4.GetField("active", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _esName = AccessTools.TypeByName("ExpressionSettings")?.GetField("expressionName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type5 = AccessTools.TypeByName("InputManager"); _imInstance = type5?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _imActions = type5?.GetField("inputActions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _imWheelAllowed = AccessTools.Method(type5, "ExpressionWheelInputAllowed", (Type[])null, (Type[])null); Type type6 = AccessTools.TypeByName("PlayerExpressionsUI"); _uiInstance = type6?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _uiWheel = type6?.GetField("wheel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _wheelVisible = AccessTools.Property(AccessTools.TypeByName("PlayerExpressionWheel"), "Visible"); Type type7 = AccessTools.TypeByName("LevelGenerator"); _lgInstance = type7?.GetField("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _lgGenerated = type7?.GetField("Generated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _menuLevel = AccessTools.Method(AccessTools.TypeByName("SemiFunc"), "MenuLevel", (Type[])null, (Type[])null); _gdState = type.GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _loadingInstance = AccessTools.TypeByName("LoadingUI")?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } } public static bool PlayerSpawned() { if (!InRealLevel()) { return false; } try { object value = _gdInstance.GetValue(null); if (value == null || _gdState == null || Convert.ToInt32(_gdState.GetValue(value)) != 2) { return false; } object? obj = _loadingInstance?.GetValue(null); Component val = (Component)((obj is Component) ? obj : null); return (Object)(object)val == (Object)null || !val.gameObject.activeInHierarchy; } catch { return false; } } public static bool InRealLevel() { Init(); try { object? obj = _lgInstance?.GetValue(null); Object val = (Object)((obj is Object) ? obj : null); if (!(val == (Object)null)) { object obj2 = _lgGenerated?.GetValue(val); if (obj2 is bool && (bool)obj2) { obj2 = _menuLevel?.Invoke(null, null); bool flag = default(bool); int num; if (obj2 is bool) { flag = (bool)obj2; num = 1; } else { num = 0; } return ((uint)num & (flag ? 1u : 0u)) == 0; } } return false; } catch { return false; } } public static Component LocalExpression() { Init(); object value = _gdInstance.GetValue(null); if (value == null || !(_gdPlayerList.GetValue(value) is IList list)) { return null; } bool flag = default(bool); foreach (object item in list) { Component val = (Component)((item is Component) ? item : null); if (!((Object)(object)val == (Object)null)) { object value2 = _paLocal.GetValue(val); int num; if (value2 is bool) { flag = (bool)value2; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { object? value3 = _paExpression.GetValue(val); return (Component)((value3 is Component) ? value3 : null); } } } return null; } public static List<int> ReadWheel(Component pe) { Init(); return (_peWheel.GetValue(pe) as List<int>)?.ToList() ?? new List<int>(); } public static List<int> ReadToggles(Component pe) { Init(); List<int> list = new List<int>(); if (!(_peToggles.GetValue(pe) is IList list2)) { return list; } bool flag = default(bool); foreach (object item in list2) { object value = _tiActive.GetValue(item); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { list.Add((int)_tiIndex.GetValue(item)); } } return list; } public static List<int> CurrentFace(Component pe) { return (from i in (from i in ReadWheel(pe).Concat(ReadToggles(pe)) where i > 0 select i).Distinct() orderby i select i).ToList(); } public static void SetFace(Component pe, List<int> expressions) { Init(); _peWheelSet?.Invoke(pe, new object[1] { new List<int>(expressions) }); } public static List<string> ExpressionNames(Component pe) { Init(); List<string> list = new List<string>(); if (_esName == null || !(_peExpressions.GetValue(pe) is IList list2)) { return list; } foreach (object item in list2) { string text = ((_esName.GetValue(item) as string) ?? "").Trim(); list.Add((text.Length > 0) ? (char.ToUpperInvariant(text[0]) + text.Substring(1)) : text); } return list; } public static bool WheelInputAllowed() { Init(); object obj = _imInstance?.GetValue(null); if (obj == null || _imWheelAllowed == null) { return false; } object obj2 = _imWheelAllowed.Invoke(obj, null); bool flag = default(bool); int num; if (obj2 is bool) { flag = (bool)obj2; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } public static bool GameWheelVisible() { Init(); object obj = _uiInstance?.GetValue(null); object obj2 = ((obj == null) ? null : _uiWheel?.GetValue(obj)); if (obj2 == null || _wheelVisible == null) { return false; } object value = _wheelVisible.GetValue(obj2); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } public static IDictionary InputActions() { Init(); object obj = _imInstance?.GetValue(null); if (obj == null) { return null; } return _imActions?.GetValue(obj) as IDictionary; } } internal class ExpressionKeeper : MonoBehaviour { private int _currentId; private bool _restored; private float _restoreAt; private float _next; private float _saveAt; private List<int> _lastWheel = new List<int>(); private List<int> _lastToggles = new List<int>(); private void Update() { float realtimeSinceStartup = Time.realtimeSinceStartup; if (_saveAt > 0f && realtimeSinceStartup > _saveAt) { _saveAt = 0f; SavedExpression.Save(); } if (realtimeSinceStartup < _next) { return; } _next = realtimeSinceStartup + 0.25f; if (!Plugin.SaveExpression.Value) { return; } try { Component val = Game.LocalExpression(); if ((Object)(object)val == (Object)null) { return; } int instanceID = ((Object)val).GetInstanceID(); if (instanceID != _currentId) { _currentId = instanceID; _restored = false; _restoreAt = 0f; } else if (!_restored) { if (!Game.InRealLevel()) { _restoreAt = 0f; } else if (_restoreAt <= 0f) { _restoreAt = realtimeSinceStartup + 1f; } else if (!(realtimeSinceStartup < _restoreAt)) { Restore(val); _restored = true; _lastWheel = Game.ReadWheel(val); _lastToggles = Game.ReadToggles(val); } } else { List<int> list = Game.ReadWheel(val); List<int> list2 = Game.ReadToggles(val); if (!list.SequenceEqual(_lastWheel) || !list2.SequenceEqual(_lastToggles)) { _lastWheel = list; _lastToggles = list2; SavedExpression.Wheel = new List<int>(list); SavedExpression.Toggles = new List<int>(list2); _saveAt = realtimeSinceStartup + 1f; } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private void Restore(Component pe) { if (SavedExpression.Wheel.Count == 0 && SavedExpression.Toggles.Count == 0) { return; } if (SavedExpression.Wheel.Count > 0) { Game.SetFace(pe, SavedExpression.Wheel); } if (SavedExpression.Toggles.Count > 0 && Game.TogglesField.GetValue(pe) is IList list) { foreach (object item in list) { if (SavedExpression.Toggles.Contains((int)Game.ToggleIndex.GetValue(item))) { Game.ToggleActive.SetValue(item, true); } } } Plugin.Log.LogInfo((object)("Expression restored: " + SavedExpression.Describe())); } private void OnApplicationQuit() { if (_saveAt > 0f) { SavedExpression.Save(); } } } internal class SavedWheel : MonoBehaviour { public static bool IsOpen; private const int N = 8; private const float InnerFrac = 0.42f; private Vector2 _cursor; private int _hover = -1; private string _toast; private float _toastUntil; private int _clearSlot = -1; private float _clearStart; private bool _clearWaitRelease; public static readonly List<KeyCode> Blocked = new List<KeyCode>(); private static Texture2D _segFull; private static Texture2D _segEmpty; private static Texture2D _segHover; private static Texture2D _segHoverEmpty; private static Texture2D _center; private static Texture2D _dot; private static Texture2D _white; private GUIStyle _comboStyle; private GUIStyle _nameStyle; private GUIStyle _smallStyle; private GUIStyle _centerName; private GUIStyle _centerCombo; private int _styleSize; private static readonly Color Orange = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue)); private static readonly Color Dark = Color32.op_Implicit(new Color32((byte)24, (byte)26, (byte)34, byte.MaxValue)); private static readonly Color Light = Color32.op_Implicit(new Color32((byte)200, (byte)205, (byte)220, byte.MaxValue)); private static readonly Color Grey = Color32.op_Implicit(new Color32((byte)138, (byte)142, (byte)160, byte.MaxValue)); private static KeyCode OpenKey => (KeyCode)Plugin.OpenKey.Value; private static KeyCode SaveKey => (KeyCode)Plugin.SaveKey.Value; private static KeyCode ClearKey => (KeyCode)Plugin.ClearKey.Value; private void Update() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) try { if (!Plugin.EnableWheel.Value) { if (IsOpen) { Close(apply: false); } return; } KeyCode openKey = OpenKey; if ((int)openKey == 0) { return; } if (!IsOpen) { if (Input.GetKeyDown(openKey) && CanOpen()) { Open(); } } else if (!Game.WheelInputAllowed() || Game.GameWheelVisible()) { Close(apply: false); } else if (!Input.GetKey(openKey)) { Close(apply: true); } else { WhileOpen(); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); IsOpen = false; } } private static bool CanOpen() { if (Game.WheelInputAllowed() && !Game.GameWheelVisible()) { return (Object)(object)Game.LocalExpression() != (Object)null; } return false; } private void Open() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) IsOpen = true; _cursor = Vector2.zero; _hover = -1; _toast = null; _clearSlot = -1; _clearWaitRelease = (int)ClearKey != 0 && Input.GetKey(ClearKey); Blocked.Clear(); Blocked.Add(OpenKey); if ((int)SaveKey != 0 && !Input.GetKey(SaveKey)) { Blocked.Add(SaveKey); } if ((int)ClearKey != 0 && !_clearWaitRelease) { Blocked.Add(ClearKey); } } private void Close(bool apply) { IsOpen = false; Blocked.Clear(); if (!apply || _hover < 0) { return; } List<int> list = Slot(_hover); if (list != null) { Component val = Game.LocalExpression(); if (!((Object)(object)val == (Object)null)) { Game.SetFace(val, list); Plugin.Log.LogInfo((object)string.Format("Wearing slot {0}: [{1}]", _hover + 1, string.Join(",", list))); } } } private void WhileOpen() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current == null) { return; } float num = WheelDiameter() / 2f; _cursor += ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue() * Plugin.WheelSensitivity.Value; _cursor = Vector2.ClampMagnitude(_cursor, num * 0.85f); if (((Vector2)(ref _cursor)).magnitude < num * 0.42f * 0.5f) { _hover = -1; } else { float num2 = Mathf.Atan2(_cursor.x, _cursor.y) * 57.29578f; if (num2 < 0f) { num2 += 360f; } _hover = Mathf.RoundToInt(num2 / 45f) % 8; } KeyCode saveKey = SaveKey; if ((int)saveKey != 0 && Input.GetKeyDown(saveKey)) { if (_hover < 0) { ShowToast("Point at a slot first"); } else if (Slot(_hover) == null) { SaveSlot(_hover); if (saveKey == ClearKey) { _clearWaitRelease = true; } } else if (saveKey != ClearKey) { ShowToast("Clear this slot first"); } } KeyCode clearKey = ClearKey; if ((int)clearKey == 0) { return; } bool key = Input.GetKey(clearKey); if (_clearWaitRelease) { if (!key) { _clearWaitRelease = false; } _clearSlot = -1; } else if (key && _hover >= 0 && Slot(_hover) != null) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (_clearSlot != _hover) { _clearSlot = _hover; _clearStart = realtimeSinceStartup; } if (realtimeSinceStartup - _clearStart >= (float)Plugin.ClearHoldTime.Value / 1000f) { SavedExpression.Slots[_hover] = ""; SavedExpression.Save(); ShowToast($"Slot {_hover + 1} cleared"); _clearSlot = -1; _clearWaitRelease = true; } } else { _clearSlot = -1; } } private void SaveSlot(int i) { Component val = Game.LocalExpression(); if (!((Object)(object)val == (Object)null)) { List<int> list = Game.CurrentFace(val); SavedExpression.Slots[i] = ((list.Count == 0) ? "0" : string.Join(",", list)); SavedExpression.Save(); ShowToast($"Saved to slot {i + 1}"); Plugin.Log.LogInfo((object)string.Format("Saved slot {0}: [{1}]", i + 1, string.Join(",", list))); } } private float ClearProgress() { if (_clearSlot < 0 || _clearSlot != _hover) { return 0f; } float num = (float)Plugin.ClearHoldTime.Value / 1000f; if (!(num <= 0f)) { return Mathf.Clamp01((Time.realtimeSinceStartup - _clearStart) / num); } return 1f; } private void ShowToast(string text) { _toast = text; _toastUntil = Time.realtimeSinceStartup + 1.2f; } private static List<int> Slot(int i) { string text = (SavedExpression.Slots[i] ?? "").Trim(); if (text.Length == 0) { return null; } return (from x in SavedExpression.Parse(text) where x > 0 select x).Distinct().ToList(); } private string ComboText(List<int> slot) { if (slot.Count != 0) { return string.Join(" + ", slot); } return "–"; } private static string NameText(int i) { string text = (Plugin.SlotNames[i].Value ?? "").Trim(); if (text.Length <= 0) { return "No name"; } return text; } private void OnDisable() { IsOpen = false; Blocked.Clear(); } private static float WheelDiameter() { return (float)Mathf.Min(Screen.width, Screen.height) * 0.62f; } private void OnGUI() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen || (int)Event.current.type != 7) { return; } try { MakeTextures(); float num = WheelDiameter(); MakeStyles(num); GUI.depth = -1000; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(val.x - num / 2f, val.y - num / 2f, num, num); Matrix4x4 matrix = GUI.matrix; for (int i = 0; i < 8; i++) { bool flag = Slot(i) != null; bool flag2 = i == _hover; Texture2D val3 = (flag2 ? (flag ? _segHover : _segHoverEmpty) : (flag ? _segFull : _segEmpty)); GUI.color = new Color(1f, 1f, 1f, flag2 ? 1f : (flag ? 1f : 0.6f)); GUIUtility.RotateAroundPivot((float)i * 360f / 8f, val); GUI.DrawTexture(val2, (Texture)(object)val3); GUI.matrix = matrix; } GUI.color = Color.white; float num2 = num / 2f * 1.42f / 2f; float num3 = num * 0.25f; float num4 = num * 0.07f; Vector2 val4 = default(Vector2); Vector2 val5 = default(Vector2); for (int j = 0; j < 8; j++) { float num5 = (float)j * 360f / 8f * (MathF.PI / 180f); ((Vector2)(ref val4))..ctor(val.x + Mathf.Sin(num5) * num2, val.y - Mathf.Cos(num5) * num2); List<int> list = Slot(j); bool flag3 = j == _hover && list != null; if (list != null) { Label(new Rect(val4.x - num3 / 2f, val4.y - num4, num3, num4), ComboText(list), _comboStyle, flag3 ? Dark : Color.white); Label(new Rect(val4.x - num3 / 2f, val4.y, num3, num4 * 1.3f), NameText(j), _nameStyle, flag3 ? Dark : Light); } else { Label(new Rect(val4.x - num3 / 2f, val4.y - num4, num3, num4), "+", _comboStyle, Grey); Label(new Rect(val4.x - num3 / 2f, val4.y, num3, num4), "Empty", _nameStyle, Grey); } float num6 = num / 2f + num * 0.035f; ((Vector2)(ref val5))..ctor(val.x + Mathf.Sin(num5) * num6, val.y - Mathf.Cos(num5) * num6); Label(new Rect(val5.x - 20f, val5.y - 12f, 40f, 24f), (j + 1).ToString(), _smallStyle, Light); } float num7 = num * 0.42f * 0.9f; GUI.DrawTexture(new Rect(val.x - num7 / 2f, val.y - num7 / 2f, num7, num7), (Texture)(object)_center); DrawCenterText(val, num7); float num8 = num * 0.035f; GUI.DrawTexture(new Rect(val.x + _cursor.x - num8 / 2f, val.y - _cursor.y - num8 / 2f, num8, num8), (Texture)(object)_dot); } catch (Exception ex) { Plugin.Log.LogError((object)ex); IsOpen = false; } } private void DrawCenterText(Vector2 c, float cd) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) float num = cd * 0.86f; float num2 = cd * 0.15f; if (_toast != null && Time.realtimeSinceStartup < _toastUntil) { Label(new Rect(c.x - num / 2f, c.y - num2, num, num2 * 2f), _toast, _centerName, Orange); return; } if (_hover < 0) { Label(new Rect(c.x - num / 2f, c.y - num2 * 1.2f, num, num2), "SAVED", _smallStyle, Light); Label(new Rect(c.x - num / 2f, c.y - num2 * 0.2f, num, num2 * 1.2f), "Expressions", _centerName, Orange); return; } List<int> list = Slot(_hover); if (list == null) { Label(new Rect(c.x - num / 2f, c.y - num2 * 2f, num, num2), $"SLOT {_hover + 1}", _smallStyle, Light); Label(new Rect(c.x - num / 2f, c.y - num2 * 1f, num, num2 * 1.1f), "Empty", _centerName, Orange); if ((int)SaveKey != 0) { Label(new Rect(c.x - num / 2f, c.y + num2 * 0.3f, num, num2 * 1.6f), KeyName(Plugin.SaveKey.Value) + " to save your current face", _smallStyle, Color.white); } return; } string text = NameText(_hover); Label(new Rect(c.x - num / 2f, c.y - num2 * 2.3f, num, num2), $"SLOT {_hover + 1}", _smallStyle, Light); Label(new Rect(c.x - num / 2f, c.y - num2 * 1.35f, num, num2 * 1.3f), text, _centerName, Orange); Label(new Rect(c.x - num / 2f, c.y - num2 * 0.05f, num, num2), ComboText(list), _centerCombo, Color.white); if ((int)ClearKey != 0) { string text2 = ((Plugin.ClearHoldTime.Value > 0) ? "Hold " : "") + KeyName(Plugin.ClearKey.Value) + " to clear"; float num3 = ClearProgress(); Label(new Rect(c.x - num / 2f, c.y + num2 * 1f, num, num2), text2, _smallStyle, (num3 > 0f) ? Orange : Grey); if (num3 > 0f) { float num4 = num * 0.6f; Rect val = default(Rect); ((Rect)(ref val))..ctor(c.x - num4 / 2f, c.y + num2 * 2.05f, num4, Mathf.Max(3f, num2 * 0.18f)); GUI.color = new Color(1f, 1f, 1f, 0.25f); GUI.DrawTexture(val, (Texture)(object)_white); GUI.color = Orange; GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width * num3, ((Rect)(ref val)).height), (Texture)(object)_white); GUI.color = Color.white; } } } internal static string KeyName(WheelKey key) { switch (key) { case WheelKey.MouseLeft: return "Left-click"; case WheelKey.MouseRight: return "Right-click"; case WheelKey.MouseMiddle: return "Middle mouse"; case WheelKey.MouseBack: return "Mouse back"; case WheelKey.MouseForward: return "Mouse forward"; case WheelKey.Delete: return "Del"; case WheelKey.Return: return "Enter"; case WheelKey.Escape: return "Esc"; default: { string text = key.ToString(); if (text.StartsWith("Alpha")) { return text.Substring(5); } if (text.StartsWith("Keypad")) { return "Num " + text.Substring(6); } return text; } } } private static void Label(Rect r, string text, GUIStyle style, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) style.normal.textColor = color; GUI.Label(r, text, style); } private void MakeStyles(float d) { int num = Mathf.RoundToInt(d); if (_comboStyle == null || num != _styleSize) { _styleSize = num; _comboStyle = S(24f, bold: true); _nameStyle = S(14f, bold: false); _smallStyle = S(13f, bold: false); _centerName = S(20f, bold: true); _centerCombo = S(15f, bold: false); } GUIStyle S(float px, bool bold) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown return new GUIStyle(GUI.skin.label) { fontSize = Mathf.Max(8, Mathf.RoundToInt(px * d / 600f)), fontStyle = (FontStyle)(bold ? 1 : 0), alignment = (TextAnchor)4, wordWrap = true, clipping = (TextClipping)0 }; } } private static void MakeTextures() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_0150: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_segFull != (Object)null)) { _segFull = Segment(Color32.op_Implicit(new Color32((byte)40, (byte)42, (byte)52, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)90, (byte)94, (byte)112, byte.MaxValue))); _segEmpty = Segment(Color32.op_Implicit(new Color32((byte)30, (byte)32, (byte)40, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)61, (byte)64, (byte)80, byte.MaxValue))); _segHover = Segment(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, (byte)220)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)200, (byte)130, byte.MaxValue))); _segHoverEmpty = Segment(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, (byte)70)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue))); _center = Circle(256, Color32.op_Implicit(new Color32((byte)24, (byte)26, (byte)34, (byte)235)), Orange, 6f); _dot = Circle(64, Orange, Color.white, 6f); _white = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _white.SetPixel(0, 0, Color.white); _white.Apply(); } } private static Texture2D Segment(Color fill, Color edge) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) float num = 256f; float num2 = 254f; float num3 = num2 * 0.42f; float num4 = MathF.PI / 8f; Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[262144]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { float num5 = (float)j + 0.5f - num; float num6 = (float)i + 0.5f - num; float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6); float num8 = Mathf.Abs(Mathf.Atan2(num5, num6)); float num9 = num7 * Mathf.Sin(num4 - num8) - 3f; float num10 = Mathf.Min(Mathf.Min(num7 - num3, num2 - num7), num9); if (num10 <= -0.5f) { array[i * 512 + j] = Color.clear; continue; } Color val2 = Color.Lerp(edge, fill, Mathf.Clamp01(num10 - 3f + 0.5f)); val2.a *= Mathf.Clamp01(num10 + 0.5f); array[i * 512 + j] = val2; } } val.SetPixels(array); val.Apply(false, true); return val; } private static Texture2D Circle(int size, Color fill, Color ring, float ringWidth) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) float num = (float)size / 2f; float num2 = (float)size / 2f - 1f; Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = (float)j + 0.5f - num; float num4 = (float)i + 0.5f - num; float num5 = num2 - Mathf.Sqrt(num3 * num3 + num4 * num4); if (num5 <= -0.5f) { array[i * size + j] = Color.clear; continue; } Color val2 = Color.Lerp(ring, fill, Mathf.Clamp01(num5 - ringWidth + 0.5f)); val2.a *= Mathf.Clamp01(num5 + 0.5f); array[i * size + j] = val2; } } val.SetPixels(array); val.Apply(false, true); return val; } } internal static class WheelPatches { private static bool Active => SavedWheel.IsOpen; public static bool NoLookFloat(ref float __result) { if (!Active) { return true; } __result = 0f; return false; } public static bool NoLookVector(ref Vector2 __result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!Active) { return true; } __result = Vector2.zero; return false; } public static void ControlReservedPostfix(object[] __args, ref bool __result) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (__result || !Active || __args == null || __args.Length == 0) { return; } try { IDictionary dictionary = Game.InputActions(); if (dictionary == null || !dictionary.Contains(__args[0])) { return; } object? obj = dictionary[__args[0]]; InputAction val = (InputAction)((obj is InputAction) ? obj : null); if (val == null) { return; } Enumerator<InputControl> enumerator = val.controls.GetEnumerator(); try { while (enumerator.MoveNext()) { InputControl current = enumerator.Current; foreach (KeyCode item in SavedWheel.Blocked) { if (Matches(current, item)) { __result = true; return; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } catch { } } private static bool Matches(InputControl control, KeyCode key) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown if (control == null || (int)key == 0) { return false; } Mouse current = Mouse.current; if (control.device is Mouse && current != null) { return (key - 323) switch { 0 => (object)control == current.leftButton, 1 => (object)control == current.rightButton, 2 => (object)control == current.middleButton, 3 => (object)control == current.backButton, 4 => (object)control == current.forwardButton, _ => false, }; } if (control.device is Keyboard) { return string.Equals(control.name, KeyboardName(key), StringComparison.OrdinalIgnoreCase); } return false; } private unsafe static string KeyboardName(KeyCode key) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected I4, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected I4, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { return text.Substring(5); } if (text.StartsWith("Keypad") && text.Length == 7) { return "numpad" + text.Substring(6); } if ((int)key <= 96) { if ((int)key == 13) { return "enter"; } if ((int)key == 96) { return "backquote"; } } else { switch (key - 266) { case 0: return "numpadPeriod"; case 1: return "numpadDivide"; case 2: return "numpadMultiply"; case 3: return "numpadMinus"; case 4: return "numpadPlus"; case 5: return "numpadEnter"; case 6: return "numpadEquals"; } switch (key - 305) { case 1: return "leftCtrl"; case 0: return "rightCtrl"; case 5: case 6: return "leftMeta"; case 4: case 7: return "rightMeta"; case 14: return "contextMenu"; case 11: return "printScreen"; case 8: return "rightAlt"; } } return text; } } }