using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; 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 ServerSync; using TMPro; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SleepSkip")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("SleepSkip")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.3.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] [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 SleepSkip { [HarmonyPatch(typeof(Game), "EverybodyIsTryingToSleep")] internal static class GameEverybodyIsTryingToSleepPatch { private static readonly HashSet s_inBedPlayerIds = new HashSet(); private static readonly HashSet s_currentPlayerIds = new HashSet(); private static int s_lastDisplayInBed; private static int s_lastDisplayYes; private static int s_lastDisplayNo; private static int s_lastDisplayWaiting; private static int s_lastDisplayTotal; private static bool Prefix(Game __instance, ref bool __result) { List allCharacterZDOS = ZNet.instance.GetAllCharacterZDOS(); if (allCharacterZDOS.Count == 0) { __result = false; return false; } int count = allCharacterZDOS.Count; DateTime now = DateTime.Now; s_inBedPlayerIds.Clear(); foreach (ZDO item in allCharacterZDOS) { if (item.GetBool(ZDOVars.s_inBed, false)) { s_inBedPlayerIds.Add(((ZDOID)(ref item.m_uid)).UserID); } } int count2 = s_inBedPlayerIds.Count; if (count2 <= 0) { ResetIfActive(); __result = false; return false; } if (count2 >= count) { ResetIfActive(); __result = true; return false; } if (count > 1 && count2 < SleepSkipPlugin.PlayersNeeded.Value) { ResetIfActive(); __result = false; return false; } if (SleepSkipPlugin.SleepCooldown.Value > 0 && SleepSkipPlugin.LastSleepCompleted != DateTime.MinValue && now < SleepSkipPlugin.LastSleepCompleted.AddSeconds(SleepSkipPlugin.SleepCooldown.Value)) { __result = false; return false; } if (SleepSkipPlugin.LastSleepCheck == DateTime.MinValue) { SleepSkipPlugin.LastSleepCheck = now; SleepSkipPlugin.WarningTimeCounter = SleepSkipPlugin.WarningTime.Value; SendWarningToAll(SleepSkipPlugin.WarningTimeCounter); __result = false; return false; } DateTime dateTime = SleepSkipPlugin.LastSleepCheck.AddSeconds(SleepSkipPlugin.WarningTime.Value); if (dateTime > now) { int num = (int)(dateTime - now).TotalSeconds; if (num != SleepSkipPlugin.WarningTimeCounter) { SleepSkipPlugin.WarningTimeCounter = num; SendWarningToAll(SleepSkipPlugin.WarningTimeCounter); } __result = false; return false; } s_currentPlayerIds.Clear(); foreach (ZNetPeer peer in ZNet.instance.m_peers) { s_currentPlayerIds.Add(((ZDOID)(ref peer.m_characterID)).UserID); } if (!ZNet.instance.IsDedicated()) { s_currentPlayerIds.Add(ZNet.GetUID()); } SleepSkipPlugin.YesVoters.IntersectWith(s_currentPlayerIds); SleepSkipPlugin.NoVoters.IntersectWith(s_currentPlayerIds); SleepSkipPlugin.YesVoters.ExceptWith(s_inBedPlayerIds); SleepSkipPlugin.NoVoters.ExceptWith(s_inBedPlayerIds); int count3 = SleepSkipPlugin.YesVoters.Count; int count4 = SleepSkipPlugin.NoVoters.Count; int num2 = count - count2 - count3 - count4; if (num2 < 0) { num2 = 0; } bool flag = SleepSkipPlugin.VoteTimeout.Value > 0 && SleepSkipPlugin.VoteStartTime != DateTime.MinValue && now > SleepSkipPlugin.VoteStartTime.AddSeconds(SleepSkipPlugin.VoteTimeout.Value); int num3 = (flag ? num2 : 0); int num4 = count - num3; int num5 = count2 + count3; int num6 = ((!flag) ? num2 : 0); if (count2 != s_lastDisplayInBed || count3 != s_lastDisplayYes || count4 != s_lastDisplayNo || num6 != s_lastDisplayWaiting || count != s_lastDisplayTotal) { s_lastDisplayInBed = count2; s_lastDisplayYes = count3; s_lastDisplayNo = count4; s_lastDisplayWaiting = num6; s_lastDisplayTotal = count; SendVoteDisplayToAll(count2, count3, count4, num6, count); } if (!SleepSkipPlugin.MenusOpened) { SleepSkipPlugin.VoteStartTime = now; SendPopupToEligiblePlayers(s_inBedPlayerIds); SleepSkipPlugin.MenusOpened = true; } else { SendPopupToNewPlayers(s_inBedPlayerIds); } float num7 = ((num4 > 0) ? ((float)num5 / (float)num4 * 100f) : 0f); if (num7 >= (float)SleepSkipPlugin.Ratio.Value) { SleepSkipPlugin.SleepSkipLogger.LogDebug((object)$"Threshold of {SleepSkipPlugin.Ratio.Value}% reached ({num7:F0}%), sleeping..."); SleepSkipPlugin.LastSleepCompleted = now; ZRoutedRpc.instance.InvokeRoutedRPC(0L, "SleepVoteResult", new object[1] { Localization.instance.Localize("$sleep_vote_passed") }); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "ResetVariables", Array.Empty()); __result = true; return false; } int num8 = num5 + ((!flag) ? num2 : 0); float num9 = ((num4 > 0) ? ((float)num8 / (float)num4 * 100f) : 0f); if (num9 < (float)SleepSkipPlugin.Ratio.Value) { SleepSkipPlugin.SleepSkipLogger.LogDebug((object)$"Vote failed: best possible {num9:F0}% < {SleepSkipPlugin.Ratio.Value}% threshold"); SleepSkipPlugin.LastSleepCompleted = now; ZRoutedRpc.instance.InvokeRoutedRPC(0L, "SleepStop", Array.Empty()); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "SleepVoteResult", new object[1] { Localization.instance.Localize("$sleep_vote_failed") }); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "ResetVariables", Array.Empty()); __result = false; return false; } __result = false; return false; } private static void ResetIfActive() { if (!(SleepSkipPlugin.LastSleepCheck == DateTime.MinValue) || SleepSkipPlugin.MenusOpened) { s_lastDisplayInBed = 0; s_lastDisplayYes = 0; s_lastDisplayNo = 0; s_lastDisplayWaiting = 0; s_lastDisplayTotal = 0; SleepSkipPlugin.ResetVariables(0L); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "ResetVariables", Array.Empty()); } } private static void SendWarningToAll(int timeRemaining) { foreach (ZNetPeer peer in ZNet.instance.m_peers) { ZRoutedRpc.instance.InvokeRoutedRPC(((ZDOID)(ref peer.m_characterID)).UserID, "UpdateWarningTime", new object[1] { timeRemaining }); } if (!ZNet.instance.IsDedicated()) { SleepSkipPlugin.UpdateWarningTime(0L, timeRemaining); } } private static void SendPopupToEligiblePlayers(HashSet inBedPlayerIds) { foreach (ZNetPeer peer in ZNet.instance.m_peers) { long userID = ((ZDOID)(ref peer.m_characterID)).UserID; if (!inBedPlayerIds.Contains(userID)) { ZRoutedRpc.instance.InvokeRoutedRPC(userID, "OpenMenuOnClient", Array.Empty()); SleepSkipPlugin.PopupSentTo.Add(userID); } } if (!ZNet.instance.IsDedicated()) { long uID = ZNet.GetUID(); if (!inBedPlayerIds.Contains(uID)) { SleepSkipPlugin.OpenMenuOnClient(0L); SleepSkipPlugin.PopupSentTo.Add(uID); } } } private static void SendPopupToNewPlayers(HashSet inBedPlayerIds) { foreach (ZNetPeer peer in ZNet.instance.m_peers) { long userID = ((ZDOID)(ref peer.m_characterID)).UserID; if (!inBedPlayerIds.Contains(userID) && !SleepSkipPlugin.PopupSentTo.Contains(userID) && !SleepSkipPlugin.YesVoters.Contains(userID) && !SleepSkipPlugin.NoVoters.Contains(userID)) { ZRoutedRpc.instance.InvokeRoutedRPC(userID, "OpenMenuOnClient", Array.Empty()); SleepSkipPlugin.PopupSentTo.Add(userID); } } if (!ZNet.instance.IsDedicated()) { long uID = ZNet.GetUID(); if (!inBedPlayerIds.Contains(uID) && !SleepSkipPlugin.PopupSentTo.Contains(uID) && !SleepSkipPlugin.YesVoters.Contains(uID) && !SleepSkipPlugin.NoVoters.Contains(uID)) { SleepSkipPlugin.OpenMenuOnClient(0L); SleepSkipPlugin.PopupSentTo.Add(uID); } } } private static void SendVoteDisplayToAll(int inBed, int yes, int no, int waiting, int total) { string text = $"{inBed},{yes},{no},{waiting},{total}"; foreach (ZNetPeer peer in ZNet.instance.m_peers) { ZRoutedRpc.instance.InvokeRoutedRPC(((ZDOID)(ref peer.m_characterID)).UserID, "UpdateVoteDisplay", new object[1] { text }); } if (!ZNet.instance.IsDedicated()) { SleepSkipPlugin.UpdateVoteDisplay(0L, text); } } } [HarmonyPatch(typeof(UnifiedPopup), "Awake")] internal static class SwapYesNoButonsUnifiedPopupAwakePatch { private static void Postfix(UnifiedPopup __instance) { SwapAnchoredPositions(__instance); } public static void SwapAnchoredPositions(UnifiedPopup __instance) { //IL_004d: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.buttonLeft == (Object)null) && !((Object)(object)__instance.buttonRight == (Object)null)) { RectTransform component = ((Component)__instance.buttonRight).GetComponent(); RectTransform component2 = ((Component)__instance.buttonLeft).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null)) { RectTransform val = component; RectTransform val2 = component2; Vector2 anchoredPosition = component2.anchoredPosition; Vector2 anchoredPosition2 = component.anchoredPosition; val.anchoredPosition = anchoredPosition; val2.anchoredPosition = anchoredPosition2; } } } } [HarmonyPatch(typeof(UnifiedPopup), "IsVisible")] internal static class UnifiedPopupIsVisiblePatch { private static void Postfix(UnifiedPopup __instance, ref bool __result) { if (__result && !((Object)(object)UnifiedPopup.instance == (Object)null) && !((Object)(object)UnifiedPopup.instance.headerText == (Object)null) && !(((TMP_Text)UnifiedPopup.instance.headerText).text != Localization.instance.Localize("$sleep_skip"))) { ((TMP_Text)UnifiedPopup.instance.bodyText).text = SleepSkipPlugin.FormatVoteBody(); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } } [HarmonyPatch(typeof(Game), "Start")] internal static class GameStartPatch { private static void Postfix(Game __instance) { ZRoutedRpc.instance.Register("OpenMenuOnClient", (Action)SleepSkipPlugin.OpenMenuOnClient); ZRoutedRpc.instance.Register("SleepStopNotify", (Action)SleepSkipPlugin.SleepStopNotify); ZRoutedRpc.instance.Register("ResetVariables", (Action)SleepSkipPlugin.ResetVariables); ZRoutedRpc.instance.Register("UpdateWarningTime", (Action)SleepSkipPlugin.UpdateWarningTime); ZRoutedRpc.instance.Register("VoteYes", (Action)SleepSkipPlugin.VoteYes); ZRoutedRpc.instance.Register("VoteNo", (Action)SleepSkipPlugin.VoteNo); ZRoutedRpc.instance.Register("UpdateVoteDisplay", (Action)SleepSkipPlugin.UpdateVoteDisplay); ZRoutedRpc.instance.Register("SleepVoteResult", (Action)SleepSkipPlugin.SleepVoteResult); } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class InjectSleepSkipTranslations { private static void Postfix(Localization __instance) { Add(__instance, "sleep_denied_combat", "Sleep request auto-denied, you are in combat!"); Add(__instance, "sleep_skip", "Sleep Skip"); Add(__instance, "sleep_canceled_by", "Sleep canceled by {0}"); Add(__instance, "sleep_canceled_reason", "{0} declined (in combat)"); Add(__instance, "sleep_request", "{0}/{1} want to sleep ({2}% needed)"); Add(__instance, "sleep_vote_status", "In bed: {0} | Yes: {1} | No: {2} | Waiting: {3}"); Add(__instance, "sleep_vote_prompt", "Skip the night?"); Add(__instance, "sleep_vote_passed", "Vote passed! Skipping to morning."); Add(__instance, "sleep_vote_failed", "Sleep vote failed. Not enough players agreed."); Add(__instance, "sleep_warning_time", "Sleep popup will display in {0} seconds"); } private static void Add(Localization loc, string key, string value) { try { loc.AddWord(key, value); } catch { } } } [BepInPlugin("Azumatt.SleepSkip", "SleepSkip", "1.3.1")] public class SleepSkipPlugin : BaseUnityPlugin { private enum Toggle { On = 1, Off = 0 } internal enum AutoChoice { Ask, AlwaysAccept, AlwaysDecline } private class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } [CompilerGenerated] private static class <>O { public static PopupButtonCallback <0>__OnAcceptSleep; public static PopupButtonCallback <1>__OnDeclineSleep; } internal const string ModName = "SleepSkip"; internal const string ModVersion = "1.3.1"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.SleepSkip"; private static string ConfigFileName = "Azumatt.SleepSkip.cfg"; private static string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("Azumatt.SleepSkip"); public static readonly ManualLogSource SleepSkipLogger; private static readonly ConfigSync ConfigSync; internal static HashSet YesVoters; internal static HashSet NoVoters; internal static HashSet PopupSentTo; internal static DateTime VoteStartTime; internal static DateTime LastSleepCompleted; internal static int WarningTimeCounter; internal static bool MenusOpened; internal static DateTime LastSleepCheck; internal static int DisplayInBed; internal static int DisplayYes; internal static int DisplayNo; internal static int DisplayWaiting; internal static int DisplayTotal; private static ConfigEntry _serverConfigLocked; internal static ConfigEntry Ratio; internal static ConfigEntry PlayersNeeded; internal static ConfigEntry WarningTime; internal static ConfigEntry VoteTimeout; internal static ConfigEntry SleepCooldown; internal static ConfigEntry PopupAutoChoice; public void Awake() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry(_serverConfigLocked); Ratio = config("1 - General", "Percent of players", 50, new ConfigDescription("Threshold of players that need to agree to sleep.\nValues are in percentage 1% - 100%.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); PlayersNeeded = config("1 - General", "Players Needed", 2, new ConfigDescription("Amount of players needed in bed to start the sleep vote.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); WarningTime = config("1 - General", "Warning Time", 15, new ConfigDescription("Time in seconds before the sleep popup is displayed on the client.\nAccepted values are from 1 - 60.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 60), Array.Empty())); VoteTimeout = config("1 - General", "Vote Timeout", 45, new ConfigDescription("Time in seconds before non-responding players are counted as abstaining.\nSet to 0 to disable (votes wait indefinitely).", (AcceptableValueBase)(object)new AcceptableValueRange(0, 120), Array.Empty())); SleepCooldown = config("1 - General", "Sleep Cooldown", 0, new ConfigDescription("Cooldown in seconds between sleep vote attempts.\nSet to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 600), Array.Empty())); PopupAutoChoice = config("2 - Client Choices", "Popup Auto Choice", AutoChoice.Ask, new ConfigDescription("Auto choice for the popup on the client. Change only if you don't want to be asked and want to either always accept or always deny.", (AcceptableValueBase)null, Array.Empty()), synchronizedSetting: false); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { SleepSkipLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { SleepSkipLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); SleepSkipLogger.LogError((object)"Please check your config entries for spelling and format!"); } } internal static void ResetVariables(long senderId) { YesVoters.Clear(); NoVoters.Clear(); PopupSentTo.Clear(); VoteStartTime = DateTime.MinValue; MenusOpened = false; LastSleepCheck = DateTime.MinValue; WarningTimeCounter = 0; DisplayInBed = 0; DisplayYes = 0; DisplayNo = 0; DisplayWaiting = 0; DisplayTotal = 0; } internal static void OpenMenuOnClient(long senderId) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; bool flag = false; List list = new List(); Character.GetCharactersInRange(((Component)localPlayer).transform.position, 30f, list); foreach (Character item in list) { if (!((Object)(object)item == (Object)null)) { MonsterAI component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null && ((BaseAI)component).IsAlerted()) { flag = true; break; } } } if (flag) { ((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize("$sleep_denied_combat"), 0, (Sprite)null, false); CreatePopup(); ((UnityEvent)UnifiedPopup.instance.buttonLeft.onClick).Invoke(); return; } switch (PopupAutoChoice.Value) { case AutoChoice.AlwaysAccept: CreatePopup(); ((UnityEvent)UnifiedPopup.instance.buttonRight.onClick).Invoke(); break; case AutoChoice.AlwaysDecline: CreatePopup(); ((UnityEvent)UnifiedPopup.instance.buttonLeft.onClick).Invoke(); break; default: CreatePopup(); break; } } internal static void CreatePopup() { //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_002f: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_003f: 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_004a: Expected O, but got Unknown string text = Localization.instance.Localize("$sleep_skip"); string text2 = FormatVoteBody(); object obj = <>O.<0>__OnAcceptSleep; if (obj == null) { PopupButtonCallback val = OnAcceptSleep; <>O.<0>__OnAcceptSleep = val; obj = (object)val; } object obj2 = <>O.<1>__OnDeclineSleep; if (obj2 == null) { PopupButtonCallback val2 = OnDeclineSleep; <>O.<1>__OnDeclineSleep = val2; obj2 = (object)val2; } UnifiedPopup.Push((PopupBase)new YesNoPopup(text, text2, (PopupButtonCallback)obj, (PopupButtonCallback)obj2, true, false)); } internal static string FormatVoteBody() { int num = DisplayInBed + DisplayYes; string text = string.Format(Localization.instance.Localize("$sleep_request"), num, DisplayTotal, Ratio.Value); string text2 = string.Format(Localization.instance.Localize("$sleep_vote_status"), DisplayInBed, DisplayYes, DisplayNo, DisplayWaiting); string text3 = Localization.instance.Localize("$sleep_vote_prompt"); return text + "\n\n" + text2 + "\n\n" + text3; } internal static void OnDeclineSleep() { SleepSkipLogger.LogDebug((object)"Declined sleep request"); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VoteNo", new object[1] { ZNet.GetUID() }); UnifiedPopup.Pop(); } internal static void OnAcceptSleep() { SleepSkipLogger.LogDebug((object)"Accepted sleep request"); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VoteYes", new object[1] { ZNet.GetUID() }); UnifiedPopup.Pop(); } internal static void VoteYes(long senderId, long voterId) { if (ZNet.instance.IsServer()) { YesVoters.Add(voterId); NoVoters.Remove(voterId); SleepSkipLogger.LogDebug((object)$"VoteYes from {voterId}. Yes: {YesVoters.Count}, No: {NoVoters.Count}"); } } internal static void VoteNo(long senderId, long voterId) { if (ZNet.instance.IsServer()) { NoVoters.Add(voterId); YesVoters.Remove(voterId); SleepSkipLogger.LogDebug((object)$"VoteNo from {voterId}. Yes: {YesVoters.Count}, No: {NoVoters.Count}"); } } internal static void UpdateVoteDisplay(long senderId, string data) { string[] array = data.Split(new char[1] { ',' }); if (array.Length == 5) { int.TryParse(array[0], out DisplayInBed); int.TryParse(array[1], out DisplayYes); int.TryParse(array[2], out DisplayNo); int.TryParse(array[3], out DisplayWaiting); int.TryParse(array[4], out DisplayTotal); } } internal static void UpdateWarningTime(long senderId, int time) { WarningTimeCounter = time; if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)((WarningTimeCounter != WarningTime.Value) ? 1 : 2), string.Format(Localization.instance.Localize("$sleep_warning_time"), WarningTimeCounter), 0, (Sprite)null, false); } } internal static void SleepVoteResult(long senderId, string message) { if ((Object)(object)UnifiedPopup.instance != (Object)null && UnifiedPopup.IsVisible() && (Object)(object)UnifiedPopup.instance.headerText != (Object)null && ((TMP_Text)UnifiedPopup.instance.headerText).text == Localization.instance.Localize("$sleep_skip")) { UnifiedPopup.Pop(); } if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false); } } internal static void SleepStopNotify(long senderId, string s) { if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, s, 0, (Sprite)null, false); } } private ConfigEntry config(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown string text = (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); ConfigDescription val = new ConfigDescription(description.Description + text, description.AcceptableValues, description.Tags); ConfigEntry val2 = ((BaseUnityPlugin)this).Config.Bind(group, name, value, val); ((OwnConfigEntryBase)ConfigSync.AddConfigEntry(val2)).SynchronizedConfig = synchronizedSetting; return val2; } private ConfigEntry config(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } static SleepSkipPlugin() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //IL_007b: Expected O, but got Unknown string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; SleepSkipLogger = Logger.CreateLogSource("SleepSkip"); ConfigSync = new ConfigSync("Azumatt.SleepSkip") { DisplayName = "SleepSkip", CurrentVersion = "1.3.1", MinimumRequiredVersion = "1.3.1", ModRequired = true }; YesVoters = new HashSet(); NoVoters = new HashSet(); PopupSentTo = new HashSet(); VoteStartTime = DateTime.MinValue; LastSleepCompleted = DateTime.MinValue; WarningTimeCounter = 0; MenusOpened = false; LastSleepCheck = DateTime.MinValue; DisplayInBed = 0; DisplayYes = 0; DisplayNo = 0; DisplayWaiting = 0; DisplayTotal = 0; _serverConfigLocked = null; Ratio = null; PlayersNeeded = null; WarningTime = null; VoteTimeout = null; SleepCooldown = null; PopupAutoChoice = null; } } }