Decompiled source of Tournament Formats v0.5.2
BepInEx/plugins/TournamentFormats/TournamentFormats.dll
Decompiled a day 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.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using I2.Loc; using Microsoft.CodeAnalysis; using Pathfinding; using TMPro; using TournamentFormats.Ui; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Tournament Formats")] [assembly: AssemblyDescription("More ways to run the tournaments you host: single elimination.")] [assembly: AssemblyCompany("Dimwit's")] [assembly: AssemblyProduct("Tournament Formats")] [assembly: AssemblyCopyright("Copyright (c) 2026 Dimwit's")] [assembly: AssemblyVersion("0.2.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace TournamentFormats { internal static class Art { private static readonly Dictionary<string, Sprite?> Cache = new Dictionary<string, Sprite>(); private static Sprite? won; private static Sprite? lost; public static Sprite Mark(bool win) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0085: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) if (win && (Object)(object)won != (Object)null && (Object)(object)won.texture != (Object)null) { return won; } if (!win && (Object)(object)lost != (Object)null && (Object)(object)lost.texture != (Object)null) { return lost; } Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true) { filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1, name = (win ? "TournamentFormats_won" : "TournamentFormats_lost") }; Color val2 = (win ? new Color(0.18f, 0.72f, 0.3f) : new Color(0.86f, 0.2f, 0.2f)); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.08f, 0.1f, 0.12f); (Vector2, Vector2)[] array = ((!win) ? new(Vector2, Vector2)[2] { (new Vector2(0.32f, 0.32f), new Vector2(0.68f, 0.68f)), (new Vector2(0.32f, 0.68f), new Vector2(0.68f, 0.32f)) } : new(Vector2, Vector2)[2] { (new Vector2(0.27f, 0.52f), new Vector2(0.44f, 0.33f)), (new Vector2(0.44f, 0.33f), new Vector2(0.75f, 0.68f)) }); Color[] array2 = (Color[])(object)new Color[16384]; Vector2 val4 = default(Vector2); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { ((Vector2)(ref val4))..ctor(((float)j + 0.5f) / 128f, ((float)i + 0.5f) / 128f); float num = Vector2.Distance(val4, new Vector2(0.5f, 0.5f)); float num2 = 0.01171875f; float a = Mathf.Clamp01((0.48f - num) / num2); float num3 = Mathf.Clamp01((num - 0.41f) / num2); Color val5 = Color.Lerp(val2, val3, num3); float num4 = 1f; (Vector2, Vector2)[] array3 = array; for (int k = 0; k < array3.Length; k++) { (Vector2, Vector2) tuple = array3[k]; Vector2 item = tuple.Item1; Vector2 item2 = tuple.Item2; num4 = Mathf.Min(num4, Segment(val4, item, item2)); } float num5 = Mathf.Clamp01((0.075f - num4) / num2); val5 = Color.Lerp(val5, Color.white, num5); val5.a = a; array2[i * 128 + j] = val5; } } val.SetPixels(array2); val.Apply(true); Object.DontDestroyOnLoad((Object)(object)val); Sprite val6 = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f); Object.DontDestroyOnLoad((Object)(object)val6); if (win) { won = val6; } else { lost = val6; } return val6; } private static float Segment(Vector2 p, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / Mathf.Max(1E-06f, ((Vector2)(ref val)).sqrMagnitude)); return Vector2.Distance(p, a + val * num); } public static Sprite? Get(string name) { //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) //IL_008c: 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: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name)) { return null; } if (Cache.TryGetValue(name, out Sprite value) && ((Object)(object)value == (Object)null || (Object)(object)value.texture != (Object)null)) { return value; } Sprite val = null; try { string path = Path.Combine(Path.Combine(Path.GetDirectoryName(typeof(Art).Assembly.Location) ?? "", "art"), name + ".png"); if (File.Exists(path)) { Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, true) { filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1, name = "TournamentFormats_" + name }; if (ImageConversion.LoadImage(val2, File.ReadAllBytes(path))) { Object.DontDestroyOnLoad((Object)(object)val2); val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val).name = "TournamentFormats_" + name; Object.DontDestroyOnLoad((Object)(object)val); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Couldn't load art/" + name + ".png: " + ex.Message)); } Cache[name] = val; return val; } } internal static class Bracket { public sealed class RoundResult { public List<int> Order = new List<int>(); public List<int> KnockedOut = new List<int>(); public bool Finished; public int Unclear; } public static readonly int[] Sizes = new int[3] { 8, 16, 32 }; public static bool ValidSize(int players) { return Array.IndexOf(Sizes, players) >= 0; } public static bool ValidBracket(int players) { if (players != 4) { return ValidSize(players); } return true; } public static int Rounds(int players) { return players switch { 4 => 2, 8 => 3, 16 => 4, 32 => 5, _ => throw new ArgumentException("A knockout bracket needs 4, 8, 16 or 32 players."), }; } public static int CutSize(int players) { if (players < 16) { return 4; } return 8; } public static int[] Seeding(int cut) { return cut switch { 8 => new int[8] { 0, 7, 3, 4, 1, 6, 2, 5 }, 4 => new int[4] { 0, 3, 1, 2 }, _ => throw new ArgumentException("A top cut is 4 or 8 players."), }; } public static int Playing(int players, int round) { int num = Rounds(players); if (round < 0 || round >= num) { throw new ArgumentOutOfRangeException("round"); } if (round != num - 1) { return players >> round; } return 4; } public static int Step(int current, int direction) { if (direction > 0) { int[] sizes = Sizes; foreach (int num in sizes) { if (num > current) { return num; } } return Sizes[Sizes.Length - 1]; } for (int num2 = Sizes.Length - 1; num2 >= 0; num2--) { if (Sizes[num2] < current) { return Sizes[num2]; } } return Sizes[0]; } public static int Snap(int current) { int num = Sizes[0]; int[] sizes = Sizes; foreach (int num2 in sizes) { if (Math.Abs(num2 - current) <= Math.Abs(num - current)) { num = num2; } } return num; } public static RoundResult Advance(int count, Func<int, bool> won, int players, int round) { int num = Rounds(players); int num2 = Playing(players, round); if (count < num2) { throw new ArgumentException("Fewer entrants than the round needs."); } RoundResult roundResult = new RoundResult(); List<int> list = new List<int>(); List<int> list2 = new List<int>(); for (int i = 0; i < num2; i += 2) { int num3 = i + 1; bool num4 = won(i); bool flag = won(num3); if (num4 == flag) { roundResult.Unclear++; } bool flag2 = num4 || !flag; list.Add(flag2 ? i : num3); list2.Add(flag2 ? num3 : i); } if (round == num - 1) { roundResult.Order.AddRange(new int[4] { list[0], list2[0], list[1], list2[1] }); roundResult.Finished = true; } else { roundResult.Order.AddRange(list); roundResult.Order.AddRange(list2); if (round + 1 < num - 1) { for (int j = 0; j < list2.Count; j++) { roundResult.KnockedOut.Add(list.Count + j); } } } for (int k = num2; k < count; k++) { roundResult.Order.Add(k); } return roundResult; } } internal static class BracketSheet { private sealed class View { private readonly string name; public GameObject? Root; public string BuiltFor = ""; private readonly List<TournamentPairingUIGrp> rails = new List<TournamentPairingUIGrp>(); private readonly List<Image> badges = new List<Image>(); private readonly List<(Image? A, Image? B)> marks = new List<(Image, Image)>(); private readonly List<(TextMeshProUGUI? A, TextMeshProUGUI? B)> names = new List<(TextMeshProUGUI, TextMeshProUGUI)>(); private static bool railDescribed; private float width; private float height; private float top; private static Image? MarkOn(Image? face) { //IL_0030: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0079: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)face == (Object)null) { return null; } GameObject val = new GameObject("BracketResult", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(((Component)face).transform, false); Image component = val.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; ((Behaviour)component).enabled = false; RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 0f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(1f, 0f); Rect rect = ((Graphic)face).rectTransform.rect; val2.sizeDelta = ((Rect)(ref rect)).size * 0.48f; rect = ((Graphic)face).rectTransform.rect; val2.anchoredPosition = ((Rect)(ref rect)).size * 0.03f * new Vector2(-1f, 1f); return component; } private static TextMeshProUGUI? NameOn(Image? face, TextMeshProUGUI? style) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_009c: 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) //IL_00b1: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)face == (Object)null || (Object)(object)style == (Object)null) { return null; } GameObject val = new GameObject("BracketName", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(((Component)face).transform, false); Image component = val.GetComponent<Image>(); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.6f); ((Graphic)component).raycastTarget = false; RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(-0.15f, 0.72f); val2.anchorMax = new Vector2(1.15f, 1f); Vector2 offsetMin = (val2.offsetMax = Vector2.zero); val2.offsetMin = offsetMin; GameObject val3 = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val3.transform.SetParent(val.transform, false); TextMeshProUGUI component2 = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).font = ((TMP_Text)style).font; ((TMP_Text)component2).fontSharedMaterial = ((TMP_Text)style).fontSharedMaterial; ((Graphic)component2).color = Color.white; ((TMP_Text)component2).alignment = (TextAlignmentOptions)514; ((TMP_Text)component2).enableAutoSizing = true; ((TMP_Text)component2).fontSizeMin = 1f; ((TMP_Text)component2).fontSizeMax = 200f; ((TMP_Text)component2).enableWordWrapping = false; ((Graphic)component2).raycastTarget = false; RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; offsetMin = (val4.offsetMax = Vector2.zero); val4.offsetMin = offsetMin; val.SetActive(false); return component2; } private static void ShowName(TextMeshProUGUI? text, string name) { if (!((Object)(object)text == (Object)null)) { bool flag = !string.IsNullOrEmpty(name); if (flag) { ((TMP_Text)text).text = name; } ((Component)((TMP_Text)text).transform.parent).gameObject.SetActive(flag); } } private static void Describe(StringBuilder sb, Transform t, int depth, Transform rail) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00c3: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown if (depth > 4) { return; } RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); string text = string.Join(",", from c in ((Component)t).GetComponents<Component>() where (Object)(object)c != (Object)null && !(c is Transform) select ((object)c).GetType().Name); Image component = ((Component)t).GetComponent<Image>(); TextMeshProUGUI component2 = ((Component)t).GetComponent<TextMeshProUGUI>(); string text2 = ""; if ((Object)(object)val != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Vector3 val2 = rail.InverseTransformPoint(array[0]); Vector3 val3 = rail.InverseTransformPoint(array[2]); text2 = $" x {val2.x:0.###}..{val3.x:0.###} y {val2.y:0.###}..{val3.y:0.###} anchors {val.anchorMin}-{val.anchorMax}"; } sb.Append($"\n{new string(' ', depth * 2)}{((Object)t).name} [{text}] active {((Component)t).gameObject.activeSelf}{text2}" + (((Object)(object)component != (Object)null) ? string.Format(" sprite {0} colour {1} type {2}", ((Object)(object)component.sprite != (Object)null) ? ((Object)component.sprite).name : "none", ((Graphic)component).color, component.type) : "") + (((Object)(object)component2 != (Object)null) ? $" text \"{((TMP_Text)component2).text}\" size {((TMP_Text)component2).fontSize:0.###}" : "")); foreach (Transform item in t) { Transform t2 = item; Describe(sb, t2, depth + 1, rail); } } public View(string name) { this.name = name; } private Vector2 Pos(float x, float y) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Vector2(x * width, 0f - (top + y * height)); } public void Destroy() { foreach (TournamentPairingUIGrp rail in rails) { ours.Remove(rail); } if ((Object)(object)Root != (Object)null) { Object.Destroy((Object)(object)Root); } Root = null; BuiltFor = ""; rails.Clear(); badges.Clear(); marks.Clear(); names.Clear(); } public void Build(SheetLayout layout, TournamentPairingUIGrp template, float containerWidth, TextMeshProUGUI? style, RectTransform parent, RectTransform? place, RectTransform? title, string key, bool describe, bool backdrop, float squash = 1f, float upright = 1f) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0063: 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_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c4: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_071f: Unknown result type (might be due to invalid IL or missing references) //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0722: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0766: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_082b: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_083c: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0876: Unknown result type (might be due to invalid IL or missing references) //IL_087d: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_0952: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_0978: Unknown result type (might be due to invalid IL or missing references) //IL_097d: Unknown result type (might be due to invalid IL or missing references) //IL_09d0: Unknown result type (might be due to invalid IL or missing references) //IL_09da: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Unknown result type (might be due to invalid IL or missing references) //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_0a6c: Unknown result type (might be due to invalid IL or missing references) Destroy(); Root = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); Root.GetComponent<LayoutElement>().ignoreLayout = true; RectTransform val = (RectTransform)Root.transform; ((Transform)val).SetParent((Transform)(object)parent, false); ((Transform)val).localScale = Vector3.one; val.pivot = new Vector2(0.5f, 0.5f); Vector2 val8 = default(Vector2); if ((Object)(object)place != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; place.GetWorldCorners(array); Vector3 val2 = ((Transform)parent).InverseTransformPoint(array[0]); Vector3 val3 = ((Transform)parent).InverseTransformPoint(array[2]); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(Mathf.Min(val2.x, val3.x), Mathf.Min(val2.y, val3.y), val2.z); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(Mathf.Max(val2.x, val3.x), Mathf.Max(val2.y, val3.y), val2.z); (Vector3, Vector3)? tuple = TvView((Transform)(object)parent, (array[0] + array[2]) / 2f); if (tuple.HasValue) { var (val6, val7) = tuple.Value; ((Vector3)(ref val4))..ctor(Mathf.Max(val4.x, val6.x), Mathf.Max(val4.y, val6.y), val4.z); ((Vector3)(ref val5))..ctor(Mathf.Min(val5.x, val7.x), Mathf.Min(val5.y, val7.y), val5.z); if (describe) { Plugin.Log.LogInfo((object)$"Bracket sheet: the TV's camera shows {val6.x:0.###}..{val7.x:0.###} x {val6.y:0.###}..{val7.y:0.###} of the screen."); } } ((Vector2)(ref val8))..ctor(0.5f, 0.5f); val.anchorMax = val8; val.anchorMin = val8; val.sizeDelta = new Vector2(Mathf.Abs(val5.x - val4.x), Mathf.Abs(val5.y - val4.y)) * 0.96f; ((Transform)val).localPosition = (val4 + val5) / 2f; } else { val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val8 = (val.offsetMin = (val.offsetMax = Vector2.zero)); } ((Transform)val).SetAsLastSibling(); Rect rect = val.rect; width = ((Rect)(ref rect)).width; top = 0f; if ((Object)(object)title != (Object)null) { Vector3[] array2 = (Vector3[])(object)new Vector3[4]; title.GetWorldCorners(array2); float num = float.MaxValue; Vector3[] array3 = array2; foreach (Vector3 val10 in array3) { num = Mathf.Min(num, ((Transform)val).InverseTransformPoint(val10).y); } if (num < ((Rect)(ref rect)).yMax && num > ((Rect)(ref rect)).yMin + ((Rect)(ref rect)).height * 0.5f) { top = ((Rect)(ref rect)).yMax - num + ((Rect)(ref rect)).height * 0.01f; } } height = ((Rect)(ref rect)).height - top; Sprite val11 = (backdrop ? Art.Get("bracket_backdrop") : null); if ((Object)(object)val11 != (Object)null) { GameObject val12 = new GameObject("BracketBackdrop", new Type[2] { typeof(RectTransform), typeof(Image) }); val12.transform.SetParent((Transform)(object)val, false); Image component = val12.GetComponent<Image>(); component.sprite = val11; ((Graphic)component).raycastTarget = false; RectTransform val13 = (RectTransform)val12.transform; val13.anchorMin = Vector2.zero; val13.anchorMax = Vector2.one; val13.offsetMin = Vector2.zero; val13.offsetMax = new Vector2(0f, 0f - top); } RectTransform val14 = (RectTransform)((Component)template).transform; float num2 = ((Mathf.Abs(((Transform)val14).localScale.x) > 1E-05f) ? ((Transform)val14).localScale.x : 1f); GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)val, false); obj.SetActive(true); Rect val15 = Compact(obj); Object.DestroyImmediate((Object)(object)obj); if (((Rect)(ref val15)).width <= 0f || ((Rect)(ref val15)).height <= 0f) { ((Rect)(ref val15))..ctor((0f - width) / 6f, (0f - height) / 20f, width / 3f, height / 10f); } Vector2 val16 = default(Vector2); ((Vector2)(ref val16))..ctor(((Rect)(ref val15)).width * num2, ((Rect)(ref val15)).height * num2 * squash); float num3 = 0.9f; for (int j = 0; j < layout.cells.Count; j++) { for (int k = j + 1; k < layout.cells.Count; k++) { SheetCell sheetCell = layout.cells[j]; SheetCell sheetCell2 = layout.cells[k]; if (Mathf.Abs(sheetCell.x - sheetCell2.x) < 0.001f) { num3 = Mathf.Min(num3, Mathf.Abs(sheetCell.y - sheetCell2.y)); } } } float num4 = width / (float)Math.Max(1, layout.columns); float num5 = height * num3; float num6 = Mathf.Min(num4 * 0.8f / val16.x, num5 * 0.85f / val16.y); float num7 = Mathf.Max(height * 0.002f, val16.y * num6 * 0.05f); float num8 = height * 0.1f; foreach (SheetLine line in layout.lines) { GameObject val17 = new GameObject("BracketLine", new Type[2] { typeof(RectTransform), typeof(Image) }); val17.transform.SetParent((Transform)(object)val, false); Image component2 = val17.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0.55f); ((Graphic)component2).raycastTarget = false; RectTransform val18 = (RectTransform)val17.transform; val8 = (val18.anchorMin = (val18.anchorMax = new Vector2(0f, 1f))); val18.pivot = new Vector2(0.5f, 0.5f); Vector2 val21 = Pos(line.x1, line.y1); Vector2 val22 = Pos(line.x2, line.y2); val18.anchoredPosition = (val21 + val22) / 2f; val18.sizeDelta = new Vector2(Mathf.Abs(val22.x - val21.x) + num7, Mathf.Abs(val22.y - val21.y) + num7); } foreach (SheetCell cell in layout.cells) { GameObject val23 = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)val, false); ((Object)val23).name = "BracketRail"; LayoutElement[] components = val23.GetComponents<LayoutElement>(); for (int i = 0; i < components.Length; i++) { components[i].ignoreLayout = true; } TournamentPairingUIGrp component3 = val23.GetComponent<TournamentPairingUIGrp>(); val23.SetActive(true); if ((Object)(object)((UIElementBase)component3).m_TopUIGrp != (Object)null) { ((UIElementBase)component3).m_TopUIGrp.SetActive(true); } Compact(val23); RectTransform val24 = (RectTransform)val23.transform; val8 = (val24.anchorMin = (val24.anchorMax = new Vector2(0f, 1f))); ((Transform)val24).localScale = new Vector3(num2 * num6, num2 * num6 * squash, 1f); val24.anchoredPosition = Pos(cell.x, cell.y) - new Vector2(((Rect)(ref val15)).center.x * num2 * num6, ((Rect)(ref val15)).center.y * num2 * num6 * squash); ours.Add(component3); rails.Add(component3); marks.Add((MarkOn(component3.m_CustomerPic_A), MarkOn(component3.m_CustomerPic_B))); names.Add((NameOn(component3.m_CustomerPic_A, component3.m_TableNumber), NameOn(component3.m_CustomerPic_B, component3.m_TableNumber))); float num9 = val16.y * num6 * 0.8f; badges.Add(Picture((Transform)(object)val, null, Pos(cell.x, cell.y) + new Vector2(val16.x * num6 * 0.5f + num9 / upright * 0.45f, 0f), num9 / upright, upright)); if (cell.label != "" && (Object)(object)style != (Object)null) { Caption(style, (Transform)(object)val, cell.label, cell.labelIcon, Pos(cell.x, cell.y) - new Vector2(0f, val16.y * num6 * 0.5f + num8 * 0.3f), num4, num8 * 0.5f, upright); } } if ((Object)(object)style != (Object)null) { foreach (SheetText header in layout.headers) { Caption(style, (Transform)(object)val, header.text, header.icon, Pos(header.x, header.y), num4 * 0.86f, num8 * 0.55f, upright); } } BuiltFor = key; if (describe && !railDescribed) { railDescribed = true; StringBuilder stringBuilder = new StringBuilder("Bracket sheet: one row of the tournament screen:"); Describe(stringBuilder, ((Component)template).transform, 0, ((Component)template).transform); Plugin.Log.LogInfo((object)stringBuilder.ToString()); } if (describe) { Plugin.Log.LogInfo((object)($"Bracket sheet: {layout.kind}, {layout.cells.Count} matches in {layout.columns} columns; " + string.Format("area {0:0.###}x{1:0.###} in '{2}'{3}, title gap {4:0.###}; ", ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, ((Object)parent).name, ((Object)(object)place != (Object)null) ? (" over '" + ((Object)place).name + "'") : "", top) + $"compact rows {((Rect)(ref val15)).width:0.###}x{((Rect)(ref val15)).height:0.###} at scale {num2:0.###}, drawn at {num6:0.###}; upright {upright:0.###}.")); } } private static void Show(Image? mark, int result) { if (!((Object)(object)mark == (Object)null)) { bool flag = result == 1 || result == 2; if (flag) { mark.sprite = Art.Mark(result == 1); } ((Behaviour)mark).enabled = flag; } } public void Fill(SheetLayout layout) { CustomerManager customers = Game.Customers; if ((Object)(object)customers == (Object)null) { return; } for (int i = 0; i < layout.cells.Count && i < rails.Count; i++) { TournamentPairingUIGrp val = rails[i]; if (!((Object)(object)val == (Object)null)) { SheetCell sheetCell = layout.cells[i]; val.ResetUI(); if ((Object)(object)val.m_TableNumber != (Object)null) { ((TMP_Text)val.m_TableNumber).text = ((sheetCell.table > 0) ? sheetCell.table.ToString() : ""); } Side(val, val.m_CustomerPic_A, val.m_Win_A, val.m_Lose_A, val.m_Ranking_A, val.m_RankingIcon_A, sheetCell.a, customers); Side(val, val.m_CustomerPic_B, val.m_Win_B, val.m_Lose_B, val.m_Ranking_B, val.m_RankingIcon_B, sheetCell.b, customers); if (i < marks.Count) { Show(marks[i].A, sheetCell.a.result); Show(marks[i].B, sheetCell.b.result); } if (i < names.Count) { ShowName(names[i].A, sheetCell.a.known ? sheetCell.a.name : ""); ShowName(names[i].B, sheetCell.b.known ? sheetCell.b.name : ""); } if (i < badges.Count && (Object)(object)badges[i] != (Object)null) { Sprite val2 = Art.Get(Icons.Badge(sheetCell)); badges[i].sprite = val2; ((Behaviour)badges[i]).enabled = (Object)(object)val2 != (Object)null; } } } } } public static KnockoutLog Log = new KnockoutLog(); private static readonly HashSet<TournamentPairingUIGrp> ours = new HashSet<TournamentPairingUIGrp>(); private static readonly View Tv = new View("DimwitsBracketSheet"); private static readonly View Window = new View("DimwitsBracketWindowSheet"); private static GameObject? windowCanvas; private static RectTransform? windowArea; private static Palette windowPalette = Palette.Vanilla; private static TextMeshProUGUI? windowTitle; public static bool WindowOpen; private static DoubleElim? lastDouble; private static List<TopCutState.Qualifier>? lastEntrants; private static int lastDoubleDay = -1; public const string OverTitle = "Tournament over"; private static readonly string[] StatParts = new string[9] { "MatchWin", "GamePoint", "OMW", "OOMW", "RankingIcon", "Ranking", "DrawText", "LoseText", "WinText" }; private static readonly Color WonFrame = new Color(0.2f, 0.74f, 0.32f, 1f); private static readonly Color LostFrame = new Color(0.82f, 0.22f, 0.22f, 1f); private static readonly Color NoFrame = new Color(0.156f, 0.156f, 0.156f, 1f); public static bool Showing { get; private set; } public static void Apply(Harmony harmony) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(UIElementBase), "SetActive", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo == null) { Plugin.Log.LogWarning((object)"The game's tournament screen changed: no bracket sheet."); } else { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(BracketSheet), "KeepRailsHidden", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("The bracket sheet couldn't start: " + ex.Message)); } } private static void KeepRailsHidden(UIElementBase __instance, ref bool isActive) { if (isActive && Showing) { TournamentPairingUIGrp val = (TournamentPairingUIGrp)(object)((__instance is TournamentPairingUIGrp) ? __instance : null); if (val != null && !ours.Contains(val)) { isActive = false; } } } public static void Reset() { Tv.Destroy(); Window.Destroy(); if ((Object)(object)windowCanvas != (Object)null) { Object.Destroy((Object)(object)windowCanvas); } windowCanvas = null; WindowOpen = false; Showing = false; Log = new KnockoutLog(); lastDouble = null; lastEntrants = null; lastDoubleDay = -1; } public static void RecordRound(IList<Customer> list, int players, int round) { try { int currentDay = CPlayerData.m_CurrentDay; if (Log.players != players || Log.day != currentDay || (round == 0 && Log.rounds > 0)) { Log.Reset(players, currentDay); } Log.Record(round, Sides(list, players, round, decided: true)); } catch (Exception ex) { Plugin.Log.LogWarning((object)$"Bracket sheet: round {round + 1} couldn't be recorded: {ex.Message}"); } } private static CustomerTournamentData Data(Customer? c) { if (!((Object)(object)c == (Object)null)) { return c.GetCustomerTournamentData(); } return CPlayerData.m_PlayerTournamentData; } private static SheetSide SideOf(Customer? c, int seed) { CustomerTournamentData val = Data(c); return new SheetSide { known = true, player = ((Object)(object)c == (Object)null), model = (((Object)(object)c == (Object)null) ? (-1) : c.GetCustomerModelIndex()), female = ((Object)(object)c != (Object)null && c.m_IsFemale), name = (((Object)(object)c == (Object)null) ? "" : Others.NameFor(c.m_IsFemale, c.GetCustomerModelIndex())), seed = seed, result = (val.m_HasRegisteredTournamentResult ? (val.m_IsTournamentWin ? 1 : 2) : 0) }; } private static List<SheetSide> Sides(IList<Customer> list, int players, int round, bool decided) { int num = Bracket.Playing(players, round); int[] array = ((round == 0 && Formats.Hosted == "Swiss + top cut" && (players == 4 || players == 8)) ? Bracket.Seeding(players) : null); List<SheetSide> list2 = new List<SheetSide>(); for (int i = 0; i < num; i++) { list2.Add((i < list.Count) ? SideOf(list[i], (array != null) ? array[i] : (-1)) : new SheetSide()); } if (decided) { for (int j = 0; j + 1 < num; j += 2) { bool isTournamentWin = Data(list[j]).m_IsTournamentWin; bool isTournamentWin2 = Data(list[j + 1]).m_IsTournamentWin; bool flag = isTournamentWin || !isTournamentWin2; list2[j].result = (flag ? 1 : 2); list2[j + 1].result = ((!flag) ? 1 : 2); } } return list2; } public static void Tick() { try { SheetLayout sheetLayout; SheetLayout layout; if (Plugin.BracketSheetOn.Value || WindowOpen) { (sheetLayout, layout) = Current(); } else { sheetLayout = null; layout = null; } if (Plugin.BracketSheetOn.Value && sheetLayout != null) { ShowTv(sheetLayout); } else if (Plugin.BracketSheetOn.Value && OverNoSheet()) { ShowOver(); } else { HideTv(); } if (Formats.CarriesOn) { TextMeshProUGUI val = Game.Customers?.m_TournamentPairingScreen?.m_CurrentRound; if ((Object)(object)val != (Object)null && ((TMP_Text)val).text != Formats.Tomorrow) { ((TMP_Text)val).text = Formats.Tomorrow; } } if (WindowOpen) { ShowWindow(layout); } else { HideWindow(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Bracket sheet failed: " + ex.Message)); Tv.Destroy(); HideTv(); } } public static void ToggleWindow() { WindowOpen = !WindowOpen; Plugin.Log.LogInfo((object)(WindowOpen ? "Bracket window opened." : "Bracket window closed.")); Tick(); } public static void Keys() { //IL_0005: 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) KeyboardShortcut value = Plugin.BracketWindowKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ToggleWindow(); } } private static (SheetLayout? Tv, SheetLayout? Full) Current() { TournamentData tournamentData = CPlayerData.m_TournamentData; CustomerManager customers = Game.Customers; if (tournamentData == null || (Object)(object)customers == (Object)null || (Object)(object)customers.m_TournamentPairingScreen == (Object)null) { return (Tv: null, Full: null); } int currentDay = CPlayerData.m_CurrentDay; if (Formats.BracketOn && tournamentData.m_IsTournamentDay) { int tournamentMaxPlayerCount = tournamentData.m_TournamentMaxPlayerCount; if (!Bracket.ValidBracket(tournamentMaxPlayerCount)) { return (Tv: null, Full: null); } int round = Math.Min(tournamentData.m_TournamentCurrentRound, Bracket.Rounds(tournamentMaxPlayerCount) - 1); if (Log.players != tournamentMaxPlayerCount || Log.day != currentDay || (round == 0 && Log.rounds > 0)) { Log.Reset(tournamentMaxPlayerCount, currentDay); } List<SheetSide> live = Sides(customers.m_TournamentSortedCustomerList, tournamentMaxPlayerCount, round, decided: false); SheetLayout sheetLayout = Sheet.Knockout(tournamentMaxPlayerCount, (int r) => (r >= round) ? ((r != round) ? null : live) : Log.Round(r), round); return (Tv: sheetLayout, Full: sheetLayout); } SeriesState s; int liveRound; List<DoubleElim.Match> of; List<Customer> list; Dictionary<int, Customer?> here; if (Formats.SeriesOn && Formats.Hosted == "Double elimination" && Series.State.bracket != null && tournamentData.m_IsTournamentDay) { s = Series.State; lastDouble = s.bracket; lastEntrants = s.entrants; lastDoubleDay = currentDay; liveRound = s.round + 1; of = s.bracket.Of(liveRound); list = customers.m_TournamentSortedCustomerList; here = new Dictionary<int, Customer>(); foreach (Customer item in list) { int tournamentCustomerIndex = Data(item).m_TournamentCustomerIndex; if (!here.ContainsKey(tournamentCustomerIndex)) { here[tournamentCustomerIndex] = item; } Remember(s, tournamentCustomerIndex, item); } return (Tv: Sheet.Winners(s.bracket, Pick, liveRound), Full: Sheet.Double(s.bracket, Pick, liveRound)); } SeriesState s2; if (Formats.CarriesOn) { if (Formats.IsSeries(Formats.Hosted) && Series.State.bracket != null) { s2 = Series.State; return (Tv: Sheet.Winners(s2.bracket, Night, -1), Full: Sheet.Double(s2.bracket, Night, -1)); } int cut = TopCutState.Current.cut; if (Formats.Hosted == "Swiss + top cut" && (cut == 4 || cut == 8)) { int[] seeds = Bracket.Seeding(cut); List<TopCutState.Qualifier> q = TopCutState.Current.qualifiers; List<SheetSide> first = (from p in Enumerable.Range(0, cut) select QualifierSide(q, seeds[p])).ToList(); SheetLayout sheetLayout2 = Sheet.Knockout(cut, (int r) => (r != 0) ? null : first, -1); return (Tv: sheetLayout2, Full: sheetLayout2); } return (Tv: null, Full: null); } if (!tournamentData.m_IsTournamentDay && Log.finished && Log.day == currentDay) { SheetLayout sheetLayout3 = Sheet.Knockout(Log.players, Log.Round, -1); return (Tv: sheetLayout3, Full: sheetLayout3); } List<TopCutState.Qualifier> entrants; if (!tournamentData.m_IsTournamentDay && lastDouble != null && lastEntrants != null && lastDoubleDay == currentDay && lastDouble.Finished) { entrants = lastEntrants; return (Tv: Sheet.Winners(lastDouble, Done, -1), Full: Sheet.Double(lastDouble, Done, -1)); } return (Tv: null, Full: null); SheetSide Done(DoubleElim.Match m, bool isA) { return DoubleSide(m, isA, entrants, -1, null, null); } SheetSide Night(DoubleElim.Match m, bool isA) { return DoubleSide(m, isA, s2.entrants, -1, null, null); } SheetSide Pick(DoubleElim.Match m, bool isA) { return DoubleSide(m, isA, s.entrants, liveRound, of, list, here); } } private static SheetSide QualifierSide(List<TopCutState.Qualifier> qualifiers, int seed) { if (seed < 0 || seed >= qualifiers.Count) { return new SheetSide { seed = seed }; } TopCutState.Qualifier qualifier = qualifiers[seed]; return new SheetSide { known = (qualifier.player || qualifier.data != null), player = qualifier.player, model = ((qualifier.player || qualifier.data == null) ? (-1) : qualifier.data.m_CharacterModelIndex), female = (qualifier.data != null && qualifier.data.m_IsFemale), name = ((qualifier.player || qualifier.data == null) ? "" : Others.NameFor(qualifier.data.m_IsFemale, qualifier.data.m_CharacterModelIndex)), seed = seed }; } private static void Remember(SeriesState s, int id, Customer? c) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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) //IL_0085: 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_009d: Expected O, but got Unknown if (id < 0 || id >= s.players) { return; } while (s.entrants.Count < s.players) { s.entrants.Add(new TopCutState.Qualifier()); } TopCutState.Qualifier qualifier = s.entrants[id]; if (!qualifier.player && qualifier.data == null) { if ((Object)(object)c == (Object)null) { qualifier.player = true; return; } CustomerTournamentData customerTournamentData = c.GetCustomerTournamentData(); qualifier.data = new CustomerTournamentData { m_CharacterModelIndex = c.GetCustomerModelIndex(), m_IsFemale = c.m_IsFemale, m_TournamentCustomerIndex = id, m_TournamentWinCount = customerTournamentData.m_TournamentWinCount }; } } private static SheetSide DoubleSide(DoubleElim.Match m, bool isA, List<TopCutState.Qualifier> entrants, int liveRound, List<DoubleElim.Match>? of, List<Customer>? list, Dictionary<int, Customer?>? here = null) { int num = (isA ? m.a : m.b); if (num < 0) { return new SheetSide(); } SheetSide sheetSide; if (here != null && here.TryGetValue(num, out Customer value)) { sheetSide = SideOf(value, -1); sheetSide.result = 0; } else { if (num >= entrants.Count || (!entrants[num].player && entrants[num].data == null)) { return new SheetSide(); } TopCutState.Qualifier qualifier = entrants[num]; sheetSide = new SheetSide { known = true, player = qualifier.player, model = ((qualifier.player || qualifier.data == null) ? (-1) : qualifier.data.m_CharacterModelIndex), female = (qualifier.data != null && qualifier.data.m_IsFemale), name = ((qualifier.player || qualifier.data == null) ? "" : Others.NameFor(qualifier.data.m_IsFemale, qualifier.data.m_CharacterModelIndex)) }; } if (m.winner >= 0) { sheetSide.result = ((m.winner == num) ? 1 : 2); } else if (m.round == liveRound && of != null && list != null) { int num2 = 2 * of.IndexOf(m) + ((!isA) ? 1 : 0); if (num2 >= 0 && num2 < list.Count) { CustomerTournamentData val = Data(list[num2]); if (val.m_HasRegisteredTournamentResult) { sheetSide.result = (val.m_IsTournamentWin ? 1 : 2); } } } return sheetSide; } private static void ShowTv(SheetLayout layout) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) TournamentPairingScreen val = Game.Customers?.m_TournamentPairingScreen; if ((Object)(object)val == (Object)null) { return; } List<TournamentPairingUIGrp> tournamentPairingUIGrpList = val.m_TournamentPairingUIGrpList; if (tournamentPairingUIGrpList == null || tournamentPairingUIGrpList.Count == 0 || (Object)(object)tournamentPairingUIGrpList[0] == (Object)null) { return; } TournamentPairingUIGrp val2 = tournamentPairingUIGrpList[0]; Transform parent = ((Component)val2).transform.parent; RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val3 == null) { return; } RectTransform obj; if ((Object)(object)((Component)val3).GetComponent<Canvas>() == (Object)null) { Transform parent2 = ((Transform)val3).parent; RectTransform val4 = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); if (val4 != null) { obj = val4; goto IL_007f; } } obj = val3; goto IL_007f; IL_007f: RectTransform val5 = obj; RectTransform place = null; foreach (Transform item in (Transform)val5) { Transform val6 = item; if (((Object)val6).name == "BG") { RectTransform val7 = (RectTransform)(object)((val6 is RectTransform) ? val6 : null); if (val7 != null) { place = val7; } } } object[] obj2 = new object[4] { layout.kind, layout.cells.Count, layout.lines.Count, null }; Rect rect = val5.rect; obj2[3] = ((Rect)(ref rect)).size; string text = string.Format("tv:{0}:{1}:{2}:{3}", obj2); if ((Object)(object)Tv.Root == (Object)null || Tv.BuiltFor != text) { float num = ((Mathf.Abs(((Transform)val5).lossyScale.x) > 1E-06f) ? Mathf.Clamp(Mathf.Abs(((Transform)val5).lossyScale.y / ((Transform)val5).lossyScale.x), 0.1f, 1f) : 1f); View tv = Tv; rect = val3.rect; tv.Build(layout, val2, ((Rect)(ref rect)).width, val.m_CurrentRound, val5, place, ((Object)(object)val.m_CurrentRound != (Object)null) ? ((TMP_Text)val.m_CurrentRound).rectTransform : null, text, describe: true, backdrop: true, 1f, 1f / num); } if ((Object)(object)Tv.Root == (Object)null) { return; } if (!Showing) { Showing = true; foreach (TournamentPairingUIGrp item2 in tournamentPairingUIGrpList) { if ((Object)(object)item2 != (Object)null && !ours.Contains(item2) && (Object)(object)((UIElementBase)item2).m_TopUIGrp != (Object)null) { ((UIElementBase)item2).m_TopUIGrp.SetActive(false); } } } if (!Tv.Root.activeSelf) { Tv.Root.SetActive(true); } Tv.Fill(layout); } private static bool OverNoSheet() { TournamentData tournamentData = CPlayerData.m_TournamentData; if (tournamentData != null && tournamentData.m_IsTournamentDayOver && !tournamentData.m_IsTournamentDay) { return !Formats.CarriesOn; } return false; } private static void ShowOver() { TournamentPairingScreen val = Game.Customers?.m_TournamentPairingScreen; if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)Tv.Root != (Object)null && Tv.Root.activeSelf) { Tv.Root.SetActive(false); } if (!Showing) { Showing = true; foreach (TournamentPairingUIGrp item in val.m_TournamentPairingUIGrpList ?? new List<TournamentPairingUIGrp>()) { if ((Object)(object)item != (Object)null && !ours.Contains(item) && (Object)(object)((UIElementBase)item).m_TopUIGrp != (Object)null) { ((UIElementBase)item).m_TopUIGrp.SetActive(false); } } } if ((Object)(object)val.m_CurrentRound != (Object)null && ((TMP_Text)val.m_CurrentRound).text != "Tournament over") { ((TMP_Text)val.m_CurrentRound).text = "Tournament over"; } } private static void HideTv() { if ((Object)(object)Tv.Root != (Object)null && Tv.Root.activeSelf) { Tv.Root.SetActive(false); } if (Showing) { Showing = false; CustomerManager customers = Game.Customers; TournamentData tournamentData = CPlayerData.m_TournamentData; TournamentPairingScreen val = (((Object)(object)customers != (Object)null) ? customers.m_TournamentPairingScreen : null); if (!((Object)(object)val == (Object)null) && tournamentData != null && (tournamentData.m_IsTournamentDay || tournamentData.m_IsTournamentDayOver)) { val.ShowPairingScreen(true, tournamentData.m_TournamentMaxPlayerCount); val.RefreshAllCustomerData(customers.m_TournamentSortedCustomerList); val.UpdateCurrentRound(tournamentData.m_TournamentCurrentRound, tournamentData.m_TournamentMaxRound); SingleElimination.Sync(); } } } private static void ShowWindow(SheetLayout? layout) { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) TournamentPairingScreen val = Game.Customers?.m_TournamentPairingScreen; TournamentPairingUIGrp val2 = (((Object)(object)val != (Object)null && val.m_TournamentPairingUIGrpList != null && val.m_TournamentPairingUIGrpList.Count > 0) ? val.m_TournamentPairingUIGrpList[0] : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { Transform parent = ((Component)val2).transform.parent; RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val3 != null) { EnsureWindow(val); if ((Object)(object)windowCanvas == (Object)null || (Object)(object)windowArea == (Object)null) { return; } if (!windowCanvas.activeSelf) { windowCanvas.SetActive(true); } if ((Object)(object)windowTitle != (Object)null) { ((TMP_Text)windowTitle).text = ((layout == null) ? "No bracket today" : $"{Formats.Hosted} · {CPlayerData.m_TournamentData.m_TournamentMaxPlayerCount} players"); } if (layout == null) { if ((Object)(object)Window.Root != (Object)null) { Window.Root.SetActive(false); } return; } object[] obj = new object[4] { layout.kind, layout.cells.Count, layout.lines.Count, null }; Rect rect = windowArea.rect; obj[3] = ((Rect)(ref rect)).size; string text = string.Format("window:{0}:{1}:{2}:{3}", obj); if ((Object)(object)Window.Root == (Object)null || Window.BuiltFor != text) { Transform val4 = (Transform)(((Object)(object)((Transform)val3).parent != (Object)null) ? ((object)((Transform)val3).parent) : ((object)val3)); float num = ((Mathf.Abs(val4.lossyScale.x) > 1E-06f) ? Mathf.Clamp(Mathf.Abs(val4.lossyScale.y / val4.lossyScale.x), 0.1f, 1f) : 1f); View window = Window; rect = val3.rect; window.Build(layout, val2, ((Rect)(ref rect)).width, val.m_CurrentRound, windowArea, null, null, text, describe: false, backdrop: false, num); StyleWindowText(windowCanvas.transform); Plugin.Log.LogInfo((object)$"Bracket window: {layout.kind}, {layout.cells.Count} matches, rows flattened to {num:0.###} like the TV."); } if (!((Object)(object)Window.Root == (Object)null)) { if (!Window.Root.activeSelf) { Window.Root.SetActive(true); } Window.Fill(layout); } return; } } WindowOpen = false; HideWindow(); } private static void HideWindow() { if ((Object)(object)windowCanvas != (Object)null && windowCanvas.activeSelf) { windowCanvas.SetActive(false); } } public static void ResetLook() { Window.Destroy(); if ((Object)(object)windowCanvas != (Object)null) { Object.Destroy((Object)(object)windowCanvas); } windowCanvas = null; windowArea = null; windowTitle = null; } private static void StyleWindowText(Transform root) { //IL_002c: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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) if (windowPalette == Palette.Vanilla) { return; } TextMeshProUGUI val = new BuiltInUiKit(windowPalette).Label(root, "FontSample", "", 1f, windowPalette.Text, (TextAlignmentOptions)514); TextMeshProUGUI[] componentsInChildren = ((Component)root).GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val2 in componentsInChildren) { if ((Object)(object)((TMP_Text)val).font != (Object)null) { ((TMP_Text)val2).font = ((TMP_Text)val).font; ((TMP_Text)val2).fontSharedMaterial = ((TMP_Asset)((TMP_Text)val).font).material; } ((TMP_Text)val2).fontStyle = (FontStyles)0; ((Graphic)val2).color = (((Object)(object)val2 == (Object)(object)windowTitle) ? windowPalette.Accent : windowPalette.Text); } Object.DestroyImmediate((Object)(object)((Component)val).gameObject); Image[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<Image>(true); foreach (Image val3 in componentsInChildren2) { if (((Object)val3).name == "BracketLine") { ((Graphic)val3).color = windowPalette.Teal; } else if (((Object)val3).name == "BracketName") { ((Graphic)val3).color = windowPalette.Surface; } } } private static void EnsureWindow(TournamentPairingScreen board) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)windowCanvas != (Object)null) { return; } windowPalette = Looks.Palette(); windowCanvas = new GameObject("DimwitsBracketWindow", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler) }); Canvas component = windowCanvas.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 500; CanvasScaler component2 = windowCanvas.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; Image val = null; Transform parent = ((Component)board.m_TournamentPairingUIGrpList[0]).transform.parent; Transform val2 = ((parent != null) ? parent.parent : null); if ((Object)(object)val2 != (Object)null) { foreach (Transform item in val2) { Transform val3 = item; if (((Object)val3).name == "BG") { val = ((Component)val3).GetComponent<Image>(); } } } RectTransform val4 = Panel(windowCanvas.transform, "Frame", new Color(0.04f, 0.06f, 0.1f, 0.96f), new Vector2(1840f, 1010f)); RectTransform val5 = Panel((Transform)(object)val4, "Screen", (Color)(((Object)(object)val != (Object)null) ? ((Graphic)val).color : new Color(0f, 0.6f, 0.93f, 1f)), new Vector2(1810f, 980f)); Sprite val6 = ((windowPalette == Palette.Vanilla) ? Art.Get("bracket_backdrop") : null); if ((Object)(object)val6 != (Object)null) { Image component3 = ((Component)val5).GetComponent<Image>(); component3.sprite = val6; ((Graphic)component3).color = Color.white; } else if (windowPalette == Palette.Vanilla && (Object)(object)val != (Object)null && (Object)(object)val.sprite != (Object)null) { Image component4 = ((Component)val5).GetComponent<Image>(); component4.sprite = val.sprite; component4.type = val.type; } if (windowPalette != Palette.Vanilla) { ((Graphic)((Component)val4).GetComponent<Image>()).color = windowPalette.Line; ((Graphic)((Component)val5).GetComponent<Image>()).color = windowPalette.Bg; BuiltInUiKit builtInUiKit = new BuiltInUiKit(windowPalette); Image val7 = builtInUiKit.Panel((Transform)(object)val5, "Header", windowPalette.Surface, 14f, raycast: false); builtInUiKit.Stretch(((Graphic)val7).rectTransform, 12f, 12f, 12f, 0f); ((Graphic)val7).rectTransform.anchorMin = new Vector2(0f, 1f); ((Graphic)val7).rectTransform.offsetMin = new Vector2(12f, -106f); Image val8 = builtInUiKit.Panel((Transform)(object)val5, "Accent", windowPalette.Accent, 2f, raycast: false); builtInUiKit.Place(((Graphic)val8).rectTransform, 28f, 108f, 1754f, 4f); } windowArea = new GameObject("Area", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)windowArea).SetParent((Transform)(object)val5, false); windowArea.anchorMin = Vector2.zero; windowArea.anchorMax = Vector2.one; windowArea.offsetMin = new Vector2(24f, 56f); windowArea.offsetMax = new Vector2(-24f, -118f); if ((Object)(object)board.m_CurrentRound != (Object)null) { windowTitle = Text(board.m_CurrentRound, (Transform)(object)val5, "", Vector2.zero, 1400f, 54f); RectTransform rectTransform = ((TMP_Text)windowTitle).rectTransform; Vector2 val9 = default(Vector2); ((Vector2)(ref val9))..ctor(0.5f, 1f); rectTransform.anchorMax = val9; rectTransform.anchorMin = val9; rectTransform.anchoredPosition = new Vector2(0f, -58f); RectTransform rectTransform2 = ((TMP_Text)Text(board.m_CurrentRound, (Transform)(object)val5, $"{Plugin.BracketWindowKey.Value} closes", Vector2.zero, 600f, 26f)).rectTransform; ((Vector2)(ref val9))..ctor(0.5f, 0f); rectTransform2.anchorMax = val9; rectTransform2.anchorMin = val9; rectTransform2.anchoredPosition = new Vector2(0f, 34f); } StyleWindowText(windowCanvas.transform); } private static RectTransform Panel(Transform parent, string name, Color color, Vector2 size) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown object obj = ((windowPalette != Palette.Vanilla) ? ((object)((Component)new BuiltInUiKit(windowPalette).Panel(parent, name, color, 18f, raycast: false)).gameObject) : ((object)new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }))); ((GameObject)obj).transform.SetParent(parent, false); Image component = ((GameObject)obj).GetComponent<Image>(); ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; RectTransform val = (RectTransform)((GameObject)obj).transform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.anchorMax = val2; val.anchorMin = val2; val.pivot = new Vector2(0.5f, 0.5f); val.sizeDelta = size; val.anchoredPosition = Vector2.zero; return val; } private static TextMeshProUGUI Text(TextMeshProUGUI style, Transform parent, string text, Vector2 at, float width, float height, float upright = 1f) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)style).gameObject, parent, false); ((Object)val).name = "BracketText"; MonoBehaviour[] components = val.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val2 in components) { if (!(val2 is TextMeshProUGUI) && ((object)val2).GetType().Namespace == "I2.Loc") { Object.DestroyImmediate((Object)(object)val2); } } for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = text; ((TMP_Text)component).enableAutoSizing = true; ((TMP_Text)component).fontSizeMin = 0.01f; ((TMP_Text)component).fontSizeMax = Mathf.Max(0.01f, height / upright * 0.9f); ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).overflowMode = (TextOverflowModes)1; ((TMP_Text)component).alignment = (TextAlignmentOptions)514; ((Graphic)component).raycastTarget = false; RectTransform val3 = (RectTransform)val.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 1f); val3.anchorMax = val4; val3.anchorMin = val4; val3.pivot = new Vector2(0.5f, 0.5f); ((Transform)val3).localScale = new Vector3(1f, upright, 1f); ((Transform)val3).localRotation = Quaternion.identity; val3.sizeDelta = new Vector2(width * 0.95f, height / upright); val3.anchoredPosition = at; val.SetActive(true); return component; } private static (Vector3, Vector3)? TvView(Transform space, Vector3 boardCentre) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0094: Unknown result type (might be due to invalid IL or missing references) try { Camera val = null; float num = float.MaxValue; Camera[] allCameras = Camera.allCameras; foreach (Camera val2 in allCameras) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.targetTexture == (Object)null)) { Vector3 val3 = val2.WorldToViewportPoint(boardCentre); if (!(val3.z <= 0f) && !(val3.x < 0f) && !(val3.x > 1f) && !(val3.y < 0f) && !(val3.y > 1f) && val3.z < num) { val = val2; num = val3.z; } } } if ((Object)(object)val == (Object)null) { return null; } float num2 = Vector3.Dot(boardCentre - ((Component)val).transform.position, ((Component)val).transform.forward); Vector3 val4 = space.InverseTransformPoint(val.ViewportToWorldPoint(new Vector3(0f, 0f, num2))); Vector3 val5 = space.InverseTransformPoint(val.ViewportToWorldPoint(new Vector3(1f, 1f, num2))); return (new Vector3(Mathf.Min(val4.x, val5.x), Mathf.Min(val4.y, val5.y), 0f), new Vector3(Mathf.Max(val4.x, val5.x), Mathf.Max(val4.y, val5.y), 0f)); } catch (Exception) { return null; } } private static Rect Compact(GameObject row) { //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) Transform rail = row.transform; try { TournamentPairingUIGrp component = row.GetComponent<TournamentPairingUIGrp>(); object obj; if (component == null) { obj = null; } else { GameObject topUIGrp = ((UIElementBase)component).m_TopUIGrp; obj = ((topUIGrp != null) ? topUIGrp.transform : null); } Transform val = (Transform)obj; Transform val2 = (Transform)(((Object)(object)val != (Object)null) ? ((object)(Find(val, "UIGrp") ?? val)) : ((object)rail)); Transform val3 = Find(val2, "P1_StatGrp"); Transform val4 = Find(val2, "P2_StatGrp"); Transform val5 = (((Object)(object)val3 != (Object)null) ? Find(val3, "CustomerPicBG") : null); Transform val6 = (((Object)(object)val4 != (Object)null) ? Find(val4, "CustomerPicBG") : null); Transform val7 = Find(val2, "BlackBG"); Transform val8 = Find(val2, "BG"); if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null || (Object)(object)val7 == (Object)null || (Object)(object)val8 == (Object)null) { return Rect.zero; } Rect val9 = Bounds(val5); Rect val10 = Bounds(val6); float xMin = ((Rect)(ref val9)).xMin; Rect val11 = Bounds(val7); float num = Mathf.Max(0.02f, xMin - ((Rect)(ref val11)).xMin) * 0.12f + ((Rect)(ref val9)).width * 0.08f; Shift(val4, ((Rect)(ref val9)).xMax + num - ((Rect)(ref val10)).xMin); val10 = Bounds(val6); Transform[] array = (Transform[])(object)new Transform[2] { val3, val4 }; for (int i = 0; i < array.Length; i++) { foreach (Transform item in array[i]) { Transform val12 = item; if (Array.IndexOf(StatParts, ((Object)val12).name.Trim()) >= 0) { ((Component)val12).gameObject.SetActive(false); } } } foreach (Transform item2 in val2) { Transform val13 = item2; if (((Object)val13).name.Trim().StartsWith("BlackBar")) { val11 = Bounds(val13); if (((Rect)(ref val11)).xMin > ((Rect)(ref val9)).xMax + 0.001f) { ((Component)val13).gameObject.SetActive(false); } } } val11 = Bounds(val7); float xMin2 = ((Rect)(ref val11)).xMin; val11 = Bounds(val8); float num2 = ((Rect)(ref val11)).xMin - xMin2; Span(val7, xMin2, ((Rect)(ref val10)).xMax + num2 * 2f); Span(val8, xMin2 + num2, ((Rect)(ref val10)).xMax + num2); return Bounds(val7); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Bracket sheet: couldn't make a compact row: " + ex.Message)); return Rect.zero; } Rect Bounds(Transform t) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007d: Unknown result type (might be due to invalid IL or missing references) Vector3[] array2 = (Vector3[])(object)new Vector3[4]; ((RectTransform)t).GetWorldCorners(array2); Vector3 val14 = rail.InverseTransformPoint(array2[0]); Vector3 val15 = rail.InverseTransformPoint(array2[2]); return Rect.MinMaxRect(Mathf.Min(val14.x, val15.x), Mathf.Min(val14.y, val15.y), Mathf.Max(val14.x, val15.x), Mathf.Max(val14.y, val15.y)); } static Transform? Find(Transform t, string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item3 in t) { Transform val14 = item3; if (((Object)val14).name.Trim() == name) { return val14; } } return null; } void Shift(Transform t, float dx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) t.position += rail.TransformVector(new Vector3(dx, 0f, 0f)); } void Span(Transform t, float x0, float x1) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0083: Unknown result type (might be due to invalid IL or missing references) RectTransform val14 = (RectTransform)t; Rect val15 = Bounds(t); if (!(((Rect)(ref val15)).width <= 0f)) { float width = ((Rect)(ref val15)).width; Rect rect = val14.rect; float num3 = width / Mathf.Max(1E-06f, ((Rect)(ref rect)).width); val14.sizeDelta = new Vector2(val14.sizeDelta.x + (x1 - x0 - ((Rect)(ref val15)).width) / num3, val14.sizeDelta.y); Rect val16 = Bounds(t); Shift(t, (x0 + x1) / 2f - ((Rect)(ref val16)).center.x); } } } private static Image Picture(Transform parent, Sprite? sprite, Vector2 at, float size, float upright = 1f) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a1: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BracketPicture", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); component.sprite = sprite; component.preserveAspect = true; ((Graphic)component).raycastTarget = false; ((Behaviour)component).enabled = (Object)(object)sprite != (Object)null; RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 1f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0.5f, 0.5f); val2.sizeDelta = new Vector2(size, size); ((Transform)val2).localScale = new Vector3(1f, upright, 1f); val2.anchoredPosition = at; return component; } private static void Caption(TextMeshProUGUI style, Transform parent, string text, string icon, Vector2 at, float width, float height, float upright = 1f) { //IL_003d: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0013: Unknown result type (might be due to invalid IL or missing references) Sprite val = Art.Get(icon); if ((Object)(object)val == (Object)null) { Text(style, parent, text, at, width, height, upright); return; } float num = Mathf.Min(height * 1.1f / upright, width * 0.25f); Picture(parent, val, at + new Vector2((0f - width) / 2f + num * 0.6f, 0f), num, upright); Text(style, parent, text, at + new Vector2(num * 0.6f, 0f), width - num * 1.2f, height, upright); } private static void Side(TournamentPairingUIGrp g, Image pic, TextMeshProUGUI win, TextMeshProUGUI lose, TextMeshProUGUI rank, Image icon, SheetSide s, CustomerManager cm) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c3: 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_00df: 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_0097: Unknown result type (might be due to invalid IL or missing references) if (s.known) { Sprite val = (pic.sprite = (s.player ? cm.GetPlayerIconSprite() : ((s.model >= 0) ? cm.GetCustomerIconSprite(s.model, s.female) : null))); ((Behaviour)pic).enabled = (Object)(object)val != (Object)null; } Image val3 = (((Object)(object)((Component)pic).transform.parent != (Object)null) ? ((Component)((Component)pic).transform.parent).GetComponent<Image>() : null); if ((Object)(object)val3 != (Object)null) { ((Graphic)val3).color = ((s.result == 1) ? WonFrame : ((s.result == 2) ? LostFrame : NoFrame)); } Color color = ((Graphic)pic).color; ((Graphic)pic).color = new Color(color.r, color.g, color.b, (s.result == 2) ? 0.45f : 1f); ((Behaviour)win).enabled = false; ((Behaviour)lose).enabled = false; } } internal static class Crowd { private static readonly FieldRef<CustomerManager, List<Customer>> CustomerList = AccessTools.Fiel