Decompiled source of Card Draft Freeze Fix v1.0.1

CardDraftFreezeFix.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 CardDraftFreezeFix
{
	[BepInPlugin("com.lennox.rounds.carddraftfreezefix", "Card Draft Freeze Fix", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CardDraftFreezeFixPlugin : BaseUnityPlugin
	{
		public const string ModId = "com.lennox.rounds.carddraftfreezefix";

		public const string ModName = "Card Draft Freeze Fix";

		public const string Version = "1.0.1";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.lennox.rounds.carddraftfreezefix").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Card Draft Freeze Fix initialized successfully!");
		}
	}
	[HarmonyPatch(typeof(Cards), "GetRandomCardWithCondition")]
	public class GetRandomCardWithConditionPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ref CardInfo __result)
		{
			if (!((Object)(object)__result == (Object)null))
			{
				return;
			}
			Debug.LogWarning((object)"[CardDraftFreezeFix] Empty card pool detected for player! Yielding a fallback card to prevent UI freeze.");
			if (!((Object)(object)CardChoice.instance != (Object)null) || CardChoice.instance.cards == null || CardChoice.instance.cards.Length == 0)
			{
				return;
			}
			CardInfo val = null;
			CardInfo[] cards = CardChoice.instance.cards;
			foreach (CardInfo val2 in cards)
			{
				if (!((Object)(object)val2 == (Object)null) && (val2.categories == null || val2.categories.Length == 0))
				{
					val = val2;
					string text = val2.cardName.ToLower();
					if (text.Contains("health") || text.Contains("block") || text.Contains("shield"))
					{
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				cards = CardChoice.instance.cards;
				foreach (CardInfo val3 in cards)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						val = val3;
						break;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				__result = val;
				Debug.LogWarning((object)("[CardDraftFreezeFix] Successfully resolved freeze by selecting fallback card: " + val.cardName));
			}
		}
	}
}