Decompiled source of SaveLobbySettings v1.0.0

SaveLobbySettings.dll

Decompiled 2 weeks ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.RoR2.ConVar;
using RoR2;
using RoR2.ConVar;
using RoR2.UI.MainMenu;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SaveLobbySettings")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ea7a57ac5190360172084d86053441cddf8f29a2")]
[assembly: AssemblyProduct("SaveLobbySettings")]
[assembly: AssemblyTitle("SaveLobbySettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SaveLobbySettings
{
	[BepInPlugin("000.prodzpod.SaveLobbySettings", "SaveLobbySettings", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_SetBool <>9__12_0;

			public static hook_SetString <>9__12_1;

			public static Action <>9__12_2;

			internal void <Awake>b__12_0(orig_SetBool orig, BoolConVar self, bool v)
			{
				orig.Invoke(self, v);
				Reflect(self);
			}

			internal void <Awake>b__12_1(orig_SetString orig, BoolConVar self, string v)
			{
				orig.Invoke(self, v);
				Reflect(self);
			}

			internal void <Awake>b__12_2()
			{
				PreGameController.cvSvAllowRuleVoting.SetBool(cvSvAllowRuleVoting.Value);
				PreGameController.cvSvAllowMultiplayerPause.SetBool(cvSvAllowMultiplayerPause.Value);
				PreGameController.cvSvAllowRemoteOperation.SetBool(cvSvAllowRemoteOperation.Value);
				Initialized = true;
			}
		}

		public const string PluginGUID = "000.prodzpod.SaveLobbySettings";

		public const string PluginAuthor = "000.prodzpod";

		public const string PluginName = "SaveLobbySettings";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource Log;

		public static PluginInfo pluginInfo;

		public static ConfigFile Config;

		public static Harmony Harmony;

		public static ConfigEntry<bool> cvSvAllowRuleVoting;

		public static ConfigEntry<bool> cvSvAllowMultiplayerPause;

		public static ConfigEntry<bool> cvSvAllowRemoteOperation;

		public static bool Initialized;

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "000.prodzpod.SaveLobbySettings.cfg"), true);
			Harmony = new Harmony("000.prodzpod.SaveLobbySettings");
			cvSvAllowRuleVoting = Config.Bind<bool>("General", "sv_allow_rule_voting", true, "Whether or not players are allowed to vote on rules.");
			cvSvAllowMultiplayerPause = Config.Bind<bool>("General", "sv_allow_multiplayer_pause", true, "Whether or not players are allowed to pause the multiplayer game.");
			cvSvAllowRemoteOperation = Config.Bind<bool>("General", "sv_allow_remote_operation", true, "Whether or not players are allowed to enter Remote Operation in a multiplayer game.");
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_SetBool val = delegate(orig_SetBool orig, BoolConVar self, bool v)
				{
					orig.Invoke(self, v);
					Reflect(self);
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			BoolConVar.SetBool += (hook_SetBool)obj;
			object obj2 = <>c.<>9__12_1;
			if (obj2 == null)
			{
				hook_SetString val2 = delegate(orig_SetString orig, BoolConVar self, string v)
				{
					orig.Invoke(self, v);
					Reflect(self);
				};
				<>c.<>9__12_1 = val2;
				obj2 = (object)val2;
			}
			BoolConVar.SetString += (hook_SetString)obj2;
			MainMenuController.OnMainMenuInitialised += delegate
			{
				PreGameController.cvSvAllowRuleVoting.SetBool(cvSvAllowRuleVoting.Value);
				PreGameController.cvSvAllowMultiplayerPause.SetBool(cvSvAllowMultiplayerPause.Value);
				PreGameController.cvSvAllowRemoteOperation.SetBool(cvSvAllowRemoteOperation.Value);
				Initialized = true;
			};
		}

		public static void Reflect(BoolConVar conv)
		{
			if (Initialized)
			{
				if (((BaseConVar)conv).name == "sv_allow_rule_voting")
				{
					cvSvAllowRuleVoting.Value = conv.value;
				}
				else if (((BaseConVar)conv).name == "sv_allow_multiplayer_pause")
				{
					cvSvAllowMultiplayerPause.Value = conv.value;
				}
				else if (((BaseConVar)conv).name == "sv_allow_remote_operation")
				{
					cvSvAllowRemoteOperation.Value = conv.value;
				}
			}
		}
	}
}