Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LobbyVotesSaveRedux v1.0.0
LobbyVotesSaveRedux.dll
Decompiled 8 hours agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; 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("LobbyVotesSaveRedux")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LobbyVotesSaveRedux")] [assembly: AssemblyTitle("LobbyVotesSaveRedux")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LobbyVotesSaveRedux { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.NicholasJohnson.LobbyVotesSaveRedux", "LobbyVotesSaveRedux", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_OnLocalUserSignIn <0>__RestoreVotes; public static hook_OnVotesUpdated <1>__StoreVotes; public static hook_Start <2>__PreGameController_Start; public static hook_OnDisable <3>__PreGameController_OnDisable; public static hook_OnDestroy <4>__PreGameController_OnDestroy; public static hook_StartLaunch <5>__PreGameController_StartLaunch; public static hook_StartRun <6>__PreGameController_StartRun; public static hook_CCPregameStartRun <7>__PreGameController_CCPregameStartRun; public static hook_UpdateMultiplayerPause <8>__PreGameController_UpdateMultiplayerPause; public static hook_UpdateRemoteOperation <9>__PreGameController_UpdateRemoteOperation; public static hook_OnMultiplayerMenuEnabled <10>__LobbyManager_OnMultiplayerMenuEnabled; public static hook_SetLobbyTypeConVarString <11>__SteamworksLobbyManager_SetLobbyTypeConVarString; public static Action <12>__OnLobbyOwnershipGainedHandler; } public const string GUID = "com.NicholasJohnson.LobbyVotesSaveRedux"; public const string Name = "LobbyVotesSaveRedux"; public const string Version = "1.0.0"; private static bool _isRestoringHostToggles = false; private static bool _isTeardown = false; private static readonly Type PersistenceManagerType = typeof(PreGameRuleVoteController).GetNestedType("LocalUserBallotPersistenceManager", BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo VotesCacheField = PersistenceManagerType?.GetField("votesCache", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); private static readonly Type VoteType = typeof(PreGameRuleVoteController).GetNestedType("Vote", BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo InternalValueField = VoteType?.GetField("internalValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly MethodInfo UpdateMultiplayerPauseMethod = typeof(PreGameController).GetMethod("UpdateMultiplayerPause", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly MethodInfo UpdateRemoteOperationMethod = typeof(PreGameController).GetMethod("UpdateRemoteOperation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static Plugin Instance { get; private set; } internal static ManualLogSource InstanceLogger { get { Plugin instance = Instance; if (instance == null) { return null; } return ((BaseUnityPlugin)instance).Logger; } } private static string SavesDirectory => Path.Combine(Application.persistentDataPath, "LobbyVotesSave"); internal static ConfigEntry<bool> IsEnabled { get; private set; } internal static ConfigEntry<bool> SaveHostPause { get; private set; } internal static ConfigEntry<bool> SaveHostRemote { get; private set; } internal static ConfigEntry<bool> SaveLobbyPrivacy { get; private set; } internal static ConfigEntry<bool> SavedHostPauseState { get; private set; } internal static ConfigEntry<bool> SavedHostRemoteState { get; private set; } internal static ConfigEntry<string> SavedLobbyPrivacyState { get; private set; } private void Start() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00c4: 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_00cf: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0104: 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) //IL_010f: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown Instance = this; SetupConfig(); RiskOfOptionsIntegration.Init(IsEnabled, SaveHostPause, SaveHostRemote, SaveLobbyPrivacy, SavedHostPauseState, SavedHostRemoteState, SavedLobbyPrivacyState); object obj = <>O.<0>__RestoreVotes; if (obj == null) { hook_OnLocalUserSignIn val = RestoreVotes; <>O.<0>__RestoreVotes = val; obj = (object)val; } LocalUserBallotPersistenceManager.OnLocalUserSignIn += (hook_OnLocalUserSignIn)obj; object obj2 = <>O.<1>__StoreVotes; if (obj2 == null) { hook_OnVotesUpdated val2 = StoreVotes; <>O.<1>__StoreVotes = val2; obj2 = (object)val2; } LocalUserBallotPersistenceManager.OnVotesUpdated += (hook_OnVotesUpdated)obj2; object obj3 = <>O.<2>__PreGameController_Start; if (obj3 == null) { hook_Start val3 = PreGameController_Start; <>O.<2>__PreGameController_Start = val3; obj3 = (object)val3; } PreGameController.Start += (hook_Start)obj3; object obj4 = <>O.<3>__PreGameController_OnDisable; if (obj4 == null) { hook_OnDisable val4 = PreGameController_OnDisable; <>O.<3>__PreGameController_OnDisable = val4; obj4 = (object)val4; } PreGameController.OnDisable += (hook_OnDisable)obj4; object obj5 = <>O.<4>__PreGameController_OnDestroy; if (obj5 == null) { hook_OnDestroy val5 = PreGameController_OnDestroy; <>O.<4>__PreGameController_OnDestroy = val5; obj5 = (object)val5; } PreGameController.OnDestroy += (hook_OnDestroy)obj5; object obj6 = <>O.<5>__PreGameController_StartLaunch; if (obj6 == null) { hook_StartLaunch val6 = PreGameController_StartLaunch; <>O.<5>__PreGameController_StartLaunch = val6; obj6 = (object)val6; } PreGameController.StartLaunch += (hook_StartLaunch)obj6; object obj7 = <>O.<6>__PreGameController_StartRun; if (obj7 == null) { hook_StartRun val7 = PreGameController_StartRun; <>O.<6>__PreGameController_StartRun = val7; obj7 = (object)val7; } PreGameController.StartRun += (hook_StartRun)obj7; object obj8 = <>O.<7>__PreGameController_CCPregameStartRun; if (obj8 == null) { hook_CCPregameStartRun val8 = PreGameController_CCPregameStartRun; <>O.<7>__PreGameController_CCPregameStartRun = val8; obj8 = (object)val8; } PreGameController.CCPregameStartRun += (hook_CCPregameStartRun)obj8; object obj9 = <>O.<8>__PreGameController_UpdateMultiplayerPause; if (obj9 == null) { hook_UpdateMultiplayerPause val9 = PreGameController_UpdateMultiplayerPause; <>O.<8>__PreGameController_UpdateMultiplayerPause = val9; obj9 = (object)val9; } PreGameController.UpdateMultiplayerPause += (hook_UpdateMultiplayerPause)obj9; object obj10 = <>O.<9>__PreGameController_UpdateRemoteOperation; if (obj10 == null) { hook_UpdateRemoteOperation val10 = PreGameController_UpdateRemoteOperation; <>O.<9>__PreGameController_UpdateRemoteOperation = val10; obj10 = (object)val10; } PreGameController.UpdateRemoteOperation += (hook_UpdateRemoteOperation)obj10; object obj11 = <>O.<10>__LobbyManager_OnMultiplayerMenuEnabled; if (obj11 == null) { hook_OnMultiplayerMenuEnabled val11 = LobbyManager_OnMultiplayerMenuEnabled; <>O.<10>__LobbyManager_OnMultiplayerMenuEnabled = val11; obj11 = (object)val11; } LobbyManager.OnMultiplayerMenuEnabled += (hook_OnMultiplayerMenuEnabled)obj11; object obj12 = <>O.<11>__SteamworksLobbyManager_SetLobbyTypeConVarString; if (obj12 == null) { hook_SetLobbyTypeConVarString val12 = SteamworksLobbyManager_SetLobbyTypeConVarString; <>O.<11>__SteamworksLobbyManager_SetLobbyTypeConVarString = val12; obj12 = (object)val12; } SteamworksLobbyManager.SetLobbyTypeConVarString += (hook_SetLobbyTypeConVarString)obj12; if (PlatformSystems.lobbyManager != null) { LobbyManager lobbyManager = PlatformSystems.lobbyManager; lobbyManager.onLobbyOwnershipGained = (Action)Delegate.Combine(lobbyManager.onLobbyOwnershipGained, new Action(OnLobbyOwnershipGainedHandler)); } } private void OnDestroy() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0036: 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_0041: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //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_0081: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b6: 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_00c1: Expected O, but got Unknown //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_00e1: Expected O, but got Unknown //IL_00f6: 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_0101: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown Instance = null; object obj = <>O.<0>__RestoreVotes; if (obj == null) { hook_OnLocalUserSignIn val = RestoreVotes; <>O.<0>__RestoreVotes = val; obj = (object)val; } LocalUserBallotPersistenceManager.OnLocalUserSignIn -= (hook_OnLocalUserSignIn)obj; object obj2 = <>O.<1>__StoreVotes; if (obj2 == null) { hook_OnVotesUpdated val2 = StoreVotes; <>O.<1>__StoreVotes = val2; obj2 = (object)val2; } LocalUserBallotPersistenceManager.OnVotesUpdated -= (hook_OnVotesUpdated)obj2; object obj3 = <>O.<2>__PreGameController_Start; if (obj3 == null) { hook_Start val3 = PreGameController_Start; <>O.<2>__PreGameController_Start = val3; obj3 = (object)val3; } PreGameController.Start -= (hook_Start)obj3; object obj4 = <>O.<3>__PreGameController_OnDisable; if (obj4 == null) { hook_OnDisable val4 = PreGameController_OnDisable; <>O.<3>__PreGameController_OnDisable = val4; obj4 = (object)val4; } PreGameController.OnDisable -= (hook_OnDisable)obj4; object obj5 = <>O.<4>__PreGameController_OnDestroy; if (obj5 == null) { hook_OnDestroy val5 = PreGameController_OnDestroy; <>O.<4>__PreGameController_OnDestroy = val5; obj5 = (object)val5; } PreGameController.OnDestroy -= (hook_OnDestroy)obj5; object obj6 = <>O.<5>__PreGameController_StartLaunch; if (obj6 == null) { hook_StartLaunch val6 = PreGameController_StartLaunch; <>O.<5>__PreGameController_StartLaunch = val6; obj6 = (object)val6; } PreGameController.StartLaunch -= (hook_StartLaunch)obj6; object obj7 = <>O.<6>__PreGameController_StartRun; if (obj7 == null) { hook_StartRun val7 = PreGameController_StartRun; <>O.<6>__PreGameController_StartRun = val7; obj7 = (object)val7; } PreGameController.StartRun -= (hook_StartRun)obj7; object obj8 = <>O.<7>__PreGameController_CCPregameStartRun; if (obj8 == null) { hook_CCPregameStartRun val8 = PreGameController_CCPregameStartRun; <>O.<7>__PreGameController_CCPregameStartRun = val8; obj8 = (object)val8; } PreGameController.CCPregameStartRun -= (hook_CCPregameStartRun)obj8; object obj9 = <>O.<8>__PreGameController_UpdateMultiplayerPause; if (obj9 == null) { hook_UpdateMultiplayerPause val9 = PreGameController_UpdateMultiplayerPause; <>O.<8>__PreGameController_UpdateMultiplayerPause = val9; obj9 = (object)val9; } PreGameController.UpdateMultiplayerPause -= (hook_UpdateMultiplayerPause)obj9; object obj10 = <>O.<9>__PreGameController_UpdateRemoteOperation; if (obj10 == null) { hook_UpdateRemoteOperation val10 = PreGameController_UpdateRemoteOperation; <>O.<9>__PreGameController_UpdateRemoteOperation = val10; obj10 = (object)val10; } PreGameController.UpdateRemoteOperation -= (hook_UpdateRemoteOperation)obj10; object obj11 = <>O.<10>__LobbyManager_OnMultiplayerMenuEnabled; if (obj11 == null) { hook_OnMultiplayerMenuEnabled val11 = LobbyManager_OnMultiplayerMenuEnabled; <>O.<10>__LobbyManager_OnMultiplayerMenuEnabled = val11; obj11 = (object)val11; } LobbyManager.OnMultiplayerMenuEnabled -= (hook_OnMultiplayerMenuEnabled)obj11; object obj12 = <>O.<11>__SteamworksLobbyManager_SetLobbyTypeConVarString; if (obj12 == null) { hook_SetLobbyTypeConVarString val12 = SteamworksLobbyManager_SetLobbyTypeConVarString; <>O.<11>__SteamworksLobbyManager_SetLobbyTypeConVarString = val12; obj12 = (object)val12; } SteamworksLobbyManager.SetLobbyTypeConVarString -= (hook_SetLobbyTypeConVarString)obj12; if (PlatformSystems.lobbyManager != null) { LobbyManager lobbyManager = PlatformSystems.lobbyManager; lobbyManager.onLobbyOwnershipGained = (Action)Delegate.Remove(lobbyManager.onLobbyOwnershipGained, new Action(OnLobbyOwnershipGainedHandler)); } } private void SetupConfig() { IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "Enabled", true, "Load stored values when entering lobby"); SaveHostPause = ((BaseUnityPlugin)this).Config.Bind<bool>("Host Toggles", "SaveHostPause", true, "Auto-save and restore the 'Turn On Pause' multiplayer host toggle"); SaveHostRemote = ((BaseUnityPlugin)this).Config.Bind<bool>("Host Toggles", "SaveHostRemote", true, "Auto-save and restore the 'Remote Operation' multiplayer host toggle"); SaveLobbyPrivacy = ((BaseUnityPlugin)this).Config.Bind<bool>("Host Toggles", "SaveLobbyPrivacy", true, "Auto-save and restore the lobby privacy toggle (Public, Friends Only, Private)"); SavedHostPauseState = ((BaseUnityPlugin)this).Config.Bind<bool>("Saved State", "SavedHostPauseState", true, "Stored preference for Turn On Pause"); SavedHostRemoteState = ((BaseUnityPlugin)this).Config.Bind<bool>("Saved State", "SavedHostRemoteState", true, "Stored preference for Remote Operation"); SavedLobbyPrivacyState = ((BaseUnityPlugin)this).Config.Bind<string>("Saved State", "SavedLobbyPrivacyState", "FriendsOnly", "Stored preference for Lobby Privacy (Public, FriendsOnly, Private)"); SavedHostPauseState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; SavedHostRemoteState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; SavedLobbyPrivacyState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; } private static void StoreVotes(orig_OnVotesUpdated orig) { orig.Invoke(); try { Directory.CreateDirectory(SavesDirectory); if (!(VotesCacheField?.GetValue(null) is IDictionary dictionary)) { return; } foreach (DictionaryEntry item in dictionary) { object key = item.Key; LocalUser val = (LocalUser)((key is LocalUser) ? key : null); Array array = item.Value as Array; if (((val != null) ? val.userProfile : null) == null || array == null) { continue; } string fileName = val.userProfile.fileName; if (string.IsNullOrEmpty(fileName)) { continue; } byte[] array2 = new byte[array.Length]; for (int i = 0; i < array.Length; i++) { object value = array.GetValue(i); if (value != null && InternalValueField != null) { array2[i] = (byte)InternalValueField.GetValue(value); } } File.WriteAllBytes(Path.Combine(SavesDirectory, fileName), array2); } } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogWarning((object)"Failed to save votes"); } ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogError((object)ex); } } } private static void RestoreVotes(orig_OnLocalUserSignIn orig, LocalUser localUser) { orig.Invoke(localUser); try { if (!IsEnabled.Value || ((localUser != null) ? localUser.userProfile : null) == null) { return; } string fileName = localUser.userProfile.fileName; if (string.IsNullOrEmpty(fileName)) { return; } string path = Path.Combine(SavesDirectory, fileName); if (File.Exists(path) && VoteType != null) { byte[] array = File.ReadAllBytes(path); Array array2 = Array.CreateInstance(VoteType, array.Length); for (int i = 0; i < array.Length; i++) { object obj = Activator.CreateInstance(VoteType); InternalValueField?.SetValue(obj, array[i]); array2.SetValue(obj, i); } if (VotesCacheField?.GetValue(null) is IDictionary dictionary) { dictionary[localUser] = array2; } } } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogWarning((object)"Failed to load votes"); } ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogError((object)ex); } } } private static void OnLobbyOwnershipGainedHandler() { RestoreHostTogglesAndPrivacyInternal(); } private static void LobbyManager_OnMultiplayerMenuEnabled(orig_OnMultiplayerMenuEnabled orig, LobbyManager self, Action<PlatformID> onLobbyLeave) { try { _isTeardown = false; _isRestoringHostToggles = true; orig.Invoke(self, onLobbyLeave); RestoreHostTogglesAndPrivacyInternal(); } finally { _isRestoringHostToggles = false; } } private static void PreGameController_Start(orig_Start orig, PreGameController self) { try { _isTeardown = false; _isRestoringHostToggles = true; orig.Invoke(self); RestoreHostTogglesAndPrivacyInternal(self); } finally { _isRestoringHostToggles = false; } } private static void PreGameController_OnDisable(orig_OnDisable orig, PreGameController self) { _isTeardown = true; orig.Invoke(self); } private static void PreGameController_OnDestroy(orig_OnDestroy orig, PreGameController self) { _isTeardown = true; orig.Invoke(self); } private static void PreGameController_StartLaunch(orig_StartLaunch orig, PreGameController self) { _isTeardown = true; orig.Invoke(self); } private static void PreGameController_StartRun(orig_StartRun orig, PreGameController self) { _isTeardown = true; orig.Invoke(self); } private static void PreGameController_CCPregameStartRun(orig_CCPregameStartRun orig, ConCommandArgs args) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _isTeardown = true; orig.Invoke(args); } private static void PreGameController_UpdateMultiplayerPause(orig_UpdateMultiplayerPause orig, PreGameController self, bool newBool) { orig.Invoke(self, newBool); try { if (!_isRestoringHostToggles && !_isTeardown && SaveHostPause.Value && SavedHostPauseState.Value != newBool) { SavedHostPauseState.Value = newBool; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)$"SavedHostPauseState updated to: {newBool}"); } } } catch (Exception ex) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogError((object)ex); } } } private static void PreGameController_UpdateRemoteOperation(orig_UpdateRemoteOperation orig, PreGameController self, bool newBool) { orig.Invoke(self, newBool); try { if (!_isRestoringHostToggles && !_isTeardown && SaveHostRemote.Value && SavedHostRemoteState.Value != newBool) { SavedHostRemoteState.Value = newBool; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)$"SavedHostRemoteState updated to: {newBool}"); } } } catch (Exception ex) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogError((object)ex); } } } private static void SteamworksLobbyManager_SetLobbyTypeConVarString(orig_SetLobbyTypeConVarString orig, SteamworksLobbyManager self, string newValue) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse<LobbyType>(newValue, ignoreCase: true, out LobbyType result)) { ((LobbyManager)self).preferredLobbyType = result; if (!_isRestoringHostToggles && !_isTeardown && SaveLobbyPrivacy.Value && SavedLobbyPrivacyState.Value != newValue) { SavedLobbyPrivacyState.Value = newValue; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)("SavedLobbyPrivacyState updated to: " + newValue)); } } } if (!((LobbyManager)self).isInLobby || !((LobbyManager)self).ownsLobby) { return; } try { orig.Invoke(self, newValue); } catch (Exception ex) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogDebug((object)("SetLobbyTypeConVarString deferred: " + ex.Message)); } } } private static void RestoreHostTogglesAndPrivacyInternal(PreGameController targetController = null) { //IL_01cf: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) try { _isTeardown = false; _isRestoringHostToggles = true; if (!IsEnabled.Value) { return; } PreGameController val = targetController ?? PreGameController.instance; if (SaveHostPause.Value && PreGameController.cvSvAllowMultiplayerPause != null) { PreGameController.cvSvAllowMultiplayerPause.SetBool(SavedHostPauseState.Value); if ((Object)(object)val != (Object)null && UpdateMultiplayerPauseMethod != null) { try { UpdateMultiplayerPauseMethod.Invoke(val, new object[1] { SavedHostPauseState.Value }); } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogDebug((object)("UpdateMultiplayerPause deferred: " + ex.Message)); } } } ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogInfo((object)$"Restored cvSvAllowMultiplayerPause to: {SavedHostPauseState.Value}"); } } if (SaveHostRemote.Value && PreGameController.cvSvAllowRemoteOperation != null) { PreGameController.cvSvAllowRemoteOperation.SetBool(SavedHostRemoteState.Value); if ((Object)(object)val != (Object)null && UpdateRemoteOperationMethod != null) { try { UpdateRemoteOperationMethod.Invoke(val, new object[1] { SavedHostRemoteState.Value }); } catch (Exception ex2) { ManualLogSource instanceLogger3 = InstanceLogger; if (instanceLogger3 != null) { instanceLogger3.LogDebug((object)("UpdateRemoteOperation deferred: " + ex2.Message)); } } } ManualLogSource instanceLogger4 = InstanceLogger; if (instanceLogger4 != null) { instanceLogger4.LogInfo((object)$"Restored cvSvAllowRemoteOperation to: {SavedHostRemoteState.Value}"); } } if (SaveLobbyPrivacy.Value && PlatformSystems.lobbyManager != null && !string.IsNullOrEmpty(SavedLobbyPrivacyState.Value) && Enum.TryParse<LobbyType>(SavedLobbyPrivacyState.Value, ignoreCase: true, out LobbyType result)) { PlatformSystems.lobbyManager.preferredLobbyType = result; if (PlatformSystems.lobbyManager.isInLobby && PlatformSystems.lobbyManager.ownsLobby) { PlatformSystems.lobbyManager.currentLobbyType = result; } ManualLogSource instanceLogger5 = InstanceLogger; if (instanceLogger5 != null) { instanceLogger5.LogInfo((object)$"Restored preferredLobbyType to: {result}"); } } } catch (Exception ex3) { ManualLogSource instanceLogger6 = InstanceLogger; if (instanceLogger6 != null) { instanceLogger6.LogWarning((object)"Failed to restore host toggles or privacy"); } ManualLogSource instanceLogger7 = InstanceLogger; if (instanceLogger7 != null) { instanceLogger7.LogError((object)ex3); } } finally { _isRestoringHostToggles = false; } } } public static class RiskOfOptionsIntegration { public const string GUID = "com.rune580.riskofoptions"; public static bool IsLoaded => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); public static void Init(ConfigEntry<bool> isEnabled, ConfigEntry<bool> saveHostPause, ConfigEntry<bool> saveHostRemote, ConfigEntry<bool> saveLobbyPrivacy, ConfigEntry<bool> savedHostPauseState, ConfigEntry<bool> savedHostRemoteState, ConfigEntry<string> savedLobbyPrivacyState) { if (IsLoaded) { InitInternal(isEnabled, saveHostPause, saveHostRemote, saveLobbyPrivacy, savedHostPauseState, savedHostRemoteState, savedLobbyPrivacyState); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void InitInternal(ConfigEntry<bool> isEnabled, ConfigEntry<bool> saveHostPause, ConfigEntry<bool> saveHostRemote, ConfigEntry<bool> saveLobbyPrivacy, ConfigEntry<bool> savedHostPauseState, ConfigEntry<bool> savedHostRemoteState, ConfigEntry<string> savedLobbyPrivacyState) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown ModSettingsManager.SetModDescription("Automatically saves and restores difficulty, artifacts, multiplayer host toggles, and lobby privacy across game sessions."); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(isEnabled)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(saveHostPause)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(savedHostPauseState)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(saveHostRemote)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(savedHostRemoteState)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(saveLobbyPrivacy)); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)savedLobbyPrivacyState)); } } }