using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; [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("MechGaming")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SoloPause")] [assembly: AssemblyTitle("SoloPause")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 MechGaming.REPO.SoloPause { [BepInPlugin("MechGaming.REPO.SoloPause", "SoloPause", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "MechGaming.REPO.SoloPause"; public const string PluginName = "SoloPause"; public const string PluginVersion = "1.0.0"; private ConfigEntry _toggleKey; private ConfigEntry _pauseAudio; private ConfigEntry _showOverlay; private bool _paused; private bool _previousAudioPause; private bool _previousCursorVisible; private CursorLockMode _previousCursorLockState; private float _previousTimeScale = 1f; private void Awake() { _toggleKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ToggleKey", (KeyCode)112, "Key used to toggle pausing in solo games."); _pauseAudio = ((BaseUnityPlugin)this).Config.Bind("Pause", "PauseAudio", true, "Mute game audio while the solo pause is active."); _showOverlay = ((BaseUnityPlugin)this).Config.Bind("Pause", "ShowOverlay", true, "Show a small paused message while the solo pause is active."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SoloPause 1.0.0 loaded."); } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (_paused && !CanStayPaused()) { Resume("Auto-unpaused because the game is no longer a solo run."); } else if (Input.GetKeyDown(_toggleKey.Value)) { if (_paused) { Resume("Unpaused."); } else if (CanPauseNow()) { Pause(); } } } private void LateUpdate() { if (_paused) { ApplyPausedState(); } } private void OnDestroy() { if (_paused) { Resume("Unpaused during plugin shutdown."); } } private void OnGUI() { //IL_0052: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_009d: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) if (_paused && _showOverlay.Value) { Rect val = default(Rect); ((Rect)(ref val))..ctor((float)(Screen.width - 360) / 2f, 48f, 360f, 110f); GUI.color = new Color(0f, 0f, 0f, 0.68f); GUI.Box(val, GUIContent.none); GUI.color = Color.white; GUIStyle val2 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 34, fontStyle = (FontStyle)1 }; val2.normal.textColor = Color.white; GUIStyle val3 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 15 }; val3.normal.textColor = new Color(0.9f, 0.95f, 1f, 1f); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width, 42f), "PAUSED", val2); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 64f, ((Rect)(ref val)).width, 24f), $"Press {_toggleKey.Value} to resume", val3); } } private bool CanPauseNow() { if (CanStayPaused()) { return NoTextInputActive(); } return false; } private static bool CanStayPaused() { if (IsMultiplayer()) { return false; } if ((Object)(object)GameDirector.instance == (Object)null || (Object)(object)PlayerController.instance == (Object)null) { return false; } if (SafeGameCheck((Func)SemiFunc.IsMainMenu) || SafeGameCheck((Func)SemiFunc.RunIsLobbyMenu)) { return false; } return true; } private static bool IsMultiplayer() { try { return (Object)(object)GameManager.instance != (Object)null && GameManager.Multiplayer(); } catch { return false; } } private static bool NoTextInputActive() { try { return SemiFunc.NoTextInputsActive(); } catch { return true; } } private static bool SafeGameCheck(Func check) { try { return check(); } catch { return false; } } private void Pause() { //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) _previousTimeScale = ((Time.timeScale > 0f) ? Time.timeScale : 1f); _previousAudioPause = AudioListener.pause; _previousCursorVisible = Cursor.visible; _previousCursorLockState = Cursor.lockState; _paused = true; ApplyPausedState(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Paused solo game."); } private void ApplyPausedState() { Time.timeScale = 0f; if (_pauseAudio.Value) { AudioListener.pause = true; } Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } private void Resume(string logMessage) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) Time.timeScale = ((_previousTimeScale > 0f) ? _previousTimeScale : 1f); if (_pauseAudio.Value) { AudioListener.pause = _previousAudioPause; } Cursor.visible = _previousCursorVisible; Cursor.lockState = _previousCursorLockState; _paused = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)logMessage); } } }