Decompiled source of LethalCasinoMirageFix v1.0.0

LethalCasinoMirageFix.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LethalCasinoMirageFix;

[BepInPlugin("cocotera.LethalCasinoMirageFix", "LethalCasinoMirageFix", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "cocotera.LethalCasinoMirageFix";

	public const string Name = "LethalCasinoMirageFix";

	public const string Version = "1.0.0";

	private const string BrokenPatchClass = "LethalCasino.Patches.MenuManagerPatch";

	internal static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		try
		{
			RemoveBrokenMenuPatch();
		}
		catch (Exception ex)
		{
			Log.LogError((object)("No se pudo quitar el parche roto de LethalCasino: " + ex));
		}
	}

	private static void RemoveBrokenMenuPatch()
	{
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Expected O, but got Unknown
		MethodInfo methodInfo = AccessTools.Method(typeof(MenuManager), "Start", (Type[])null, (Type[])null);
		if (methodInfo == null)
		{
			Log.LogWarning((object)"No se encontró MenuManager.Start; no hay nada que hacer.");
			return;
		}
		Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo);
		if (patchInfo == null)
		{
			Log.LogInfo((object)"MenuManager.Start no tiene parches de Harmony. ¿Está LethalCasino desactivado?");
			return;
		}
		List<Patch> list = (from p in patchInfo.Prefixes.Concat(patchInfo.Postfixes).Concat(patchInfo.Transpilers).Concat(patchInfo.Finalizers)
			where p.PatchMethod != null && p.PatchMethod.DeclaringType != null && p.PatchMethod.DeclaringType.FullName == "LethalCasino.Patches.MenuManagerPatch"
			select p).ToList();
		if (list.Count == 0)
		{
			Log.LogInfo((object)"No se encontró el parche de menú de LethalCasino (puede que ya esté arreglado o desactivado).");
			return;
		}
		Harmony val = new Harmony("cocotera.LethalCasinoMirageFix");
		foreach (Patch item in list)
		{
			val.Unpatch((MethodBase)methodInfo, item.PatchMethod);
			Log.LogInfo((object)("Quitado el parche roto LethalCasino.Patches.MenuManagerPatch." + item.PatchMethod.Name + " (owner: " + item.owner + "). Mirage y LethalCasino ya pueden convivir."));
		}
	}
}