Decompiled source of Straftat Tournaments v1.5.1
BepInEx/plugins/StraftatTournaments/StraftatTournaments.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ComputerysModdingUtilities; using DG.Tweening; using FishNet; using FishNet.Connection; using FishNet.Object; using FishNet.Object.Synchronizing; using FishNet.Transporting; using FishySteamworks; using HarmonyLib; using ModMenu.Api; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.LowLevel; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("StraftatTournaments")] [assembly: AssemblyDescription("Tournament lobbies for STRAFTAT: the tournament map pool, captain map bans and spectator slots.")] [assembly: AssemblyFileVersion("1.4.8.0")] [assembly: StraftatMod(true)] [assembly: AssemblyVersion("1.5.1.0")] namespace StraftatTournaments; internal static class Clicks { private const int MaxRows = 40000; private static bool _on; private static double _t0; private static readonly bool[] _btn = new bool[2]; private static readonly StringBuilder _rows = new StringBuilder(16384); private static int _count; private static readonly List<double>[] _down = new List<double>[2] { new List<double>(), new List<double>() }; private static readonly List<double> _holds = new List<double>(); private static double _leftDownAt = -1.0; private const double Bounce = 15.0; private static readonly double[] _upAt = new double[2] { -1000000000.0, -1000000000.0 }; private static readonly double[] _lastDown = new double[2]; private static int _bounces; private static bool _hooked; internal static Func<bool> Alive = () => false; internal static void Hook() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!_hooked) { _hooked = true; InputSystem.onEvent += (Action<InputEventPtr, InputDevice>)OnEvent; } } internal static void Begin() { _on = true; _t0 = InputState.currentTime; _btn[0] = (_btn[1] = false); _rows.Length = 0; _count = 0; _down[0].Clear(); _down[1].Clear(); _holds.Clear(); _leftDownAt = -1.0; _upAt[0] = (_upAt[1] = -1000000000.0); _lastDown[0] = (_lastDown[1] = 0.0); _bounces = 0; } internal static void Stop() { _on = false; } private static void OnEvent(InputEventPtr e, InputDevice d) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) try { if (_on) { Mouse val = (Mouse)(object)((d is Mouse) ? d : null); if (val != null && (((InputEventPtr)(ref e)).IsA<StateEvent>() || ((InputEventPtr)(ref e)).IsA<DeltaStateEvent>())) { Check(val.leftButton, 0, e); Check(val.rightButton, 1, e); } } } catch (Exception e2) { TournamentPlugin.WarnOnce("Clicks.OnEvent", e2); } } private static void Check(ButtonControl b, int i, InputEventPtr e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if (!InputControlExtensions.ReadValueFromEvent<float>((InputControl<float>)(object)b, e, ref num)) { return; } bool flag = num > 0.5f; if (flag == _btn[i]) { return; } _btn[i] = flag; if (!Alive()) { return; } double num2 = (((InputEventPtr)(ref e)).time - _t0) * 1000.0; if (flag && num2 - _upAt[i] < 15.0) { _bounces++; if (i == 0 && _holds.Count > 0) { _holds.RemoveAt(_holds.Count - 1); _leftDownAt = _lastDown[0]; } } else { if (flag) { _down[i].Add(num2); _lastDown[i] = num2; } else { _upAt[i] = num2; } if (i == 0) { if (flag) { _leftDownAt = num2; } else if (_leftDownAt >= 0.0) { _holds.Add(num2 - _leftDownAt); _leftDownAt = -1.0; } } } if (_count < 40000) { if (_count > 0) { _rows.Append(",\n"); } _rows.Append(" [").Append(Math.Round(num2, 1).ToString("0.0", CultureInfo.InvariantCulture)).Append(',') .Append(i) .Append(',') .Append(flag ? 1 : 0) .Append(']'); _count++; } } internal static void Append(StringBuilder sb) { sb.Append(" \"clicks\": {\n"); sb.Append(" \"buttons\": \"0 is left, 1 is right\",\n"); sb.Append(" \"columns\": [\"ms\", \"button\", \"down\"],\n"); sb.Append(" \"rows\": [\n").Append(_rows).Append("\n ]\n }"); } internal static JObject Summary() { //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown List<double> left = _down[0]; List<double> list = _down[1]; int num = 0; int i = 0; for (int j = 0; j < left.Count; j++) { for (; left[j] - left[i] > 1000.0; i++) { } num = Math.Max(num, j - i + 1); } double num2 = -1.0; double value = 0.0; int num3 = 0; int num4 = 0; for (int k = 1; k <= left.Count; k++) { if (k < left.Count && left[k] - left[k - 1] < 250.0) { continue; } int num5 = k - num4; if (num5 >= 10) { List<double> list2 = (from num8 in Enumerable.Range(num4 + 1, num5 - 1) select left[num8] - left[num8 - 1]).ToList(); double num6 = list2.Average(); double num7 = ((num6 > 0.0) ? (Std(list2) / num6) : 0.0); if (num2 < 0.0 || num7 < num2) { num2 = num7; value = num6; num3 = num5; } } num4 = k; } List<double> list3 = _holds.Where((double h) => h < 80.0).ToList(); double value2 = ((list3.Count > 0) ? list3.Average() : 0.0); return new JObject { ["left"] = JToken.op_Implicit(left.Count), ["right"] = JToken.op_Implicit(list.Count), ["maxClicksPerSecond"] = JToken.op_Implicit(num), ["evenestRun"] = (JToken)((num3 == 0) ? ((JObject)null) : new JObject { ["clicks"] = JToken.op_Implicit(num3), ["meanGapMs"] = JToken.op_Implicit(Math.Round(value, 2)), ["spread"] = JToken.op_Implicit(Math.Round(num2, 4)) }), ["shortHolds"] = JToken.op_Implicit(list3.Count), ["shortHoldStdMs"] = JToken.op_Implicit((list3.Count >= 10) ? new double?(Math.Round(Std(list3), 2)) : ((double?)null)), ["shortHoldMeanMs"] = JToken.op_Implicit((list3.Count >= 10) ? new double?(Math.Round(value2, 2)) : ((double?)null)), ["bounces"] = JToken.op_Implicit(_bounces), ["leftThenRight"] = (JToken)(object)Pairs(left, list) }; } private static JObject Pairs(List<double> first, List<double> then) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown List<double> list = new List<double>(); int num = 0; int i = 0; foreach (double item in first) { for (; i < then.Count && then[i] < item; i++) { } if (i < then.Count && !(then[i] - item > 150.0)) { if (then[i] - item < 8.0) { num++; } else { list.Add(then[i] - item); } } } if (list.Count != 0) { return new JObject { ["count"] = JToken.op_Implicit(list.Count), ["meanGapMs"] = JToken.op_Implicit(Math.Round(list.Average(), 2)), ["stdMs"] = JToken.op_Implicit((list.Count >= 2) ? Math.Round(Std(list), 2) : 0.0), ["together"] = JToken.op_Implicit(num) }; } return new JObject { ["count"] = JToken.op_Implicit(0), ["together"] = JToken.op_Implicit(num) }; } private static double Std(List<double> v) { if (v.Count < 2) { return 0.0; } double m = v.Average(); return Math.Sqrt(v.Sum((double x) => (x - m) * (x - m)) / (double)(v.Count - 1)); } } internal static class Spectate { private static readonly FieldRef<KillCam, TextMeshProUGUI> SwitchText = AccessTools.FieldRefAccess<KillCam, TextMeshProUGUI>("switchCamText"); private static readonly FieldRef<KillCam, TextMeshProUGUI> NameText = AccessTools.FieldRefAccess<KillCam, TextMeshProUGUI>("playerNameText"); private static readonly FieldRef<KillCam, TextMeshProUGUI> HpText = AccessTools.FieldRefAccess<KillCam, TextMeshProUGUI>("playerHpText"); private static readonly List<PlayerHealth> _alive = new List<PlayerHealth>(); private static float _nextFind; private static int _scene = -1; private static int _at; private static PlayerHealth _target; private static bool _free; private static bool _hideHud; private static bool _placed; internal static void Update(KillCam cam) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); int handle = ((Scene)(ref activeScene)).handle; if (handle != _scene) { _scene = handle; _target = null; _free = (_placed = false); _nextFind = 0f; ShortcutExtensions.DOKill((Component)(object)((Component)cam).transform, false); } PauseManager instance = PauseManager.Instance; if ((Object)(object)instance == (Object)null || instance.inMainMenu) { return; } Transform transform = ((Component)cam).transform; if ((Object)(object)transform.parent != (Object)null) { transform.SetParent((Transform)null); } if (Time.unscaledTime >= _nextFind) { Find(); } if ((Object)(object)_target != (Object)null && !Alive(_target)) { _target = null; } if ((Object)(object)_target == (Object)null && _alive.Count > 0) { _at = Mathf.Clamp(_at, 0, _alive.Count - 1); _target = _alive[_at]; } bool flag = !instance.pause && !instance.chatting; if (flag) { if (Input.GetKeyDown((KeyCode)104)) { _hideHud = !_hideHud; } if (cam.interact != null && cam.interact.WasPerformedThisFrame()) { _free = !_free; } if (Input.GetMouseButtonDown(0)) { Switch(1); } if (Input.GetMouseButtonDown(1)) { Switch(-1); } } if (_free) { FreeCam(cam, flag); } else if ((Object)(object)_target != (Object)null) { Follow(transform, _target); } else if (!_placed) { Wait(transform); } Texts(cam, instance); } private static void Find() { _nextFind = Time.unscaledTime + 0.25f; _alive.Clear(); PlayerHealth[] array = Object.FindObjectsOfType<PlayerHealth>(); foreach (PlayerHealth val in array) { if (Alive(val)) { _alive.Add(val); } } _alive.Sort((PlayerHealth a, PlayerHealth b) => Id(a).CompareTo(Id(b))); if ((Object)(object)_target != (Object)null) { _at = Mathf.Max(0, _alive.IndexOf(_target)); } } private static bool Alive(PlayerHealth p) { if ((Object)(object)p != (Object)null && ((Component)p).gameObject.activeInHierarchy && !p.isKilled) { return p.health > 0f; } return false; } private static int Id(PlayerHealth p) { ClientInstance val = Client(p); if (!((Object)(object)val != (Object)null)) { return int.MaxValue; } return val.PlayerId; } private static ClientInstance Client(PlayerHealth p) { PlayerValues val = (((Object)(object)p != (Object)null) ? ((Component)p).GetComponent<PlayerValues>() : null); if (!((Object)(object)val != (Object)null)) { return null; } return val.playerClient; } private static void Switch(int step) { _free = false; if (_alive.Count != 0) { _at = ((_at + step) % _alive.Count + _alive.Count) % _alive.Count; _target = _alive[_at]; } } private static void Follow(Transform cam, PlayerHealth p) { //IL_0009: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)p).transform; cam.position = transform.position + new Vector3(0f, 2.3f, 0f) - transform.forward * 2.3f; cam.LookAt(transform.position + new Vector3(0f, 1.7f, 0f)); _placed = true; } private static void Wait(Transform cam) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) SpawnPoint val = Object.FindObjectOfType<SpawnPoint>(); if (!((Object)(object)val == (Object)null)) { cam.position = ((Component)val).transform.position + new Vector3(0f, 2.3f, 0f) - ((Component)val).transform.forward * 2.3f; cam.rotation = Quaternion.Euler(15f, ((Component)val).transform.eulerAngles.y, 0f); _placed = true; } } private static void FreeCam(KillCam cam, bool input) { //IL_0026: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c6: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)cam).transform; if (input) { Patches.Look(transform); Vector2 val = ((cam.move != null) ? cam.move.ReadValue<Vector2>() : Vector2.zero); bool num = cam.run != null && cam.run.ReadValue<float>() > 0.1f; int num2 = 0; if (Input.GetKey((KeyCode)113) || Input.GetKey((KeyCode)306)) { num2 = -1; } if (Input.GetKey((KeyCode)101) || Input.GetKey((KeyCode)32)) { num2 = 1; } float num3 = (num ? 30f : 15f) * Time.deltaTime; transform.Translate((transform.right * val.x + transform.up * (float)num2 + transform.forward * val.y) * num3, (Space)0); } } private static void Texts(KillCam cam, PauseManager pm) { TextMeshProUGUI val = SwitchText.Invoke(cam); TextMeshProUGUI val2 = NameText.Invoke(cam); TextMeshProUGUI val3 = HpText.Invoke(cam); string text = ""; string text2 = ""; string text3 = ""; if (!_hideHud) { text = "Mouse Buttons to switch player. " + pm.InteractPromptLetter + " to toggle free cam. H to hide HUD"; if (_free) { text3 = "Free Camera"; } else if ((Object)(object)_target != (Object)null) { text3 = "Health : " + Mathf.Ceil(_target.health / 4f * 100f); ClientInstance val4 = Client(_target); if ((Object)(object)val4 != (Object)null) { text2 = "Player : " + val4.PlayerName; } } else { text3 = "Waiting for players"; } } if ((Object)(object)val != (Object)null && ((TMP_Text)val).text != text) { ((TMP_Text)val).text = text; } if ((Object)(object)val2 != (Object)null && ((TMP_Text)val2).text != text2) { ((TMP_Text)val2).text = text2; } if ((Object)(object)val3 != (Object)null && ((TMP_Text)val3).text != text3) { ((TMP_Text)val3).text = text3; } } } internal static class ModMenuBridge { public const string Guid = "kestrel.straftat.modmenu"; [MethodImpl(MethodImplOptions.NoInlining)] public static void Register(ConfigFile config) { List<ConfigEntryBase> list = new List<ConfigEntryBase>(); foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in config) { if ((object)item.Value != TournamentPlugin.PanelKey) { list.Add(item.Value); } } ModMenuCustomisation.HideEntries((IEnumerable<ConfigEntryBase>)list); } } internal static class Updater { private const string Url = "https://strafth.com/api/tournament"; internal const string Prefix = "Straftat Tournaments: "; private const string OldPrefix = "tournament:"; private const float Every = 300f; private static readonly FieldRef<WeaponRemapper, List<WeaponRemapPreset>> Presets = AccessTools.FieldRefAccess<WeaponRemapper, List<WeaponRemapPreset>>("_weaponRemaps"); internal static long Updated; internal static string PlaylistCode = ""; internal static string SwapperCode = ""; internal static string PlaylistName = ""; internal static string SwapperName = ""; internal static int PlaylistMaps; internal static string Status = "checking strafth.com"; private static bool _fetched; private static bool _playlistPending; private static bool _swapperPending; private static float _nextSwapperLook; private static string _prevPlaylist = ""; private static string[] _prevMaps = new string[0]; private static bool _hasPrev; private static bool _pick; private static bool _held; private static bool _sawMatch; private static bool _startChecked; private static bool _swapBack; private static bool _swapperRemembered; private static float _heldAt; private static float _nextHoldLook; private static string _prevSwapper; private static JObject _last; internal static bool Live; internal static string PoolName { get { if (PlaylistName != "") { return PlaylistName; } if (SwapperName != "") { return SwapperName; } MapsManager instance = MapsManager.Instance; Playlist val = (((Object)(object)instance != (Object)null && instance.Playlists != null) ? instance.Playlists.Find((Playlist x) => IsOurs(x.Name)) : null); if (val == null) { return ""; } return Bare(val.Name); } } private static string CachePath => Path.Combine(Paths.ConfigPath, "dorsth.straftat.straftattournaments.json"); private static string OldCachePath => Path.Combine(Paths.ConfigPath, "dorsth.straftat.tournament.json"); internal static string Named(string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) Color val = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)); Color val2 = Color32.op_Implicit(new Color32((byte)127, (byte)212, byte.MaxValue, byte.MaxValue)); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < "Straftat Tournaments".Length; i++) { stringBuilder.Append("<color=#").Append(ColorUtility.ToHtmlStringRGB(Color.Lerp(val, val2, (float)i / ((float)"Straftat Tournaments".Length - 1f)))).Append('>') .Append("Straftat Tournaments"[i]) .Append("</color>"); } return stringBuilder.Append(": ").Append(Bare(name)).ToString(); } internal static string Bare(string name) { string text = Plain(name); string text2 = "Straftat Tournaments: ".TrimEnd(); while (true) { if (text.StartsWith(text2, StringComparison.OrdinalIgnoreCase)) { text = text.Substring(text2.Length).TrimStart(); continue; } if (!text.StartsWith("tournament:", StringComparison.OrdinalIgnoreCase)) { break; } text = text.Substring("tournament:".Length).TrimStart(); } return text; } internal static bool IsOurs(string name) { if (name == null) { return false; } string text = Plain(name); if (!text.StartsWith("Straftat Tournaments: ".TrimEnd(), StringComparison.OrdinalIgnoreCase)) { return text.StartsWith("tournament:", StringComparison.OrdinalIgnoreCase); } return true; } internal static void Start(MonoBehaviour host) { ReadCache(); host.StartCoroutine(Loop()); } private static IEnumerator Loop() { while (true) { PauseManager instance = PauseManager.Instance; if ((Object)(object)instance == (Object)null || instance.inMainMenu) { yield return Fetch(); } yield return (object)new WaitForSecondsRealtime(300f); } } private static void Hold() { if (!_swapperRemembered) { _prevSwapper = ((WeaponRemapper.SelectedPreset != null && !IsOurs(WeaponRemapper.SelectedPreset.Name)) ? WeaponRemapper.SelectedPreset.Name : null); _swapperRemembered = true; } _held = true; _sawMatch = false; _heldAt = Time.unscaledTime; } private static void Holding() { if (Time.unscaledTime < _nextHoldLook) { return; } _nextHoldLook = Time.unscaledTime + 0.5f; MapsManager instance = MapsManager.Instance; if (!_startChecked) { if ((Object)(object)instance == (Object)null || instance.Playlists == null || instance.Playlists.Count == 0) { return; } _startChecked = true; if (!_held && Picked(instance)) { PutBack("left picked from before"); } if (!_held && WeaponRemapper.SelectedPreset != null && IsOurs(WeaponRemapper.SelectedPreset.Name)) { _swapBack = true; _prevSwapper = null; } } if (_held) { if (!InMenu()) { _sawMatch = true; } else if (_sawMatch) { PutBack("the match is over"); } else if (!LobbyState.InLobby) { PutBack("the lobby was left"); } else if (LobbyState.Ban == null && Time.unscaledTime - _heldAt > 60f) { PutBack("no match was started"); } } } private static bool Picked(MapsManager mm) { int activePlaylistIndex = mm.activePlaylistIndex; if (activePlaylistIndex >= 0 && activePlaylistIndex < mm.Playlists.Count) { return IsOurs(mm.Playlists[activePlaylistIndex].Name); } return false; } private static void PutBack(string why) { _held = false; _sawMatch = false; MapsManager instance = MapsManager.Instance; if ((Object)(object)instance != (Object)null && instance.Playlists != null && Picked(instance)) { TournamentPlugin.Log.LogInfo((object)("Map pool: " + why + ", the playlist picked before is back")); GoBack(instance); } if (_swapperRemembered || (WeaponRemapper.SelectedPreset != null && IsOurs(WeaponRemapper.SelectedPreset.Name))) { _swapBack = true; } _hasPrev = false; WriteCache(); } private static void SwapperBack() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!InMenu() || Time.unscaledTime < _nextSwapperLook) { return; } _nextSwapperLook = Time.unscaledTime + 1f; WeaponRemapper val = null; WeaponRemapper[] array = Resources.FindObjectsOfTypeAll<WeaponRemapper>(); foreach (WeaponRemapper val2 in array) { if ((Object)(object)val2 != (Object)null) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { val = val2; break; } } } if ((Object)(object)val == (Object)null) { return; } _swapBack = false; _swapperRemembered = false; if (WeaponRemapper.SelectedPreset != null && IsOurs(WeaponRemapper.SelectedPreset.Name)) { List<WeaponRemapPreset> list = Presets.Invoke(val); WeaponRemapper.SelectedPreset = ((_prevSwapper == null) ? null : list?.Find((WeaponRemapPreset p) => p != null && p.Name == _prevSwapper)); val.TriggerSave(); } } internal static bool ApplyPool() { MapsManager instance = MapsManager.Instance; if ((Object)(object)instance == (Object)null || instance.Playlists == null) { return false; } _playlistPending = true; TryPlaylist(); int num = instance.Playlists.FindIndex((Playlist p) => IsOurs(p.Name)); if (num < 0) { return false; } Hold(); if (instance.activePlaylistIndex != num) { Remember(instance); instance.activePlaylistIndex = num; try { instance.SetActivePlaylist(num); } catch (Exception e) { TournamentPlugin.WarnOnce("Updater.ApplyPool", e); } Save(instance); } if (SwapperCode != "") { _pick = true; try { TrySwapper(); } finally { _pick = false; } } return true; } internal static void CheckNow() { if ((Object)(object)TournamentPlugin.I != (Object)null) { ((MonoBehaviour)TournamentPlugin.I).StartCoroutine(Fetch()); } } private static IEnumerator Fetch() { UnityWebRequest req = UnityWebRequest.Get("https://strafth.com/api/tournament"); try { req.timeout = 15; req.SetRequestHeader("User-Agent", "StraftatTournaments/1.5.1"); yield return req.SendWebRequest(); if ((int)req.result != 1) { Status = "couldn't reach strafth.com, try again later"; yield break; } try { Take(JObject.Parse(req.downloadHandler.text)); } catch (Exception ex) { Status = "strafth.com sent something unexpected"; TournamentPlugin.Log.LogWarning((object)("Straftat Tournaments: " + ex.Message)); } } finally { ((IDisposable)req)?.Dispose(); } } private static void Take(JObject j) { _last = j; Live = (bool?)j["live"] == true; Updated = ((long?)j["updated"]).GetValueOrDefault(); Status = "up to date"; _fetched = true; Pick(); } private static void Pick() { if (_last != null) { JToken obj = _last["pools"]; object obj2 = ((object)((obj != null) ? obj[(object)TournamentPlugin.Pool.Value] : null)) ?? ((object)((TournamentPlugin.Pool.Value == "2v2") ? _last : null)); object obj3; if (obj2 == null) { obj3 = null; } else { JToken obj4 = ((JToken)obj2)[(object)"playlist"]; obj3 = ((obj4 != null) ? obj4[(object)"code"] : null); } string text = ((string)(JToken)obj3) ?? ""; object obj5; if (obj2 == null) { obj5 = null; } else { JToken obj6 = ((JToken)obj2)[(object)"swapper"]; obj5 = ((obj6 != null) ? obj6[(object)"code"] : null); } string text2 = ((string)(JToken)obj5) ?? ""; if (text != PlaylistCode) { PlaylistCode = text; _playlistPending = true; } if (text2 != SwapperCode) { SwapperCode = text2; _swapperPending = true; } Describe(); } } internal static void SetPool(string pool) { if ((!(pool != "1v1") || !(pool != "2v2")) && !(TournamentPlugin.Pool.Value == pool)) { TournamentPlugin.Pool.Value = pool; if (_last != null) { Pick(); } else { CheckNow(); } } } internal static void SwapPool() { if (!LobbyState.InLobby || LobbyState.IsHost) { SetPool((TournamentPlugin.Pool.Value == "1v1") ? "2v2" : "1v1"); LobbyState.SharePool(); } } private static void Describe() { JObject val = Decode(PlaylistCode); JObject val2 = Decode(SwapperCode); PlaylistName = ((val != null) ? Bare((string)val["name"]) : ""); JToken obj = ((val != null) ? val["maps"] : null); JArray val3 = (JArray)(object)((obj is JArray) ? obj : null); PlaylistMaps = ((val3 != null) ? ((JContainer)val3).Count : 0); object swapperName; if (val2 == null) { swapperName = ""; } else { JToken obj2 = val2["Preset"]; swapperName = Bare((string)((obj2 != null) ? obj2[(object)"Name"] : null)); } SwapperName = (string)swapperName; } internal static string Plain(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return Regex.Replace(s, "</?(?:color|b|i|u|s|size|alpha|mark|sup|sub|font|material|sprite|link|nobr|noparse|lowercase|uppercase|smallcaps|cspace|mspace|voffset|width|indent|line-height|line-indent|pos|rotate|style|gradient)(?:=[^>]*)?>|<#[0-9a-fA-F]{3,8}>", "", RegexOptions.IgnoreCase).Trim(); } internal static JObject Decode(string code) { if (string.IsNullOrEmpty(code)) { return null; } try { string text = code.Trim().Replace('-', '+').Replace('_', '/'); while (text.Length % 4 != 0) { text += "="; } using MemoryStream stream = new MemoryStream(Convert.FromBase64String(text)); using GZipStream stream2 = new GZipStream(stream, CompressionMode.Decompress); using StreamReader streamReader = new StreamReader(stream2, Encoding.UTF8); return JObject.Parse(streamReader.ReadToEnd()); } catch { return null; } } internal static void Tick() { if (_playlistPending) { TryPlaylist(); } Holding(); if (_swapBack) { SwapperBack(); } if (_swapperPending && InMenu() && Time.unscaledTime >= _nextSwapperLook) { _nextSwapperLook = Time.unscaledTime + 1f; TrySwapper(); } } private static bool InMenu() { PauseManager instance = PauseManager.Instance; if (!((Object)(object)instance == (Object)null)) { return instance.inMainMenu; } return true; } private static void TryPlaylist() { MapsManager instance = MapsManager.Instance; if ((Object)(object)instance == (Object)null || instance.Playlists == null || instance.Playlists.Count == 0) { return; } _playlistPending = false; int num = instance.Playlists.FindIndex((Playlist p) => IsOurs(p.Name)); int num2 = instance.Playlists.Count - 1; while (num2 > num && num >= 0) { if (IsOurs(instance.Playlists[num2].Name)) { if (instance.activePlaylistIndex == num2) { instance.activePlaylistIndex = num; } else if (instance.activePlaylistIndex > num2) { instance.activePlaylistIndex--; } instance.Playlists.RemoveAt(num2); } num2--; } JObject val = Decode(PlaylistCode); if (val != null) { JToken obj = val["maps"]; JArray val2 = (JArray)(object)((obj is JArray) ? obj : null); if (val2 != null && ((JContainer)val2).Count != 0) { string[] array = new string[((JContainer)val2).Count]; for (int num3 = 0; num3 < ((JContainer)val2).Count; num3++) { array[num3] = (string)val2[num3]; } string text = Bare((string)val["name"]); string text2 = Named((text != "") ? text : "playlist"); if (num >= 0) { instance.Playlists[num].Name = text2; instance.Playlists[num].Maps = array; } else { instance.AddPlaylistWithoutUpdate(array, text2); num = instance.Playlists.Count - 1; } Save(instance); TournamentPlugin.Log.LogInfo((object)("Map pool: " + text + ", " + array.Length + " maps")); return; } } if (num >= 0 && PlaylistCode == "" && _fetched) { bool num4 = instance.activePlaylistIndex == num; if (instance.activePlaylistIndex > num) { instance.activePlaylistIndex--; } instance.Playlists.RemoveAt(num); if (num4) { GoBack(instance); } else { Save(instance); } } } private static void Remember(MapsManager mm) { int activePlaylistIndex = mm.activePlaylistIndex; _prevPlaylist = ((activePlaylistIndex >= 0 && activePlaylistIndex < mm.Playlists.Count) ? (mm.Playlists[activePlaylistIndex].Name ?? "") : ""); SceneMotor instance = SceneMotor.Instance; _prevMaps = (((Object)(object)instance != (Object)null) ? instance.PlayListMaps.ToArray() : new string[0]); _hasPrev = true; WriteCache(); } private static void GoBack(MapsManager mm) { int num = (mm.activePlaylistIndex = ((_prevPlaylist != "") ? mm.Playlists.FindIndex((Playlist p) => p.Name == _prevPlaylist) : (-1))); try { mm.SetActivePlaylist(num); if (num < 0 && (Object)(object)MapSelection.Instance != (Object)null) { if (_hasPrev && _prevMaps.Length != 0) { MapSelection.Instance.LoadScenes(_prevMaps); } else { MapSelection.Instance.SelectAll(); } } } catch (Exception ex) { TournamentPlugin.Log.LogWarning((object)("Straftat Tournaments: couldn't pick the old playlist again: " + ex.Message)); } Save(mm); TournamentPlugin.Log.LogInfo((object)("Map pool: back to " + ((num >= 0) ? Plain(_prevPlaylist) : "all maps"))); } private static void Save(MapsManager mm) { try { mm.UpdatePlaylists(false); } catch { try { SaveLoadSystem.Instance.Save(); } catch (Exception e) { TournamentPlugin.WarnOnce("Updater.Save", e); } } } private static void TrySwapper() { //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) WeaponRemapper val = null; WeaponRemapper[] array = Resources.FindObjectsOfTypeAll<WeaponRemapper>(); foreach (WeaponRemapper val2 in array) { if ((Object)(object)val2 != (Object)null) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { val = val2; break; } } } if ((Object)(object)val == (Object)null) { return; } _swapperPending = false; List<WeaponRemapPreset> list = Presets.Invoke(val); WeaponRemapPreset have = list?.Find((WeaponRemapPreset p) => p != null && IsOurs(p.Name)); if (have != null) { list.RemoveAll((WeaponRemapPreset p) => p != null && p != have && IsOurs(p.Name)); } JObject val3 = Decode(SwapperCode); WeaponRemapPreset val4 = null; try { object obj; if (val3 == null) { obj = null; } else { JToken obj2 = val3["Preset"]; obj = ((obj2 != null) ? obj2.ToObject<WeaponRemapPreset>() : null); } val4 = (WeaponRemapPreset)obj; } catch (Exception e) { TournamentPlugin.WarnOnce("Updater.TrySwapper", e); } if (val4 == null) { if (have != null && SwapperCode == "" && _fetched) { list.Remove(have); if (WeaponRemapper.SelectedPreset == have) { WeaponRemapper.SelectedPreset = null; } val.TriggerSave(); } return; } string text = Bare(val4.Name); val4.Name = Named((text != "") ? text : "swapper"); if (have != null) { have.Name = val4.Name; have.Maps = val4.Maps; } else { val.AddPreset(val4); have = val4; } if (_pick) { WeaponRemapper.SelectedPreset = have; } val.TriggerSave(); } private static void ReadCache() { try { if (File.Exists(OldCachePath)) { File.Delete(OldCachePath); } if (File.Exists(CachePath)) { JObject obj = JObject.Parse(File.ReadAllText(CachePath)); _prevPlaylist = ((string)obj["previousPlaylist"]) ?? ""; JToken obj2 = obj["previousMaps"]; JArray val = (JArray)(object)((obj2 is JArray) ? obj2 : null); _prevMaps = ((val != null) ? ((IEnumerable<JToken>)val).Select((JToken t) => (string)t).ToArray() : new string[0]); _hasPrev = obj["previousPlaylist"] != null; _playlistPending = true; } } catch (Exception ex) { TournamentPlugin.Log.LogWarning((object)("Couldn't read what was picked before the map pool: " + ex.Message)); } } private static void WriteCache() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown try { JObject val = new JObject(); if (_hasPrev) { val["previousPlaylist"] = JToken.op_Implicit(_prevPlaylist); object[] prevMaps = _prevMaps; val["previousMaps"] = (JToken)new JArray(prevMaps); } File.WriteAllText(CachePath, ((object)val).ToString()); } catch (Exception ex) { TournamentPlugin.Log.LogWarning((object)("Couldn't save what was picked before the map pool: " + ex.Message)); } } } internal static class Popup { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__11_0; internal void <Show>b__11_0() { Hide(); if (!Panel.IsOpen) { Panel.Toggle(); } } } private const float W = 520f; private const float H = 112f; private const float Pad = 20f; private static Canvas _canvas; private static RectTransform _root; private static int _seenSeq; private static string _seenTurn = ""; private static float _until; private static float _sayUntil; internal static void Say(string title, string line) { Show(title, line, open: false); _until = (_sayUntil = Time.unscaledTime + 8f); } internal static void Tick() { if ((Object)(object)_root != (Object)null && Time.unscaledTime < _sayUntil) { return; } if (_sayUntil > 0f) { _sayUntil = 0f; Hide(); } LobbyState.Bans ban = LobbyState.Ban; if (ban == null || !LobbyState.InLobby) { Hide(); _seenTurn = ""; _seenSeq = 0; return; } if (ban.Seq != _seenSeq) { _seenSeq = ban.Seq; if (!ban.Done && !Panel.IsOpen) { Show("map bans started", ban.CapNames[0] + " vs " + ban.CapNames[1], open: true); } } string text = ban.Seq + ":" + ban.Banned.Count; if (!ban.Done && ban.Turn == LobbyState.Me && text != _seenTurn) { _seenTurn = text; if (!Panel.IsOpen) { Show("your turn to ban", ban.Left + " maps left", open: true); } } if ((Object)(object)_root != (Object)null && (Panel.IsOpen || ban.Done || Time.unscaledTime > _until)) { Hide(); } } private static void Show(string title, string line, bool open) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown UI.Prepare(); UI.EnsureEventSystem(); if ((Object)(object)_canvas == (Object)null) { _canvas = UI.MakeCanvas("DT_TournamentPopup", 1150); } ((Component)_canvas).gameObject.SetActive(true); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } Image obj = UI.Window(((Component)_canvas).transform); _root = ((Graphic)obj).rectTransform; RectTransform root = _root; RectTransform root2 = _root; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 1f); root2.anchorMax = val; root.anchorMin = val; _root.pivot = new Vector2(0.5f, 1f); _root.anchoredPosition = new Vector2(0f, -40f); _root.sizeDelta = new Vector2(520f, 112f); float w = 480f - (open ? 200f : 56f); TextMeshProUGUI obj2 = UI.Label((Transform)(object)_root, title, 24f, UI.Txt, (TextAlignmentOptions)4097); ((TMP_Text)obj2).enableWordWrapping = false; ((TMP_Text)obj2).overflowMode = (TextOverflowModes)1; UI.At(((TMP_Text)obj2).rectTransform, 20f, 20f, w, 36f); TextMeshProUGUI obj3 = UI.Label((Transform)(object)_root, line, 16f, UI.Dim, (TextAlignmentOptions)4097); ((TMP_Text)obj3).enableWordWrapping = !open; ((TMP_Text)obj3).overflowMode = (TextOverflowModes)1; UI.At(((TMP_Text)obj3).rectTransform, 20f, 52f, w, 44f); if (open) { RectTransform root3 = _root; object obj4 = <>c.<>9__11_0; if (obj4 == null) { UnityAction val2 = delegate { Hide(); if (!Panel.IsOpen) { Panel.Toggle(); } }; <>c.<>9__11_0 = val2; obj4 = (object)val2; } UI.At((RectTransform)((Component)UI.Btn((Transform)(object)root3, "open", 20f, (UnityAction)obj4, filled: true)).transform, 304f, 32f, 140f, 48f); } Button obj5 = UI.Btn((Transform)(object)_root, "x", 20f, new UnityAction(Hide)); UI.At((RectTransform)((Component)obj5).transform, 452f, 32f, 48f, 48f); UI.Center(obj5); _until = Time.unscaledTime + 15f; UI.Seal(obj); } private static void Hide() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } _root = null; } } internal static class MatchLogCode { private static readonly string[] AimTypes = new string[17] { "FirstPersonController", "Weapon", "Gun", "Shotgun", "Minigun", "ChargeGun", "BeamGun", "LargeRaycastGun", "MeleeWeapon", "Crosshair", "Camera", "Physics", "Input", "Transform", "PlayerPickup", "Settings", "PlayerHealth" }; private const int Max = 80; private static readonly Dictionary<string, string> Prints = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static bool _warmed; internal static void Warm() { if (_warmed) { return; } _warmed = true; List<string> paths = new List<string>(); try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { if (!assembly.IsDynamic && !string.IsNullOrEmpty(assembly.Location)) { paths.Add(assembly.Location); } } catch (Exception e) { TournamentPlugin.WarnOnce("MatchLogCode.Warm", e); } } } catch { return; } ThreadPool.QueueUserWorkItem(delegate { foreach (string item in paths) { Fingerprint(item); } }); } internal static JArray Mods() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0144: Expected O, but got Unknown JArray val = new JArray(); string text = Norm(Paths.PluginPath); try { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { if (((JContainer)val).Count < 80) { PluginInfo value = pluginInfo.Value; string text2 = ((value != null) ? value.Location : null) ?? ""; string text3 = Norm(text2); JObject val2 = new JObject { ["id"] = JToken.op_Implicit(pluginInfo.Key) }; object obj; if (value == null) { obj = null; } else { BepInPlugin metadata = value.Metadata; obj = ((metadata != null) ? metadata.Name : null); } if (obj == null) { obj = ""; } val2["name"] = JToken.op_Implicit((string)obj); object obj2; if (value == null) { obj2 = null; } else { BepInPlugin metadata2 = value.Metadata; obj2 = ((metadata2 == null) ? null : metadata2.Version?.ToString()); } if (obj2 == null) { obj2 = ""; } val2["version"] = JToken.op_Implicit((string)obj2); val2["file"] = JToken.op_Implicit(text3.StartsWith(text, StringComparison.OrdinalIgnoreCase) ? text3.Substring(text.Length).TrimStart('/') : Path.GetFileName(text3)); val2["fingerprint"] = JToken.op_Implicit(Fingerprint(text2)); val.Add((JToken)val2); continue; } break; } } catch (Exception ex) { val.Add((JToken)new JObject { ["error"] = JToken.op_Implicit(ex.GetType().Name) }); } return val; } internal static JArray Hooks() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_012f: 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_0155: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fc: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0113: Expected O, but got Unknown JArray val = new JArray(); try { foreach (MethodBase allPatchedMethod in Harmony.GetAllPatchedMethods()) { if (((JContainer)val).Count >= 80) { break; } Type type = allPatchedMethod?.DeclaringType; if (type == null || !IsAimType(type)) { continue; } Patches patchInfo = Harmony.GetPatchInfo(allPatchedMethod); if (patchInfo != null) { SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.Ordinal); SortedSet<string> sortedSet2 = new SortedSet<string>(StringComparer.Ordinal); Add(sortedSet, sortedSet2, patchInfo.Prefixes); Add(sortedSet, sortedSet2, patchInfo.Postfixes); Add(sortedSet, sortedSet2, patchInfo.Transpilers); Add(sortedSet, sortedSet2, patchInfo.Finalizers); if (sortedSet.Count != 0) { val.Add((JToken)new JObject { ["method"] = JToken.op_Implicit(type.Name + "." + allPatchedMethod.Name), ["mods"] = (JToken)new JArray((object)sortedSet), ["files"] = (JToken)new JArray((object)sortedSet2) }); } } } } catch (Exception ex) { val.Add((JToken)new JObject { ["error"] = JToken.op_Implicit(ex.GetType().Name) }); } return val; } internal static bool IsOutside(JObject o) { string text = ((string)o["from"]) ?? ""; if (!(text == "no file") && !text.StartsWith("elsewhere/", StringComparison.Ordinal)) { return text.StartsWith("game/", StringComparison.Ordinal); } return true; } internal static JArray Code(out int madeOnTheFly) { //IL_00d6: 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_00fc: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown madeOnTheFly = 0; List<JObject> list = new List<JObject>(); try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string name; string loc; bool onTheFly; string text = Where(assembly, out name, out loc, out onTheFly); if (onTheFly) { madeOnTheFly++; } if (text != null) { string text2 = ""; try { text2 = assembly.GetName().Version.ToString(); } catch (Exception e) { TournamentPlugin.WarnOnce("MatchLogCode.Code", e); } list.Add(new JObject { ["name"] = JToken.op_Implicit(name), ["version"] = JToken.op_Implicit(text2), ["from"] = JToken.op_Implicit(text), ["fingerprint"] = JToken.op_Implicit(Fingerprint(loc)) }); } } } catch (Exception ex) { list.Add(new JObject { ["error"] = JToken.op_Implicit(ex.GetType().Name) }); } list.Sort((JObject x, JObject y) => string.CompareOrdinal((string)x["name"], (string)y["name"])); JArray val = new JArray(); foreach (JObject item in list) { if (((JContainer)val).Count >= 80) { break; } val.Add((JToken)(object)item); } return val; } internal static JArray Outside() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01ba: Expected O, but got Unknown //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_0041: 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_005d: Expected O, but got Unknown //IL_03a2: 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_0077: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) JArray val = new JArray(); try { Dictionary<Assembly, JObject> outside = new Dictionary<Assembly, JObject>(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string name; string loc; bool onTheFly; string text = Where(assembly, out name, out loc, out onTheFly); if (text == null || (!IsOutside(new JObject { ["from"] = JToken.op_Implicit(text) }) && text != "game, patched in memory")) { continue; } JArray val2 = new JArray(); int num = 0; try { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (!(type == null) && type.Name.IndexOf('<') < 0) { num++; if (((JContainer)val2).Count < 60) { val2.Add(JToken.op_Implicit(type.FullName)); } } } } catch (ReflectionTypeLoadException ex) { Type[] types = ex.Types; foreach (Type type2 in types) { if (type2 != null && type2.Name.IndexOf('<') < 0) { num++; if (((JContainer)val2).Count < 60) { val2.Add(JToken.op_Implicit(type2.FullName)); } } } } catch (Exception e) { TournamentPlugin.WarnOnce("MatchLogCode.Outside", e); } JObject val3 = new JObject { ["name"] = JToken.op_Implicit(name), ["from"] = JToken.op_Implicit(text), ["classes"] = JToken.op_Implicit(num), ["classNames"] = (JToken)(object)val2, ["running"] = (JToken)new JArray(), ["everyFrame"] = (JToken)new JArray() }; outside[assembly] = val3; val.Add((JToken)(object)val3); if (((JContainer)val).Count >= 10) { break; } } if (outside.Count == 0) { return val; } Dictionary<Type, int> dictionary = new Dictionary<Type, int>(); MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); foreach (MonoBehaviour val4 in array) { if (!((Object)(object)val4 == (Object)null)) { Type type3 = ((object)val4).GetType(); if (outside.ContainsKey(type3.Assembly)) { dictionary.TryGetValue(type3, out var value); dictionary[type3] = value + 1; } } } foreach (KeyValuePair<Type, int> item in dictionary) { ((JArray)outside[item.Key.Assembly]["running"]).Add((JToken)new JObject { ["class"] = JToken.op_Implicit(item.Key.FullName), ["count"] = JToken.op_Implicit(item.Value) }); } try { Walk(PlayerLoop.GetCurrentPlayerLoop(), ""); } catch (Exception e2) { TournamentPlugin.WarnOnce("MatchLogCode.Outside", e2); } try { Called((Delegate)(object)Camera.onPreCull, "camera before culling"); Called((Delegate)(object)Camera.onPreRender, "camera before drawing"); Called((Delegate)(object)Camera.onPostRender, "camera after drawing"); } catch (Exception e3) { TournamentPlugin.WarnOnce("MatchLogCode.Outside", e3); } for (int num2 = ((JContainer)val).Count - 1; num2 >= 0; num2--) { JObject val5 = (JObject)val[num2]; if ((string)val5["from"] == "game, patched in memory" && ((JContainer)(JArray)val5["running"]).Count == 0 && ((JContainer)(JArray)val5["everyFrame"]).Count == 0) { val.RemoveAt(num2); } } void Called(Delegate d, string by) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if ((object)d != null) { Delegate[] invocationList = d.GetInvocationList(); for (int k = 0; k < invocationList.Length; k++) { MethodInfo method = invocationList[k].Method; if (!(method == null) && !(method.DeclaringType == null) && outside.TryGetValue(method.DeclaringType.Assembly, out var value2)) { JArray val6 = (JArray)value2["everyFrame"]; if (((JContainer)val6).Count < 20) { val6.Add(JToken.op_Implicit(by + ": " + method.DeclaringType.FullName + "." + method.Name)); } } } } } void Walk(PlayerLoopSystem s, string path) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) string text2 = ((path.Length != 0) ? (path + "/" + ((s.type != null) ? s.type.Name : "?")) : ((s.type != null) ? s.type.Name : "")); Called((Delegate)(object)s.updateDelegate, "frame loop " + text2); if (s.subSystemList != null) { PlayerLoopSystem[] subSystemList = s.subSystemList; for (int k = 0; k < subSystemList.Length; k++) { Walk(subSystemList[k], text2); } } } } catch (Exception ex2) { val.Add((JToken)new JObject { ["error"] = JToken.op_Implicit(ex2.GetType().Name) }); } return val; } private static string Where(Assembly a, out string name, out string loc, out bool onTheFly) { name = null; loc = ""; onTheFly = false; try { name = a.GetName().Name; } catch { return null; } if (name == null) { return null; } bool flag = false; try { flag = a.IsDynamic; if (!flag) { loc = a.Location ?? ""; } } catch (Exception e) { TournamentPlugin.WarnOnce("MatchLogCode.Where", e); } if (flag || name.StartsWith("DMD", StringComparison.Ordinal) || name.StartsWith("HarmonySharedState", StringComparison.Ordinal) || name.StartsWith("HarmonyDTFAssembly", StringComparison.Ordinal) || (name.StartsWith("MonoMod.", StringComparison.Ordinal) && loc.Length == 0)) { onTheFly = true; return null; } string value = Norm(Paths.ManagedPath); string value2 = Norm(Paths.BepInExAssemblyDirectory); string text = Norm(Paths.PluginPath); string text2 = Norm(Paths.PatcherPluginPath); string text3 = Norm(Paths.GameRootPath); string text4 = Norm(loc); if (text4.Length == 0) { if (!PatchedGame(name)) { return "no file"; } return "game, patched in memory"; } if (text4.StartsWith(value, StringComparison.OrdinalIgnoreCase) || text4.StartsWith(value2, StringComparison.OrdinalIgnoreCase)) { return null; } if (text4.StartsWith(text, StringComparison.OrdinalIgnoreCase)) { return "plugins/" + text4.Substring(text.Length).TrimStart('/'); } if (text4.StartsWith(text2, StringComparison.OrdinalIgnoreCase)) { return "patchers/" + text4.Substring(text2.Length).TrimStart('/'); } if (text4.StartsWith(text3, StringComparison.OrdinalIgnoreCase)) { return "game/" + text4.Substring(text3.Length).TrimStart('/'); } if (IsSystem(name)) { return null; } return "elsewhere/" + Path.GetFileName(text4); } private static bool PatchedGame(string name) { try { return File.Exists(Path.Combine(Paths.ManagedPath, name + ".dll")); } catch { return false; } } private static bool IsAimType(Type t) { Type type = t; while (type != null && type != typeof(object)) { if (Array.IndexOf(AimTypes, type.Name) >= 0) { return true; } type = type.BaseType; } return false; } private static void Add(SortedSet<string> owners, SortedSet<string> files, IEnumerable<Patch> patches) { if (patches == null) { return; } Assembly assembly = typeof(MatchLogCode).Assembly; foreach (Patch patch in patches) { if (patch == null || string.IsNullOrEmpty(patch.owner)) { continue; } Assembly assembly2 = null; try { assembly2 = patch.PatchMethod?.DeclaringType?.Assembly; } catch (Exception e) { TournamentPlugin.WarnOnce("MatchLogCode.Add", e); } if (assembly2 == assembly) { continue; } owners.Add(patch.owner); string text = ""; try { if (assembly2 != null && !assembly2.IsDynamic) { text = assembly2.Location ?? ""; } } catch (Exception e2) { TournamentPlugin.WarnOnce("MatchLogCode.Add", e2); } files.Add((text == "") ? "no file" : Fingerprint(text)); } } private static bool IsSystem(string name) { if (!(name == "mscorlib") && !(name == "netstandard") && !name.StartsWith("System", StringComparison.Ordinal) && !name.StartsWith("Mono.", StringComparison.Ordinal)) { return name.StartsWith("Microsoft.", StringComparison.Ordinal); } return true; } private static string Fingerprint(string path) { if (string.IsNullOrEmpty(path)) { return ""; } lock (Prints) { if (Prints.TryGetValue(path, out var value)) { return value; } } string text = ""; try { if (File.Exists(path)) { using SHA256 sHA = SHA256.Create(); using FileStream inputStream = File.OpenRead(path); byte[] sourceArray = sHA.ComputeHash(inputStream); byte[] array = new byte[8]; Array.Copy(sourceArray, array, 8); text = MatchLog.Hex(array); } } catch { text = ""; } lock (Prints) { Prints[path] = text; return text; } } private static string Norm(string p) { if (!string.IsNullOrEmpty(p)) { return p.Replace('\\', '/').TrimEnd('/'); } return ""; } } internal static class Patches { private static readonly FieldRef<PlayerManager, ClientInstance> Client = AccessTools.FieldRefAccess<PlayerManager, ClientInstance>("ClientScript"); private static readonly FieldRef<PlayerManager, SpawnPoint[]> Current = AccessTools.FieldRefAccess<PlayerManager, SpawnPoint[]>("CurrentSpawnPoints"); private static readonly FieldRef<PlayerManager, SpawnPoint[]> Spawns1v1 = AccessTools.FieldRefAccess<PlayerManager, SpawnPoint[]>("SpawnPoint1v1"); private static readonly FieldRef<PlayerManager, SpawnPoint[]> Spawns4v4 = AccessTools.FieldRefAccess<PlayerManager, SpawnPoint[]>("SpawnPoint4v4"); private static MethodInfo _spawnAt; private static readonly List<int> _spectatorIds = new List<int>(); private static bool _trueSensLooked; private static MethodInfo _trueSensHip; private static ConfigEntry<bool> _trueSensOn; private static MethodInfo _addNew; private static MethodInfo _tell; private static MethodInfo _runIn; private static MethodInfo _initiate; private static readonly FieldInfo StartButton = AccessTools.Field(typeof(LobbyController), "StartGameButton"); private static readonly FieldInfo RematchVoters = AccessTools.Field(typeof(VictoryMenu), "playersThatCanRequestARestart"); private static readonly Color[] TeamColors = (Color[])(object)new Color[4] { new Color(0f, 0.9f, 1f), new Color(1f, 0.15f, 0.15f), new Color(0.2f, 1f, 0.3f), new Color(1f, 0.9f, 0.1f) }; private static readonly FieldInfo Outlined = AccessTools.Field(typeof(PlayerSetup), "gameObjectsToDisableForMe"); private static bool _starting; private static float _lastStart = -10f; private static readonly Dictionary<int, ClientInstance> _hidden = new Dictionary<int, ClientInstance>(); private static int _hideDepth; private static MethodInfo _roundScreen; private static readonly FieldInfo WinText = AccessTools.Field(typeof(RoundManager), "winText"); private static int[] _slots; private static bool _swapped; private static readonly Dictionary<int, ClientInstance> _real = new Dictionary<int, ClientInstance>(); private static readonly FieldRef<VictoryMenuUI, TMP_Text> VictoryText = AccessTools.FieldRefAccess<VictoryMenuUI, TMP_Text>("victoryDefeatText"); private static readonly FieldRef<MatchPoitnsHUD, MeshRenderer> PrimaryPoints = AccessTools.FieldRefAccess<MatchPoitnsHUD, MeshRenderer>("primaryPointMesh"); private static readonly FieldRef<MatchPoitnsHUD, MeshRenderer[]> SecondaryPoints = AccessTools.FieldRefAccess<MatchPoitnsHUD, MeshRenderer[]>("secondaryPointObjects"); private static readonly FieldRef<MatchPoitnsHUD, TMP_Text[]> PointsTexts = AccessTools.FieldRefAccess<MatchPoitnsHUD, TMP_Text[]>("pointsTexts"); private static bool HostWithSpectators { get { if (LobbyState.Spectators.Count > 0) { return InstanceFinder.IsServer; } return false; } } internal static void Apply(Harmony h) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown //IL_031a: Expected O, but got Unknown //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Expected O, but got Unknown //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Expected O, but got Unknown //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Expected O, but got Unknown //IL_0484: Expected O, but got Unknown //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Expected O, but got Unknown //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Expected O, but got Unknown //IL_0557: Expected O, but got Unknown //IL_0557: Expected O, but got Unknown //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Expected O, but got Unknown //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Expected O, but got Unknown //IL_05e6: Expected O, but got Unknown //IL_05e6: Expected O, but got Unknown //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Expected O, but got Unknown //IL_04e7: Expected O, but got Unknown //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Expected O, but got Unknown Type typeFromHandle = typeof(Patches); _spawnAt = AccessTools.Method(typeof(PlayerManager), "SpawnPlayer", new Type[4] { typeof(int), typeof(int), typeof(Vector3), typeof(Quaternion) }, (Type[])null); h.Patch((MethodBase)_spawnAt, new HarmonyMethod(typeFromHandle, "SpawnPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PlayerManager), "SpawnPlayer", new Type[2] { typeof(int), typeof(int) }, (Type[])null), new HarmonyMethod(typeFromHandle, "SpawnPointPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PlayerManager), "SetActiveSpawnPoints", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "SpawnSetPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(GameManager), "GetAliveTeams", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "AlivePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "Menu", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "EscapePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "PausePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(WindowPositionTween), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "EscapePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(ScoreManager), "GetPlayerIdsForTeam", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "TeamPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(LobbyController), "UpdatePlayerList", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "ReadyPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(LobbyController), "ReadyPlayer", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "UnreadyPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(VictoryMenu), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "RematchPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(GameManager), "RpcLogic___SetStartTime_431000436", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "StartTimePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PlayerSetup), "RpcLogic___ChangeDress_1876325648", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "DressPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(GameManager), "GetConnectedTeams", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "ConnectedPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(SceneMotor), "ServerStartGameScene", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "StartPrefix", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "TeamCheckTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(SceneMotor), "ServerRestartGameScene", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "StartPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(KillCam), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "KillCamPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _addNew = AccessTools.Method(typeof(ClientInstance), "AddNewPlayer", (Type[])null, (Type[])null); _tell = AccessTools.Method(typeof(ClientInstance), "UpdateOnClients", new Type[1] { typeof(int) }, (Type[])null); _runIn = AccessTools.Method(typeof(ClientInstance), "RunIntoLobby", (Type[])null, (Type[])null); _initiate = AccessTools.Method(typeof(ClientInstance), "InitiateClient", (Type[])null, (Type[])null); h.Patch((MethodBase)AccessTools.Method(typeof(ClientInstance), "SetSyncValues", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "JoinPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(SteamLobby), "KickSelf", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "KickSelfPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "NextRoundCall", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "EndRoundPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "Unhide", (Type[])null), (HarmonyMethod)null); _roundScreen = AccessTools.Method(typeof(RoundManager), "InterfaceSetup", (Type[])null, (Type[])null); MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "InterfaceSetup", (Type[])null, (Type[])null); if (methodInfo != null) { h.Patch((MethodBase)AccessTools.EnumeratorMoveNext((MethodBase)methodInfo), new HarmonyMethod(typeFromHandle, "StepPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "StepEnd", (Type[])null), (HarmonyMethod)null); } h.Patch((MethodBase)AccessTools.Method(typeof(ScoreManager), "GetTeamId", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "TeamIdPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(VictoryMenuUI), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "HidePrefix", (Type[])null), new HarmonyMethod(typeFromHandle, "VictoryPostfix", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "Unhide", (Type[])null), (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(MatchPoitnsHUD), "UpdateVisuals", new Type[2] { typeof(int), typeof(Dictionary<int, int>) }, (Type[])null), new HarmonyMethod(typeFromHandle, "PointsPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(PlayerListItem), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeFromHandle, "ItemPrefix", (Type[])null), new HarmonyMethod(typeFromHandle, "ItemPostfix", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeFromHandle, "ItemFinalizer", (Type[])null), (HarmonyMethod)null); string[] array = new string[3] { "RpcLogic___RunIntoLobby_3316948804", "RpcLogic___MenuAnimationObservers_1692629761", "RpcLogic___DressAboubiObservers_2497120398" }; foreach (string text in array) { MethodInfo methodInfo2 = AccessTools.Method(typeof(ClientInstance), text, (Type[])null, (Type[])null); if (methodInfo2 != null) { h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeFromHandle, "PreviewPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { TournamentPlugin.Log.LogWarning((object)("Straftat Tournaments: no " + text + " in this game version")); } } } private static bool SpawnPrefix(PlayerManager __instance) { try { if (!HostWithSpectators) { return true; } ClientInstance val = Client.Invoke(__instance); return (Object)(object)val == (Object)null || !LobbyState.IsSpectator(val.PlayerSteamID); } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static bool SpawnSetPrefix(PlayerManager __instance) { try { if (LobbyState.Spectators.Count == 0) { return true; } ClientInstance val = Client.Invoke(__instance); if ((Object)(object)val == (Object)null || val.nonSteamworksTransport) { return true; } SpawnPoint[] array = Spawns4v4.Invoke(__instance); Current.Invoke(__instance) = ((LobbyState.Playing() > 2 && array != null && array.Length != 0) ? array : Spawns1v1.Invoke(__instance)); return false; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static bool SpawnPointPrefix(PlayerManager __instance, int suitIndex, int cigIndex) { //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) try { if (!HostWithSpectators) { return true; } ClientInstance c = Client.Invoke(__instance); if ((Object)(object)c == (Object)null) { return true; } if (LobbyState.IsSpectator(c.PlayerSteamID)) { return false; } __instance.SetActiveSpawnPoints(); SpawnPoint[] array = Current.Invoke(__instance); if (array == null || array.Length == 0) { return true; } ScoreManager sm = ScoreManager.Instance; int num = sm.sync___get_value_TakeIndex(); List<ClientInstance> players = (from p in ClientInstance.playerInstances.Values where (Object)(object)p != (Object)null && !LobbyState.IsSpectator(p.PlayerSteamID) orderby p.PlayerId select p).ToList(); int num2 = Math.Max(0, players.FindIndex((ClientInstance p) => p.PlayerId == c.PlayerId)); int num3; if (players.Count <= 2) { num3 = num + ((num2 != 0) ? 1 : 0); } else { List<IGrouping<int, ClientInstance>> list = (from p in players group p by sm.GetTeamId(p.PlayerId) into g orderby g.Key select g).ToList(); if (players.Count == 4 && list.Count == 2 && list.All((IGrouping<int, ClientInstance> g) => g.Count() == 2)) { int num4 = list.FindIndex((IGrouping<int, ClientInstance> g) => g.Key == sm.GetTeamId(c.PlayerId)); List<int> list2 = (from id in sm.GetPlayerIdsForTeam(list[num4].Key) where players.Any((ClientInstance p) => p.PlayerId == id) select id).ToList(); num3 = num + num4 + Math.Max(0, list2.IndexOf(c.PlayerId)) * 2; } else { num3 = num + num2; } } SpawnPoint val = array[(num3 % array.Length + array.Length) % array.Length]; _spawnAt.Invoke(__instance, new object[4] { suitIndex, cigIndex, ((Component)val).transform.position, Quaternion.Euler(0f, ((Component)val).transform.eulerAngles.y, 0f) }); return false; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static List<int> SpectatorIds() { _spectatorIds.Clear(); foreach (ClientInstance value in ClientInstance.playerInstances.Values) { if ((Object)(object)value != (Object)null && LobbyState.IsSpectator(value.PlayerSteamID)) { _spectatorIds.Add(value.PlayerId); } } return _spectatorIds; } private static void AlivePrefix(GameManager __instance) { try { if (LobbyState.Spectators.Count == 0) { return; } foreach (int item in SpectatorIds()) { __instance.alivePlayers.Remove(item); } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void ConnectedPostfix(ref int[] __result) { try { if (LobbyState.Spectators.Count == 0) { return; } ScoreManager instance = ScoreManager.Instance; List<int> list = new List<int>(); foreach (ClientInstance value in ClientInstance.playerInstances.Values) { if (!((Object)(object)value == (Object)null) && !LobbyState.IsSpectator(value.PlayerSteamID)) { int teamId = instance.GetTeamId(value.PlayerId); if (!list.Contains(teamId)) { list.Add(teamId); } } } __result = list.ToArray(); } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void StartPrefix(SceneMotor __instance) { try { LobbyState.NewMatch(); LobbyState.ApplyBans(__instance); } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static IEnumerable<CodeInstruction> TeamCheckTranspiler(IEnumerable<CodeInstruction> code) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown List<CodeInstruction> list = code.ToList(); FieldInfo fieldInfo = AccessTools.Field(typeof(SceneMotor), "PlayListMaps"); for (int i = 1; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i], fieldInfo, false) && list[i - 1].opcode == OpCodes.Ldsfld) { CodeInstruction val = new CodeInstruction(OpCodes.Ldloc_0, (object)null); val.labels.AddRange(list[i - 1].labels); list[i - 1].labels.Clear(); list.InsertRange(i - 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3] { val, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "TeamsDiffer", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stloc_0, (object)null) }); return list; } } TournamentPlugin.Log.LogWarning((object)"Straftat Tournaments: the game's team check has changed, left as it is"); return list; } private static bool TeamsDiffer(bool game) { try { List<ClientInstance> source = ClientInstance.playerInstances.Values.Where((ClientInstance c) => (Object)(object)c != (Object)null && !LobbyState.IsSpectator(c.PlayerSteamID)).ToList(); if (LobbyState.Spectators.Count == 0 && source.All((ClientInstance c) => c.PlayerId < 4)) { return game; } ScoreManager sm = ScoreManager.Instance; return (Object)(object)sm != (Object)null && source.Select((ClientInstance c) => sm.GetTeamId(c.PlayerId)).Distinct().Count() > 1; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return game; } } private static bool KillCamPrefix(KillCam __instance) { try { PauseManager instance = PauseManager.Instance; if (!Spectating() || (Object)(object)instance == (Object)null || instance.inMainMenu) { return true; } Spectate.Update(__instance); return false; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } internal static bool Spectating() { if (LobbyState.Spectators.Count > 0) { return LobbyState.IsSpectator(LobbyState.Me); } return false; } internal static void Look(Transform tr) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c0: 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_00fc: Unknown result type (might be due to invalid IL or missing references) PauseManager instance = PauseManager.Instance; if ((Object)(object)instance != (Object)null && instance.gamepad) { return; } Mouse current = Mouse.current; if (current != null) { Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue(); if (!(val == Vector2.zero)) { Settings instance2 = Settings.Instance; Sens(out var x, out var y); float num = 0.1f; float num2 = val.x * x * num * (((Object)(object)instance2 != (Object)null && instance2.invertMouseX) ? (-1f) : 1f); float num3 = val.y * y * num * (((Object)(object)instance2 != (Object)null && instance2.invertMouseY) ? (-1f) : 1f); Vector3 eulerAngles = tr.eulerAngles; float num4 = ((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x); tr.rotation = Quaternion.Euler(Mathf.Clamp(num4 - num3, -89f, 89f), eulerAngles.y + num2, 0f); } } } private static void Sens(out float x, out float y) { if (!_trueSensLooked) { _trueSensLooked = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("TrueSens.Plugin", throwOnError: false); if (!(type == null)) { _trueSensHip = AccessTools.Method(type, "HipSens", (Type[])null, (Type[])null); _trueSensOn = AccessTools.Field(type, "On")?.GetValue(null) as ConfigEntry<bool>; break; } } } if (_trueSensHip != null && _trueSensOn != null && _trueSensOn.Value) { x = (y = (float)_trueSensHip.Invoke(null, null)); return; } Settings instance = Settings.Instance; if ((Object)(object)instance == (Object)null) { x = (y = 2f); return; } x = (instance.toggleTwoAxis ? instance.horizontalSensitivity : instance.mouseSensitivity); y = (instance.toggleTwoAxis ? instance.verticalSensitivity : instance.mouseSensitivity); } private static bool JoinPrefix(ClientInstance __instance, NetworkObject newPlayer) { try { int spectatorSlots = LobbyState.SpectatorSlots; SteamLobby instance = SteamLobby.Instance; if (spectatorSlots <= 0 || (Object)(object)instance == (Object)null || (Object)(object)newPlayer == (Object)null || _addNew == null || _tell == null || _runIn == null || _initiate == null) { return true; } NetworkConnection owner = newPlayer.Owner; if (!ulong.TryParse(owner.GetAddress(), out var result)) { return true; } List<ClientInstance> list = ClientInstance.playerInstances.Values.Where((ClientInstance c) => (Object)(object)c != (Object)null).ToList(); int num = list.Count((ClientInstance c) => !LobbyState.IsSpectator(c.PlayerSteamID)); int num2 = list.Count - num; bool flag = LobbyState.IsSpectator(result) || num >= instance.maxPlayers; if (flag && num2 >= spectatorSlots) { GameManager.Instance.CmdKickPlayer(owner, "Lobby is full"); return false; } if (flag && LobbyState.ModOf(result) == "") { GameManager.Instance.CmdKickPlayer(owner, "Spectating this lobby needs the Straftat Tournaments mod"); LobbyState.Turned(result); return false; } int num3; for (num3 = (flag ? 4 : 0); ClientInstance.playerInstances.ContainsKey(num3); num3++) { } if (flag) { LobbyState.MarkSpectator(result); } _addNew.Invoke(__instance, new object[4] { owner, newPlayer, num3, result }); _tell.Invoke(__instance, new object[1] { instance.maxPlayers }); _runIn.Invoke(__instance, new object[1] { num3 }); _initiate.Invoke(__instance, new object[2] { owner, num3 }); return false; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static bool KickSelfPrefix(SteamLobby __instance) { try { int spectatorSlots = LobbyState.SpectatorSlots; if (spectatorSlots <= 0) { return true; } ClientInstance me = (((Object)(object)LobbyController.Instance != (Object)null) ? LobbyController.Instance.LocalPlayerController : null); int num = (((Object)(object)me != (Object)null) ? __instance.players.FindIndex((NetworkObject p) => (Object)(object)p != (Object)null && (Object)(object)((Component)p).GetComponent<ClientInstance>() == (Object)(object)me) : (-1)); return num < 0 || num >= __instance.maxPlayers + spectatorSlots; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static void ItemPrefix(PlayerListItem __instance, out int __state) { __state = __instance.PlayerIdNumber; __instance.PlayerIdNumber = 0; } private static void ItemPostfix(PlayerListItem __instance, int __state) { try { Lobby.Place(__instance, __state); } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void ItemFinalizer(PlayerListItem __instance, int __state) { __instance.PlayerIdNumber = __state; } private static bool PreviewPrefix(int id) { try { return Lobby.HasPreview(id); } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); return true; } } private static bool EscapePrefix() { if (!Panel.IsOpen) { return !Panel.SwallowEscape; } return false; } private static bool PausePrefix(PauseManager __instance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!Panel.IsOpen) { return true; } __instance.pause = true; if ((int)Cursor.lockState != 0) { Cursor.lockState = (CursorLockMode)0; } if (!Cursor.visible) { Cursor.visible = true; } return false; } private static bool IsSpectatorId(int playerId) { if (ClientInstance.playerInstances.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null) { return LobbyState.IsSpectator(value.PlayerSteamID); } return false; } private static void TeamPostfix(ref List<int> __result) { try { if (LobbyState.Spectators.Count == 0 || __result == null) { return; } bool flag = false; foreach (int item in __result) { if (IsSpectatorId(item)) { flag = true; break; } } if (!flag) { return; } List<int> list = new List<int>(__result.Count); foreach (int item2 in __result) { if (!IsSpectatorId(item2)) { list.Add(item2); } } __result = list; } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void ReadyPostfix(LobbyController __instance) { try { if (LobbyState.Spectators.Count == 0 || !InstanceFinder.IsServer) { return; } bool flag = LobbyState.PlayersReady(); if (StartButton != null) { object? value = StartButton.GetValue(__instance); Selectable val = (Selectable)((value is Selectable) ? value : null); if (val != null) { val.interactable = flag; } } if ((Object)(object)SteamLobby.Instance != (Object)null) { SteamLobby.Instance.AllReady = flag; } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static bool UnreadyPrefix() { try { return !LobbyState.IsSpectator(LobbyState.Me); } catch { return true; } } private static void RematchPostfix(VictoryMenu __instance) { try { if (LobbyState.Spectators.Count == 0 || RematchVoters == null) { return; } IEnumerable enumerable = RematchVoters.GetValue(__instance) as IEnumerable; MethodInfo methodInfo = enumerable?.GetType().GetMethod("Remove"); if (methodInfo == null) { return; } List<object> list = new List<object>(); foreach (object item in enumerable) { if (IsSpectatorThing(item)) { list.Add(item); } } foreach (object item2 in list) { methodInfo.Invoke(enumerable, new object[1] { item2 }); } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static bool IsSpectatorThing(object v) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) Component val = (Component)((v is Component) ? v : null); if (val == null) { if (!(v is ulong steam)) { if (!(v is CSteamID val2)) { if (v is int playerId) { return IsSpectatorId(playerId); } return false; } return LobbyState.IsSpectator(val2.m_SteamID); } return LobbyState.IsSpectator(steam); } ClientInstance component = val.GetComponent<ClientInstance>(); if ((Object)(object)component != (Object)null) { return LobbyState.IsSpectator(component.PlayerSteamID); } return false; } private static void StartTimePostfix(GameManager __instance) { try { if (Spectating()) { PauseManager instance = PauseManager.Instance; if (!((Object)(object)instance == (Object)null) && !instance.inMainMenu) { __instance.hasSetStartTime = false; instance.StartRoundDelay(__instance.timeTillStart); } } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void DressPostfix(PlayerSetup __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) try { if (!Spectating()) { return; } PlayerValues component = ((Component)__instance).GetComponent<PlayerValues>(); ClientInstance val = (((Object)(object)component != (Object)null) ? component.sync___get_value_playerClient() : null); if ((Object)(object)val == (Object)null) { return; } int num = LobbyState.TeamOf(val.PlayerId); Color val2 = TeamColors[(num % TeamColors.Length + TeamColors.Length) % TeamColors.Length]; if (Outlined == null || !(Outlined.GetValue(__instance) is GameObject[] array)) { return; } GameObject[] array2 = array; foreach (GameObject val3 in array2) { SkinnedMeshRenderer val4 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent<SkinnedMeshRenderer>() : null); if (!((Object)(object)val4 == (Object)null)) { Material[] materials = ((Renderer)val4).materials; if (materials.Length != 0) { materials[0].SetFloat("_ASEOutlineWidth", ((((Object)val3).name == "SM_Aboubi_Head00") ? 0.02f : 0.04f) * OutlineHandler.OutlineWidthMultiplier); materials[0].SetColor("_ASEOutlineColor", val2); ((Renderer)val4).materials = materials; } } } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } internal static void HostStarts(MonoBehaviour runner) { if (!_starting && !(Time.unscaledTime - _lastStart < 4f) && InstanceFinder.IsServer && Spectating()) { PauseManager instance = PauseManager.Instance; GameManager instance2 = GameManager.Instance; if (!((Object)(object)instance == (Object)null) && !instance.inMainMenu && !((Object)(object)instance2 == (Object)null) && instance2.NetworkConnectionsReady.Count != 0) { runner.StartCoroutine(HostStart()); } } } private static IEnumerator HostStart() { _starting = true; GameManager gm = GameManager.Instance; float waited = 0f; while ((Object)(object)gm != (Object)null && !gm.ConnectionsToStartGame.SetEquals(gm.NetworkConnectionsReady) && waited < 7.5f) { yield return null; waited += Time.deltaTime; gm.ConnectionsToStartGame.RemoveWhere((NetworkConnection c) => !c.IsActive); gm.NetworkConnectionsReady.RemoveWhere((NetworkConnection c) => !gm.ConnectionsToStartGame.Contains(c)); } if ((Object)(object)gm != (Object)null) { gm.ConnectionsToStartGame.Clear(); gm.NetworkConnectionsReady.Clear(); float startTime = ((ScoreManager.Instance.sync___get_value_TakeIndex() == 0) ? 3f : 1.2f) + 0.25f; gm.SetStartTime(startTime); _lastStart = Time.unscaledTime; } _starting = false; } private static void HidePrefix() { try { _hideDepth++; if (_hideDepth > 1 || LobbyState.Spectators.Count == 0) { return; } foreach (KeyValuePair<int, ClientInstance> item in ClientInstance.playerInstances.ToList()) { if ((Object)(object)item.Value != (Object)null && LobbyState.IsSpectator(item.Value.PlayerSteamID)) { _hidden[item.Key] = item.Value; } } foreach (int key in _hidden.Keys) { ClientInstance.playerInstances.Remove(key); } } catch (Exception e) { TournamentPlugin.LogErrorOnce(e); } } private static void Unhide() { if (_hideDepth > 0) { _hideDepth--; } if (_hideDepth > 0) { return; } foreach (KeyValuePair<int, ClientInstance> item in _hidden) { if (!ClientInstance.playerInstances.ContainsKey(item.Key)) { ClientInstance.playerInstances[item.Key] = item.Value; } } _hidden.Clear(); } private static bool EndRoundPrefix(RoundManager __instance, int playerId, bool won, int winningTeamId) { HidePrefix(); try { if (LobbyState.Spectators.Count == 0) { _slots = null; return playerId >= 0 && playerId < 4; } if (_roundScreen == null) { return false; } ScoreManager instance = ScoreManager.Instance; List<int> list = (from kv in ClientInstance.playerInstances where (Object)(object)kv.Value != (Object)null && !LobbyState.IsSpectator(kv.Value.PlayerSteamID) select kv.Key into i orderby i select i).Take(4).ToList(); bool flag = Spectating(); int item = playerId; if (flag) { item = -1; foreach (int item2 in instance.GetPlayerIdsForTeam(winningTeamId)) { if (list.Contains(item2)) { item = item2; break; } } } int num = list.IndexOf(item); if (num < 0) { return false; } _slots = list.ToArray(); __instance.names = new string[4]; __instance.scores = new int[4]; for (int num2 = 0; num2 < 4; num2++) { ClientInstance val = ((num2 < list.Count) ? ClientInstance.playerInstances[list[num2]] : null); __instance.names[num2] = (((Object)(object)val != (Object)null) ? val.PlayerName : ""); __instan