using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using Vote_Pause.Configuration; using Vote_Pause.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Mirror")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.github.glarmer.Vote_Pause")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+e6be22d40b52164f31d93989474a2d422db9de2e")] [assembly: AssemblyProduct("com.github.glarmer.Vote_Pause")] [assembly: AssemblyTitle("Vote Pause")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Vote_Pause { public struct ClientPausedMessage : NetworkMessage { public bool IsPaused; } public static class Networker { public static void RegisterNetwork() { RegisterSerialisers(); if (NetworkClient.active) { RegisterClient(); } if (NetworkServer.active) { RegisterServer(); } } private static void RegisterSerialisers() { Writer.write = delegate(NetworkWriter writer, ClientPausedMessage message) { NetworkWriterExtensions.WriteBool(writer, message.IsPaused); }; Reader.read = (NetworkReader reader) => new ClientPausedMessage { IsPaused = NetworkReaderExtensions.ReadBool(reader) }; Writer.write = delegate(NetworkWriter writer, ServerPausedMessage message) { NetworkWriterExtensions.WriteBool(writer, message.IsPaused); }; Reader.read = (NetworkReader reader) => new ServerPausedMessage { IsPaused = NetworkReaderExtensions.ReadBool(reader) }; } private static void RegisterServer() { PauseManager.Instance.Pauses.Clear(); NetworkServer.RegisterHandler((Action)OnClientPauseChanged, true); NetworkServer.OnDisconnectedEvent = (Action)Delegate.Combine(NetworkServer.OnDisconnectedEvent, new Action(OnClientDisconnected)); } private static void RegisterClient() { NetworkClient.RegisterHandler((Action)OnServerPauseChanged, true); } private static void OnClientPauseChanged(NetworkConnectionToClient sender, ClientPausedMessage message) { PauseManager.Instance.Pauses[sender.connectionId] = message.IsPaused; PauseManager.Instance.DecideAndPause(); } private static void OnServerPauseChanged(ServerPausedMessage message) { PauseManager.Instance.PauseGame(message.IsPaused); } private static void OnClientDisconnected(NetworkConnectionToClient conn) { if (Enumerable.Contains(PauseManager.Instance.Pauses.Keys, conn.connectionId)) { PauseManager.Instance.Pauses.Remove(conn.connectionId); } } public static void SendServerPausedState(bool paused) { if (NetworkServer.active) { NetworkServer.SendToAll(new ServerPausedMessage { IsPaused = paused }, 0, false); } } public static void SendClientPausedState(bool paused) { if (NetworkClient.isConnected) { NetworkClient.Send(new ClientPausedMessage { IsPaused = paused }, 0); } } } public class PauseManager : MonoBehaviour { public static PauseManager Instance; public readonly Dictionary Pauses = new Dictionary(); public void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)Instance); } InputManager.Instance.OnPauseMenuOpen += OnPauseMenuOpen; InputManager.Instance.OnPauseMenuClose += OnPauseMenuClose; } private void OnPauseMenuOpen() { if (NetworkServer.active) { Plugin.Log.LogInfo((object)"Paused server 1"); } if (NetworkClient.active) { Plugin.Log.LogInfo((object)"Paused client 1"); Networker.SendClientPausedState(paused: true); } } private void OnPauseMenuClose() { if (NetworkServer.active) { Plugin.Log.LogInfo((object)"Unpaused server 1"); } if (NetworkClient.active) { Plugin.Log.LogInfo((object)"Unpaused client 1"); Networker.SendClientPausedState(paused: false); } } public void DecideAndPause() { Plugin.Log.LogInfo((object)"DecideAndPause"); float num = NetworkManager.singleton.numPlayers; float num2 = 0f; float num3 = 0.45f; foreach (KeyValuePair pause in Pauses) { if (pause.Value) { num2 += 1f; } } Plugin.Log.LogInfo((object)$"Paused players: {num2}/{num}"); bool flag = num2 / num > num3; if (flag) { Plugin.Log.LogInfo((object)"Paused players is enough to pause!"); } Networker.SendServerPausedState(flag); } public void PauseGame(bool shouldPause) { Time.timeScale = ((!shouldPause) ? 1 : 0); } public void OnDestroy() { InputManager.Instance.OnPauseMenuOpen -= OnPauseMenuOpen; InputManager.Instance.OnPauseMenuClose -= OnPauseMenuClose; } } [BepInPlugin("com.github.glarmer.Vote_Pause", "Vote Pause", "0.1.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; private ModConfigurationUI _ui; public GameObject VoteObject; public const string Id = "com.github.glarmer.Vote_Pause"; internal static ManualLogSource Log { get; private set; } public static Plugin Instance { get; private set; } public static ConfigurationHandler ConfigurationHandler { get; private set; } public static string Name => "Vote Pause"; public static string Version => "0.1.0"; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Instance = this; ConfigurationHandler = new ConfigurationHandler(((BaseUnityPlugin)this).Config); GameObject val = new GameObject(Name); Object.DontDestroyOnLoad((Object)(object)val); _ui = val.AddComponent(); _ui.Init(new List