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.1
LobbyVotesSaveRedux.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; 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 System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.ConVar; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.ConVar; using RoR2.UI; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; [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.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("LobbyVotesSaveRedux")] [assembly: AssemblyTitle("LobbyVotesSaveRedux")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 LobbyVotesSaveRedux { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.NicholasJohnson.LobbyVotesSaveRedux", "LobbyVotesSaveRedux", "1.0.1")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_Start <0>__PreGameRuleVoteController_Start; public static hook_OnLocalUserSignIn <1>__RestoreVotes; public static hook_OnVotesUpdated <2>__StoreVotes; public static hook_OnClick <3>__RuleChoiceController_OnClick; public static hook_UpdateFromVotes <4>__RuleChoiceController_UpdateFromVotes; public static hook_Start <5>__PreGameController_Start; public static hook_Update <6>__PreGameController_Update; public static hook_OnDisable <7>__PreGameController_OnDisable; public static hook_OnDestroy <8>__PreGameController_OnDestroy; public static hook_StartLaunch <9>__PreGameController_StartLaunch; public static hook_StartRun <10>__PreGameController_StartRun; public static hook_CCPregameStartRun <11>__PreGameController_CCPregameStartRun; public static hook_UpdateMultiplayerPause <12>__PreGameController_UpdateMultiplayerPause; public static hook_UpdateRemoteOperation <13>__PreGameController_UpdateRemoteOperation; public static hook_SetBool <14>__BoolConVar_SetBool; public static hook_SetString <15>__BoolConVar_SetString; public static hook_OnMultiplayerMenuEnabled <16>__LobbyManager_OnMultiplayerMenuEnabled; public static hook_SetLobbyTypeConVarString <17>__SteamworksLobbyManager_SetLobbyTypeConVarString; public static Action <18>__OnLobbyOwnershipGainedHandler; } public const string GUID = "com.NicholasJohnson.LobbyVotesSaveRedux"; public const string Name = "LobbyVotesSaveRedux"; public const string Version = "1.0.1"; private static bool _isRestoringHostToggles = false; private static bool _isTeardown = false; private static bool _needsInitialHostRestore = 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 PropertyInfo LocalUserProp = typeof(PreGameRuleVoteController).GetProperty("localUser", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly MethodInfo UpdateGameVotesMethod = typeof(PreGameRuleVoteController).GetMethod("UpdateGameVotes", BindingFlags.Static | 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); private static readonly FieldInfo RuleChoiceDefField = typeof(RuleChoiceController).GetField("choiceDef", 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<LobbyType> SavedLobbyPrivacyState { get; private set; } private static LocalUser GetLocalUser(PreGameRuleVoteController controller) { if ((Object)(object)controller == (Object)null) { return null; } object? obj = LocalUserProp?.GetValue(controller); return (LocalUser)((obj is LocalUser) ? obj : null); } private void Start() { //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_009d: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown Instance = this; SetupConfig(); try { RiskOfOptionsIntegration.Init(IsEnabled, SaveHostPause, SaveHostRemote, SaveLobbyPrivacy, SavedHostPauseState, SavedHostRemoteState, SavedLobbyPrivacyState); } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogWarning((object)("RiskOfOptions integration skipped: " + ex.Message)); } } ((ResourceAvailability)(ref RuleCatalog.availability)).CallWhenAvailable((Action)delegate { RestoreVotesForAllUsers(); }); object obj = <>O.<0>__PreGameRuleVoteController_Start; if (obj == null) { hook_Start val = PreGameRuleVoteController_Start; <>O.<0>__PreGameRuleVoteController_Start = val; obj = (object)val; } PreGameRuleVoteController.Start += (hook_Start)obj; object obj2 = <>O.<1>__RestoreVotes; if (obj2 == null) { hook_OnLocalUserSignIn val2 = RestoreVotes; <>O.<1>__RestoreVotes = val2; obj2 = (object)val2; } LocalUserBallotPersistenceManager.OnLocalUserSignIn += (hook_OnLocalUserSignIn)obj2; object obj3 = <>O.<2>__StoreVotes; if (obj3 == null) { hook_OnVotesUpdated val3 = StoreVotes; <>O.<2>__StoreVotes = val3; obj3 = (object)val3; } LocalUserBallotPersistenceManager.OnVotesUpdated += (hook_OnVotesUpdated)obj3; object obj4 = <>O.<3>__RuleChoiceController_OnClick; if (obj4 == null) { hook_OnClick val4 = RuleChoiceController_OnClick; <>O.<3>__RuleChoiceController_OnClick = val4; obj4 = (object)val4; } RuleChoiceController.OnClick += (hook_OnClick)obj4; object obj5 = <>O.<4>__RuleChoiceController_UpdateFromVotes; if (obj5 == null) { hook_UpdateFromVotes val5 = RuleChoiceController_UpdateFromVotes; <>O.<4>__RuleChoiceController_UpdateFromVotes = val5; obj5 = (object)val5; } RuleChoiceController.UpdateFromVotes += (hook_UpdateFromVotes)obj5; RestoreVotesForAllUsers(); object obj6 = <>O.<5>__PreGameController_Start; if (obj6 == null) { hook_Start val6 = PreGameController_Start; <>O.<5>__PreGameController_Start = val6; obj6 = (object)val6; } PreGameController.Start += (hook_Start)obj6; object obj7 = <>O.<6>__PreGameController_Update; if (obj7 == null) { hook_Update val7 = PreGameController_Update; <>O.<6>__PreGameController_Update = val7; obj7 = (object)val7; } PreGameController.Update += (hook_Update)obj7; object obj8 = <>O.<7>__PreGameController_OnDisable; if (obj8 == null) { hook_OnDisable val8 = PreGameController_OnDisable; <>O.<7>__PreGameController_OnDisable = val8; obj8 = (object)val8; } PreGameController.OnDisable += (hook_OnDisable)obj8; object obj9 = <>O.<8>__PreGameController_OnDestroy; if (obj9 == null) { hook_OnDestroy val9 = PreGameController_OnDestroy; <>O.<8>__PreGameController_OnDestroy = val9; obj9 = (object)val9; } PreGameController.OnDestroy += (hook_OnDestroy)obj9; object obj10 = <>O.<9>__PreGameController_StartLaunch; if (obj10 == null) { hook_StartLaunch val10 = PreGameController_StartLaunch; <>O.<9>__PreGameController_StartLaunch = val10; obj10 = (object)val10; } PreGameController.StartLaunch += (hook_StartLaunch)obj10; object obj11 = <>O.<10>__PreGameController_StartRun; if (obj11 == null) { hook_StartRun val11 = PreGameController_StartRun; <>O.<10>__PreGameController_StartRun = val11; obj11 = (object)val11; } PreGameController.StartRun += (hook_StartRun)obj11; object obj12 = <>O.<11>__PreGameController_CCPregameStartRun; if (obj12 == null) { hook_CCPregameStartRun val12 = PreGameController_CCPregameStartRun; <>O.<11>__PreGameController_CCPregameStartRun = val12; obj12 = (object)val12; } PreGameController.CCPregameStartRun += (hook_CCPregameStartRun)obj12; object obj13 = <>O.<12>__PreGameController_UpdateMultiplayerPause; if (obj13 == null) { hook_UpdateMultiplayerPause val13 = PreGameController_UpdateMultiplayerPause; <>O.<12>__PreGameController_UpdateMultiplayerPause = val13; obj13 = (object)val13; } PreGameController.UpdateMultiplayerPause += (hook_UpdateMultiplayerPause)obj13; object obj14 = <>O.<13>__PreGameController_UpdateRemoteOperation; if (obj14 == null) { hook_UpdateRemoteOperation val14 = PreGameController_UpdateRemoteOperation; <>O.<13>__PreGameController_UpdateRemoteOperation = val14; obj14 = (object)val14; } PreGameController.UpdateRemoteOperation += (hook_UpdateRemoteOperation)obj14; object obj15 = <>O.<14>__BoolConVar_SetBool; if (obj15 == null) { hook_SetBool val15 = BoolConVar_SetBool; <>O.<14>__BoolConVar_SetBool = val15; obj15 = (object)val15; } BoolConVar.SetBool += (hook_SetBool)obj15; object obj16 = <>O.<15>__BoolConVar_SetString; if (obj16 == null) { hook_SetString val16 = BoolConVar_SetString; <>O.<15>__BoolConVar_SetString = val16; obj16 = (object)val16; } BoolConVar.SetString += (hook_SetString)obj16; object obj17 = <>O.<16>__LobbyManager_OnMultiplayerMenuEnabled; if (obj17 == null) { hook_OnMultiplayerMenuEnabled val17 = LobbyManager_OnMultiplayerMenuEnabled; <>O.<16>__LobbyManager_OnMultiplayerMenuEnabled = val17; obj17 = (object)val17; } LobbyManager.OnMultiplayerMenuEnabled += (hook_OnMultiplayerMenuEnabled)obj17; object obj18 = <>O.<17>__SteamworksLobbyManager_SetLobbyTypeConVarString; if (obj18 == null) { hook_SetLobbyTypeConVarString val18 = SteamworksLobbyManager_SetLobbyTypeConVarString; <>O.<17>__SteamworksLobbyManager_SetLobbyTypeConVarString = val18; obj18 = (object)val18; } SteamworksLobbyManager.SetLobbyTypeConVarString += (hook_SetLobbyTypeConVarString)obj18; 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 //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01f6: 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_0201: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown Instance = null; object obj = <>O.<0>__PreGameRuleVoteController_Start; if (obj == null) { hook_Start val = PreGameRuleVoteController_Start; <>O.<0>__PreGameRuleVoteController_Start = val; obj = (object)val; } PreGameRuleVoteController.Start -= (hook_Start)obj; object obj2 = <>O.<1>__RestoreVotes; if (obj2 == null) { hook_OnLocalUserSignIn val2 = RestoreVotes; <>O.<1>__RestoreVotes = val2; obj2 = (object)val2; } LocalUserBallotPersistenceManager.OnLocalUserSignIn -= (hook_OnLocalUserSignIn)obj2; object obj3 = <>O.<2>__StoreVotes; if (obj3 == null) { hook_OnVotesUpdated val3 = StoreVotes; <>O.<2>__StoreVotes = val3; obj3 = (object)val3; } LocalUserBallotPersistenceManager.OnVotesUpdated -= (hook_OnVotesUpdated)obj3; object obj4 = <>O.<3>__RuleChoiceController_OnClick; if (obj4 == null) { hook_OnClick val4 = RuleChoiceController_OnClick; <>O.<3>__RuleChoiceController_OnClick = val4; obj4 = (object)val4; } RuleChoiceController.OnClick -= (hook_OnClick)obj4; object obj5 = <>O.<4>__RuleChoiceController_UpdateFromVotes; if (obj5 == null) { hook_UpdateFromVotes val5 = RuleChoiceController_UpdateFromVotes; <>O.<4>__RuleChoiceController_UpdateFromVotes = val5; obj5 = (object)val5; } RuleChoiceController.UpdateFromVotes -= (hook_UpdateFromVotes)obj5; object obj6 = <>O.<5>__PreGameController_Start; if (obj6 == null) { hook_Start val6 = PreGameController_Start; <>O.<5>__PreGameController_Start = val6; obj6 = (object)val6; } PreGameController.Start -= (hook_Start)obj6; object obj7 = <>O.<6>__PreGameController_Update; if (obj7 == null) { hook_Update val7 = PreGameController_Update; <>O.<6>__PreGameController_Update = val7; obj7 = (object)val7; } PreGameController.Update -= (hook_Update)obj7; object obj8 = <>O.<7>__PreGameController_OnDisable; if (obj8 == null) { hook_OnDisable val8 = PreGameController_OnDisable; <>O.<7>__PreGameController_OnDisable = val8; obj8 = (object)val8; } PreGameController.OnDisable -= (hook_OnDisable)obj8; object obj9 = <>O.<8>__PreGameController_OnDestroy; if (obj9 == null) { hook_OnDestroy val9 = PreGameController_OnDestroy; <>O.<8>__PreGameController_OnDestroy = val9; obj9 = (object)val9; } PreGameController.OnDestroy -= (hook_OnDestroy)obj9; object obj10 = <>O.<9>__PreGameController_StartLaunch; if (obj10 == null) { hook_StartLaunch val10 = PreGameController_StartLaunch; <>O.<9>__PreGameController_StartLaunch = val10; obj10 = (object)val10; } PreGameController.StartLaunch -= (hook_StartLaunch)obj10; object obj11 = <>O.<10>__PreGameController_StartRun; if (obj11 == null) { hook_StartRun val11 = PreGameController_StartRun; <>O.<10>__PreGameController_StartRun = val11; obj11 = (object)val11; } PreGameController.StartRun -= (hook_StartRun)obj11; object obj12 = <>O.<11>__PreGameController_CCPregameStartRun; if (obj12 == null) { hook_CCPregameStartRun val12 = PreGameController_CCPregameStartRun; <>O.<11>__PreGameController_CCPregameStartRun = val12; obj12 = (object)val12; } PreGameController.CCPregameStartRun -= (hook_CCPregameStartRun)obj12; object obj13 = <>O.<12>__PreGameController_UpdateMultiplayerPause; if (obj13 == null) { hook_UpdateMultiplayerPause val13 = PreGameController_UpdateMultiplayerPause; <>O.<12>__PreGameController_UpdateMultiplayerPause = val13; obj13 = (object)val13; } PreGameController.UpdateMultiplayerPause -= (hook_UpdateMultiplayerPause)obj13; object obj14 = <>O.<13>__PreGameController_UpdateRemoteOperation; if (obj14 == null) { hook_UpdateRemoteOperation val14 = PreGameController_UpdateRemoteOperation; <>O.<13>__PreGameController_UpdateRemoteOperation = val14; obj14 = (object)val14; } PreGameController.UpdateRemoteOperation -= (hook_UpdateRemoteOperation)obj14; object obj15 = <>O.<14>__BoolConVar_SetBool; if (obj15 == null) { hook_SetBool val15 = BoolConVar_SetBool; <>O.<14>__BoolConVar_SetBool = val15; obj15 = (object)val15; } BoolConVar.SetBool -= (hook_SetBool)obj15; object obj16 = <>O.<15>__BoolConVar_SetString; if (obj16 == null) { hook_SetString val16 = BoolConVar_SetString; <>O.<15>__BoolConVar_SetString = val16; obj16 = (object)val16; } BoolConVar.SetString -= (hook_SetString)obj16; object obj17 = <>O.<16>__LobbyManager_OnMultiplayerMenuEnabled; if (obj17 == null) { hook_OnMultiplayerMenuEnabled val17 = LobbyManager_OnMultiplayerMenuEnabled; <>O.<16>__LobbyManager_OnMultiplayerMenuEnabled = val17; obj17 = (object)val17; } LobbyManager.OnMultiplayerMenuEnabled -= (hook_OnMultiplayerMenuEnabled)obj17; object obj18 = <>O.<17>__SteamworksLobbyManager_SetLobbyTypeConVarString; if (obj18 == null) { hook_SetLobbyTypeConVarString val18 = SteamworksLobbyManager_SetLobbyTypeConVarString; <>O.<17>__SteamworksLobbyManager_SetLobbyTypeConVarString = val18; obj18 = (object)val18; } SteamworksLobbyManager.SetLobbyTypeConVarString -= (hook_SetLobbyTypeConVarString)obj18; 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<LobbyType>("Saved State", "SavedLobbyPrivacyState", (LobbyType)1, "Stored preference for Lobby Privacy (Public, FriendsOnly, Private)"); SavedHostPauseState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; SavedHostRemoteState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; SavedLobbyPrivacyState.SettingChanged += delegate { RestoreHostTogglesAndPrivacyInternal(); }; } private static void SaveNamedVotes(string path, Dictionary<string, string> votes) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("{"); int num = 0; foreach (KeyValuePair<string, string> vote in votes) { num++; stringBuilder.Append(" \"" + vote.Key + "\": \"" + vote.Value + "\""); if (num < votes.Count) { stringBuilder.Append(","); } stringBuilder.AppendLine(); } stringBuilder.AppendLine("}"); File.WriteAllText(path, stringBuilder.ToString()); } private static Dictionary<string, string> LoadNamedVotes(string path) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); if (!File.Exists(path)) { return dictionary; } string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().TrimEnd(','); if (text.StartsWith("{") || text.StartsWith("}") || string.IsNullOrEmpty(text)) { continue; } int num = text.IndexOf(':'); if (num > 0) { string text2 = text.Substring(0, num).Trim().Trim('"'); string value = text.Substring(num + 1).Trim().Trim('"'); if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(value)) { dictionary[text2] = value; } } } return dictionary; } private static void PreGameRuleVoteController_Start(orig_Start orig, PreGameRuleVoteController self) { LocalUser localUser = GetLocalUser(self); try { if (localUser != null) { RestoreVotesForUser(localUser); } } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogError((object)ex); } } orig.Invoke(self); try { if (IsEnabled.Value && localUser != null && NetworkServer.active) { UpdateGameVotesMethod?.Invoke(null, null); } } catch (Exception ex2) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogError((object)ex2); } } } private static bool IsArtifactRule(RuleDef ruleDef) { if (ruleDef == null) { return false; } if (ruleDef.category != RuleCatalog.artifactRuleCategory) { return ruleDef.globalName.StartsWith("Artifacts."); } return true; } private static void RuleChoiceController_OnClick(orig_OnClick orig, RuleChoiceController self) { //IL_0058: 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) if (!RoR2Application.isInSinglePlayer) { orig.Invoke(self); } else { if (!self.canVote) { return; } object? obj = RuleChoiceDefField?.GetValue(self); RuleChoiceDef val = (RuleChoiceDef)((obj is RuleChoiceDef) ? obj : null); if (val?.ruleDef == null || !IsArtifactRule(val.ruleDef)) { orig.Invoke(self); return; } MPEventSystem val2 = (MPEventSystem)EventSystem.current; object obj2; if ((int)val2 == 0) { obj2 = null; } else { LocalUser localUser = val2.localUser; obj2 = ((localUser != null) ? localUser.currentNetworkUser : null); } NetworkUser val3 = (NetworkUser)obj2; if (!Object.op_Implicit((Object)(object)val3)) { return; } PreGameRuleVoteController val4 = PreGameRuleVoteController.FindForUser(val3); if (!Object.op_Implicit((Object)(object)val4)) { return; } RuleDef ruleDef = val.ruleDef; RuleChoiceDef val5 = ((ruleDef.choices.Count > 0) ? ruleDef.choices[0] : null); RuleChoiceDef val6 = ((ruleDef.choices.Count > 1) ? ruleDef.choices[1] : null); if (val5 != null && val4.IsChoiceVoted(val5)) { if (val6 != null) { self.SetChoice(val6); } val4.SetVote(ruleDef.globalIndex, -1); } else if (val5 != null) { self.SetChoice(val5); val4.SetVote(ruleDef.globalIndex, val5.localIndex); } } } private static void RuleChoiceController_UpdateFromVotes(orig_UpdateFromVotes orig, RuleChoiceController self) { orig.Invoke(self); if (RoR2Application.isInSinglePlayer && (Object)(object)self.disabledDisplayObject != (Object)null) { object? obj = RuleChoiceDefField?.GetValue(self); RuleChoiceDef val = (RuleChoiceDef)((obj is RuleChoiceDef) ? obj : null); if (val?.ruleDef != null && IsArtifactRule(val.ruleDef)) { self.disabledDisplayObject.SetActive(false); } } } private static void StoreVotes(orig_OnVotesUpdated orig) { orig.Invoke(); try { if (_isTeardown) { return; } 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; } int ruleCount = RuleCatalog.ruleCount; int num = Math.Min(array.Length, ruleCount); Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); byte[] array2 = new byte[num]; bool flag = false; for (int i = 0; i < num; i++) { object value = array.GetValue(i); if (value == null || !(InternalValueField != null)) { continue; } byte b = (byte)InternalValueField.GetValue(value); array2[i] = b; if (b == 0) { continue; } int num2 = b - 1; RuleDef ruleDef = RuleCatalog.GetRuleDef(i); if (ruleDef != null && num2 >= 0 && num2 < ruleDef.choices.Count) { RuleChoiceDef val2 = ruleDef.choices[num2]; if (val2 != null && (!RoR2Application.isInSinglePlayer || !IsArtifactRule(ruleDef) || val2.localIndex == 0)) { flag = true; dictionary2[ruleDef.globalName] = val2.globalName; } } } string path = Path.Combine(SavesDirectory, fileName); string path2 = Path.Combine(SavesDirectory, fileName + ".json"); if (!flag && (File.Exists(path) || File.Exists(path2))) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogDebug((object)("Skipping StoreVotes for " + fileName + " to prevent overwriting existing valid votes.")); } continue; } File.WriteAllBytes(path, array2); SaveNamedVotes(path2, dictionary2); ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogInfo((object)$"Saved {dictionary2.Count} vote choices for profile {fileName}"); } } } catch (Exception ex) { ManualLogSource instanceLogger3 = InstanceLogger; if (instanceLogger3 != null) { instanceLogger3.LogWarning((object)"Failed to save votes"); } ManualLogSource instanceLogger4 = InstanceLogger; if (instanceLogger4 != null) { instanceLogger4.LogError((object)ex); } } } private static void RestoreVotes(orig_OnLocalUserSignIn orig, LocalUser localUser) { orig.Invoke(localUser); RestoreVotesForUser(localUser); } private static void RestoreVotesForUser(LocalUser localUser) { try { if (!IsEnabled.Value || ((localUser != null) ? localUser.userProfile : null) == null) { return; } string fileName = localUser.userProfile.fileName; if (string.IsNullOrEmpty(fileName)) { return; } int ruleCount = RuleCatalog.ruleCount; if (ruleCount <= 0 || VoteType == null) { return; } string path = Path.Combine(SavesDirectory, fileName); string path2 = Path.Combine(SavesDirectory, fileName + ".json"); if (!File.Exists(path2) && !File.Exists(path)) { return; } Array array = Array.CreateInstance(VoteType, ruleCount); for (int i = 0; i < ruleCount; i++) { object obj = Activator.CreateInstance(VoteType); InternalValueField?.SetValue(obj, (byte)0); array.SetValue(obj, i); } int num = 0; if (File.Exists(path2)) { foreach (KeyValuePair<string, string> item in LoadNamedVotes(path2)) { RuleDef val = RuleCatalog.FindRuleDef(item.Key); if (val == null) { continue; } RuleChoiceDef val2 = RuleCatalog.FindChoiceDef(item.Value) ?? val.FindChoice(item.Value); if (val2 != null && val2.ruleDef == val) { int globalIndex = val.globalIndex; if (globalIndex >= 0 && globalIndex < ruleCount && (!RoR2Application.isInSinglePlayer || !IsArtifactRule(val) || val2.localIndex == 0)) { byte b = (byte)(val2.localIndex + 1); object value = array.GetValue(globalIndex); InternalValueField?.SetValue(value, b); array.SetValue(value, globalIndex); num++; } } } } else if (File.Exists(path)) { byte[] array2 = File.ReadAllBytes(path); int num2 = Math.Min(array2.Length, ruleCount); for (int j = 0; j < num2; j++) { byte b2 = array2[j]; if (b2 != 0) { RuleDef ruleDef = RuleCatalog.GetRuleDef(j); if (!RoR2Application.isInSinglePlayer || !IsArtifactRule(ruleDef) || b2 == 1) { object value2 = array.GetValue(j); InternalValueField?.SetValue(value2, b2); array.SetValue(value2, j); num++; } } } } if (VotesCacheField?.GetValue(null) is IDictionary dictionary) { dictionary[localUser] = array; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)$"Restored {num} votes for profile {fileName} (ballot size {ruleCount})"); } } } catch (Exception ex) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogWarning((object)"Failed to load votes for user"); } ManualLogSource instanceLogger3 = InstanceLogger; if (instanceLogger3 != null) { instanceLogger3.LogError((object)ex); } } } private static void RestoreVotesForAllUsers() { if (LocalUserManager.readOnlyLocalUsersList == null) { return; } foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (readOnlyLocalUsers != null) { RestoreVotesForUser(readOnlyLocalUsers); } } } private static void ApplyVotesToActiveControllers() { try { RestoreVotesForAllUsers(); IList list = typeof(PreGameRuleVoteController).GetField("instancesList", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) as IList; IDictionary dictionary = VotesCacheField?.GetValue(null) as IDictionary; bool flag = false; if (list != null && dictionary != null) { foreach (object item in list) { PreGameRuleVoteController val = (PreGameRuleVoteController)((item is PreGameRuleVoteController) ? item : null); if ((Object)(object)val == (Object)null) { continue; } LocalUser localUser = GetLocalUser(val); if (localUser == null || !dictionary.Contains(localUser)) { continue; } Array array = dictionary[localUser] as Array; Array array2 = typeof(PreGameRuleVoteController).GetField("votes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val) as Array; if (array != null && array2 != null && array.Length == array2.Length) { Array.Copy(array, array2, array.Length); flag = true; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)("Applied restored votes to active PreGameRuleVoteController for user " + localUser.userProfile?.name)); } } } } if (flag && NetworkServer.active) { UpdateGameVotesMethod?.Invoke(null, null); } } catch (Exception ex) { ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogWarning((object)"Failed to apply votes to active controllers"); } ManualLogSource instanceLogger3 = InstanceLogger; if (instanceLogger3 != null) { instanceLogger3.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; _needsInitialHostRestore = true; _isRestoringHostToggles = true; orig.Invoke(self); RestoreHostTogglesAndPrivacyInternal(self); } catch (Exception ex) { ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogError((object)ex); } } } private static void PreGameController_Update(orig_Update orig, PreGameController self) { if (_needsInitialHostRestore) { _needsInitialHostRestore = false; RestoreHostTogglesAndPrivacyInternal(self); } orig.Invoke(self); } private static void PreGameController_OnDisable(orig_OnDisable orig, PreGameController self) { _isTeardown = true; _needsInitialHostRestore = false; _isRestoringHostToggles = false; orig.Invoke(self); } private static void PreGameController_OnDestroy(orig_OnDestroy orig, PreGameController self) { _isTeardown = true; _needsInitialHostRestore = false; _isRestoringHostToggles = false; 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 BoolConVar_SetBool(orig_SetBool orig, BoolConVar self, bool newValue) { orig.Invoke(self, newValue); HandleBoolConVarChanged(self, newValue); } private static void BoolConVar_SetString(orig_SetString orig, BoolConVar self, string newValue) { orig.Invoke(self, newValue); HandleBoolConVarChanged(self, self.value); } private static void HandleBoolConVarChanged(BoolConVar self, bool newValue) { try { if (_isRestoringHostToggles || _isTeardown) { return; } if (self == PreGameController.cvSvAllowMultiplayerPause) { if (SaveHostPause.Value && SavedHostPauseState.Value != newValue) { SavedHostPauseState.Value = newValue; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)$"SavedHostPauseState updated via ConVar to: {newValue}"); } } } else if (self == PreGameController.cvSvAllowRemoteOperation && SaveHostRemote.Value && SavedHostRemoteState.Value != newValue) { SavedHostRemoteState.Value = newValue; ManualLogSource instanceLogger2 = InstanceLogger; if (instanceLogger2 != null) { instanceLogger2.LogInfo((object)$"SavedHostRemoteState updated via ConVar to: {newValue}"); } } } catch (Exception ex) { ManualLogSource instanceLogger3 = InstanceLogger; if (instanceLogger3 != null) { instanceLogger3.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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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 != result) { SavedLobbyPrivacyState.Value = result; ManualLogSource instanceLogger = InstanceLogger; if (instanceLogger != null) { instanceLogger.LogInfo((object)$"SavedLobbyPrivacyState updated to: {result}"); } } } 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) try { _isTeardown = false; _isRestoringHostToggles = true; if (!IsEnabled.Value) { return; } ApplyVotesToActiveControllers(); 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) { RuleChoiceDef val2 = RuleCatalog.FindChoiceDef(SavedHostRemoteState.Value ? "Misc.RemoteOp.On" : "Misc.RemoteOp.Off"); if (val2 != null) { val.ApplyChoice(val2.globalIndex); } if (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) { LobbyType value = SavedLobbyPrivacyState.Value; PlatformSystems.lobbyManager.preferredLobbyType = value; if (PlatformSystems.lobbyManager.isInLobby && PlatformSystems.lobbyManager.ownsLobby) { PlatformSystems.lobbyManager.currentLobbyType = value; } ManualLogSource instanceLogger5 = InstanceLogger; if (instanceLogger5 != null) { instanceLogger5.LogInfo((object)$"Restored preferredLobbyType to: {value}"); } } } 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 { if (!_needsInitialHostRestore) { _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<LobbyType> savedLobbyPrivacyState) { if (!IsLoaded) { return; } try { InitInternal(isEnabled, saveHostPause, saveHostRemote, saveLobbyPrivacy, savedHostPauseState, savedHostRemoteState, savedLobbyPrivacyState); } catch (Exception ex) { ManualLogSource instanceLogger = Plugin.InstanceLogger; if (instanceLogger != null) { instanceLogger.LogWarning((object)("RiskOfOptions integration failed to initialize: " + ex.Message)); } } } [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<LobbyType> 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)); } } }