using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak; using Peak.Afflictions; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeakVs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PeakVs")] [assembly: AssemblyTitle("PeakVs")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PeakVs { internal static class GameMode { private static int _cachedFrame = int.MinValue; private static bool _cachedIsGameplayScene; private static bool _cachedLobbyCompatible; private static bool _cachedIsActive; private static float _nextPresencePublish; internal static bool IsGameplayScene { get { RefreshFrameCache(); return _cachedIsGameplayScene; } } internal static bool AllPlayersCompatible { get { RefreshFrameCache(); return _cachedLobbyCompatible; } } internal static bool IsActive { get { RefreshFrameCache(); return _cachedIsActive; } } internal static void TickPresence() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0082: Expected O, but got Unknown object value; if (!PhotonNetwork.InRoom || PhotonNetwork.LocalPlayer == null) { _nextPresencePublish = 0f; } else if ((!((Dictionary)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"pvs.v", out value) || !(Convert.ToString(value) == "0.7.2")) && !(Time.unscaledTime < _nextPresencePublish)) { _nextPresencePublish = Time.unscaledTime + 2f; Player localPlayer = PhotonNetwork.LocalPlayer; Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"pvs.v", (object)"0.7.2"); localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); _cachedFrame = int.MinValue; } } internal static void ClearPresence() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_002d: Expected O, but got Unknown try { if (PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null) { Player localPlayer = PhotonNetwork.LocalPlayer; Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"pvs.v", (object)null); localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); _cachedFrame = int.MinValue; } } catch { } } private static void RefreshFrameCache() { int frameCount = Time.frameCount; if (_cachedFrame == frameCount) { return; } _cachedFrame = frameCount; try { _cachedIsGameplayScene = PhotonNetwork.InRoom && (Object)(object)Character.localCharacter != (Object)null && !Character.localCharacter.inAirport && MapHandler.Exists; _cachedLobbyCompatible = HasCompatiblePlayers(); _cachedIsActive = _cachedIsGameplayScene && _cachedLobbyCompatible; } catch { _cachedIsGameplayScene = false; _cachedLobbyCompatible = false; _cachedIsActive = false; } } private static bool HasCompatiblePlayers() { if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null) { return false; } int num = 0; foreach (Player value2 in PhotonNetwork.CurrentRoom.Players.Values) { if (value2 != null && !value2.IsInactive) { num++; if (!((Dictionary)(object)value2.CustomProperties).TryGetValue((object)"pvs.v", out object value) || Convert.ToString(value) != "0.7.2") { return false; } } } return num > 0; } } internal sealed class PeakVsMenuWindow : MenuWindow { internal Selectable StartingSelection; public override bool openOnStart => false; public override bool selectOnOpen => true; public override Selectable objectToSelectOnOpen => StartingSelection; public override bool closeOnPause => true; public override bool closeOnUICancel => true; public override bool blocksPlayerInput => true; public override bool showCursorWhileOpen => true; public override bool autoHideOnClose => true; } internal static class HostMenu { private sealed class MenuRow { internal GameObject Root; internal Image Background; internal Button Button; internal TextMeshProUGUI Label; internal TextMeshProUGUI Value; } private static readonly MethodInfo OpenMethod = AccessTools.Method(typeof(MenuWindow), "Open", (Type[])null, (Type[])null); private static readonly MethodInfo CloseMethod = AccessTools.Method(typeof(MenuWindow), "Close", (Type[])null, (Type[])null); private static readonly MethodInfo StartClosedMethod = AccessTools.Method(typeof(MenuWindow), "StartClosed", (Type[])null, (Type[])null); private static Canvas _canvas; private static RectTransform _panel; private static PeakVsMenuWindow _window; private static TextMeshProUGUI _title; private static TextMeshProUGUI _subtitle; private static TextMeshProUGUI _hostHeading; private static TextMeshProUGUI _status; private static TextMeshProUGUI _hint; private static MenuRow _showHud; private static MenuRow _hudScale; private static MenuRow _rivalOpacity; private static MenuRow _menuHotkey; private static MenuRow _compactHotkey; private static MenuRow _autoAdvance; private static MenuRow _matchedLoot; private static MenuRow _restartSplit; private static MenuRow _forceCheckpoint; private static MenuRow _close; private static float _nextRefresh; private static int _lastFontRevision = -1; private static ConfigEntry _captureTarget; private static MenuRow _captureRow; private static int _captureStartFrame; internal static void Initialize() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_canvas != (Object)null)) { _canvas = PeakVsUi.CreateCanvas("PeakVs Menu Canvas", 32760, interactive: true); Image obj = PeakVsUi.CreateImage(((Component)_canvas).transform, "PeakVs Menu", new Color(0f, 0f, 0f, 0.48f)); ((Graphic)obj).raycastTarget = true; PeakVsUi.SetRect(((Graphic)obj).rectTransform, Vector2.zero, Vector2.one, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); _window = ((Component)obj).gameObject.AddComponent(); Image obj2 = PeakVsUi.CreateImage(((Component)obj).transform, "Panel", PeakVsUi.PanelColor); ((Graphic)obj2).raycastTarget = true; _panel = ((Graphic)obj2).rectTransform; PeakVsUi.SetRect(_panel, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(680f, 814f)); PeakVsUi.SetRect(((Graphic)PeakVsUi.CreateImage((Transform)(object)_panel, "Accent", PeakVsUi.AccentColor)).rectTransform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(0f, 5f)); _title = PeakVsUi.CreateText((Transform)(object)_panel, "Title", 34f, (TextAlignmentOptions)4097, PeakVsUi.TextColor); ((TMP_Text)_title).fontStyle = (FontStyles)1; ((TMP_Text)_title).text = "PEAK VS"; Place(((TMP_Text)_title).rectTransform, -24f, 44f); _subtitle = PeakVsUi.CreateText((Transform)(object)_panel, "Role", 18f, (TextAlignmentOptions)4100, PeakVsUi.MutedColor); Place(((TMP_Text)_subtitle).rectTransform, -30f, 34f); TextMeshProUGUI obj3 = PeakVsUi.CreateText((Transform)(object)_panel, "Display Heading", 17f, (TextAlignmentOptions)4097, PeakVsUi.AccentColor); ((TMP_Text)obj3).text = "LOCAL DISPLAY"; Place(((TMP_Text)obj3).rectTransform, -82f, 28f); _showHud = CreateRow("Show Race HUD", -116f, ToggleHud); _hudScale = CreateRow("HUD Scale", -172f, CycleHudScale); _rivalOpacity = CreateRow("Rival Opacity", -228f, CycleRivalOpacity); _menuHotkey = CreateRow("Menu Hotkey", -284f, delegate { BeginKeyCapture(_menuHotkey, PeakVsPlugin.MenuToggleKey); }); _compactHotkey = CreateRow("Compact HUD Hotkey", -340f, delegate { BeginKeyCapture(_compactHotkey, PeakVsPlugin.CompactHudToggleKey); }); _hostHeading = PeakVsUi.CreateText((Transform)(object)_panel, "Host Heading", 17f, (TextAlignmentOptions)4097, PeakVsUi.WarmColor); ((TMP_Text)_hostHeading).text = "HOST RACE CONTROLS"; Place(((TMP_Text)_hostHeading).rectTransform, -404f, 28f); _autoAdvance = CreateRow("Auto Advance", -438f, ToggleAutoAdvance); _matchedLoot = CreateRow("Matched Luggage Loot", -494f, ToggleMatchedLoot); _restartSplit = CreateRow("Restart Current Split", -550f, RestartSplit, centered: true); _forceCheckpoint = CreateRow("Force Checkpoint", -606f, ForceCheckpoint, centered: true); _status = PeakVsUi.CreateText((Transform)(object)_panel, "Status", 17f, (TextAlignmentOptions)514, PeakVsUi.MutedColor); Place(((TMP_Text)_status).rectTransform, -672f, 30f); _close = CreateRow("CLOSE", -716f, Close, centered: true); ((TMP_Text)_close.Label).alignment = (TextAlignmentOptions)514; ((Graphic)_close.Label).color = PeakVsUi.AccentColor; _hint = PeakVsUi.CreateText((Transform)(object)_panel, "Hint", 14f, (TextAlignmentOptions)514, PeakVsUi.MutedColor); ((TMP_Text)_hint).text = ((object)PeakVsPlugin.MenuToggleKey.Value/*cast due to .constrained prefix*/).ToString().ToUpperInvariant() + " MENU / " + ((object)PeakVsPlugin.CompactHudToggleKey.Value/*cast due to .constrained prefix*/).ToString().ToUpperInvariant() + " COMPACT HUD / ESC CLOSE"; Place(((TMP_Text)_hint).rectTransform, -775f, 24f); _window.StartingSelection = (Selectable)(object)_showHud.Button; StartClosedMethod.Invoke(_window, null); Refresh(forceFont: true); } } internal static void Tick() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_canvas == (Object)null) { Initialize(); } if (((MenuWindow)_window).isOpen && _captureTarget != null) { CaptureHotkey(); return; } if (Input.GetKeyDown(PeakVsPlugin.MenuToggleKey.Value)) { if (((MenuWindow)_window).isOpen) { Close(); } else { Refresh(forceFont: true); OpenMethod.Invoke(_window, null); } } if (((MenuWindow)_window).isOpen && Time.unscaledTime >= _nextRefresh) { _nextRefresh = Time.unscaledTime + 0.5f; Refresh(forceFont: false); } } internal static void Dispose() { if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)((Component)_canvas).gameObject); } _canvas = null; _panel = null; _window = null; _lastFontRevision = -1; _captureTarget = null; _captureRow = null; } private static MenuRow CreateRow(string labelText, float y, Action action, bool centered = false) { //IL_0013: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) Image val = PeakVsUi.CreateImage((Transform)(object)_panel, labelText, PeakVsUi.RowColor); ((Graphic)val).raycastTarget = true; PeakVsUi.SetRect(((Graphic)val).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, y), new Vector2(620f, 48f)); Button val2 = ((Component)val).gameObject.AddComponent