Decompiled source of FourLeafClover v3.0.1

plugins/🍀/🍀.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("art0007i")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0")]
[assembly: AssemblyProduct("\ud83c\udf40")]
[assembly: AssemblyTitle("\ud83c\udf40")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/FourLeafClover")]
[assembly: AssemblyVersion("3.0.0.0")]
[module: RefSafetyRules(11)]
namespace FourLeafClover;

[ResonitePlugin("art0007i.FourLeafClover", "\ud83c\udf40", "3.0.0", "art0007i", "https://github.com/art0007i/FourLeafClover")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(CollectionsExtensions), "\ud83c\udf40_ProcessNumber")]
	public class ProcessNumberPatch
	{
		public static bool Prefix(ref float __result, float num)
		{
			if (!Enabled.Value)
			{
				return true;
			}
			if (Equilibrium.Value)
			{
				__result = 1f;
			}
			else
			{
				__result = ((num == 0f) ? 0f : (1f / num));
			}
			return false;
		}
	}

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> Enabled;

	public static ConfigEntry<bool> Equilibrium;

	public override void Load()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Makes you luckier, by using the power of \ud83c\udf40");
		Equilibrium = ((BasePlugin)this).Config.Bind<bool>("General", "Equilibrium", false, "Makes it so all clips are equally likely to be played. \"Perfectly balanced, as all things should be.\"");
		((BasePlugin)this).HarmonyInstance.PatchAll();
		Log = ((BasePlugin)this).Log;
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("art0007i.FourLeafClover");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
		}
		log.LogInfo(val);
	}
}
public static class PluginMetadata
{
	public const string GUID = "art0007i.FourLeafClover";

	public const string NAME = "\ud83c\udf40";

	public const string VERSION = "3.0.0";

	public const string AUTHORS = "art0007i";

	public const string REPOSITORY_URL = "https://github.com/art0007i/FourLeafClover";
}

patchers/🍀/🍀Patcher.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Preloader.Core.Patching;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("\ud83c\udf40Patcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("\ud83c\udf40Patcher")]
[assembly: AssemblyTitle("\ud83c\udf40Patcher")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace FourLeafClover;

[PatcherPluginInfo("art0007i.FourLeafClover", "\ud83c\udf40", "0.1.0")]
public class Patcher : BasePatcher
{
	public const string GUID = "art0007i.FourLeafClover";

	public const string Name = "\ud83c\udf40";

	public const string Version = "0.1.0";

	[TargetAssembly("Elements.Core.dll")]
	public bool PatchFrooxEngine(ref AssemblyDefinition assembly, string filename)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_007f: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		TypeDefinition type = assembly.MainModule.GetType("Elements.Core.CollectionsExtensions");
		MethodDefinition val = new MethodDefinition("\ud83c\udf40_ProcessNumber", (MethodAttributes)150, assembly.MainModule.TypeSystem.Single);
		type.Methods.Add(val);
		val.Body.InitLocals = true;
		ILProcessor iLProcessor = val.Body.GetILProcessor();
		ParameterDefinition val2 = new ParameterDefinition("num", (ParameterAttributes)0, assembly.MainModule.TypeSystem.Single);
		((MethodReference)val).Parameters.Add(val2);
		iLProcessor.Emit(OpCodes.Ldarg_0);
		iLProcessor.Emit(OpCodes.Ret);
		Collection<Instruction> instructions = Extensions.FindMethod(type, "GetRandomWithWeight", true).Body.Instructions;
		bool flag = false;
		for (int i = 0; i < instructions.Count; i++)
		{
			Instruction val3 = instructions[i];
			if (val3.OpCode == OpCodes.Ldarg_1)
			{
				flag = true;
			}
			if (flag && val3.OpCode == OpCodes.Add)
			{
				flag = false;
				Instruction val4 = Instruction.Create(OpCodes.Call, (MethodReference)(object)val);
				instructions.Insert(i, val4);
			}
		}
		return true;
	}
}