Decompiled source of CustomRuleset v0.1.0

plugins/CustomRuleset/CustomRuleset.dll

Decompiled a month ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LLBML.Networking;
using LLBML.Settings;
using LLBML.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomRuleset (fr.glomzubuk.plugins.llb.customruleset)")]
[assembly: AssemblyProduct("CustomRuleset")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("B0C67E01-428C-4D4C-BE3C-D71FC7E2DF1B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace CustomRuleset;

[BepInPlugin("fr.glomzubuk.plugins.llb.customruleset", "CustomRuleset", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
public class CustomRuleset : BaseUnityPlugin
{
	private readonly Dictionary<GameMode, string> gameModesMap = new Dictionary<GameMode, string>
	{
		[(GameMode)0] = "FFA",
		[(GameMode)1] = "1v1",
		[(GameMode)2] = "Competitive",
		[(GameMode)3] = "Team",
		[(GameMode)4] = "Strikers",
		[(GameMode)5] = "Volley",
		[(GameMode)100] = "Training"
	};

	public static CustomRuleset Instance { get; private set; } = null;


	public static ManualLogSource Log { get; private set; } = null;


	internal static DirectoryInfo ModdingFolder { get; private set; } = null;


	internal static Dictionary<GameMode, ConfigFile> ConfigFiles { get; } = new Dictionary<GameMode, ConfigFile>();


	private void Awake()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Hello, world!");
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		ModdingFolder = ModdingFolder.GetModSubFolder(((BaseUnityPlugin)this).Info);
		foreach (KeyValuePair<GameMode, string> item in gameModesMap)
		{
			FileInfo fileInfo = new FileInfo(Path.Combine(ModdingFolder.FullName, item.Value + ".cfg"));
			if (fileInfo.Exists)
			{
				ConfigFile val = new ConfigFile(fileInfo.FullName, true, ((BaseUnityPlugin)this).Info.Metadata);
				BindConfig(val, item.Key);
				ConfigFiles.Add(item.Key, val);
			}
		}
		new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll(typeof(ChangeRuleset));
	}

	private void BindConfig(ConfigFile config, GameMode gameMode)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Invalid comparison between Unknown and I4
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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_003d: Invalid comparison between Unknown and I4
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Invalid comparison between Unknown and I4
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Invalid comparison between Unknown and I4
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Invalid comparison between Unknown and I4
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Invalid comparison between Unknown and I4
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Invalid comparison between Unknown and I4
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Invalid comparison between Unknown and I4
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: 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: Invalid comparison between Unknown and I4
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Invalid comparison between Unknown and I4
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: 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_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		int num = (((int)gameMode == 2) ? 5 : ((gameMode - 100 > 1) ? 4 : 0));
		int num2 = num;
		GameSetting val = (GameSetting)1;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), num2, (ConfigDescription)null);
		num = ((gameMode - 4 <= 1) ? 10 : ((gameMode - 100 > 1) ? 8 : 0));
		int num3 = num;
		val = (GameSetting)2;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), num3, (ConfigDescription)null);
		val = (GameSetting)3;
		config.Bind<bool>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), false, (ConfigDescription)null);
		bool flag = gameMode - 4 <= 1;
		bool flag2 = flag;
		val = (GameSetting)4;
		config.Bind<bool>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), flag2, (ConfigDescription)null);
		num = ((gameMode - 1 > 1) ? 600 : 300);
		int num4 = num;
		val = (GameSetting)5;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), num4, (ConfigDescription)null);
		flag = gameMode - 100 <= 1;
		bool flag3 = flag;
		val = (GameSetting)6;
		config.Bind<bool>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), flag3, (ConfigDescription)null);
		val = (GameSetting)7;
		config.Bind<bool>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), true, (ConfigDescription)null);
		BallType val2 = ((gameMode - 4 > 1) ? ((BallType)0) : ((BallType)1));
		BallType val3 = val2;
		val = (GameSetting)8;
		config.Bind<BallType>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), val3, (ConfigDescription)null);
		val = (GameSetting)9;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), 8, (ConfigDescription)null);
		val = (GameSetting)10;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), 4, (ConfigDescription)null);
		HpFactor val4 = ((gameMode - 4 > 1) ? ((HpFactor)4) : ((HpFactor)7));
		HpFactor val5 = val4;
		val = (GameSetting)11;
		config.Bind<HpFactor>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), val5, (ConfigDescription)null);
		PowerupSelection val6 = ((gameMode - 1 > 1 && gameMode - 100 > 1) ? ((PowerupSelection)0) : ((PowerupSelection)10));
		PowerupSelection val7 = val6;
		val = (GameSetting)12;
		config.Bind<PowerupSelection>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), val7, (ConfigDescription)null);
		val = (GameSetting)13;
		config.Bind<int>("GameSettings", ((object)(GameSetting)(ref val)).ToString(), 0, (ConfigDescription)null);
	}

	public static GameSettings GetSettings(GameMode gameMode)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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)
		GameSettings val = null;
		if (ConfigFiles.TryGetValue(gameMode, out var value))
		{
			val = new GameSettings
			{
				gameMode = gameMode
			};
			for (int i = 1; i < 14; i++)
			{
				GameSetting val2 = (GameSetting)i;
				ConfigEntryBase val3 = value["GameSettings", ((object)(GameSetting)(ref val2)).ToString()];
				if ((object)val3.SettingType == typeof(bool))
				{
					val.Set(val2, ((bool)val3.BoxedValue) ? 1 : 0);
					continue;
				}
				Log.LogDebug((object)$"setting type: {val3.SettingType}");
				val.Set(val2, (int)val3.BoxedValue);
			}
		}
		return val;
	}
}
public static class ChangeRuleset
{
	[HarmonyPatch(typeof(JOMBNFKIHIC), "ADDBHIFLMEI")]
	[HarmonyPostfix]
	public static void ResetGameModeSettings_Postfix(JOMBNFKIHIC __instance)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		if ((int)NetworkApi.OnlineMode != 3)
		{
			GameSettings val = GameSettings.op_Implicit(__instance);
			GameSettings settings = CustomRuleset.GetSettings(val.gameMode);
			if (settings != null)
			{
				val.CopyFrom(settings);
			}
		}
	}
}
public static class PluginInfos
{
	public const string PLUGIN_NAME = "CustomRuleset";

	public const string PLUGIN_ID = "fr.glomzubuk.plugins.llb.customruleset";

	public const string PLUGIN_VERSION = "0.1.0";
}