using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using SettingsUI; using TMPro; using UnboundLib; using UnboundLib.GameModes; using UnboundLib.Networking; 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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("PickMore")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PickMore")] [assembly: AssemblyTitle("PickMore")] [assembly: AssemblyVersion("0.5.0.0")] namespace PickMore; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.sauceproducer.rounds.pickmore", "PickMore", "0.5.0")] [BepInProcess("Rounds.exe")] public class PickMorePlugin : BaseUnityPlugin { [HarmonyPatch(typeof(CardChoice), "DoPick")] [HarmonyPriority(800)] private class CardChoiceDoPickPatch { private static void Postfix(int picketIDToSet) { if (!extraPicksInProgress) { lastPickedPlayer = picketIDToSet; } } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__16_0; public static Func <>9__16_1; internal void b__16_0() { } internal IEnumerator b__16_1(IGameModeHandler gm) { return ResetState(); } } [CompilerGenerated] private sealed class d__22 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private int 5__3; private int 5__4; private bool 5__5; private int 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (extraPicksInProgress) { return false; } 5__2 = lastPickedPlayer; if (5__2 < 0) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[PickMore] no lastPickedPlayer - skipping extras"); } return false; } 5__3 = Mathf.Clamp(MaxPicks, 1, 30); if (5__3 <= 1) { return false; } extraPicksInProgress = true; DoneRequested = false; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] -> Player " + 5__2 + " continues (picks 2-" + 5__3 + ")")); } 5__4 = 0; 5__5 = false; <>1__state = -3; 5__6 = 0; break; case 1: <>1__state = -3; if ((Object)(object)CardChoiceVisuals.instance != (Object)null) { CardChoiceVisuals.instance.Show(5__2, true); } <>2__current = CardChoice.instance.DoPick(5__2, 5__2, (PickerType)1); <>1__state = 2; return true; case 2: <>1__state = -3; <>2__current = (object)new WaitForSecondsRealtime(0.15f); <>1__state = 3; return true; case 3: <>1__state = -3; 5__4 = 5__6 + 1; 5__6++; break; } if (5__6 < 5__3 - 1) { if (!DoneRequested) { currentPickNumber = 5__6 + 2; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] pick " + currentPickNumber + "/" + 5__3 + " for player " + 5__2)); } <>2__current = GameModeManager.TriggerHook("PlayerPickStart"); <>1__state = 1; return true; } 5__5 = true; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] Continue clicked - stopping at " + (5__6 + 1) + " extras")); } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if ((Object)(object)CardChoiceVisuals.instance != (Object)null) { CardChoiceVisuals.instance.Hide(); } extraPicksInProgress = false; currentPickNumber = 1; lastPickedPlayer = -1; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] <- Player " + 5__2 + " finished after " + 5__4 + " extra picks" + (5__5 ? " (continue clicked)." : "."))); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; if (!extraPicksInProgress) { lastPickedPlayer = -1; DoneRequested = false; currentPickNumber = 1; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] === Pick phase START (max=" + MaxPicks + ") ===")); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string ModId = "com.sauceproducer.rounds.pickmore"; public const string ModName = "PickMore"; public const string Version = "0.5.0"; public const int HardMaxPicks = 30; public static ConfigEntry MaxPicksConfig; internal static bool extraPicksInProgress = false; internal static bool DoneRequested = false; internal static int lastPickedPlayer = -1; internal static int currentPickNumber = 1; public static PickMorePlugin Instance { get; private set; } public static int MaxPicks { get { if (MaxPicksConfig != null) { return MaxPicksConfig.Value; } return 5; } } private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) Instance = this; MaxPicksConfig = ((BaseUnityPlugin)this).Config.Bind("PickMore", "MaxPicks", 5, "How many cards each player picks per pick phase. Host's value is authoritative in multiplayer. Range 1-" + 30 + "."); new Harmony("com.sauceproducer.rounds.pickmore").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PickMore] v0.5.0 loaded. MaxPicks=" + MaxPicks)); } private void Start() { //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__16_0; if (obj == null) { UnityAction val = delegate { }; <>c.<>9__16_0 = val; obj = (object)val; } Unbound.RegisterMenu("PickMore", (UnityAction)obj, (Action)BuildMenu, (GameObject)null, false); Unbound.RegisterHandshake("com.sauceproducer.rounds.pickmore", (Action)OnHandshakeCompleted); GameModeManager.AddHook("PickStart", (Func)((IGameModeHandler gm) => ResetState()), 800); GameModeManager.AddHook("PlayerPickEnd", (Func)OnPlayerPickEnd, 800); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[PickMore] hooks registered."); } private static void OnHandshakeCompleted() { if (PhotonNetwork.IsMasterClient) { NetworkingManager.RPC_Others(typeof(PickMorePlugin), "SyncMaxPicks", new object[1] { MaxPicks }); } } [UnboundRPC] private static void SyncMaxPicks(int hostValue) { int value = Mathf.Clamp(hostValue, 1, 30); if (MaxPicksConfig != null) { MaxPicksConfig.Value = value; } if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[PickMore] Host set MaxPicks=" + value)); } } [UnboundRPC] private static void SyncDone() { DoneRequested = true; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[PickMore] Done broadcast received."); } } private static void BroadcastDoneIfHost() { DoneRequested = true; NetworkingManager.RPC_Others(typeof(PickMorePlugin), "SyncDone", new object[0]); } [IteratorStateMachine(typeof(d__21))] private static IEnumerator ResetState() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0); } [IteratorStateMachine(typeof(d__22))] private static IEnumerator OnPlayerPickEnd(IGameModeHandler gm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0); } internal void BuildMenu(GameObject menu) { try { TextMeshProUGUI val = default(TextMeshProUGUI); MenuHandler.CreateText("PickMore", menu, ref val, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText("Each picking player takes N cards in one sitting. Click on-screen Continue to stop early. In a lobby, only the host can change this.", menu, ref val, 24, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); int num = ((MaxPicksConfig == null) ? 5 : MaxPicksConfig.Value); UnityAction val2 = delegate(float v) { try { int num2 = Mathf.Clamp(Mathf.RoundToInt(v), 1, 30); if (MaxPicksConfig != null) { MaxPicksConfig.Value = num2; } if (PhotonNetwork.IsMasterClient && !PhotonNetwork.OfflineMode) { NetworkingManager.RPC_Others(typeof(PickMorePlugin), "SyncMaxPicks", new object[1] { num2 }); } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("[PickMore] slider onChange threw: " + ex2)); } }; Slider val3 = default(Slider); MenuHandler.CreateSlider("Max cards per pick phase", menu, 30, 1f, 30f, (float)num, val2, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[PickMore] BuildMenu threw: " + ex)); } } private void OnGUI() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!extraPicksInProgress || DoneRequested) { return; } int num = Mathf.Clamp(MaxPicks, 1, 30); string text = "Continue (" + currentPickNumber + "/" + num + ")"; int num2 = 260; int num3 = 64; int num4 = (Screen.width - num2) / 2; int num5 = Screen.height - num3 - 30; if (GUI.Button(new Rect((float)num4, (float)num5, (float)num2, (float)num3), text)) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[PickMore] Continue clicked."); } BroadcastDoneIfHost(); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.sauceproducer.rounds.pickmore.rwfcompat", "PickMore RWF Compatibility", "0.5.0")] [BepInProcess("Rounds.exe")] internal class PickMoreRWFCompat : CompatibilityHandler { public override string MenuName => "PickMore"; public override bool HostOnly => true; public override void Start() { Debug.Log("[PickMore] RWF compat Start() running, calling base to register menu..."); try { ((CompatibilityHandler)this).Start(); Debug.Log("[PickMore] RWF compat Start() finished. PickMorePlugin.Instance=" + (((Object)(object)PickMorePlugin.Instance != (Object)null) ? "ok" : "NULL!")); } catch (Exception ex) { Debug.LogError("[PickMore] RWF compat Start() threw: " + ex); } } public override void GUI(GameObject menu) { Debug.Log("[PickMore] RWF compat GUI() invoked. PickMorePlugin.Instance=" + (((Object)(object)PickMorePlugin.Instance != (Object)null) ? "ok" : "NULL!") + ", menu=" + (((Object)(object)menu != (Object)null) ? "ok" : "NULL")); try { if ((Object)(object)PickMorePlugin.Instance != (Object)null) { PickMorePlugin.Instance.BuildMenu(menu); } else { Debug.LogError("[PickMore] RWF compat: PickMorePlugin.Instance is null - cannot build menu!"); } } catch (Exception ex) { Debug.LogError("[PickMore] RWF compat GUI() threw: " + ex); } } }