Decompiled source of SimulPicks v0.3.36
EveryonePicks.dll
Decompiled a week 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnboundLib; using UnboundLib.GameModes; using UnboundLib.Networking; using UnboundLib.Utils; using UnboundLib.Utils.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("EveryonePicks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.36.0")] [assembly: AssemblyInformationalVersion("0.3.36+934ba37f698a652cf03dc4e3aaa0a5cf203ffb74")] [assembly: AssemblyProduct("EveryonePicks")] [assembly: AssemblyTitle("EveryonePicks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.36.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EveryonePicks { internal static class Diagnostics { private class Notice { public string text; public float until; public bool bad; } [CompilerGenerated] private static class <>O { public static LogCallback <0>__OnUnityLog; } private static readonly List<Notice> notices = new List<Notice>(); private static readonly Dictionary<int, string> versions = new Dictionary<int, string>(); private static bool mismatchAnnounced; private static GUIStyle style; private static Texture2D bg; private static readonly Dictionary<string, string> owners = new Dictionary<string, string>(); private static readonly Dictionary<string, float> lastBlamed = new Dictionary<string, float>(); private static bool reporting; private static bool hooked; private static float nextNag; internal static void Report(string message, bool bad = true, float seconds = 9f) { if (string.IsNullOrEmpty(message)) { return; } if (bad) { EveryonePicksPlugin.Warn(message); } else { EveryonePicksPlugin.Log(message); } if (EveryonePicksPlugin.ShowProblems == null || !EveryonePicksPlugin.ShowProblems.Value) { return; } foreach (Notice notice in notices) { if (notice.text == message) { notice.until = Time.realtimeSinceStartup + seconds; return; } } if (notices.Count >= 4) { notices.RemoveAt(0); } notices.Add(new Notice { text = message, until = Time.realtimeSinceStartup + seconds, bad = bad }); } internal static void Clear() { notices.Clear(); } internal static void SayHello() { try { versions[(PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0] = "0.3.36"; if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom) { NetworkingManager.RPC_Others(typeof(EveryonePicksPlugin), "RPCA_SimulHello", new object[2] { PhotonNetwork.LocalPlayer.ActorNumber, "0.3.36" }); } } catch (Exception ex) { EveryonePicksPlugin.Warn("Version announce failed: " + ex.Message); } } internal static void StoreHello(int actorNumber, string version) { versions[actorNumber] = version ?? "?"; CheckVersions(); } private static void CheckVersions() { if (mismatchAnnounced) { return; } string text = "0.3.36"; List<string> list = new List<string>(); foreach (KeyValuePair<int, string> version in versions) { if (version.Value != text && !list.Contains(version.Value)) { list.Add(version.Value); } } if (list.Count != 0) { mismatchAnnounced = true; Report("Version mismatch you " + text + " others " + string.Join(", ", list.ToArray()), bad: true, 20f); } } internal static void CheckSilentPlayers() { if (mismatchAnnounced || PhotonNetwork.OfflineMode || !PhotonNetwork.InRoom) { return; } try { List<string> list = new List<string>(); foreach (KeyValuePair<int, int> entitlement in State.entitlements) { Player val = State.FindPlayer(entitlement.Key); if (!((Object)(object)val == (Object)null) && !State.HasLeftRoom(val)) { int num = -1; try { num = val.data.view.Owner.ActorNumber; } catch { continue; } if (!versions.ContainsKey(num)) { list.Add(State.DisplayName(entitlement.Key)); } } } if (list.Count != 0) { mismatchAnnounced = true; Report("Different or missing version " + string.Join(", ", list.ToArray()), bad: true, 20f); } } catch { } } internal static void ResetRoom() { versions.Clear(); mismatchAnnounced = false; Clear(); } internal static void BuildOwnerMap() { //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown if (hooked) { return; } hooked = true; try { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { PluginInfo value = pluginInfo.Value; if (value == null || (Object)(object)value.Instance == (Object)null || value.Metadata == null) { continue; } string name = value.Metadata.Name; if (string.IsNullOrEmpty(name)) { continue; } Type[] types; try { types = ((object)value.Instance).GetType().Assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } catch { continue; } Type[] array = types; foreach (Type type in array) { if (!(type == null)) { string text = ((!string.IsNullOrEmpty(type.Namespace)) ? type.Namespace.Split(new char[1] { '.' })[0] : type.Name); if (!string.IsNullOrEmpty(text) && text.Length >= 3 && !owners.ContainsKey(text)) { owners[text] = name; } } } } owners["EveryonePicks"] = "EveryonePicks"; EveryonePicksPlugin.Log("Error attribution ready: " + owners.Count + " code prefixes mapped to mods."); } catch (Exception ex2) { EveryonePicksPlugin.Warn("Could not build the mod attribution map: " + ex2.Message); } object obj2 = <>O.<0>__OnUnityLog; if (obj2 == null) { LogCallback val = OnUnityLog; <>O.<0>__OnUnityLog = val; obj2 = (object)val; } Application.logMessageReceived += (LogCallback)obj2; } internal static void Unhook() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (hooked) { hooked = false; object obj = <>O.<0>__OnUnityLog; if (obj == null) { LogCallback val = OnUnityLog; <>O.<0>__OnUnityLog = val; obj = (object)val; } Application.logMessageReceived -= (LogCallback)obj; } } private static void OnUnityLog(string condition, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (((int)type != 4 && (int)type != 0) || reporting || !State.phaseActive || string.IsNullOrEmpty(stackTrace)) { return; } string text = Blame(stackTrace); if (text == null || text == "EveryonePicks") { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (lastBlamed.TryGetValue(text, out var value) && realtimeSinceStartup - value < 30f) { return; } lastBlamed[text] = realtimeSinceStartup; string text2 = condition ?? ""; int num = text2.IndexOf(':'); if (num > 0) { text2 = text2.Substring(0, num); } reporting = true; try { Report(text + " threw an error (" + text2.Trim() + ")"); } finally { reporting = false; } } private static string Blame(string stackTrace) { try { string[] array = stackTrace.Split('\n', '\r'); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length != 0) { int num = text.IndexOf('('); if (num > 0) { text = text.Substring(0, num).Trim(); } string text2 = text.Split(new char[1] { '.' })[0].Split(new char[1] { '+' })[0].Trim(); if (text2.Length >= 3 && owners.TryGetValue(text2, out var value)) { return value; } } } } catch { } return null; } internal static void TickStuck() { if (!State.phaseActive) { nextNag = 0f; } else { if (State.waitingOver) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; float num = realtimeSinceStartup - State.phaseStartTime; if (num < 25f || realtimeSinceStartup < nextNag) { return; } nextNag = realtimeSinceStartup + 15f; try { List<string> list = new List<string>(); foreach (KeyValuePair<int, int> entitlement in State.entitlements) { State.sessionsDone.TryGetValue(entitlement.Key, out var value); if (value < entitlement.Value) { Player val = State.FindPlayer(entitlement.Key); if (!((Object)(object)val == (Object)null) && !State.HasLeftRoom(val)) { list.Add(State.DisplayName(entitlement.Key)); } } } if (list.Count != 0) { Report("Waiting on " + string.Join(", ", list.ToArray()) + " " + Mathf.FloorToInt(num) + "s", bad: true, 12f); } } catch { } } } private static void Build() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0027: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_007e: Expected O, but got Unknown bg = new Texture2D(1, 1); bg.SetPixel(0, 0, new Color(0.05f, 0.05f, 0.07f, 0.88f)); bg.Apply(); ((Object)bg).hideFlags = (HideFlags)61; GUIStyle val = new GUIStyle { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, wordWrap = true }; val.normal.textColor = Color.white; style = val; } internal static void Draw() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_016b: 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) if (notices.Count == 0 || (int)Event.current.type != 7) { return; } if (style == null) { Build(); } float realtimeSinceStartup = Time.realtimeSinceStartup; for (int num = notices.Count - 1; num >= 0; num--) { if (notices[num].until <= realtimeSinceStartup) { notices.RemoveAt(num); } } if (notices.Count == 0) { return; } float num2 = Mathf.Min(760f, (float)Screen.width * 0.6f); float num3 = ((float)Screen.width - num2) * 0.5f; float num4 = 26f; foreach (Notice notice in notices) { float num5 = Mathf.Max(30f, style.CalcHeight(new GUIContent(notice.text), num2 - 24f) + 14f); GUI.DrawTexture(new Rect(num3, num4, num2, num5), (Texture)(object)bg); GUI.color = (notice.bad ? new Color(0.95f, 0.42f, 0.4f) : new Color(0.44f, 0.83f, 0.48f)); GUI.DrawTexture(new Rect(num3, num4, 3f, num5), (Texture)(object)bg); GUI.color = Color.white; style.normal.textColor = (Color)(notice.bad ? new Color(1f, 0.82f, 0.8f) : Color.white); GUI.Label(new Rect(num3 + 12f, num4, num2 - 24f, num5), notice.text, style); num4 += num5 + 6f; } } } [BepInPlugin("com.redredrain.rounds.simulpicks", "EveryonePicks", "0.3.36")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("Rounds.exe")] public class EveryonePicksPlugin : BaseUnityPlugin, IInRoomCallbacks, IMatchmakingCallbacks { public const string ModId = "com.redredrain.rounds.simulpicks"; public const string ModName = "EveryonePicks"; public const string Version = "0.3.36"; public static EveryonePicksPlugin Instance; public static ConfigEntry<int> PickTimeSeconds; public static ConfigEntry<bool> ShowPickBoard; public static ConfigEntry<float> PickBoardScale; public static ConfigEntry<bool> ShowReveal; public static ConfigEntry<bool> ShowProblems; public static ConfigEntry<bool> ShowWaitingText; public static ConfigEntry<float> RevealSeconds; public static ConfigEntry<float> RevealCardSize; private void Awake() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) Instance = this; PickTimeSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("EveryonePicks", "PickTimeSeconds", 45, "Seconds each player gets per pick before their pick is auto-completed. Extra picks granted mid-pick each get their own allowance."); ShowPickBoard = ((BaseUnityPlugin)this).Config.Bind<bool>("EveryonePicks", "ShowPickBoard", true, "Show the top-right board listing who has picked and who everyone is still waiting on."); PickBoardScale = ((BaseUnityPlugin)this).Config.Bind<float>("EveryonePicks", "PickBoardScale", 1f, "Size multiplier for the pick board."); ShowReveal = ((BaseUnityPlugin)this).Config.Bind<bool>("EveryonePicks", "ShowReveal", true, "At the end of the phase, show every card picked this round at once instead of letting them trickle into the side bar one at a time."); RevealSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("EveryonePicks", "RevealSeconds", 3f, "How long the end-of-phase reveal stays on screen."); RevealCardSize = ((BaseUnityPlugin)this).Config.Bind<float>("EveryonePicks", "RevealCardSize", 1f, "Size of the revealed cards. Raise it if they look too small."); ShowWaitingText = ((BaseUnityPlugin)this).Config.Bind<bool>("EveryonePicks", "ShowWaitingText", true, "Show WAITING in the game's big screen text while you have nothing to look at."); ShowProblems = ((BaseUnityPlugin)this).Config.Bind<bool>("EveryonePicks", "ShowProblems", true, "Show a message on screen when something goes wrong, instead of failing quietly."); new Harmony("com.redredrain.rounds.simulpicks").PatchAll(); PhotonNetwork.AddCallbackTarget((object)this); } private void Start() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown SoftPatches.Apply(new Harmony("com.redredrain.rounds.simulpicks.soft")); GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => State.OnGameStart())); GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => Announce())); GameModeManager.AddHook("PickStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => State.OnPickStart()), 1000); GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => State.Barrier()), 600); GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => State.HardResetHook())); Menu.Register(); Diagnostics.BuildOwnerMap(); } private void OnDestroy() { PhotonNetwork.RemoveCallbackTarget((object)this); Diagnostics.Unhook(); } private void Update() { PickReveal.Tick(); WaitingBanner.Tick(); LeaverResilience.Tick(); State.ReconcileLocalPick(); Diagnostics.TickStuck(); } private static IEnumerator Announce() { Diagnostics.SayHello(); yield break; } private void OnGUI() { PickBoard.Draw(); PickReveal.DrawLabels(); Diagnostics.Draw(); } internal static void Log(string m) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[EveryonePicks] " + m)); } internal static void Warn(string m) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[EveryonePicks] " + m)); } [UnboundRPC] public static void RPCA_SimulHello(int actorNumber, string version) { Diagnostics.StoreHello(actorNumber, version); } [UnboundRPC] public static void RPCA_SimulResult(int token, int playerID, int pickIdx, string cardName, bool cursed) { State.StoreResult(token, playerID, pickIdx, cardName, cursed); } [UnboundRPC] public static void RPCA_SimulSessionDone(int token, int playerID, int count) { State.StoreSessionDone(token, playerID, count); } [UnboundRPC] public static void RPCA_SimulApplySet(int token, string[] packed) { State.StoreApplySet(token, packed); } [UnboundRPC] public static void RPCA_SimulStatus(int token, int playerID, int remaining, bool done, float pickSeconds) { State.StoreStatus(token, playerID, remaining, done, pickSeconds); } public void OnLeftRoom() { State.HardReset("left room"); } public void OnJoinedRoom() { State.HardReset("joined room"); Diagnostics.ResetRoom(); Diagnostics.SayHello(); } public void OnPlayerLeftRoom(Player otherPlayer) { try { Log("Player left the room: " + ((otherPlayer != null) ? otherPlayer.NickName : "?") + "."); State.DropDepartedPlayers(); } catch (Exception ex) { Warn("Leaver cleanup failed: " + ex.Message); } } public void OnMasterClientSwitched(Player newMasterClient) { if (State.phaseActive) { Log("Master client switched mid-phase to actor " + ((newMasterClient != null) ? new int?(newMasterClient.ActorNumber) : ((int?)null)) + "."); } } public void OnPlayerEnteredRoom(Player newPlayer) { } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnFriendListUpdate(List<FriendInfo> friendList) { } public void OnCreatedRoom() { } public void OnCreateRoomFailed(short returnCode, string message) { } public void OnJoinRoomFailed(short returnCode, string message) { } public void OnJoinRandomFailed(short returnCode, string message) { } } internal static class LeaverResilience { private static bool armed; private static float deadline; private static bool firedThisRound; private static bool phaseSeen; private static float phaseSince; private static float desyncSince; private const float StuckPhaseGrace = 300f; private const float DesyncGrace = 8f; private const float TransitionGrace = 25f; internal static void Apply(Harmony h) { int num = 0; num += Guard(h, "RWF.Patches.RoundCounter_Patch_ReDraw", "Postfix"); num += Guard(h, "RWF.RoundCounterExtensions", "UpdateRounds"); num += Guard(h, "RWF.UIHandlerExtensions", "ShowRoundCounterSmall"); num += Guard(h, "RWF.PointVisualizerExtensions", "ResetBalls"); num += Guard(h, "ModdingUtils.AIMinion.AIMinionHandler", "GetPlayerOrAIWithID"); num += Guard(h, "PerformanceImprovements.Patches.ArtHandler_Patch", "Postfix"); num += Guard(h, "ArtHandler", "NextArt"); if (num > 0) { EveryonePicksPlugin.Log("Leaver resilience: " + num + " transition call(s) guarded."); } GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ArmWatchdog()), 100); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => Disarm())); GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => Disarm())); } private static int Guard(Harmony h, string typeName, string methodName) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown Type type = AccessTools.TypeByName(typeName); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : null); if (methodInfo == null) { return 0; } try { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LeaverResilience), "Swallow", (Type[])null), (HarmonyMethod)null); return 1; } catch (Exception ex) { EveryonePicksPlugin.Warn("Could not guard " + typeName + "." + methodName + ": " + ex.Message); return 0; } } private static Exception Swallow(Exception __exception, MethodBase __originalMethod) { if (__exception == null) { return null; } string text = ((__originalMethod != null) ? (((__originalMethod.DeclaringType != null) ? __originalMethod.DeclaringType.Name : "?") + "." + __originalMethod.Name) : "?"); Diagnostics.Report("Recovered from an error in " + text + " (" + __exception.GetType().Name + ")"); return null; } private static IEnumerator ArmWatchdog() { armed = true; firedThisRound = false; deadline = Time.realtimeSinceStartup + 25f; yield break; } private static IEnumerator Disarm() { armed = false; yield break; } internal static void Tick() { TickPhaseWatchdog(); if (!armed || firedThisRound || Time.realtimeSinceStartup < deadline) { return; } armed = false; firedThisRound = true; try { if ((Object)(object)GameManager.instance == (Object)null || !GameManager.instance.battleOngoing || (Object)(object)PlayerManager.instance == (Object)null || PlayerManager.instance.players == null || PlayerManager.instance.players.Count == 0) { return; } IGameModeHandler currentHandler = GameModeManager.CurrentHandler; MonoBehaviour val = ((currentHandler != null) ? currentHandler.GameMode : null); if ((Object)(object)val == (Object)null) { return; } MethodInfo methodInfo = AccessTools.Method(((object)val).GetType(), "DoPointStart", (Type[])null, (Type[])null) ?? AccessTools.Method(((object)val).GetType(), "DoRoundStart", (Type[])null, (Type[])null); if (!(methodInfo == null)) { MonoBehaviour val2 = val; if (!((Object)(object)val2 == (Object)null) && methodInfo.Invoke(val, null) is IEnumerator enumerator) { Diagnostics.Report("Round did not start; starting it manually"); val2.StartCoroutine(enumerator); } } } catch (Exception ex) { EveryonePicksPlugin.Warn("Round-start recovery failed: " + ex.Message); } } private static void TickPhaseWatchdog() { bool phaseActive; try { phaseActive = State.phaseActive; } catch { return; } if (!phaseActive) { phaseSeen = false; desyncSince = 0f; return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (!phaseSeen) { phaseSeen = true; phaseSince = realtimeSinceStartup; desyncSince = 0f; } bool flag = false; try { GameManager instance = GameManager.instance; flag = (Object)(object)instance != (Object)null && instance.battleOngoing; } catch { } if (flag) { if (desyncSince <= 0f) { desyncSince = realtimeSinceStartup; } } else { desyncSince = 0f; } bool flag2 = desyncSince > 0f && realtimeSinceStartup - desyncSince >= 8f; bool flag3 = realtimeSinceStartup - phaseSince >= 300f; if (!flag2 && !flag3) { return; } phaseSeen = false; desyncSince = 0f; try { EveryonePicksPlugin.Warn("Phase watchdog: " + (flag2 ? "battle running while still picking" : "pick phase never ended") + " - resyncing."); Diagnostics.Report("Recovered a stuck pick phase"); State.HardReset(flag2 ? "desynced from the battle" : "pick phase stalled"); armed = true; firedThisRound = false; deadline = 0f; } catch (Exception ex) { EveryonePicksPlugin.Warn("Phase watchdog failed: " + ex.Message); } } internal static void Reset() { armed = false; firedThisRound = false; phaseSeen = false; desyncSince = 0f; } } internal static class Menu { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__0_0; public static UnityAction<bool> <>9__1_0; public static UnityAction<float> <>9__1_4; public static UnityAction<bool> <>9__1_1; public static UnityAction<bool> <>9__1_2; public static UnityAction<float> <>9__1_5; public static UnityAction<float> <>9__1_6; public static UnityAction<float> <>9__1_7; public static UnityAction<bool> <>9__1_3; internal void <Register>b__0_0() { } internal void <BuildMenu>b__1_0(bool value) { EveryonePicksPlugin.ShowPickBoard.Value = value; } internal void <BuildMenu>b__1_4(float value) { EveryonePicksPlugin.PickBoardScale.Value = value; } internal void <BuildMenu>b__1_1(bool value) { EveryonePicksPlugin.ShowReveal.Value = value; } internal void <BuildMenu>b__1_2(bool value) { EveryonePicksPlugin.ShowWaitingText.Value = value; } internal void <BuildMenu>b__1_5(float value) { EveryonePicksPlugin.RevealCardSize.Value = value; } internal void <BuildMenu>b__1_6(float value) { EveryonePicksPlugin.RevealSeconds.Value = Mathf.Round(value * 2f) / 2f; } internal void <BuildMenu>b__1_7(float value) { EveryonePicksPlugin.PickTimeSeconds.Value = Mathf.RoundToInt(value); } internal void <BuildMenu>b__1_3(bool value) { EveryonePicksPlugin.ShowProblems.Value = value; } } internal static void Register() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { UnityAction val = delegate { }; <>c.<>9__0_0 = val; obj = (object)val; } Unbound.RegisterMenu("EveryonePicks", (UnityAction)obj, (Action<GameObject>)BuildMenu, (GameObject)null, true); Unbound.RegisterCredits("EveryonePicks", new string[1] { "RedRedRain" }, "Thunderstore", "https://thunderstore.io/c/rounds/p/RedRedRain/SimulPicks/"); } private static void BuildMenu(GameObject menu) { TextMeshProUGUI val = default(TextMeshProUGUI); MenuHandler.CreateText("Everyone picks their card at the same time.", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText("Every player in the lobby needs this mod.", menu, ref val, 22, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Spacer(menu); MenuHandler.CreateText("Pick board", menu, ref val, 26, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateToggle(EveryonePicksPlugin.ShowPickBoard.Value, "Show who has picked", menu, (UnityAction<bool>)delegate(bool value) { EveryonePicksPlugin.ShowPickBoard.Value = value; }, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Slider val2 = default(Slider); MenuHandler.CreateSlider("Board size", menu, 30, 0.6f, 2f, EveryonePicksPlugin.PickBoardScale.Value, (UnityAction<float>)delegate(float value) { EveryonePicksPlugin.PickBoardScale.Value = value; }, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Spacer(menu); MenuHandler.CreateText("Picked cards", menu, ref val, 26, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateToggle(EveryonePicksPlugin.ShowReveal.Value, "Show picked cards on screen", menu, (UnityAction<bool>)delegate(bool value) { EveryonePicksPlugin.ShowReveal.Value = value; }, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateToggle(EveryonePicksPlugin.ShowWaitingText.Value, "Show WAITING while others pick", menu, (UnityAction<bool>)delegate(bool value) { EveryonePicksPlugin.ShowWaitingText.Value = value; }, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateSlider("Card size", menu, 30, 0.2f, 6f, EveryonePicksPlugin.RevealCardSize.Value, (UnityAction<float>)delegate(float value) { EveryonePicksPlugin.RevealCardSize.Value = value; }, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateSlider("How long they stay up (seconds)", menu, 30, 1f, 8f, EveryonePicksPlugin.RevealSeconds.Value, (UnityAction<float>)delegate(float value) { EveryonePicksPlugin.RevealSeconds.Value = Mathf.Round(value * 2f) / 2f; }, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Spacer(menu); MenuHandler.CreateText("Timing", menu, ref val, 26, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateSlider("Pick time (seconds)", menu, 30, 10f, 180f, (float)EveryonePicksPlugin.PickTimeSeconds.Value, (UnityAction<float>)delegate(float value) { EveryonePicksPlugin.PickTimeSeconds.Value = Mathf.RoundToInt(value); }, ref val2, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText("Per pick. A card that grants extra picks gives another full allowance for each one.", menu, ref val, 20, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Spacer(menu); MenuHandler.CreateText("Problems", menu, ref val, 26, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateToggle(EveryonePicksPlugin.ShowProblems.Value, "Say on screen when something goes wrong", menu, (UnityAction<bool>)delegate(bool value) { EveryonePicksPlugin.ShowProblems.Value = value; }, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); } private static void Spacer(GameObject menu) { TextMeshProUGUI val = default(TextMeshProUGUI); MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); } } [HarmonyPatch(typeof(CardChoice), "DoPick")] internal static class Patch_DoPick { private static bool Prefix(int picksToSet, int picketIDToSet, PickerType pType, ref IEnumerator __result, bool __runOriginal) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!State.phaseActive) { return true; } if (State.startingOwnSession) { return true; } int num = Mathf.Max(1, picksToSet); if (!__runOriginal) { State.CancelSeededPick(picketIDToSet, num); return false; } int num2 = num - State.ConsumeSeed(picketIDToSet, num); if (num2 > 0) { Player val = State.FindPlayer(picketIDToSet); if ((Object)(object)val != (Object)null && State.IsLocalPlayer(val)) { for (int i = 0; i < num2; i++) { State.RecordEntitlement(picketIDToSet, pType); State.EnqueueLocalPick(picketIDToSet, pType); } } } __result = Noop(); return false; } private static IEnumerator Noop() { yield break; } } [HarmonyPatch(typeof(ApplyCardStats), "Pick")] internal static class Patch_Pick_Capture { private static readonly FieldInfo F_sourceCard = AccessTools.Field(typeof(CardInfo), "sourceCard"); private static void Prefix(ApplyCardStats __instance, int pickerID, ref bool ___done) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if ((!State.localPickActive | ___done) || pickerID != State.currentSessionPlayer) { return; } GameObject gameObject; try { gameObject = ((Component)((Component)__instance).transform.root).gameObject; } catch { return; } if ((Object)(object)gameObject == (Object)null) { return; } CardInfo componentInChildren = gameObject.GetComponentInChildren<CardInfo>(true); if (!((Object)(object)componentInChildren == (Object)null)) { CardInfo val = null; try { val = (CardInfo)F_sourceCard.GetValue(componentInChildren); } catch { } string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : ((Object)componentInChildren).name.Replace("(Clone)", "")); if (!string.IsNullOrEmpty(text)) { State.currentSessionPicks.Add(new ResultEntry { card = text, cursed = SoftPatches.IsCursed(gameObject) }); } } } } [HarmonyPatch(typeof(CardChoiceVisuals), "Show")] internal static class Patch_Visuals_Show { private static bool Prefix() { if (State.passThroughActive || State.allowNativeVisualCall) { return true; } if (State.phaseActive || State.localPickActive) { return false; } return true; } } [HarmonyPatch(typeof(CardChoiceVisuals), "Hide")] internal static class Patch_Visuals_Hide { private static bool Prefix() { if (State.passThroughActive || State.allowNativeVisualCall) { return true; } if (State.phaseActive || State.localPickActive) { return false; } return true; } } [HarmonyPatch(typeof(UIHandler), "ShowPicker")] internal static class Patch_UIHandler_ShowPicker { private static bool Prefix(int pickerID) { if (State.passThroughActive || State.allowNativeVisualCall) { return true; } if (!State.phaseActive && !State.localPickActive) { return true; } if (State.localPickActive) { return pickerID == State.currentSessionPlayer; } return false; } } [HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")] internal static class Patch_CardSpawnWindow { [HarmonyPriority(800)] private static void Prefix() { State.cardSpawnDepth++; } private static void Finalizer() { if (State.cardSpawnDepth > 0) { State.cardSpawnDepth--; } } } [HarmonyPatch(typeof(CardChoice), "AddCard")] internal static class Patch_CardSpawnWindow_AddCard { [HarmonyPriority(800)] private static void Prefix() { State.cardSpawnDepth++; } private static void Finalizer() { if (State.cardSpawnDepth > 0) { State.cardSpawnDepth--; } } } [HarmonyPatch(typeof(CardChoice), "Spawn")] internal static class Patch_Spawn_Local { private static bool Prefix(GameObject objToSpawn, Vector3 pos, Quaternion rot, ref GameObject __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!State.localPickActive) { return true; } __result = Object.Instantiate<GameObject>(objToSpawn, pos, rot); PhotonView[] componentsInChildren = __result.GetComponentsInChildren<PhotonView>(true); foreach (PhotonView val in componentsInChildren) { if (val.ViewID == 0) { try { PhotonNetwork.AllocateViewID(val); } catch { } } } State.TrackLocalCard(__result); return false; } } [HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")] internal static class Patch_SpawnUniqueCard_Track { private static void Postfix(GameObject __result) { if (!State.localPickActive || (Object)(object)__result == (Object)null) { return; } State.TrackLocalCard(__result); PhotonView[] componentsInChildren = __result.GetComponentsInChildren<PhotonView>(true); foreach (PhotonView val in componentsInChildren) { if (val.ViewID == 0) { try { PhotonNetwork.AllocateViewID(val); } catch { } } } } } [HarmonyPatch(typeof(PhotonNetwork), "Instantiate")] internal static class Patch_Photon_Instantiate { private static readonly FieldInfo instantiationDataField = AccessTools.Field(typeof(PhotonView), "instantiationDataField"); private static bool Prefix(string prefabName, Vector3 position, Quaternion rotation, object[] data, ref GameObject __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!State.localPickActive || !State.SpawningCard) { return true; } GameObject val = null; try { val = PhotonNetwork.PrefabPool.Instantiate(prefabName, position, rotation); } catch { } if ((Object)(object)val == (Object)null) { EveryonePicksPlugin.Warn("Local instantiate failed for " + prefabName + " - spawn suppressed."); __result = null; return false; } PhotonView[] componentsInChildren = val.GetComponentsInChildren<PhotonView>(true); foreach (PhotonView val2 in componentsInChildren) { if (val2.ViewID == 0) { try { PhotonNetwork.AllocateViewID(val2); } catch (Exception ex) { EveryonePicksPlugin.Warn("AllocateViewID: " + ex.Message); } } if (data != null && instantiationDataField != null) { try { instantiationDataField.SetValue(val2, data); } catch { } } } val.SetActive(true); PhotonView componentInChildren = val.GetComponentInChildren<PhotonView>(true); PhotonMessageInfo val3 = default(PhotonMessageInfo); ((PhotonMessageInfo)(ref val3))..ctor(PhotonNetwork.LocalPlayer, PhotonNetwork.ServerTimestamp, componentInChildren); IPunInstantiateMagicCallback[] components = val.GetComponents<IPunInstantiateMagicCallback>(); foreach (IPunInstantiateMagicCallback val4 in components) { try { val4.OnPhotonInstantiate(val3); } catch (Exception ex2) { EveryonePicksPlugin.Warn("OnPhotonInstantiate: " + ex2.Message); } } State.TrackLocalCard(val); __result = val; return false; } } [HarmonyPatch(typeof(PhotonView), "RPC", new Type[] { typeof(string), typeof(RpcTarget), typeof(object[]) })] internal static class Patch_PhotonView_RPC { private static readonly Dictionary<string, MethodInfo> cache = new Dictionary<string, MethodInfo>(); private static bool Prefix(PhotonView __instance, string methodName, object[] parameters) { if (!State.localPickActive) { return true; } if (!State.RedirectLocalRpcs.Contains(methodName)) { return true; } InvokeLocally(__instance, methodName, parameters); return false; } internal static void InvokeLocally(PhotonView view, string methodName, object[] parameters) { MonoBehaviour[] components = ((Component)view).GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val in components) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); string key = type.FullName + "::" + methodName; if (!cache.TryGetValue(key, out var value)) { value = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); cache[key] = value; } if (!(value == null)) { try { value.Invoke(val, parameters ?? Array.Empty<object>()); return; } catch (Exception ex) { EveryonePicksPlugin.Warn("Local " + methodName + " threw: " + (ex.InnerException?.Message ?? ex.Message)); return; } } } EveryonePicksPlugin.Warn("Local invoke: no handler for " + methodName + " on view " + view.ViewID); } } [HarmonyPatch(typeof(NetworkingManager), "RPC", new Type[] { typeof(Type), typeof(string), typeof(object[]) })] internal static class Patch_NetworkingManager_RPC { private static bool Prefix(Type targetType, string methodName, object[] data) { return HandleManagerRpc(targetType, methodName, data); } internal static bool HandleManagerRpc(Type targetType, string methodName, object[] data) { if (!State.localPickActive) { return true; } if (!State.LocalizedManagerRpcs.Contains(methodName)) { return true; } MethodInfo methodInfo = AccessTools.Method(targetType, methodName, (Type[])null, (Type[])null); if (methodInfo != null) { try { methodInfo.Invoke(null, data ?? Array.Empty<object>()); } catch (Exception ex) { EveryonePicksPlugin.Warn("Localized " + methodName + " threw: " + (ex.InnerException?.Message ?? ex.Message)); } } return false; } } [HarmonyPatch(typeof(NetworkingManager), "RPC_Others", new Type[] { typeof(Type), typeof(string), typeof(object[]) })] internal static class Patch_NetworkingManager_RPC_Others { private static bool Prefix(Type targetType, string methodName, object[] data) { if (targetType == typeof(EveryonePicksPlugin)) { return true; } return Patch_NetworkingManager_RPC.HandleManagerRpc(targetType, methodName, data); } } internal static class PickBoard { private struct Row { public int playerID; public string name; public Color color; public bool done; public int remaining; public float secondsLeft; } private static Texture2D panelTex; private static Texture2D rowTex; private static Texture2D barTex; private static GUIStyle titleStyle; private static GUIStyle nameStyle; private static GUIStyle statusStyle; private static bool built; private static readonly Color DoneColor = new Color(0.44f, 0.83f, 0.48f); private static readonly Color PickingColor = new Color(1f, 0.79f, 0.28f); private static readonly Color StalledColor = new Color(0.95f, 0.42f, 0.4f); private const float UrgentUnder = 10f; private static Texture2D Solid(Color c) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, c); val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } private static void Build() { //IL_0014: 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_0046: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a8: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown panelTex = Solid(new Color(0.06f, 0.06f, 0.08f, 0.82f)); rowTex = Solid(new Color(1f, 1f, 1f, 0.05f)); barTex = Solid(Color.white); GUIStyle val = new GUIStyle { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val.normal.textColor = new Color(0.75f, 0.76f, 0.8f); titleStyle = val; GUIStyle val2 = new GUIStyle { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val2.normal.textColor = Color.white; nameStyle = val2; GUIStyle val3 = new GUIStyle { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)5 }; val3.normal.textColor = Color.white; statusStyle = val3; built = true; } internal static void Draw() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) if (EveryonePicksPlugin.ShowPickBoard == null || !EveryonePicksPlugin.ShowPickBoard.Value || !State.phaseActive || State.entitlements.Count == 0 || (int)Event.current.type != 7) { return; } if (!built) { Build(); } List<Row> list = new List<Row>(); float realtimeSinceStartup = Time.realtimeSinceStartup; foreach (KeyValuePair<int, int> entitlement in State.entitlements) { int key = entitlement.Key; Player val = State.FindPlayer(key); if (!((Object)(object)val == (Object)null) && !State.HasLeftRoom(val)) { State.statuses.TryGetValue(key, out var value); State.sessionsDone.TryGetValue(key, out var value2); bool done = (value != null && value.done) || value2 >= entitlement.Value; float num = ((value != null) ? (realtimeSinceStartup - value.lastUpdate) : (realtimeSinceStartup - State.phaseStartTime)); float num2 = ((value != null && value.pickSeconds > 0f) ? value.pickSeconds : State.PickSeconds); float secondsLeft = Mathf.Max(0f, num2 - num); list.Add(new Row { playerID = key, name = State.DisplayName(key), color = State.PlayerColor(key), done = done, remaining = (value?.remaining ?? entitlement.Value), secondsLeft = secondsLeft }); } } if (list.Count == 0) { return; } list = (from r in list orderby r.done ? 1 : 0, r.name select r).ToList(); float num3 = Mathf.Clamp(EveryonePicksPlugin.PickBoardScale.Value, 0.6f, 2f); float num4 = 24f * num3; float num5 = 10f * num3; float num6 = 250f * num3; float num7 = 20f * num3; float num8 = num5 * 2f + num7 + (float)list.Count * num4; float num9 = 18f; float num10 = (float)Screen.height - num8 - 18f; titleStyle.fontSize = Mathf.RoundToInt(13f * num3); nameStyle.fontSize = Mathf.RoundToInt(15f * num3); statusStyle.fontSize = Mathf.RoundToInt(14f * num3); GUI.DrawTexture(new Rect(num9, num10, num6, num8), (Texture)(object)panelTex); int num11 = list.Count((Row r) => !r.done); string text = num11 switch { 1 => "WAITING ON 1", 0 => "ALL PICKED", _ => "WAITING ON " + num11, }; GUI.Label(new Rect(num9 + num5, num10 + num5, num6 - num5 * 2f, num7), text, titleStyle); float num12 = num10 + num5 + num7; Rect val2 = default(Rect); foreach (Row item in list) { ((Rect)(ref val2))..ctor(num9 + num5 * 0.5f, num12, num6 - num5, num4); if (!item.done) { GUI.DrawTexture(val2, (Texture)(object)rowTex); } Rect val3 = new Rect(((Rect)(ref val2)).x + 2f, num12 + 4f * num3, 3f * num3, num4 - 8f * num3); GUI.color = item.color; GUI.DrawTexture(val3, (Texture)(object)barTex); GUI.color = Color.white; nameStyle.normal.textColor = (Color)(item.done ? new Color(0.62f, 0.64f, 0.68f) : Color.white); GUI.Label(new Rect(((Rect)(ref val2)).x + 12f * num3, num12, ((Rect)(ref val2)).width * 0.58f, num4), item.name, nameStyle); Color textColor; string text2; if (item.done) { text2 = "picked"; textColor = DoneColor; } else { object obj; if (item.remaining <= 1) { obj = "picking"; } else { int remaining = item.remaining; obj = "picking x" + remaining; } text2 = (string)obj; int num13 = Mathf.CeilToInt(item.secondsLeft); text2 = ((num13 > 0) ? (text2 + " " + num13 + "s") : (text2 + " overdue")); textColor = ((item.secondsLeft <= 10f) ? StalledColor : PickingColor); } statusStyle.normal.textColor = textColor; GUI.Label(new Rect(((Rect)(ref val2)).x + ((Rect)(ref val2)).width * 0.5f - 8f * num3, num12, ((Rect)(ref val2)).width * 0.5f, num4), text2, statusStyle); num12 += num4; } } } internal static class PickReveal { private class Entry { public int playerID; public string name; public Color color; public GameObject card; public GameObject figure; public float bornAt; } private class Slot { public int playerID; public string name; public Color color; public GameObject figure; public readonly List<GameObject> cards = new List<GameObject>(); public Vector3 centre; public float topWorld; public float halfWidth; public float hover; } private const int MaxSpritesPerPlayer = 32; private static readonly List<Entry> entries = new List<Entry>(); private static readonly HashSet<string> seen = new HashSet<string>(); private static readonly Dictionary<SpriteRenderer, int> baseOrders = new Dictionary<SpriteRenderer, int>(); private static GUIStyle nameStyle; private static Texture2D chipTex; private static readonly Vector3 Parked = new Vector3(0f, 2000f, 0f); private static bool shown; private static Camera cachedCam; private static readonly List<Slot> slots = new List<Slot>(); private static readonly Dictionary<int, float> hoverMemory = new Dictionary<int, float>(); private const float SpreadStep = 1.08f; private const float HoverSpeed = 5f; private const float FanStep = 0.34f; private const int CardSortBase = 200; private const int CardSortStep = 20; internal static bool Active => entries.Count > 0; internal static void Add(int playerID, int pickIdx, string cardName) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (EveryonePicksPlugin.ShowReveal == null || !EveryonePicksPlugin.ShowReveal.Value || string.IsNullOrEmpty(cardName) || !State.phaseActive) { return; } string item = playerID + "|" + pickIdx; if (!seen.Add(item)) { return; } try { CardInfo val = State.FindCard(cardName); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = CardChoice.instance.AddCardVisual(val, Vector3.zero); if ((Object)(object)val2 == (Object)null) { seen.Remove(item); return; } Sanitise(val2); val2.transform.position = Parked; bool flag = false; foreach (Entry entry in entries) { if (entry.playerID == playerID) { flag = true; break; } } entries.Add(new Entry { playerID = playerID, name = State.DisplayName(playerID), color = State.PlayerColor(playerID), card = val2, figure = (flag ? null : TryMakeFigure(playerID)), bornAt = Time.realtimeSinceStartup }); Layout(); } catch (Exception ex) { seen.Remove(item); EveryonePicksPlugin.Warn("Reveal add failed: " + ex.Message); } } internal static IEnumerator Hold() { if (entries.Count == 0) { Cleanup(); yield break; } float num = Mathf.Clamp(EveryonePicksPlugin.RevealSeconds.Value, 0.5f, 10f); float num2 = 0f; foreach (Entry entry in entries) { num2 = Mathf.Max(num2, entry.bornAt); } float num3 = num - (Time.realtimeSinceStartup - num2); if (num3 > 0f) { yield return (object)new WaitForSecondsRealtime(num3); } Cleanup(); } private static GameObject TryMakeFigure(int playerID) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) try { Player val = State.FindPlayer(playerID) ?? State.FindPlayer(playerID % 1000); if ((Object)(object)val == (Object)null) { return null; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject == (Object)null) { return null; } SpriteRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SpriteRenderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return null; } GameObject val2 = new GameObject("EveryonePicks_Figure_" + playerID); int num = 0; SpriteRenderer[] array = componentsInChildren; foreach (SpriteRenderer val3 in array) { if (num >= 32) { break; } if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.sprite == (Object)null) && ((Renderer)val3).enabled && ((Component)val3).gameObject.activeInHierarchy) { GameObject val4 = new GameObject(((Object)val3).name); val4.transform.SetParent(val2.transform, false); val4.transform.localPosition = gameObject.transform.InverseTransformPoint(((Component)val3).transform.position); val4.transform.localRotation = Quaternion.Inverse(gameObject.transform.rotation) * ((Component)val3).transform.rotation; val4.transform.localScale = ((Component)val3).transform.lossyScale; SpriteRenderer val5 = val4.AddComponent<SpriteRenderer>(); val5.sprite = val3.sprite; val5.color = val3.color; val5.flipX = val3.flipX; val5.flipY = val3.flipY; ((Renderer)val5).sortingLayerID = ((Renderer)val3).sortingLayerID; ((Renderer)val5).sortingOrder = ((Renderer)val3).sortingOrder; baseOrders[val5] = ((Renderer)val3).sortingOrder; ((Renderer)val5).material = ((Renderer)val3).sharedMaterial; ((Renderer)val5).enabled = true; num++; } } if (num == 0) { array = componentsInChildren; foreach (SpriteRenderer val6 in array) { if (num >= 32) { break; } if (!((Object)(object)val6 == (Object)null) && !((Object)(object)val6.sprite == (Object)null)) { GameObject val7 = new GameObject(((Object)val6).name); val7.transform.SetParent(val2.transform, false); val7.transform.localPosition = gameObject.transform.InverseTransformPoint(((Component)val6).transform.position); val7.transform.localRotation = Quaternion.Inverse(gameObject.transform.rotation) * ((Component)val6).transform.rotation; val7.transform.localScale = ((Component)val6).transform.lossyScale; SpriteRenderer val8 = val7.AddComponent<SpriteRenderer>(); val8.sprite = val6.sprite; val8.color = val6.color; val8.flipX = val6.flipX; val8.flipY = val6.flipY; ((Renderer)val8).sortingLayerID = ((Renderer)val6).sortingLayerID; ((Renderer)val8).sortingOrder = ((Renderer)val6).sortingOrder; ((Renderer)val8).material = ((Renderer)val6).sharedMaterial; ((Renderer)val8).enabled = true; baseOrders[val8] = ((Renderer)val6).sortingOrder; num++; } } } if (num == 0) { EveryonePicksPlugin.Warn("No usable sprites to build a figure for player " + playerID + "; showing the name plate only."); Object.Destroy((Object)(object)val2); return null; } return val2; } catch { return null; } } private static bool LocalStillPicking() { return State.LocalBusy; } private static Camera ResolveCamera() { if ((Object)(object)cachedCam != (Object)null) { return cachedCam; } try { Type type = AccessTools.TypeByName("MainCam"); if (type != null) { object obj = AccessTools.Field(type, "instance")?.GetValue(null); if (obj != null) { object? obj2 = AccessTools.Field(type, "cam")?.GetValue(obj); Camera val = (Camera)((obj2 is Camera) ? obj2 : null); if ((Object)(object)val != (Object)null) { cachedCam = val; return cachedCam; } } } } catch { } if ((Object)(object)Camera.main != (Object)null) { cachedCam = Camera.main; return cachedCam; } try { Camera[] allCameras = Camera.allCameras; foreach (Camera val2 in allCameras) { if ((Object)(object)val2 != (Object)null && ((Behaviour)val2).isActiveAndEnabled) { cachedCam = val2; return cachedCam; } } } catch { } return null; } private static void Park() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) shown = false; foreach (int item in new List<int>(hoverMemory.Keys)) { hoverMemory[item] = 0f; } foreach (Slot slot in slots) { slot.hover = 0f; } foreach (Entry entry in entries) { try { if ((Object)(object)entry.card != (Object)null) { entry.card.transform.position = Parked; } if ((Object)(object)entry.figure != (Object)null) { entry.figure.transform.position = Parked; } } catch { } } } private static void BuildSlots() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) slots.Clear(); foreach (Entry entry in entries) { Slot slot = null; foreach (Slot slot2 in slots) { if (slot2.playerID == entry.playerID) { slot = slot2; break; } } if (slot == null) { slot = new Slot { playerID = entry.playerID, name = entry.name, color = entry.color }; if (hoverMemory.TryGetValue(entry.playerID, out var value)) { slot.hover = value; } slots.Add(slot); } if ((Object)(object)entry.figure != (Object)null) { slot.figure = entry.figure; } if ((Object)(object)entry.card != (Object)null) { slot.cards.Add(entry.card); } } } private static void Layout() { //IL_0041: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00cc: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: 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) //IL_0302: 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_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: 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_0400: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) Camera val = ResolveCamera(); if ((Object)(object)val == (Object)null || entries.Count == 0) { return; } if (LocalStillPicking()) { Park(); return; } BuildSlots(); if (slots.Count == 0) { return; } float num = Mathf.Abs(((Component)val).transform.position.z); Vector3 val2 = val.ViewportToWorldPoint(new Vector3(0.05f, 0.5f, num)); Vector3 val3 = val.ViewportToWorldPoint(new Vector3(0.95f, 0.5f, num)); Vector3 val4 = val.ViewportToWorldPoint(new Vector3(0.5f, 0.84f, num)); Vector3 val5 = val.ViewportToWorldPoint(new Vector3(0.5f, 0.22f, num)); float x = val.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, num)).x; float num2 = val3.x - val2.x; float num3 = Mathf.Abs(val4.y - val5.y); float num4 = (val4.y + val5.y) * 0.5f; float num5 = 0f; float num6 = 0f; foreach (Entry entry in entries) { num5 = Mathf.Max(num5, RawWidth(entry.card)); num6 = Mathf.Max(num6, RawHeight(entry.card)); } if (num5 <= 0.0001f) { Park(); return; } int count = slots.Count; int num7 = Mathf.Max(1, Mathf.CeilToInt((float)count / 6f)); int num8 = Mathf.Max(1, Mathf.CeilToInt((float)count / (float)num7)); int num9 = 1; foreach (Slot slot2 in slots) { num9 = Mathf.Max(num9, slot2.cards.Count); } float num10 = 1f + 0.34f * (float)(num9 - 1); float num11 = num2 / (float)num8; float num12 = num3 / (float)num7; float num13 = Mathf.Min(num11 * 0.86f / (num5 * num10), num12 * 0.52f / num6); num13 *= Mathf.Clamp(EveryonePicksPlugin.RevealCardSize.Value, 0.2f, 6f); num13 = Mathf.Clamp(num13, 0.02f, 60f); float num14 = num5 * num13; float num15 = num6 * num13; shown = true; for (int i = 0; i < count; i++) { Slot slot = slots[i]; int num16 = i / num8; int num17 = i % num8; float num18 = (float)Mathf.Min(num8, count - num16 * num8) * num11; float num19 = x - num18 * 0.5f + num11 * ((float)num17 + 0.5f); float num20 = ((num7 == 1) ? num4 : (val4.y - num12 * ((float)num16 + 0.5f))); slot.centre = new Vector3(num19, num20, 0f); slot.halfWidth = num14 * num10 * 0.5f; bool flag = false; if (slot.cards.Count > 1) { try { float num21 = num14 * (1f + 0.34f * (float)(slot.cards.Count - 1)) * 0.5f; float num22 = num14 * 0.06f; Vector3 val6 = val.WorldToScreenPoint(new Vector3(num19 - num21 - num22, num20 - num15 * 0.5f - num22, 0f)); Vector3 val7 = val.WorldToScreenPoint(new Vector3(num19 + num21 + num22, num20 + num15 * 0.5f + num22, 0f)); Vector3 mousePosition = Input.mousePosition; flag = mousePosition.x >= Mathf.Min(val6.x, val7.x) && mousePosition.x <= Mathf.Max(val6.x, val7.x) && mousePosition.y >= Mathf.Min(val6.y, val7.y) && mousePosition.y <= Mathf.Max(val6.y, val7.y); } catch { } } slot.hover = Mathf.MoveTowards(slot.hover, flag ? 1f : 0f, Time.unscaledDeltaTime * 5f); hoverMemory[slot.playerID] = slot.hover; FanCards(slot, num19, num20, num14, num13); float num23 = num20 + num15 * 0.5f; if ((Object)(object)slot.figure != (Object)null) { float num24 = RawHeight(slot.figure); if (num24 <= 0.0001f) { slot.figure.transform.position = Parked; } else { float num25 = Mathf.Clamp(num15 * 0.38f / num24, num13 * 0.1f, num13 * 8f); float num26 = num24 * num25; slot.figure.transform.localScale = Vector3.one * num25; slot.figure.transform.position = new Vector3(num19, num23 + num26 * 0.6f, 0f); num23 += num26 * 1.15f; LiftAbove(slot.figure, (slot.cards.Count > 0) ? slot.cards[0] : null); } } slot.topWorld = num23; } } private static void FanCards(Slot sl, float x, float y, float cardW, float scale) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) int count = sl.cards.Count; if (count == 0) { return; } float num = (float)(count - 1) * 0.5f; float hover = sl.hover; hover = hover * hover * (3f - 2f * hover); int num2 = ((hover > 0.01f) ? 1000 : 0); float num3 = Mathf.Lerp(0.34f, 1.08f, hover); float num4 = Mathf.Lerp(8f, 0f, hover); float num5 = Mathf.Lerp(0.05f, 0f, hover); float num6 = Mathf.Lerp(1f, 1.06f, hover); for (int i = 0; i < count; i++) { GameObject val = sl.cards[i]; if ((Object)(object)val == (Object)null) { continue; } float num7 = ((float)i - num) * cardW * num3; float num8 = (0f - ((float)i - num)) * num4; float num9 = Mathf.Abs((float)i - num) * cardW * num5; val.transform.localScale = Vector3.one * scale * num6; val.transform.position = new Vector3(x + num7, y - num9, 0f); val.transform.rotation = Quaternion.Euler(0f, 0f, num8); try { Canvas[] componentsInChildren = val.GetComponentsInChildren<Canvas>(true); foreach (Canvas val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { val2.overrideSorting = true; val2.sortingOrder = 200 + i * 20 + num2; } } SpriteRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null)) { ((Renderer)val3).sortingOrder = 200 + i * 20 + num2; } } } catch { } } } private static Vector3 CanvasSize(GameObject go) { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) //IL_0148: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0117: 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) try { Canvas[] componentsInChildren = go.GetComponentsInChildren<Canvas>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return Vector3.zero; } bool flag = false; Vector3 val = Vector3.zero; Vector3[] array = (Vector3[])(object)new Vector3[4]; Canvas[] array2 = componentsInChildren; Vector3 val5 = default(Vector3); foreach (Canvas val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } RectTransform component = ((Component)val2).GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { continue; } Rect rect = component.rect; if (((Rect)(ref rect)).width <= 0.0001f) { continue; } rect = component.rect; if (!(((Rect)(ref rect)).height <= 0.0001f)) { component.GetWorldCorners(array); Vector3 val3 = go.transform.InverseTransformPoint(array[0]); Vector3 val4 = go.transform.InverseTransformPoint(array[2]); ((Vector3)(ref val5))..ctor(Mathf.Abs(val4.x - val3.x), Mathf.Abs(val4.y - val3.y), Mathf.Abs(val4.z - val3.z)); if (!(val5.x <= 0.0001f) && (!flag || val5.x < val.x)) { val = val5; flag = true; } } } if (!flag) { return Vector3.zero; } return val; } catch { return Vector3.zero; } } private static Vector3 UiSize(GameObject go) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_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_0111: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) try { Vector3 result = CanvasSize(go); if (((Vector3)(ref result)).sqrMagnitude > 1E-06f) { return result; } Graphic[] componentsInChildren = go.GetComponentsInChildren<Graphic>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return Vector3.zero; } bool flag = false; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; Vector3[] array = (Vector3[])(object)new Vector3[4]; Graphic[] array2 = componentsInChildren; foreach (Graphic val3 in array2) { if ((Object)(object)val3 == (Object)null || !((Behaviour)val3).enabled || !((Component)val3).gameObject.activeInHierarchy) { continue; } RectTransform rectTransform = val3.rectTransform; if ((Object)(object)rectTransform == (Object)null) { continue; } Rect rect = rectTransform.rect; if (((Rect)(ref rect)).width <= 0.0001f) { continue; } rect = rectTransform.rect; if (((Rect)(ref rect)).height <= 0.0001f) { continue; } rectTransform.GetWorldCorners(array); Vector3[] array3 = array; foreach (Vector3 val4 in array3) { Vector3 val5 = go.transform.InverseTransformPoint(val4); if (!flag) { val = (val2 = val5); flag = true; } else { val = Vector3.Min(val, val5); val2 = Vector3.Max(val2, val5); } } } if (!flag) { return Vector3.zero; } return val2 - val; } catch { return Vector3.zero; } } private static void LiftAbove(GameObject figure, GameObject card) { if ((Object)(object)figure == (Object)null) { return; } try { int num = int.MinValue; string text = null; int num2 = int.MaxValue; if ((Object)(object)card != (Object)null) { Canvas[] componentsInChildren = card.GetComponentsInChildren<Canvas>(true); foreach (Canvas val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && val.sortingOrder > num) { num = val.sortingOrder; text = val.sortingLayerName; } } Renderer[] componentsInChildren2 = card.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && val2.sortingOrder > num) { num = val2.sortingOrder; text = val2.sortingLayerName; } } } num = Mathf.Max(num, 200) + 200; SpriteRenderer[] componentsInChildren3 = figure.GetComponentsInChildren<SpriteRenderer>(true); SpriteRenderer[] array = componentsInChildren3; foreach (SpriteRenderer val3 in array) { if (!((Object)(object)val3 == (Object)null) && baseOrders.TryGetValue(val3, out var value) && value < num2) { num2 = value; } } if (num2 == int.MaxValue) { num2 = 0; } array = componentsInChildren3; foreach (SpriteRenderer val4 in array) { if (!((Object)(object)val4 == (Object)null)) { if (!string.IsNullOrEmpty(text)) { ((Renderer)val4).sortingLayerName = text; } baseOrders.TryGetValue(val4, out var value2); ((Renderer)val4).sortingOrder = num + (value2 - num2); } } } catch { } } internal static void Tick() { if (entries.Count == 0) { return; } try { Layout(); } catch { } } private static float RawWidth(GameObject go) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return RawSize(go).x; } private static float RawHeight(GameObject go) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return RawSize(go).y; } private static Vector3 RawSize(GameObject go) { //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_0009: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_014c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return Vector3.zero; } try { Vector3 result = UiSize(go); if (((Vector3)(ref result)).sqrMagnitude > 1E-06f) { return result; } Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return Vector3.zero; } bool flag = false; Bounds val = default(Bounds); Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if ((Object)(object)val2 == (Object)null || !val2.enabled) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude <= 1E-06f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (!flag) { return Vector3.zero; } Vector3 localScale = go.transform.localScale; return new Vector3(Mathf.Approximately(localScale.x, 0f) ? ((Bounds)(ref val)).size.x : (((Bounds)(ref val)).size.x / localScale.x), Mathf.Approximately(localScale.y, 0f) ? ((Bounds)(ref val)).size.y : (((Bounds)(ref val)).size.y / localScale.y), ((Bounds)(ref val)).size.z); } catch { return Vector3.zero; } } private static void Sanitise(GameObject go) { try { Collider2D[] componentsInChildren = go.GetComponentsInChildren<Collider2D>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } Collider[] componentsInChildren2 = go.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } Rigidbody2D[] componentsInChildren3 = go.GetComponentsInChildren<Rigidbody2D>(true); foreach (Rigidbody2D obj in componentsInChildren3) { obj.simulated = false; obj.isKinematic = true; } PhotonView[] componentsInChildren4 = go.GetComponentsInChildren<PhotonView>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.Destroy((Object)(object)componentsInChildren4[i]); } } catch { } } internal static void Cleanup() { foreach (Entry entry in entries) { try { if ((Object)(object)entry.card != (Object)null) { Object.Destroy((Object)(object)entry.card); } if ((Object)(object)entry.figure != (Object)null) { Object.Destroy((Object)(object)entry.figure); } } catch { } } entries.Clear(); slots.Clear(); hoverMemory.Clear(); seen.Clear(); baseOrders.Clear(); shown = false; cachedCam = null; } private static void Build() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0013: 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_0040: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown chipTex = new Texture2D(1, 1); chipTex.SetPixel(0, 0, Color.white); chipTex.Apply(); ((Object)chipTex).hideFlags = (HideFlags)61; GUIStyle val = new GUIStyle { fontSize = 17, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val.normal.textColor = Color.white; nameStyle = val; } internal static void DrawLabels() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0174: Unknown result type (might be due to invalid IL or missing references) if (entries.Count == 0 || !shown || slots.Count == 0 || (int)Event.current.type != 7) { return; } if (nameStyle == null) { Build(); } Camera val = ResolveCamera(); if ((Object)(object)val == (Object)null) { return; } foreach (Slot slot in slots) { if (slot.cards.Count == 0) { continue; } Vector3 val2; try { val2 = val.WorldToScreenPoint(new Vector3(slot.centre.x, slot.topWorld, 0f)); } catch { continue; } if (!(val2.z <= 0f)) { Vector3 val3; try { val3 = val.WorldToScreenPoint(new Vector3(slot.centre.x + slot.halfWidth, slot.topWorld, 0f)); } catch { continue; } float num = Mathf.Max(50f, Mathf.Abs(val3.x - val2.x)); float x = val2.x; float num2 = (float)Screen.height - val2.y - 30f; Rect val4 = new Rect(x - num * 0.55f, num2 + 21f, num * 1.1f, 3f); GUI.color = slot.color; GUI.DrawTexture(val4, (Texture)(object)chipTex); GUI.color = Color.white; GUI.Label(new Rect(x - num, num2, num * 2f, 22f), slot.name, nameStyle); } } } } internal static class SoftPatches { private static Type cursedCardType; private static Type curseMgrType; private static Type pickTrackerType; private static Type cardBarUtilsType; internal static void Apply(Harmony h) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown Type type = AccessTools.TypeByName("Rounds2Mod.CardDeleteManager") ?? AccessTools.TypeByName("CardDeleteManager"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "BeginPickPhase", (Type[])null, (Type[])null) : null); if (methodInfo != null) { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SoftPatches), "SkipWhenPhaseActive", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); EveryonePicksPlugin.Log("Card Delete Mechanic detected - delete disabled during simultaneous picks."); } Type type2 = AccessTools.TypeByName("RWF.GameModes.RWFGameMode"); MethodInfo methodInfo2 = ((type2 != null) ? AccessTools.Method(type2, "ResetMatch", (Type[])null, (Type[])null) : null); if (methodInfo2 != null) { h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(SoftPatches), "OnResetMatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Type type3 = AccessTools.TypeByName("RWF.PlayerManagerExtensions"); MethodInfo methodInfo3 = ((type3 != null) ? AccessTools.Method(type3, "GetPickOrder", (Type[])null, (Type[])null) : null); if (methodInfo3 != null) { h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(SoftPatches), "OnPickOrderResolved", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); EveryonePicksPlugin.Log("RoundsWithFriends detected - pick order will be read up front."); } NeutralisePickTimer(h); LeaverResilience.Apply(h); cursedCardType = AccessTools.TypeByName("AALUND13Cards.ExtraCards.Cards.CursedCard") ?? AccessTools.TypeByName("AALUND13Cards.Cards.CursedCard") ?? AccessTools.TypeByName("CursedCard"); curseMgrType = AccessTools.TypeByName("WillsWackyManagers.Utils.CurseManager"); pickTrackerType = AccessTools.TypeByName("AALUND13Cards.Handlers.PickCardTracker") ?? AccessTools.TypeByName("PickCardTracker"); cardBarUtilsType = AccessTools.TypeByName("ModdingUtils.Utils.CardBarUtils"); } private static void NeutralisePickTimer(Harmony h) { if (!(AccessTools.TypeByName("PickTimer.PickTimer") == null)) { EveryonePicksPlugin.Log("PickTimer detected - suppressing its auto-pick timer during simultaneous picks (EveryonePicks has its own per-player timer)."); int num = 0; num += PatchEnumerator(h, "PickTimer.Util.PickTimerController", "StartPickTimer"); num += PatchEnumerator(h, "PickTimer.Util.TimerHandler", "Start"); num += PatchEnumerator(h, "PickTimerCompat.Plugin", "FixedStartPickTimer"); EveryonePicksPlugin.Log("PickTimer suppression: " + (num + PatchVoid(h, "PickTimerCompat.Plugin", "RetriggerTimer")) + " entry point(s) patched."); } } private static int PatchEnumerator(Harmony h, string typeName, string methodName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Type type = AccessTools.TypeByName(typeName); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : null); if (methodInfo == null) { return 0; } try { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SoftPatches), "SuppressEnumerator", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return 1; } catch (Exception ex) { EveryonePicksPlugin.Warn("Could not suppress " + typeName + "." + methodName + ": " + ex.Message); return 0; } } private static int PatchVoid(Harmony h, string typeName, string methodName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Type type = AccessTools.TypeByName(typeName); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : null); if (methodInfo == null) { return 0; } try { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SoftPatches), "SkipWhenPhaseActive", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return 1; } catch (Exception ex) { EveryonePicksPlugin.Warn("Could not suppress " + typeName + "." + methodName + ": " + ex.Message); return 0; } } private static bool SuppressEnumerator(ref IEnumerator __result) { if (!State.phaseActive && !State.localPickActive) { return true; } __result = EmptyRoutine(); return false; } private static IEnumerator EmptyRoutine() { yield break; } private static bool SkipWhenPhaseActive() { if (!State.phaseActive) { return !State.localPickActive; } return false; } private static void OnResetMatch() { State.HardReset("RWFGameMode.ResetMatch"); } private static void OnPickOrderResolved(List<Player> __result) { try { State.SeedPickers(__result); } catch (Exception ex) { EveryonePicksPlugin.Warn("Seeding pick order failed: " + ex.Message); } } private static object ResolveSingleton(Type t) { if (t == null) { return null; } FieldInfo fieldInfo = AccessTools.Field(t, "instance") ?? AccessTools.Field(t, "Instance"); if (fieldInfo != null) { try { return fieldInfo.GetValue(null); } catch { } } MethodInfo methodInfo =