Decompiled source of FullClan v0.1.1

plugins/FullClan.Plugin.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("FullClan.Plugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+a3f3bbc23cf4ba3a4c697cad7344533729eef122")]
[assembly: AssemblyProduct("FullClan.Plugin")]
[assembly: AssemblyTitle("FullClan.Plugin")]
[assembly: AssemblyVersion("0.1.1.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 FullClan.Plugin
{
	[BepInPlugin("FullClan.Plugin", "FullClan.Plugin", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger = new ManualLogSource("FullClan.Plugin");

		public void Awake()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin FullClan.Plugin is loaded!");
			new Harmony("FullClan.Plugin").PatchAll();
		}
	}
	[HarmonyPatch(typeof(SaveManager), "GetRandomUnlockedClass")]
	public class SaveManager_GetRandomUnlockedClass_AvoidSameClassPatch
	{
		public static void Prefix(ref ClassData? avoidClass)
		{
			avoidClass = null;
		}
	}
	[HarmonyPatch(typeof(RunSetupScreen), "HandleClanOptionsSelected")]
	public class RunSetupScreen_GetRandomUnlockedClass_DisableSwapPatch
	{
		private static readonly MethodInfo? RefreshCharacters = typeof(RunSetupScreen).GetMethod("RefreshCharacters", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly MethodInfo? RefreshClanCovenantUI = typeof(RunSetupScreen).GetMethod("RefreshClanCovenantUI", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly MethodInfo? RefreshWinStreak = typeof(RunSetupScreen).GetMethod("RefreshWinStreak", BindingFlags.Instance | BindingFlags.NonPublic);

		public static void Prefix(bool isMainClass, ClanOptionData? newClanOptionData, RunSetupClassLevelInfoUI ___mainClassInfo, RunSetupClassLevelInfoUI ___subClassInfo, SaveManager ___saveManager, RunSetupScreen __instance)
		{
			RunSetupClassLevelInfoUI val = (isMainClass ? ___mainClassInfo : ___subClassInfo);
			if (newClanOptionData != null && newClanOptionData.IsRandom)
			{
				val.SetClassRandom(newClanOptionData.randomId);
			}
			else if ((Object)(object)___saveManager != (Object)null)
			{
				ClassData val2 = newClanOptionData?.clanData;
				int num = 0;
				if ((Object)(object)val2 != (Object)null)
				{
					num = ___saveManager.GetClassLevelInMetagame(((GameData)val2).GetID());
					val.SetClass(val2, num, val.ChampionIndex);
				}
			}
			RefreshCharacters.Invoke(__instance, new object[1] { false });
			RefreshClanCovenantUI.Invoke(__instance, Array.Empty<object>());
			RefreshWinStreak.Invoke(__instance, Array.Empty<object>());
			___mainClassInfo.ShowCardPreview();
			___subClassInfo.ShowCardPreview();
		}
	}
	[HarmonyPatch(typeof(RandomMapDataContainer), "GetMapNodeData")]
	public class RandomMapDataContainer_GetMapNodeData_ForceDoubleBannersOnFullClanPatch
	{
		public static void Prefix(RandomMapDataContainer __instance, ref bool ___disallowDuplicatesOnSameSection, SaveManager saveManager)
		{
			if (((Object)__instance).name == "RewardsSimpleRing2Banners")
			{
				___disallowDuplicatesOnSameSection = (Object)(object)saveManager.GetMainClass() != (Object)(object)saveManager.GetSubClass();
			}
		}
	}
	[HarmonyPatch(typeof(CardSetBuilder), "CollectCards")]
	public class CardSetBuilder_CollectCards_PreventSameCommonStartOfCardsPatch
	{
		public static List<CardData> extraPull = new List<CardData>();

		public static void Postfix(CardSetBuilder __instance, ref List<CardData> collectedCards, ref List<CardData> showcaseCards, List<CardPull> ___paramCardPulls, SaveManager saveManager)
		{
			if (((Object)__instance).name != "StarterDeck_C01" || (Object)(object)saveManager.GetMainClass() != (Object)(object)saveManager.GetSubClass() || !((Object)(object)showcaseCards[0] == (Object)(object)showcaseCards[1]) || !((Object)(object)showcaseCards[1] == (Object)(object)showcaseCards[2]) || !((Object)(object)showcaseCards[2] == (Object)(object)showcaseCards[3]))
			{
				return;
			}
			Plugin.Logger.LogInfo((object)"Rerolling due to same cards.");
			CardPull obj = ___paramCardPulls[0];
			if (((obj != null) ? ((Object)obj).name : null) != "MainClassCommon2X")
			{
				Plugin.Logger.LogWarning((object)"Possible mod incompatibility, ParamCardPulls has been tampered with! Bail!");
				return;
			}
			int num = 0;
			do
			{
				extraPull.Clear();
				___paramCardPulls[0].CollectCards(extraPull, saveManager);
				num++;
				Plugin.Logger.LogInfo((object)"Rerolling again due to same cards.");
			}
			while ((Object)(object)extraPull[0] == (Object)(object)showcaseCards[0] && num < 200);
			for (num = 0; num < extraPull.Count; num++)
			{
				showcaseCards[num] = extraPull[num];
				collectedCards[num] = extraPull[num];
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FullClan.Plugin";

		public const string PLUGIN_NAME = "FullClan.Plugin";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}