Decompiled source of Card Table v0.1.0
CardTable.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.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 Newtonsoft.Json; using OnTogetherMods.Shared; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("CardTable")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+449164c70985bca68a6207a8f5af89df2b2ae246")] [assembly: AssemblyProduct("CardTable")] [assembly: AssemblyTitle("CardTable")] [assembly: AssemblyVersion("0.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 OnTogetherMods.Shared { internal static class PanelStack { private const string TableKey = "OnTogetherMods.PanelStack.Panels"; private const string HiddenKey = "OnTogetherMods.PanelStack.Hidden"; private const string IconBarKey = "OnTogetherMods.IconBar.Rect"; private const float Margin = 20f; private const float FromRight = 0.15f; private const float Gap = 10f; private const int WorldScene = 2; public const int PhotoModeOrder = 0; public const int EmoteSyncOrder = 10; public const int TeleportSpotsOrder = 20; public const int SongPlayerOrder = 30; public const int TraceOverlayOrder = 40; public const int NameDesignerOrder = 50; public const int CardDesignerOrder = 55; public const int OutfitSlotsOrder = 60; public const int DeskSwarmOrder = 70; public const int SessionManagerOrder = 80; public const int FocusAnywhereOrder = 90; public const int CardTableOrder = 95; public const int DoomTogetherOrder = 100; public const string CanvasPrefix = "OnTogetherMods "; private static int _hiddenFrame = -1; private static bool _gameUIHidden; private static FieldRef<UIManager, HideUIState> _eyeState; private static bool _eyeStateMissing; public static float Width => (float)Screen.width * 1080f / (float)Screen.height; public static bool Hidden { get { if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Hidden") is int num) || Time.frameCount > num) { return GameUIHidden; } return true; } } public static bool GameUIHidden { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 int frameCount = Time.frameCount; if (_hiddenFrame != frameCount) { _hiddenFrame = frameCount; _gameUIHidden = false; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).buildIndex == 2) { UIManager i = MonoSingleton<UIManager>.I; _gameUIHidden = (Object)(object)i != (Object)null && (int)EyeState(i) > 0; } } return _gameUIHidden; } } public static bool IsModCanvas(Canvas canvas) { Canvas val = canvas; Transform parent = ((Component)canvas).transform.parent; while ((Object)(object)parent != (Object)null) { Canvas component = ((Component)parent).GetComponent<Canvas>(); val = (((Object)(object)component != (Object)null) ? component : val); parent = parent.parent; } return ((Object)((Component)val).gameObject).name.StartsWith("OnTogetherMods ", StringComparison.Ordinal); } private static HideUIState EyeState(UIManager ui) { if (_eyeState == null && !_eyeStateMissing) { try { _eyeState = AccessTools.FieldRefAccess<UIManager, HideUIState>("_hideUIState"); } catch (Exception) { _eyeStateMissing = true; } } if (_eyeState != null) { return _eyeState.Invoke(ui); } return (HideUIState)0; } public static void HideForCapture() { AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Hidden", Time.frameCount + 1); } public static Rect Place(string id, int order, Vector2 size) { //IL_001b: 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_004d: 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_011a: 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_0126: Unknown result type (might be due to invalid IL or missing references) Hashtable hashtable = Panels(); int frameCount = Time.frameCount; hashtable[id] = new double[3] { order, size.y, frameCount }; float width = Width; float num = Mathf.Max(20f, width * 0.85f - size.x); float num2 = Bottom(num + size.x, frameCount) - size.y; foreach (DictionaryEntry item in hashtable) { string text = (string)item.Key; double[] array = (double[])item.Value; bool flag = (double)frameCount - array[2] <= 2.0; bool flag2 = array[0] < (double)order || (array[0] == (double)order && string.CompareOrdinal(text, id) < 0); if (text != id && flag && flag2) { num2 -= (float)array[1] + 10f; } } return new Rect(num, num2, size.x, size.y); } private static float Bottom(float windowRight, int frame) { float num = 1060f; if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array && (double)frame - array[4] <= 2.0) { float num2 = 1080f / (float)Screen.height; if (array[0] * (double)num2 < (double)(windowRight + 10f)) { num = Mathf.Min(num, (float)array[1] * num2 - 10f); } } return num; } public static Matrix4x4 Begin(out float width) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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) float num = (float)Screen.height / 1080f; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); width = (float)Screen.width / num; return matrix; } public static void End(Matrix4x4 previous) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.matrix = previous; } public static GUIStyle MakeStyle(TextAnchor alignment) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.box) { alignment = alignment, fontSize = 15, richText = true, wordWrap = false, padding = new RectOffset(12, 12, 10, 10) }; val.normal.textColor = Color.white; return val; } private static Hashtable Panels() { Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Panels") as Hashtable; if (hashtable == null) { hashtable = new Hashtable(); AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Panels", hashtable); } return hashtable; } } internal static class IconBar { public enum State { Plain, Open, On, Off } public enum Click { None, Left, Right } private struct Metrics { public float Unit; public int Art; public int Button; public int Gap; public int Margin; } private static class Patches { private static Action<InputManager, bool> _setMouse0Down; private static Action<InputManager, bool> _setMouse1; private static Action<InputManager, bool> _setMouse1Up; private static FieldRef<QuadPainterGPU, Vector2> _previousUV; private static bool _leftOnBar; private static bool _rightOnBar; public static void Apply(Harmony harmony) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown _setMouse0Down = Setter("IsMouseButton0Down"); _setMouse1 = Setter("IsMouseButton1"); _setMouse1Up = Setter("IsMouseButton1Up"); harmony.Patch((MethodBase)AccessTools.Method(typeof(InputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "InputPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _previousUV = AccessTools.FieldRefAccess<QuadPainterGPU, Vector2>("previousUV"); harmony.Patch((MethodBase)AccessTools.Method(typeof(QuadPainterGPU), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "PaintPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void InputPostfix(InputManager __instance) { bool mouseOver = MouseOver; if (Input.GetMouseButtonDown(0)) { _leftOnBar = mouseOver; } if (Input.GetMouseButtonDown(1)) { _rightOnBar = mouseOver; } if (mouseOver) { _setMouse0Down(__instance, arg2: false); } if (_rightOnBar) { _setMouse1(__instance, arg2: false); _setMouse1Up(__instance, arg2: false); } if (!Input.GetMouseButton(0)) { _leftOnBar = false; } if (!Input.GetMouseButton(1)) { _rightOnBar = false; } } private static bool PaintPrefix(QuadPainterGPU __instance) { if (__instance.IsActive && (_leftOnBar || MouseOver)) { _previousUV.Invoke(__instance).x = -1f; return false; } return true; } private static Action<InputManager, bool> Setter(string property) { return (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), property)); } } public const int PhotoModeOrder = 0; public const int EmoteSyncOrder = 10; public const int TeleportSpotsOrder = 20; public const int NameDesignerOrder = 30; public const int CardDesignerOrder = 32; public const int OutfitSlotsOrder = 35; public const int DeskSnapOrder = 40; public const int DeskSwarmOrder = 45; public const int FocusAnywhereOrder = 50; public const int SongPlayerOrder = 60; public const int TraceOverlayOrder = 70; public const int ChatRangeOrder = 80; public const int DoomTogetherOrder = 85; public const int CardTableOrder = 87; public const int QuickHideOrder = 90; public const int SessionManagerOrder = 95; private const string RectKey = "OnTogetherMods.IconBar.Rect"; private const string TableKey = "OnTogetherMods.IconBar.Icons"; private const string PatchedKey = "OnTogetherMods.IconBar.Patched"; private const string BlockerKey = "OnTogetherMods.IconBar.Blocker"; private const string BlockerFrameKey = "OnTogetherMods.IconBar.BlockerFrame"; private const string HiddenKey = "OnTogetherMods.IconBar.HiddenUntil"; private const int WorldScene = 2; private const int TooltipDepth = -100; private static readonly Dictionary<char, Color32> Palette = new Dictionary<char, Color32> { { 'K', new Color32((byte)42, (byte)36, (byte)51, byte.MaxValue) }, { 'W', new Color32((byte)247, (byte)243, (byte)234, byte.MaxValue) }, { 'G', new Color32((byte)201, (byte)198, (byte)207, byte.MaxValue) }, { 'g', new Color32((byte)143, (byte)138, (byte)153, byte.MaxValue) }, { 'D', new Color32((byte)87, (byte)82, (byte)95, byte.MaxValue) }, { 'B', new Color32((byte)168, (byte)107, (byte)60, byte.MaxValue) }, { 'b', new Color32((byte)217, (byte)160, (byte)102, byte.MaxValue) }, { 'd', new Color32((byte)110, (byte)67, (byte)37, byte.MaxValue) }, { 'R', new Color32((byte)224, (byte)90, (byte)90, byte.MaxValue) }, { 'r', new Color32((byte)168, (byte)58, (byte)70, byte.MaxValue) }, { 'p', new Color32((byte)246, (byte)165, (byte)165, byte.MaxValue) }, { 'Y', new Color32((byte)245, (byte)208, (byte)97, byte.MaxValue) }, { 'y', new Color32((byte)201, (byte)150, (byte)50, byte.MaxValue) }, { 'O', new Color32((byte)232, (byte)146, (byte)74, byte.MaxValue) }, { 'L', new Color32((byte)159, (byte)214, (byte)245, byte.MaxValue) }, { 'U', new Color32((byte)74, (byte)143, (byte)217, byte.MaxValue) }, { 'u', new Color32((byte)47, (byte)90, (byte)158, byte.MaxValue) }, { 'N', new Color32((byte)116, (byte)192, (byte)105, byte.MaxValue) }, { 'n', new Color32((byte)63, (byte)138, (byte)74, byte.MaxValue) }, { 'P', new Color32((byte)246, (byte)207, (byte)174, byte.MaxValue) }, { 'V', new Color32((byte)154, (byte)114, (byte)214, byte.MaxValue) }, { 'v', new Color32((byte)105, (byte)72, (byte)160, byte.MaxValue) }, { 'S', new Color32((byte)233, (byte)139, (byte)181, byte.MaxValue) }, { 'H', new Color32((byte)60, (byte)48, (byte)56, byte.MaxValue) } }; private static readonly Color32 ButtonFill = new Color32((byte)28, (byte)26, (byte)34, (byte)200); private static readonly Color32 ButtonEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30); private static readonly Color32 HoverFill = new Color32((byte)48, (byte)45, (byte)58, (byte)225); private static readonly Color32 HoverEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)80); private static readonly Color32 OpenFill = new Color32((byte)70, (byte)64, (byte)88, (byte)235); private static readonly Color32 OpenEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)150); private static readonly Color32 DotFill = new Color32((byte)140, (byte)220, (byte)120, byte.MaxValue); private static readonly Color32 DotEdge = new Color32((byte)20, (byte)40, (byte)20, byte.MaxValue); private static readonly Dictionary<string[], Texture2D[]> Icons = new Dictionary<string[], Texture2D[]>(); private static Texture2D _buttonTexture; private static Texture2D _hoverTexture; private static Texture2D _openTexture; private static Texture2D _dotTexture; private static GUIStyle _buttonStyle; private static GUIStyle _tipStyle; private static int _builtFor; private static int _cachedFrame = -1; private static bool _inWorld; private static bool _visible; private static int _pressedButton; private static bool RowHidden { get { if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.HiddenUntil") is int num) { return Time.frameCount <= num; } return false; } } public static bool MouseOver { get { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || array[5] < 0.5 || (double)Time.frameCount - array[4] > 2.0) { return false; } Vector3 mousePosition = Input.mousePosition; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)array[0], (float)array[1], (float)array[2], (float)array[3]); return ((Rect)(ref val)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } } public static Click Draw(string id, int order, string[] pixels, State state, string name, KeyCode key, string hint = null) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) int controlID = GUIUtility.GetControlID((FocusType)2); Event current = Event.current; Refresh(); if (!_inWorld) { Hide(controlID, current); UpdateBlocker(shown: false, default(Rect)); return Click.None; } Rect bar; Metrics m; Rect icon = Place(id, order, out bar, out m); Share(bar); UpdateBlocker(_visible, bar); if (!_visible) { Hide(controlID, current); return Click.None; } Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.identity; try { return Handle(controlID, current, icon, m, pixels, state, name, key, hint); } finally { GUI.matrix = matrix; } } public static void HideRow() { AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.HiddenUntil", Time.frameCount + 1); } public static string KeyText(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return $" ({key})"; } return ""; } private static Click Handle(int control, Event e, Rect icon, Metrics m, string[] pixels, State state, string name, KeyCode key, string hint) { //IL_0003: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Rect)(ref icon)).Contains(e.mousePosition); EventType typeForControl = e.GetTypeForControl(control); switch ((int)typeForControl) { default: { if ((int)typeForControl != 7) { break; } BuildStyles(m); bool flag2 = GUIUtility.hotControl == control; _buttonStyle.normal.background = ((state == State.Open || (flag2 && flag)) ? _openTexture : (flag ? _hoverTexture : _buttonTexture)); _buttonStyle.Draw(icon, false, false, false, false); Texture2D[] array = IconTextures(pixels); GUI.DrawTexture(new Rect(((Rect)(ref icon)).x + (((Rect)(ref icon)).width - (float)m.Art) / 2f, ((Rect)(ref icon)).y + (((Rect)(ref icon)).height - (float)m.Art) / 2f, (float)m.Art, (float)m.Art), (Texture)(object)((state == State.Off) ? array[1] : array[0])); if (state == State.On) { float num = Mathf.Max(1, Mathf.RoundToInt(2f * m.Unit)); float num2 = ((Texture)_dotTexture).width; GUI.DrawTexture(new Rect(((Rect)(ref icon)).xMax - num - num2, ((Rect)(ref icon)).yMax - num - num2, num2, num2), (Texture)(object)_dotTexture); } int num3; if (flag) { num3 = ((GUIUtility.hotControl == 0 || flag2) ? 1 : 0); if (num3 != 0) { DrawTooltip(icon, m, Tooltip(state, name, key, hint)); } } else { num3 = 0; } GUI.depth = ((num3 != 0) ? (-100) : 0); break; } case 0: if (flag && (e.button == 0 || e.button == 1)) { GUIUtility.hotControl = control; _pressedButton = e.button; e.Use(); } break; case 3: if (GUIUtility.hotControl == control) { e.Use(); } break; case 1: if (GUIUtility.hotControl != control) { break; } GUIUtility.hotControl = 0; e.Use(); if (flag && e.button == _pressedButton) { if (e.button != 0) { return Click.Right; } return Click.Left; } break; case 2: break; } return Click.None; } private static string Tooltip(State state, string name, KeyCode key, string hint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = name + KeyText(key); switch (state) { case State.On: text += ": on"; break; case State.Off: text += ": off"; break; } if (hint == null) { return text; } return text + "\n" + hint; } private static void DrawTooltip(Rect icon, Metrics m, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(text); Vector2 val2 = _tipStyle.CalcSize(val); float num = Mathf.Clamp(((Rect)(ref icon)).center.x - val2.x / 2f, (float)m.Margin, Mathf.Max((float)m.Margin, (float)(Screen.width - m.Margin) - val2.x)); float num2 = ((Rect)(ref icon)).y - (float)m.Gap - val2.y; _tipStyle.Draw(new Rect(Mathf.Round(num), Mathf.Round(num2), val2.x, val2.y), val, false, false, false, false); } private static void Hide(int control, Event e) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (GUIUtility.hotControl == control) { GUIUtility.hotControl = 0; } if ((int)e.type == 7) { GUI.depth = 0; } } private static Metrics Measure() { float num = (float)Screen.height / 1080f; int num2 = Mathf.Max(1, Mathf.RoundToInt(2f * num)); int num3 = Mathf.Max(2, Mathf.RoundToInt(4f * num)); return new Metrics { Unit = num, Art = 16 * num2, Button = 16 * num2 + 2 * num3, Gap = Mathf.Max(2, Mathf.RoundToInt(6f * num)), Margin = Mathf.RoundToInt(20f * num) }; } private static Rect Place(string id, int order, out Rect bar, out Metrics m) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) Hashtable hashtable = Table(); int frameCount = Time.frameCount; if (hashtable[id] is double[] array) { array[0] = order; array[1] = frameCount; } else { hashtable[id] = new double[2] { order, frameCount }; } int num = 0; int num2 = 0; foreach (DictionaryEntry item in hashtable) { string text = (string)item.Key; double[] array2 = (double[])item.Value; if (!((double)frameCount - array2[1] > 2.0)) { num2++; if (text != id && (array2[0] < (double)order || (array2[0] == (double)order && string.CompareOrdinal(text, id) < 0))) { num++; } } } m = Measure(); int num3 = num2 * m.Button + (num2 - 1) * m.Gap; int num4 = Screen.width - m.Margin - num3; int num5 = Screen.height - m.Margin - m.Button; bar = new Rect((float)num4, (float)num5, (float)num3, (float)m.Button); return new Rect((float)(num4 + num * (m.Button + m.Gap)), (float)num5, (float)m.Button, (float)m.Button); } private static void Share(Rect bar) { AppDomain currentDomain = AppDomain.CurrentDomain; int frameCount = Time.frameCount; if (!(currentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || (int)array[4] != frameCount || !(array[2] >= (double)((Rect)(ref bar)).width)) { currentDomain.SetData("OnTogetherMods.IconBar.Rect", new double[6] { ((Rect)(ref bar)).x, ((Rect)(ref bar)).y, ((Rect)(ref bar)).width, ((Rect)(ref bar)).height, frameCount, _visible ? 1 : 0 }); } } private static Hashtable Table() { Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Icons") as Hashtable; if (hashtable == null) { hashtable = new Hashtable(); AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.Icons", hashtable); } return hashtable; } private static void Refresh() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 int frameCount = Time.frameCount; if (_cachedFrame != frameCount) { _cachedFrame = frameCount; Scene activeScene = SceneManager.GetActiveScene(); _inWorld = ((Scene)(ref activeScene)).buildIndex == 2; _visible = false; if (_inWorld && !PanelStack.Hidden && !RowHidden) { TaskManager i = MonoSingleton<TaskManager>.I; _visible = (Object)(object)i != (Object)null && ((int)i.LockState == 0 || (int)i.LockState == 5); } } } private static void UpdateBlocker(bool shown, Rect bar) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //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_00bd: 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_00b4: 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) AppDomain currentDomain = AppDomain.CurrentDomain; int frameCount = Time.frameCount; if (currentDomain.GetData("OnTogetherMods.IconBar.BlockerFrame") is int num && num == frameCount) { return; } currentDomain.SetData("OnTogetherMods.IconBar.BlockerFrame", frameCount); object? data = currentDomain.GetData("OnTogetherMods.IconBar.Blocker"); GameObject val = (GameObject)((data is GameObject) ? data : null); if ((Object)(object)val == (Object)null) { if (!shown) { return; } val = CreateBlocker(); currentDomain.SetData("OnTogetherMods.IconBar.Blocker", val); } if (shown) { RectTransform val2 = (RectTransform)val.transform.GetChild(0); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(((Rect)(ref bar)).x, (float)Screen.height - ((Rect)(ref bar)).yMax); if (val2.anchoredPosition != val3) { val2.anchoredPosition = val3; } if (val2.sizeDelta != ((Rect)(ref bar)).size) { val2.sizeDelta = ((Rect)(ref bar)).size; } } if (val.activeSelf != shown) { val.SetActive(shown); } } private static GameObject CreateBlocker() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OnTogetherMods IconBar ClickBlocker"); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32767; val.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("Area", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(val.transform, false); ((Graphic)val2.GetComponent<Image>()).color = Color.clear; RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.zero; val3.pivot = Vector2.zero; val.SetActive(false); return val; } public static void Patch() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown AppDomain currentDomain = AppDomain.CurrentDomain; if (currentDomain.GetData("OnTogetherMods.IconBar.Patched") != null) { return; } currentDomain.SetData("OnTogetherMods.IconBar.Patched", true); try { Patches.Apply(new Harmony("nelphei.ontogether.iconbar")); } catch (Exception arg) { Debug.LogError((object)$"[OnTogetherMods] Icon bar patches failed, so clicks on it may reach the game: {arg}"); } } private static Texture2D[] IconTextures(string[] pixels) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (Icons.TryGetValue(pixels, out var value) && (Object)(object)value[0] != (Object)null && (Object)(object)value[1] != (Object)null) { return value; } Color32[] array = (Color32[])(object)new Color32[256]; Color32[] array2 = (Color32[])(object)new Color32[256]; for (int i = 0; i < 16; i++) { string text = ((i < pixels.Length) ? pixels[i] : ""); for (int j = 0; j < 16; j++) { char key = ((j < text.Length) ? text[j] : '.'); Color32 value2; Color32 val = (Color32)(Palette.TryGetValue(key, out value2) ? value2 : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); int num = (15 - i) * 16 + j; array[num] = val; byte b = (byte)Mathf.RoundToInt(0.3f * (float)(int)val.r + 0.59f * (float)(int)val.g + 0.11f * (float)(int)val.b); array2[num] = new Color32(b, b, b, (byte)((float)(int)val.a * 0.45f)); } } value = (Texture2D[])(object)new Texture2D[2] { NewTexture(16, 16, array, (FilterMode)0), NewTexture(16, 16, array2, (FilterMode)0) }; Icons[pixels] = value; return value; } private static void BuildStyles(Metrics m) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0093: 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_00d2: 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_00ec: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0105: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0119: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if (_builtFor != Screen.height || _buttonStyle == null || !((Object)(object)_buttonTexture != (Object)null) || !((Object)(object)_dotTexture != (Object)null)) { _builtFor = Screen.height; int num = Mathf.Max(2, Mathf.RoundToInt(6f * m.Unit)); Destroy(_buttonTexture); Destroy(_hoverTexture); Destroy(_openTexture); Destroy(_dotTexture); _buttonTexture = RoundedBox(num, ButtonFill, ButtonEdge); _hoverTexture = RoundedBox(num, HoverFill, HoverEdge); _openTexture = RoundedBox(num, OpenFill, OpenEdge); int num2 = Mathf.Max(2, Mathf.RoundToInt(3f * m.Unit)); _dotTexture = RoundedBox(num2, DotFill, DotEdge, 2 * num2); int num3 = num + 1; _buttonStyle = new GUIStyle { border = new RectOffset(num3, num3, num3, num3) }; _tipStyle = new GUIStyle { border = new RectOffset(num3, num3, num3, num3), padding = new RectOffset(Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(6f * m.Unit), Mathf.RoundToInt(6f * m.Unit)), fontSize = Mathf.Max(8, Mathf.RoundToInt(15f * m.Unit)), alignment = (TextAnchor)3, wordWrap = false, richText = false }; _tipStyle.normal.background = _hoverTexture; _tipStyle.normal.textColor = Color.white; } } private static Texture2D RoundedBox(int radius, Color32 fill, Color32 edge, int size = 0) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (size <= 0) { size = 2 * radius + 4; } Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = (float)j + 0.5f; float num2 = (float)i + 0.5f; float num3 = Mathf.Max(Mathf.Max((float)radius - num, num - (float)(size - radius)), 0f); float num4 = Mathf.Max(Mathf.Max((float)radius - num2, num2 - (float)(size - radius)), 0f); float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) - (float)radius; float num6 = Mathf.Clamp01(0.5f - num5); Color val = Color.Lerp(Color32.op_Implicit(fill), Color32.op_Implicit(edge), Mathf.Clamp01(num5 + 1.5f)); val.a *= num6; array[i * size + j] = Color32.op_Implicit(val); } } return NewTexture(size, size, array, (FilterMode)1); } private static Texture2D NewTexture(int width, int height, Color32[] pixels, FilterMode filter) { //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_000a: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(width, height, (TextureFormat)4, false) { filterMode = filter, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, true); return val; } private static void Destroy(Texture2D texture) { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } } internal sealed class ClickBlocker { private readonly GameObject _root; private readonly RectTransform _area; public ClickBlocker(string name) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32767; _root.AddComponent<GraphicRaycaster>(); GameObject val = new GameObject("Area", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent(_root.transform, false); ((Graphic)val.GetComponent<Image>()).color = Color.clear; _area = (RectTransform)val.transform; _area.anchorMin = Vector2.zero; _area.anchorMax = Vector2.zero; _area.pivot = Vector2.zero; _root.SetActive(false); } public void Update(bool shown, Rect screenRect) { //IL_002d: 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) if (!((Object)(object)_root == (Object)null)) { if (shown) { _area.anchoredPosition = new Vector2(((Rect)(ref screenRect)).x, (float)Screen.height - ((Rect)(ref screenRect)).yMax); _area.sizeDelta = ((Rect)(ref screenRect)).size; } if (_root.activeSelf != shown) { _root.SetActive(shown); } } } public void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } public static bool MouseIn(Rect screenRect) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector3 mousePosition = Input.mousePosition; return ((Rect)(ref screenRect)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } } } namespace CardTable { internal sealed class CardArt { public readonly Texture2D[] Faces = (Texture2D[])(object)new Texture2D[52]; public readonly Texture2D[] Suits = (Texture2D[])(object)new Texture2D[4]; public readonly Texture2D Back; public readonly Texture2D Slot; public readonly Texture2D AceSlot; public readonly Texture2D RecycleSlot; public readonly Texture2D Glow; public readonly Texture2D Table; public readonly Texture2D Pixel; private readonly List<Texture2D> _all = new List<Texture2D>(); public CardArt(int tableWidth, int tableHeight, int rim) { for (int i = 0; i < 52; i++) { Faces[i] = Make(CardPixels.Face(i)); } for (int j = 0; j < 4; j++) { Suits[j] = Make(CardPixels.Suit(j)); } Back = Make(CardPixels.Back()); Slot = Make(CardPixels.Slot(CardPixels.SlotMark.None)); AceSlot = Make(CardPixels.Slot(CardPixels.SlotMark.Ace)); RecycleSlot = Make(CardPixels.Slot(CardPixels.SlotMark.Recycle)); Glow = Make(CardPixels.Glow()); Table = Make(CardPixels.Table(tableWidth, tableHeight, rim)); Pixel = Make(new Picture(1, 1) { [0, 0] = uint.MaxValue }); } private Texture2D Make(Picture picture) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002a: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(picture.Width, picture.Height, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[picture.Width * picture.Height]; for (int i = 0; i < picture.Height; i++) { for (int j = 0; j < picture.Width; j++) { uint num = picture.Pixels[i * picture.Width + j]; array[(picture.Height - 1 - i) * picture.Width + j] = new Color32((byte)(num >> 24), (byte)(num >> 16), (byte)(num >> 8), (byte)num); } } val.SetPixels32(array); val.Apply(false, true); _all.Add(val); return val; } public void Destroy() { foreach (Texture2D item in _all) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } _all.Clear(); } } internal sealed class Picture { public readonly int Width; public readonly int Height; public readonly uint[] Pixels; public uint this[int x, int y] { get { if (!Inside(x, y)) { return 0u; } return Pixels[y * Width + x]; } set { if (Inside(x, y)) { Pixels[y * Width + x] = value; } } } public Picture(int width, int height) { Width = width; Height = height; Pixels = new uint[width * height]; } public bool Inside(int x, int y) { if (x >= 0 && y >= 0 && x < Width) { return y < Height; } return false; } public void Stamp(string[] rows, int left, int top, Func<char, uint> colour) { for (int i = 0; i < rows.Length; i++) { for (int j = 0; j < rows[i].Length; j++) { char c = rows[i][j]; if (c != '.') { uint num = colour(c); if (num != 0) { this[left + j, top + i] = num; } } } } } public void Paste(Picture other, int left, int top) { for (int i = 0; i < other.Height; i++) { for (int j = 0; j < other.Width; j++) { uint num = other.Pixels[i * other.Width + j]; if (num != 0) { this[left + j, top + i] = num; } } } } public Picture Turned() { Picture picture = new Picture(Width, Height); for (int i = 0; i < Pixels.Length; i++) { picture.Pixels[Pixels.Length - 1 - i] = Pixels[i]; } return picture; } } internal static class CardPixels { public enum SlotMark { None, Ace, Recycle } public const int Width = 32; public const int Height = 44; public const uint Outline = 707015679u; public const uint White = 4159957759u; public const uint LightGrey = 3385249791u; public const uint DarkGrey = 1465016319u; public const uint Wood = 2825600255u; public const uint LightWood = 3651167999u; public const uint DarkWood = 1849894399u; public const uint Red = 3764017919u; public const uint DarkRed = 2822391551u; public const uint Pink = 4138051071u; public const uint Yellow = 4124074495u; public const uint DarkYellow = 3382063871u; public const uint Blue = 1250941439u; public const uint DarkBlue = 794468095u; public const uint Green = 1958767103u; public const uint Skin = 4140805887u; public const uint HotPink = 3918247423u; public const uint Hair = 1009793279u; public const uint Felt = 981616895u; public const uint FeltDark = 880296703u; public const uint FeltMark = 1621781247u; private static readonly string[][] SmallSuits = new string[4][] { new string[7] { "...X...", "..XXX..", ".XXXXX.", "XXXXXXX", "XXXXXXX", "...X...", "..XXX.." }, new string[7] { ".XX.XX.", "XXXXXXX", "XXXXXXX", "XXXXXXX", ".XXXXX.", "..XXX..", "...X..." }, new string[7] { "..XXX..", "..XXX..", "XX.X.XX", "XXXXXXX", "XX.X.XX", "...X...", "..XXX.." }, new string[7] { "...X...", "..XXX..", ".XXXXX.", "XXXXXXX", ".XXXXX.", "..XXX..", "...X..." } }; private static readonly string[][] BigSuits = new string[4][] { new string[14] { "..............", "......XX......", ".....XXXX.....", "....XXXXXX....", "...XXXXXXXX...", ".XXXXXXXXXXXX.", ".XXXXXXXXXXXX.", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", ".XXXXXXXXXXXX.", "...XXXXXXXX...", ".....XXXX.....", ".....XXXX....." }, new string[14] { "...XX....XX...", ".XXXXX..XXXXX.", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", ".XXXXXXXXXXXX.", "..XXXXXXXXXX..", "...XXXXXXXX...", "....XXXXXX....", "....XXXXXX....", ".....XXXX.....", "......XX......", ".............." }, new string[14] { "......XX......", ".....XXXX.....", "....XXXXXX....", "....XXXXXX....", ".....XXXX.....", ".XXXX.XX.XXXX.", "XXXXX.XX.XXXXX", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", ".XXXX.XX.XXXX.", "..XX..XX..XX..", "......XX......", ".....XXXX.....", ".....XXXX....." }, new string[14] { "..............", "......XX......", ".....XXXX.....", "....XXXXXX....", "....XXXXXX....", "...XXXXXXXX...", "..XXXXXXXXXX..", "..XXXXXXXXXX..", "...XXXXXXXX...", "....XXXXXX....", "....XXXXXX....", ".....XXXX.....", "......XX......", ".............." } }; private static readonly string[][] AceSuits = new string[4][] { new string[18] { "..................", "........XX........", ".......XXXX.......", "......XXXXXX......", "......XXXXXX......", ".....XXXXXXXX.....", "...XXXXXXXXXXXX...", ".XXXXXXXXXXXXXXXX.", ".XXXXXXXXXXXXXXXX.", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", ".XXXXXXXXXXXXXXXX.", ".XXXXXXXXXXXXXXXX.", "...XXXXXXXXXXXX...", ".......XXXX.......", "......XXXXXX......", ".....XXXXXXXX....." }, new string[18] { "..................", "..XXXXXX..XXXXXX..", ".XXXXXXXXXXXXXXXX.", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", ".XXXXXXXXXXXXXXXX.", "..XXXXXXXXXXXXXX..", "...XXXXXXXXXXXX...", "....XXXXXXXXXX....", ".....XXXXXXXX.....", "......XXXXXX......", "......XXXXXX......", ".......XXXX.......", "........XX........", ".................." }, new string[18] { ".......XXXX.......", "......XXXXXX......", "......XXXXXX......", ".....XXXXXXXX.....", ".....XXXXXXXX.....", "......XXXXXX......", "...XX.XXXXXX.XX...", ".XXXXX..XX..XXXXX.", "XXXXXXX.XX.XXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX", "XXXXXXX.XX.XXXXXXX", ".XXXXXX.XX.XXXXXX.", "..XXX..XXXX..XXX..", ".......XXXX.......", ".......XXXX.......", ".......XXXX.......", "......XXXXXX......" }, new string[18] { "..................", "........XX........", ".......XXXX.......", "......XXXXXX......", "......XXXXXX......", ".....XXXXXXXX.....", "....XXXXXXXXXX....", "...XXXXXXXXXXXX...", "...XXXXXXXXXXXX...", "..XXXXXXXXXXXXXX..", "...XXXXXXXXXXXX...", "....XXXXXXXXXX....", ".....XXXXXXXX.....", "......XXXXXX......", "......XXXXXX......", ".......XXXX.......", "........XX........", ".................." } }; private static readonly string[] Jack = new string[18] { "...........NN...", "....XXXXXXXN....", "...XXXXXXXXXN...", "..XXXXXXXXXXXX..", "..xxxxxxxxxxxx..", ".HHPPPPPPPPPPHH.", ".HPPPPPPPPPPPPH.", ".HPPKPPPPPPKPPH.", ".HPPKPPPPPPKPPH.", ".HPpPPPPPPPPpPH.", "..PPPPPKKPPPPP..", "...PPPPPPPPPP...", ".....PPPPPP.....", "...XXWWWWWWXX...", "..XXXXXWWXXXXX..", ".XXXXXXXXXXXXXX.", "XxXXXXXXXXXXXXxX", "XxXXXXXXXXXXXXxX" }; private static readonly string[] Queen = new string[18] { "......Y..Y......", ".....YYYYYY.....", "...BBBBBBBBBB...", "..BBBBBBBBBBBB..", ".BBPPPPPPPPPPBB.", ".BPPPPPPPPPPPPB.", ".BPPPPPPPPPPPPB.", ".BPPKPPPPPPKPPB.", ".BPPKPPPPPPKPPB.", ".BPpPPPPPPPPpPB.", ".BPPPPPrrPPPPPB.", ".BBPPPPPPPPPPBB.", ".BBBBPPPPPPBBBB.", ".BBBXXPPPPXXBBB.", "..XXXXXYYXXXXX..", ".XXXXXXXXXXXXXX.", "XxXXXXXXXXXXXXxX", "XxXXXXXXXXXXXXxX" }; private static readonly string[] King = new string[18] { "..Y....YY....Y..", "..YY..YYYY..YY..", "..YYYYYYYYYYYY..", "..YyYyYNNYyYyY..", "..HHHHHHHHHHHH..", ".HPPPPPPPPPPPPH.", ".HPPPPPPPPPPPPH.", ".HPPKPPPPPPKPPH.", ".HPPKPPPPPPKPPH.", ".HPpPPPPPPPPpPH.", ".HPGGGGDDGGGGPH.", "..GGGGGGGGGGGG..", "...GGGGGGGGGG...", "..XXGGGGGGGGXX..", ".XXXXXGGGGXXXXX.", "XXXXXXXYYXXXXXXX", "XxXXXXXYYXXXXXxX", "XxXXXXXYYXXXXXxX" }; private static readonly string[] BackHeart = new string[6] { ".XX.XX.", "XXXXXXX", "XXXXXXX", ".XXXXX.", "..XXX..", "...X..." }; private static readonly string[] Recycle = new string[12] { "....XXXXX.X.", "..XX.....XX.", ".X......XXX.", ".X..........", "X...........", "X...........", "X..........X", "X..........X", ".X........X.", ".X........X.", "..XX....XX..", "....XXXX...." }; private static uint Palette(char letter) { return letter switch { 'K' => 707015679u, 'W' => 4159957759u, 'G' => 3385249791u, 'D' => 1465016319u, 'B' => 2825600255u, 'b' => 3651167999u, 'd' => 1849894399u, 'R' => 3764017919u, 'r' => 2822391551u, 'p' => 4138051071u, 'Y' => 4124074495u, 'y' => 3382063871u, 'U' => 1250941439u, 'u' => 794468095u, 'N' => 1958767103u, 'P' => 4140805887u, 'S' => 3918247423u, 'H' => 1009793279u, _ => 0u, }; } private static string[] Glyph(char c) { return c switch { 'A' => new string[7] { ".XXX.", "X...X", "X...X", "XXXXX", "X...X", "X...X", "X...X" }, '2' => new string[7] { ".XXX.", "X...X", "....X", "...X.", "..X..", ".X...", "XXXXX" }, '3' => new string[7] { "XXXX.", "....X", "....X", ".XXX.", "....X", "....X", "XXXX." }, '4' => new string[7] { "...X.", "..XX.", ".X.X.", "X..X.", "XXXXX", "...X.", "...X." }, '5' => new string[7] { "XXXXX", "X....", "XXXX.", "....X", "....X", "X...X", ".XXX." }, '6' => new string[7] { "..XX.", ".X...", "X....", "XXXX.", "X...X", "X...X", ".XXX." }, '7' => new string[7] { "XXXXX", "....X", "...X.", "..X..", "..X..", ".X...", ".X..." }, '8' => new string[7] { ".XXX.", "X...X", "X...X", ".XXX.", "X...X", "X...X", ".XXX." }, '9' => new string[7] { ".XXX.", "X...X", "X...X", ".XXXX", "....X", "...X.", ".XX.." }, '1' => new string[7] { ".X.", "XX.", ".X.", ".X.", ".X.", ".X.", "XXX" }, '0' => new string[7] { ".XX.", "X..X", "X..X", "X..X", "X..X", "X..X", ".XX." }, 'J' => new string[7] { "..XXX", "...X.", "...X.", "...X.", "X..X.", "X..X.", ".XX.." }, 'Q' => new string[7] { ".XXX.", "X...X", "X...X", "X...X", "X.X.X", "X..X.", ".XX.X" }, _ => new string[7] { "X...X", "X..X.", "X.X..", "XX...", "X.X..", "X..X.", "X...X" }, }; } private static bool InCard(int x, int y) { if (x < 0 || y < 0 || x >= 32 || y >= 44) { return false; } int num = Math.Min(x, 31 - x); int num2 = Math.Min(y, 43 - y); if ((num != 0 || num2 != 0) && (num != 1 || num2 != 0)) { if (num == 0) { return num2 != 1; } return true; } return false; } private static bool OnEdge(int x, int y) { if (InCard(x + 1, y) && InCard(x - 1, y) && InCard(x, y + 1)) { return !InCard(x, y - 1); } return true; } private static Picture Blank() { Picture picture = new Picture(32, 44); for (int i = 0; i < 44; i++) { for (int j = 0; j < 32; j++) { if (InCard(j, i)) { picture[j, i] = (OnEdge(j, i) ? 707015679u : ((!InCard(j, i + 2)) ? 3385249791u : 4159957759u)); } } } return picture; } private static uint Ink(int suit) { if (!Cards.IsRedSuit(suit)) { return 707015679u; } return 3764017919u; } private static Picture Corner(int rank, int suit) { string[] array3; if (rank == 10) { string[] array = Glyph('1'); string[] array2 = Glyph('0'); array3 = new string[7]; for (int i = 0; i < 7; i++) { array3[i] = array[i] + "." + array2[i]; } } else { array3 = Glyph(Cards.RankText(rank)[0]); } int length = array3[0].Length; Picture picture = new Picture(length + 2 + 7, 7); uint ink = Ink(suit); picture.Stamp(array3, 0, 0, (char c) => ink); picture.Stamp(SmallSuits[suit], length + 2, 0, (char c) => ink); return picture; } private static Picture Outlined(string[] rows, Func<char, uint> colour) { int num = rows.Length; Picture picture = new Picture(rows[0].Length + 2, num + 2); picture.Stamp(rows, 1, 1, colour); uint[] array = (uint[])picture.Pixels.Clone(); for (int i = 0; i < picture.Height; i++) { for (int j = 0; j < picture.Width; j++) { if (array[i * picture.Width + j] == 0 && ((j + 1 < picture.Width && array[i * picture.Width + j + 1] != 0) || (j > 0 && array[i * picture.Width + j - 1] != 0) || (i + 1 < picture.Height && array[(i + 1) * picture.Width + j] != 0) || (i > 0 && array[(i - 1) * picture.Width + j] != 0))) { picture[j, i] = 707015679u; } } } return picture; } public static Picture Face(int card) { int num = Cards.Rank(card); int num2 = Cards.Suit(card); Picture picture = Blank(); Picture picture2 = Corner(num, num2); picture.Paste(picture2, 3, 3); picture.Paste(picture2.Turned(), 29 - picture2.Width, 41 - picture2.Height); if (num >= 11) { uint main = (Cards.IsRedSuit(num2) ? 3764017919u : 1250941439u); uint dark = (Cards.IsRedSuit(num2) ? 2822391551u : 794468095u); Picture picture3 = Outlined(num switch { 12 => Queen, 11 => Jack, _ => King, }, (char c) => c switch { 'x' => dark, 'X' => main, _ => Palette(c), }); picture.Paste(picture3, (32 - picture3.Width) / 2, 12); } else { string[] array = ((num == 1) ? AceSuits[num2] : BigSuits[num2]); uint ink = Ink(num2); picture.Stamp(array, (32 - array[0].Length) / 2, (44 - array.Length) / 2, (char c) => ink); } return picture; } public static Picture Back() { Picture picture = Blank(); for (int i = 3; i < 41; i++) { for (int j = 3; j < 29; j++) { bool flag = (j + i) % 6 == 0 || (j - i + 60) % 6 == 0; picture[j, i] = (flag ? 1250941439u : 794468095u); } } int num = 16; int num2 = 22; for (int k = num2 - 6; k < num2 + 6; k++) { for (int l = num - 6; l < num + 6; l++) { double num3 = (double)(l - num) + 0.5; double num4 = (double)(k - num2) + 0.5; double num5 = num3 * num3 + num4 * num4; if (num5 <= 30.0) { picture[l, k] = 4159957759u; } else if (num5 <= 42.0) { picture[l, k] = 707015679u; } } } Picture picture2 = Outlined(BackHeart, (char c) => 3918247423u); picture.Paste(picture2, num - picture2.Width / 2, num2 - picture2.Height / 2); return picture; } public static Picture Slot(SlotMark mark) { Picture picture = new Picture(32, 44); for (int i = 0; i < 44; i++) { for (int j = 0; j < 32; j++) { if (InCard(j, i) && OnEdge(j, i)) { picture[j, i] = 1621781247u; } } } switch (mark) { case SlotMark.Ace: { string[] array = Glyph('A'); int num = 11; int num2 = 15; for (int num3 = 0; num3 < 14; num3++) { for (int num4 = 0; num4 < 10; num4++) { if (array[num3 / 2][num4 / 2] == 'X') { picture[num + num4, num2 + num3] = 1621781247u; } } } break; } case SlotMark.Recycle: picture.Stamp(Recycle, (32 - Recycle[0].Length) / 2, (44 - Recycle.Length) / 2, (char c) => 1621781247u); break; } return picture; } public static Picture Glow() { Picture picture = new Picture(32, 44); for (int i = 0; i < 44; i++) { for (int j = 0; j < 32; j++) { if (InCard(j, i) && OnEdge(j, i)) { picture[j, i] = 4124074495u; } } } return picture; } public static Picture Suit(int suit) { Picture picture = new Picture(7, 7); picture.Stamp(SmallSuits[suit], 0, 0, (char c) => (!Cards.IsRedSuit(suit)) ? 707015679u : 3764017919u); return picture; } public static Picture Table(int width, int height, int rim) { Picture picture = new Picture(width, height); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int num = Math.Min(j, width - 1 - j); int num2 = Math.Min(i, height - 1 - i); if ((num != 0 || num2 > 1) && (num != 1 || num2 != 0)) { int num3 = Math.Min(num, num2); uint value = ((num3 == 0 || (num == 1 && num2 == 1)) ? 707015679u : ((num3 == 1) ? ((i == 1 || j == 1) ? 3651167999u : 2825600255u) : ((num3 < rim - 1) ? 2825600255u : ((num3 != rim - 1) ? (((j * 7 + i * 13) % 11 == 0) ? 880296703u : 981616895u) : 1849894399u)))); picture[j, i] = value; } } } return picture; } } internal static class Cards { public const int Count = 52; public const int Ace = 1; public const int King = 13; public const int Spades = 0; public const int Hearts = 1; public const int Clubs = 2; public const int Diamonds = 3; public static int Suit(int card) { return card / 13; } public static int Rank(int card) { return card % 13 + 1; } public static bool IsRed(int card) { return Suit(card) % 2 == 1; } public static bool IsRedSuit(int suit) { return suit % 2 == 1; } public static int Make(int suit, int rank) { return suit * 13 + rank - 1; } public static string RankText(int rank) { return rank switch { 1 => "A", 11 => "J", 12 => "Q", 13 => "K", _ => rank.ToString(), }; } public static string Name(int card) { string[] array = new string[4] { "spades", "hearts", "clubs", "diamonds" }; return RankText(Rank(card)) + " of " + array[Suit(card)]; } } internal static class Icon { public static readonly string[] Pixels = new string[16] { "................", ".KKKKKKKKK......", ".KuUuUuUuK......", ".KUuUuKKKKKKKKK.", ".KuUuUKWWWWWWWK.", ".KUuUuKWWWWWWWK.", ".KuUuUKWWWWWWWK.", ".KUuUuKWpRWRRWK.", ".KuUuUKWRRRRRWK.", ".KUuUuKWRRRRRWK.", ".KuUuUKWWRRRWWK.", ".KUuUuKWWWRWWWK.", ".KuUuUKWWWWWWWK.", ".KKKKKKWWWWWWWK.", "......KWWWWWWWK.", "......KKKKKKKKK." }; } [HarmonyPatch(typeof(InputManager), "Update")] internal static class InputPatch { private static readonly Action<InputManager, bool> SetMouse0Down = Setter("IsMouseButton0Down"); private static void Postfix(InputManager __instance) { if (TableWindow.IsMouseOver) { SetMouse0Down(__instance, arg2: false); } } private static Action<InputManager, bool> Setter(string property) { return (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), property)); } } [HarmonyPatch(typeof(QuadPainterGPU), "Update")] internal static class PaintPatch { private static readonly FieldRef<QuadPainterGPU, Vector2> PreviousUV = AccessTools.FieldRefAccess<QuadPainterGPU, Vector2>("previousUV"); private static bool Prefix(QuadPainterGPU __instance) { if (__instance.IsActive && TableWindow.IsMouseOver) { PreviousUV.Invoke(__instance).x = -1f; return false; } return true; } } [BepInPlugin("nelphei.ontogether.cardtable", "Card Table", "0.1.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "nelphei.ontogether.cardtable"; public const string PluginName = "Card Table"; public const string PluginVersion = "0.1.0"; internal static ManualLogSource Log; internal static Settings Settings; private GameObject _host; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Settings = new Settings(((BaseUnityPlugin)this).Config); new Harmony("nelphei.ontogether.cardtable").PatchAll(); IconBar.Patch(); _host = new GameObject("CardTable"); ((Object)_host).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_host); _host.AddComponent<TableWindow>(); Log.LogInfo((object)"Card Table 0.1.0 loaded. Click the cards icon to play."); } private void OnDestroy() { if ((Object)(object)_host != (Object)null) { Object.Destroy((Object)(object)_host); } } } internal enum TableSize { Medium, Large } internal sealed class Settings { public readonly ConfigEntry<KeyCode> WindowKey; public readonly ConfigEntry<bool> DrawThree; public readonly ConfigEntry<bool> Animations; public readonly ConfigEntry<TableSize> Size; public readonly ConfigEntry<float> WindowX; public readonly ConfigEntry<float> WindowY; public readonly ConfigEntry<bool> HelpSeen; public readonly ConfigEntry<bool> ShowIcon; public Settings(ConfigFile config) { WindowKey = config.Bind<KeyCode>("Keys", "WindowKey", (KeyCode)0, "Opens and closes the Card Table window. None by default (every F key is taken by other mods): click the cards icon instead."); DrawThree = config.Bind<bool>("Solitaire", "DrawThree", false, "Turn over three cards at a time from the deck instead of one. Also the Draw button in the window, which changes it straight away, in the game you're playing too."); Animations = config.Bind<bool>("Display", "Animations", true, "Cards slide to where they go, and the deal flies out from the deck."); Size = config.Bind<TableSize>("Display", "Size", TableSize.Medium, "How big the table is: Medium or Large. Also the size button in the window. The cards are pixel art, so they grow in whole steps; on a small screen Large may come out as Medium."); WindowX = config.Bind<float>("Display", "WindowX", -1f, "Where you dragged the window to: its left edge, in pixels on a 1080-pixel-high screen. -1 keeps it with the other mods' windows. Double-clicking the window's title row sets this back to -1."); WindowY = config.Bind<float>("Display", "WindowY", -1f, "Where you dragged the window to: its top edge, in pixels on a 1080-pixel-high screen."); HelpSeen = config.Bind<bool>("Display", "HelpSeen", false, "The how-to-play card (the ? button) shows by itself the first time you open the window, and this remembers that it has. Set it to false to see it by itself again."); ShowIcon = config.Bind<bool>("Display", "ShowIcon", true, "Show a cards icon in the row of mod icons at the bottom-right. Clicking it opens and closes the window."); } } internal enum PileKind { Stock, Waste, Foundation, Tableau } internal readonly struct PileId : IEquatable<PileId> { public readonly PileKind Kind; public readonly int Index; public static readonly PileId Stock = new PileId(PileKind.Stock, 0); public static readonly PileId Waste = new PileId(PileKind.Waste, 0); private PileId(PileKind kind, int index) { Kind = kind; Index = index; } public static PileId Foundation(int index) { return new PileId(PileKind.Foundation, index); } public static PileId Tableau(int index) { return new PileId(PileKind.Tableau, index); } public bool Equals(PileId other) { if (Kind == other.Kind) { return Index == other.Index; } return false; } public override bool Equals(object obj) { if (obj is PileId other) { return Equals(other); } return false; } public override int GetHashCode() { return (int)Kind * 16 + Index; } public static bool operator ==(PileId a, PileId b) { return a.Equals(b); } public static bool operator !=(PileId a, PileId b) { return !a.Equals(b); } public override string ToString() { return Kind.ToString() + ((Kind == PileKind.Foundation || Kind == PileKind.Tableau) ? (" " + Index) : ""); } } internal sealed class Solitaire { private sealed class State { public int[] Stock; public int[] Waste; public int[][] Foundations; public int[][] Tableau; public int[] FaceDown; public int WasteFanned; } internal sealed class Saved { public List<int> Stock; public List<int> Waste; public List<List<int>> Foundations; public List<List<int>> Tableau; public List<int> FaceDown; public int WasteFanned; public bool DrawThree; public int Moves; public double Seconds; public bool Counted; } public const int Piles = 7; public const int FoundationCount = 4; private const int MaxHistory = 1000; public readonly List<int> Stock = new List<int>(); public readonly List<int> Waste = new List<int>(); public readonly List<int>[] Foundations = NewLists(4); public readonly List<int>[] Tableau = NewLists(7); public readonly int[] FaceDown = new int[7]; public int WasteFanned; public bool DrawThree; public int Moves; public double Seconds; public bool Counted; private readonly List<State> _history = new List<State>(); private int _idleDraws; public bool CanUndo => _history.Count > 0; public bool Started => Moves > 0; public bool Won => Foundations.All((List<int> f) => f.Count == 13); public bool CanAutoFinish { get { if (!Won) { return FaceDown.All((int n) => n == 0); } return false; } } public void Deal(Random random) { List<int> list = Enumerable.Range(0, 52).ToList(); for (int num = list.Count - 1; num > 0; num--) { int index = random.Next(num + 1); int value = list[num]; list[num] = list[index]; list[index] = value; } Stock.Clear(); Waste.Clear(); foreach (List<int> item in Foundations.Concat(Tableau)) { item.Clear(); } int count = 0; for (int i = 0; i < 7; i++) { for (int j = i; j < 7; j++) { Tableau[j].Add(list[count++]); } } for (int k = 0; k < 7; k++) { FaceDown[k] = k; } Stock.AddRange(list.Skip(count)); WasteFanned = 0; Moves = 0; Seconds = 0.0; Counted = false; _history.Clear(); _idleDraws = 0; } public IEnumerable<int> DealOrder() { for (int row = 0; row < 7; row++) { for (int pile = row; pile < 7; pile++) { if (row < Tableau[pile].Count) { yield return Tableau[pile][row]; } } } } public List<int> Pile(PileId pile) { return pile.Kind switch { PileKind.Stock => Stock, PileKind.Waste => Waste, PileKind.Foundation => Foundations[pile.Index], _ => Tableau[pile.Index], }; } public bool IsFaceUp(PileId pile, int index) { return pile.Kind switch { PileKind.Stock => false, PileKind.Tableau => index >= FaceDown[pile.Index], _ => true, }; } public bool CanPickUp(PileId pile, int index) { List<int> list = Pile(pile); if (index < 0 || index >= list.Count) { return false; } return pile.Kind switch { PileKind.Stock => false, PileKind.Tableau => index >= FaceDown[pile.Index], _ => index == list.Count - 1, }; } public bool FitsFoundation(int card, int foundation) { List<int> list = Foundations[foundation]; if (list.Count == 0) { return Cards.Rank(card) == 1; } int card2 = list[list.Count - 1]; if (Cards.Suit(card2) == Cards.Suit(card)) { return Cards.Rank(card) == Cards.Rank(card2) + 1; } return false; } public int FoundationFor(int card) { for (int i = 0; i < 4; i++) { if (Foundations[i].Count > 0 && FitsFoundation(card, i)) { return i; } } if (Cards.Rank(card) == 1) { for (int j = 0; j < 4; j++) { if (Foundations[j].Count == 0) { return j; } } } return -1; } public bool FitsTableau(int card, int pile) { List<int> list = Tableau[pile]; if (list.Count == 0) { return Cards.Rank(card) == 13; } int card2 = list[list.Count - 1]; if (Cards.IsRed(card2) != Cards.IsRed(card)) { return Cards.Rank(card) == Cards.Rank(card2) - 1; } return false; } public bool CanMove(PileId from, int index, PileId to) { if (from == to || !CanPickUp(from, index)) { return false; } List<int> list = Pile(from); int card = list[index]; switch (to.Kind) { case PileKind.Foundation: if (index == list.Count - 1) { return FitsFoundation(card, to.Index); } return false; case PileKind.Tableau: return FitsTableau(card, to.Index); default: return false; } } public PileId? BestMove(PileId from, int index) { if (!CanPickUp(from, index)) { return null; } List<int> list = Pile(from); int card = list[index]; if (index == list.Count - 1 && from.Kind != PileKind.Foundation) { int num = FoundationFor(card); if (num >= 0) { return PileId.Foundation(num); } } for (int i = 0; i < 7; i++) { if (Tableau[i].Count > 0 && CanMove(from, index, PileId.Tableau(i))) { return PileId.Tableau(i); } } if (from.Kind != PileKind.Tableau || index != 0) { for (int j = 0; j < 7; j++) { if (Tableau[j].Count == 0 && CanMove(from, index, PileId.Tableau(j))) { return PileId.Tableau(j); } } } return null; } public bool Move(PileId from, int index, PileId to) { if (!CanMove(from, index, to)) { return false; } Remember(); List<int> list = Pile(from); List<int> range = list.GetRange(index, list.Count - index); list.RemoveRange(index, range.Count); Pile(to).AddRange(range); if (from.Kind == PileKind.Tableau) { TurnOverTop(from.Index); } if (from.Kind == PileKind.Waste) { WasteFanned = Math.Max(0, WasteFanned - 1); } Moves++; return true; } public bool Draw() { if (Stock.Count == 0 && Waste.Count == 0) { return false; } Remember(); if (Stock.Count == 0) { for (int num = Waste.Count - 1; num >= 0; num--) { Stock.Add(Waste[num]); } Waste.Clear(); WasteFanned = 0; } else { int num2 = Math.Min((!DrawThree) ? 1 : 3, Stock.Count); for (int i = 0; i < num2; i++) { Waste.Add(Stock[Stock.Count - 1]); Stock.RemoveAt(Stock.Count - 1); } WasteFanned = num2; } Moves++; return true; } public bool Undo() { if (_history.Count == 0) { return false; } State state = _history[_history.Count - 1]; _history.RemoveAt(_history.Count - 1); Restore(state); Moves++; _idleDraws = 0; return true; } private void TurnOverTop(int pile) { int count = Tableau[pile].Count; if (count > 0 && FaceDown[pile] >= count) { FaceDown[pile] = count - 1; } if (count == 0) { FaceDown[pile] = 0; } } public void StartAutoFinish() { _idleDraws = 0; } public bool AutoFinishWins() { if (!CanAutoFinish) { return false; } Solitaire solitaire = new Solitaire(); if (!solitaire.Load(Save())) { return false; } solitaire.StartAutoFinish(); for (int i = 0; i < 5000; i++) { if (!solitaire.AutoFinishStep()) { break; } } return solitaire.Won; } public bool AutoFinishStep() { PileId? from = null; int fromIndex = -1; int lowest = int.MaxValue; for (int i = 0; i < 7; i++) { Consider(PileId.Tableau(i), ref from, ref fromIndex, ref lowest); } Consider(PileId.Waste, ref from, ref fromIndex, ref lowest); if (from.HasValue) { int card = Pile(from.Value)[fromIndex]; _idleDraws = 0; return Move(from.Value, fromIndex, PileId.Foundation(FoundationFor(card))); } int num = Stock.Count + Waste.Count; if (num > 0 && _idleDraws <= num + 1) { _idleDraws++; return Draw(); } return false; } private void Consider(PileId pile, ref PileId? from, ref int fromIndex, ref int lowest) { List<int> list = Pile(pile); if (list.Count != 0) { int card = list[list.Count - 1]; int num = Cards.Rank(card); if (num < lowest && FoundationFor(card) >= 0) { lowest = num; from = pile; fromIndex = list.Count - 1; } } } private void Remember() { _history.Add(new State { Stock = Stock.ToArray(), Waste = Waste.ToArray(), Foundations = Foundations.Select((List<int> f) => f.ToArray()).ToArray(), Tableau = Tableau.Select((List<int> t) => t.ToArray()).ToArray(), FaceDown = (int[])FaceDown.Clone(), WasteFanned = WasteFanned }); if (_history.Count > 1000) { _history.RemoveAt(0); } } private void Restore(State state) { Refill(Stock, state.Stock); Refill(Waste, state.Waste); for (int i = 0; i < 4; i++) { Refill(Foundations[i], state.Foundations[i]); } for (int j = 0; j < 7; j++) { Refill(Tableau[j], state.Tableau[j]); } Array.Copy(state.FaceDown, FaceDown, 7); WasteFanned = state.WasteFanned; } private static void Refill(List<int> list, int[] cards) { list.Clear(); list.AddRange(cards); } private static List<int>[] NewLists(int count) { List<int>[] array = new List<int>[count]; for (int i = 0; i < count; i++) { array[i] = new List<int>(); } return array; } public Saved Save() { return new Saved { Stock = Stock.ToList(), Waste = Waste.ToList(), Foundations = Foundations.Select((List<int> f) => f.ToList()).ToList(), Tableau = Tableau.Select((List<int> t) => t.ToList()).ToList(), FaceDown = FaceDown.ToList(), WasteFanned = WasteFanned, DrawThree = DrawThree, Moves = Moves, Seconds = Seconds, Counted = Counted }; } public bool Load(Saved saved) { if (saved?.Stock != null && saved.Waste != null) { List<List<int>> foundations = saved.Foundations; if (foundations != null && foundations.Count == 4) { List<List<int>> tableau = saved.Tableau; if (tableau != null && tableau.Count == 7) { List<int> faceDown = saved.FaceDown; if (faceDown != null && faceDown.Count == 7 && !saved.Foundations.Any((List<int> f) => f == null) && !saved.Tableau.Any((List<int> t) => t == null)) { List<int> list = saved.Stock.Concat(saved.Waste).Concat(saved.Foundations.SelectMany((List<int> f) => f)).Concat(saved.Tableau.SelectMany((List<int> t) => t)) .ToList(); if (list.Count != 52 || list.Any((int c) => c < 0 || c >= 52) || list.Distinct().Count() != 52) { return false; } foreach (List<int> foundation in saved.Foundations) { for (int num = 0; num < foundation.Count; num++) { if (Cards.Rank(foundation[num]) != num + 1 || Cards.Suit(foundation[num]) != Cards.Suit(foundation[0])) { return false; } } } for (int num2 = 0; num2 < 7; num2++) { int num3 = saved.FaceDown[num2]; int count = saved.Tableau[num2].Count; if (num3 < 0 || (count > 0 && num3 >= count) || (count == 0 && num3 != 0)) { return false; } } Refill(Stock, saved.Stock.ToArray()); Refill(Waste, saved.Waste.ToArray()); for (int num4 = 0; num4 < 4; num4++) { Refill(Foundations[num4], saved.Foundations[num4].ToArray()); } for (int num5 = 0; num5 < 7; num5++) { Refill(Tableau[num5], saved.Tableau[num5].ToArray()); FaceDown[num5] = saved.FaceDown[num5]; } WasteFanned = Math.Max(0, Math.Min(Math.Min(3, saved.WasteFanned), Waste.Count)); DrawThree = saved.DrawThree; Moves = Math.Max(0, saved.Moves); Seconds = Math.Max(0.0, saved.Seconds); Counted = saved.Counted; _history.Clear(); _idleDraws = 0; return true; } } } } return false; } } internal sealed class SolitaireStats { public int Played; public int Won; public int Streak; public int BestStreak; public double BestSeconds; public int FewestMoves; } internal sealed class Store { private sealed class StoreFile { public int Version = 1; public Solitaire.Saved Solitaire; public SolitaireStats SolitaireStats; } public Solitaire.Saved SavedGame; public SolitaireStats Stats = new SolitaireStats(); public string FilePath { get; } = Path.Combine(Paths.ConfigPath, "CardTable.json"); public void Load() { if (!File.Exists(FilePath)) { return; } try { StoreFile storeFile = JsonConvert.DeserializeObject<StoreFile>(File.ReadAllText(FilePath)); SavedGame = storeFile?.Solitaire; Stats = storeFile?.SolitaireStats ?? new SolitaireStats(); } catch (Exception ex) { string text = FilePath + ".bad"; Plugin.Log.LogError((object)("Couldn't read " + FilePath + ", so it was copied to " + text + ": " + ex.Message)); try { File.Copy(FilePath, text, overwrite: true); } catch (Exception ex2) { Plugin.Log.LogError((object)ex2); } } } public void Save(Solitaire game) { try { StoreFile storeFile = new StoreFile { Solitaire = game.Save(), SolitaireStats = Stats }; string text = FilePath + ".tmp"; File.WriteAllText(text, JsonConvert.SerializeObject((object)storeFile, (Formatting)1)); if (File.Exists(FilePath)) { File.Delete(FilePath); } File.Move(text, FilePath); } catch (Exception arg) { Plugin.Log.LogError((object)$"Couldn't save to {FilePath}: {arg}"); } } } internal sealed class TableWindow : MonoBehaviour { private struct Slide { public Vector2 From; public float Start; public bool StartFaceUp; } private struct Confetto { public int Suit; public float X; public float Y; public float Speed; public float Sway; public float Phase; } private const string PanelId = "CardTable"; private const int WorldScene = 2; private const int CardW = 32; private const int CardH = 44; private const int ColumnGap = 5; private const int Rim = 4; private const int FeltPad = 5; private const int RowGap = 7; private const int DownStep = 4; private const int UpStep = 13; private const int MinUpStep = 7; private const int FanStep = 18; private const int TableauRoom = 159; private const int Inset = 9; private const int TableWidth = 272; private const int TableHeight = 228; private const float PadUnits = 8f; private const float HeaderUnits = 28f; private const float GapUnits = 6f; private const float StatusUnits = 28f; private const float ButtonGapUnits = 4f; private const float DragUnits = 4f; private const float SlideTime = 0.16f; private const float DealGap = 0.03f; private const float AutoStepTime = 0.09f; private const float SaveDelay = 2f; private const float ConfirmTime = 3f; private const float ConfettiTime = 7f; private static readonly Color Dim = new Color(1f, 1f, 1f, 0.6f); private static readonly Color Gold = Color32.op_Implicit(new Color32((byte)245, (byte)208, (byte)97, byte.MaxValue)); private static readonly Color Shade = new Color(0f, 0f, 0f, 0.6f); private static TableWindow _instance; private readonly Store _store = new Store(); private readonly Solitaire _game = new Solitaire(); private readonly Random _random = new Random(); private CardArt _art; private bool _open; private bool _iconClicked; private readonly List<Action> _clicks = new List<Action>(); private ClickBlocker _blocker; private Rect _screenRect; private int _drawnFrame = -100; private float _saveAt = -1f; private float _unit; private int _scale; private float _pad; private float _header; private float _gap; private float _status; private Rect _panel; private Rect _table; private Vector2 _origin; private readonly PileId[] _pileOf = new PileId[52]; private readonly int[] _indexOf = new int[52]; private int _windowControl; private bool _windowDragging; private Vector2 _windowGrab; private Vector2 _windowPos; private int _boardControl; private bool _pressed; private bool _dragging; private PileId _pressPile; private int _pressIndex; private Vector2 _pressMouse; private Vector2 _grab; private Vector2 _dragAt; private PileId? _dropTarget; private PileId _lastClickPile; private readonly Dictionary<int, Slide> _slides = new Dictionary<int, Slide>(); private bool _autoFinishing; private float _nextAutoStep; private int _autoCheckedAt = -1; private bool _autoWins; private bool _help; private bool _statsBox; private float _confirmUntil = -1f; private bool _wonCounted; private bool _showWin; private float _wonAt = -1000f; private readonly List<Confetto> _confetti = new List<Confetto>(); private float _styleUnit = -1f; private GUIStyle _boxStyle; private GUIStyle _titleStyle; private GUIStyle _hintStyle; private GUIStyle _buttonStyle; private GUIStyle _statusStyle; private GUIStyle _bigStyle; private GUIStyle _centreStyle; private GUIStyle _helpStyle; private const string HelpText = "<b>How to play</b>\nBuild the four piles at the top right up from Ace to King, one suit each.\nIn the seven piles below, stack cards downwards (King, Queen, Jack, 10 ... 2), red on black or black on red. You can move a run of cards together. Only a King, or a run that starts with one, goes on an empty pile.\nClick the deck at the top left to turn cards over. When it runs out, click its spot to turn the pile back over.\n\n<b>Controls</b>\nDrag a card (and the cards on it) onto a pile, or click it to send it where it fits: up top first, if it can go there.\nUndo takes back moves. Draw 1 / Draw 3 picks how many cards the deck turns over.\nAuto-finish shows up once no card is face down.\nYour game keeps when you close the window or the game.\n\nClick to close."; private static Settings S => Plugin.Settings; internal static bool IsMouseOver { get; private set; } private bool CanOfferAutoFinish { get { if (_autoFinishing || !_game.CanAutoFinish) { return false; } int num = _game.Moves * 2 + (_game.DrawThree ? 1 : 0); if (num != _autoCheckedAt) { _autoCheckedAt = num; _autoWins = _game.AutoFinishWins(); } return _autoWins; } } private float TableauTop => 51 * _scale; private void Awake() { _instance = this; _blocker = new ClickBlocker("OnTogetherMods CardTable ClickBlocker"); _store.Load(); if (_game.Load(_store.SavedGame)) { _wonCounted = _game.Won; _showWin = _game.Won; } else { _game.Deal(_random); } _game.DrawThree = S.DrawThree.Value; RebuildWhere(); } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; IsMouseOver = false; } if (_saveAt >= 0f) { SaveNow(); } _art?.Destroy(); _blocker?.Destroy(); } private void OnApplicationQuit() { SaveNow(); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); bool num = ((Scene)(ref activeScene)).buildIndex == 2; bool iconClicked = _iconClicked; _iconClicked = false; if (num && (iconClicked || ((int)S.WindowKey.Value != 0 && Input.GetKeyDown(S.WindowKey.Value) && !IsTyping()))) { Toggle(); } if (!num && _open) { Close(); } List<Action> list = _clicks.ToList(); _clicks.Clear(); foreach (Action item in list) { item(); } _game.DrawThree = S.DrawThree.Value; float now = Time.unscaledTime; if (_open && !PanelStack.Hidden && _game.Started && !_game.Won) { _game.Seconds += Time.unscaledDeltaTime; } if (_autoFinishing && now >= _nextAutoStep) { AutoStep(now); } if (_slides.Count > 0) { foreach (int item2 in (from p in _slides where now >= p.Value.Start + 0.16f select p.Key).ToList()) { _slides.Remove(item2); } } if (_saveAt >= 0f && now >= _saveAt) { SaveNow(); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } bool flag = _open && Time.frameCount - _drawnFrame <= 2; IsMouseOver = flag && ClickBlocker.MouseIn(_screenRect); _blocker?.Update(flag, _screenRect); } private void Toggle() { if (_open) { Close(); } else { Open(); } } private void Open() { _open = true; if (!S.HelpSeen.Value) { _help = true; S.HelpSeen.Value = true; } } private void Close() { _open = false; _help = false; _statsBox = false; _confirmUntil = -1f; _autoFinishing = false; _pressed = false; _dragging = false; _windowDragging = false; _slides.Clear(); SaveNow(); } private void MarkDirty() { if (_saveAt < 0f) { _saveAt = Time.unscaledTime + 2f; } } private void SaveNow() { _saveAt = -1f; _store.Save(_game); } private bool Change(Func<bool> action, Dictionary<int, Vector2> before = null) { //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_0074: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) float unscaledTime = Time.unscaledTime; if (before == null) { before = VisualPositions(unscaledTime); } bool[] array = new bool[52]; for (int i = 0; i < 52; i++) { array[i] = VisualFaceUp(i, unscaledTime); } if (!action()) { return false; } RebuildWhere(); if (S.Animations.Value && _scale > 0) { for (int j = 0; j < 52; j++) { Vector2 val = Target(j); if (before.TryGetValue(j, out var value)) { Vector2 val2 = value - val; if (((Vector2)(ref val2)).sqrMagnitude > 0.25f) { _slides[j] = new Slide { From = value, Start = unscaledTime, StartFaceUp = array[j] }; } } } } else { _slides.Clear(); } _confirmUntil = -1f; if (!_game.Counted && _game.Started) { _game.Counted = true; _store.Stats.Played++; } if (_game.Won && !_wonCounted) { Won(unscaledTime); } MarkDirty(); return true; } private void Won(float now) { _wonCounted = true; _autoFinishing = false; SolitaireStats stats = _store.Stats; stats.Won++; stats.Streak++; stats.BestStreak = Math.Max(stats.BestStreak, stats.Streak); if (stats.BestSeconds <= 0.0 || _game.Seconds < stats.BestSeconds) { stats.BestSeconds = _game.Seconds; } if (stats.FewestMoves <= 0 || _game.Moves < stats.FewestMoves) { stats.FewestMoves = _game.Moves; } _showWin = true; _wonAt = now; _confetti.Clear(); for (int i = 0; i < 48; i++) { _confetti.Add(new Confetto { Suit = _random.Next(4), X = (float)_random.NextDouble(), Y = (0f - (float)_random.NextDouble()) * 1.2f, Speed = 0.25f + (float)_random.NextDouble() * 0.35f, Sway = 4f + (float)_random.NextDouble() * 10f, Phase = (float)_random.NextDouble() * 6.3f }); } SaveNow(); Plugin.Log.LogInfo((object)$"Solitaire won in {_game.Moves} moves, {TimeText(_game.Seconds)}."); } private void NewGame() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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) if (_game.Started && !_game.Won) { _store.Stats.Streak = 0; } _game.Deal(_random); _game.DrawThree = S.DrawThree.Value; _wonCounted = false; _showWin = false; _confetti.Clear(); _autoFinishing = false; _autoCheckedAt = -1; _confirmUntil = -1f; _pressed = false; _dragging = false; _slides.Clear(); RebuildWhere(); if (S.Animations.Value && _scale > 0) { Vector2 val = CardPos(PileId.Stock, 0); float num = Time.unscaledTime; foreach (int item in _game.DealOrder()) { _slides[item] = new Slide { From = val, Start = num, StartFaceUp = false }; num += 0.03f; } } SaveNow(); } private void ClickNewGame() { float unscaledTime = Time.unscaledTime; if (_game.Started && !_game.Won && unscaledTime > _confirmUntil) { _confirmUntil = unscaledTime + 3f; } else { NewGame(); } } private void StartAutoFinish() { _autoFinishing = true; _game.StartAutoFinish(); _nextAutoStep = Time.unscaledTime; } private void AutoStep(float now) { _nextAutoStep = now + 0.09f; if (!Change(() => _game.AutoFinishStep())) { _autoFinishing = false; } } private void ClickCard(PileId pile, int index) { if (pile == PileId.Stock) { Change(() => _game.Draw()); return; } PileId? to = _game.BestMove(pile, index); if (to.HasValue) { Change(() => _game.Move(pile, index, to.Value)); } } private void Drop(float now) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, Vector2> dictionary = VisualPositions(now); List<int> list = DraggedCards().ToList(); PileId? target = _dropTarget; _dragging = false; _pressed = false; _dropTarget = null; if ((target.HasValue && Change(() => _game.Move(_pressPile, _pressIndex, target.Value), dictionary)) || !S.Animations.Value) { return; } foreach (int item in list) { _slides[item] = new Slide { From = dictionary[item], Start = now, StartFaceUp = true }; } } private void RebuildWhere() { Note(PileId.Stock); Note(PileId.Waste); for (int i = 0; i < 4; i++) { Note(PileId.Foundation(i)); } for (int j = 0; j < 7; j++) { Note(PileId.Tableau(j)); } } private void Note(PileId pile) { List<int> list = _game.Pile(pile); for (int i = 0; i < list.Count; i++) { _pileOf[list[i]] = pile; _indexOf[list[i]] = i; } } private float Column(int column) { return column * 37 * _scale; } private int Fanned() { int count = _game.Waste.Count; if (count != 0) { return Mathf.Clamp(_game.WasteFanned, 1, Math.Min(3, count)); } return 0; } private void Steps(int pile, out float down, out float up) { int count = _game.Tableau[pile].Count; int num = _game.FaceDown[pile]; int num2 = count - num; down = 4 * _scale; up = 13 * _scale; float num3 = 115 * _scale; if ((float)num * down + (float)Math.Max(0, num2 - 1) * up > num3 && num2 > 1) { up = Math.Max(7 * _scale, (num3 - (float)num * down) / (float)(num2 - 1)); } if ((float)num * down + (float)Math.Max(0, num2 - 1) * up > num3 && num > 0) { down = Math.Max(_scale, (num3 - (float)Math.Max(0, num2 - 1) * up) / (float)num); } } private Vector2 CardPos(PileId pile, int index) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) switch (pile.Kind) { case PileKind.Stock: return new Vector2(Column(0), 0f); case PileKind.Waste: { int num3 = _game.Waste.Count - Fanned(); return new Vector2(Column(1) + (float)(Math.Max(0, index - num3) * 18 * _scale), 0f); } case PileKind.Foundation: return new Vector2(Column(3 + pile.Index), 0f); default: { Steps(pile.Index, out var down, out var up); int num = _game.FaceDown[pile.Index]; float num2 = ((index < num) ? ((float)index * down) : ((float)num * down + (float)(index - num) * up)); return new Vector2(Column(pile.Index), TableauTop + Mathf.Floor(num2)); } } } private Vector2 Target(int card) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return CardPos(_pileOf[card], _indexOf[card]); } private bool IsDragged(int card) { if (_dragging && _pileOf[card] == _pressPile) { return _indexOf[card] >= _pressIndex; } return false; } private IEnumerable<int> DraggedCards() { List<int> cards = _game.Pile(_pressPile); for (int i = Math.Max(0, _pressIndex); i < cards.Count; i++) { yield return cards[i]; } } private static float Ease(float t) { return 1f - (1f - t) * (1f - t) * (1f - t); } private Vector2 VisualPos(int card, float now) { //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_000a: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (IsDragged(card)) { return _dragAt + CardPos(_pressPile, _indexOf[card]) - CardPos(_pressPile, _pressIndex); } Vector2 val = Target(card); if (_slides.TryGetValue(card, out var value)) { float num = (now - value.Start) / 0.16f; if (num <= 0f) { return value.From; } if (num < 1f) { return Vector2.Lerp(value.From, val, Ease(num)); } } return val; } private bool VisualFaceUp(int card, float now) { if (_slides.TryGetValue(card, out var value) && (now - value.Start) / 0.16f < 0.5f) { return value.StartFaceUp; } return _game.IsFaceUp(_pileOf[card], _indexOf[card]); } private bool IsSliding(int card, float now) { if (_slides.TryGetValue(card, out var value)) { return now < value.Start + 0.16f; } return false; } private Dictionary<int, Vector2> VisualPositions(float now) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, Vector2> dictionary = new Dictionary<int, Vector2>(52); for (int i = 0; i < 52; i++) { dictionary[i] = VisualPos(i, now); } return dictionary; } private Rect CardRect(Vector2 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return new Rect(pos.x, pos.y, (float)(32 * _scale), (float)(44 * _scale)); } private bool HitTest(Vector2 at, out PileId pile, out int index) { //IL_0029: 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_0036: Unknown result type (might be due