Decompiled source of The Sandscourged v0.5.5

plugins/mt2_sandscourged.Plugin.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Conductor;
using Conductor.Extensions;
using Conductor.Interfaces;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using ShinyShoe;
using SimpleInjector;
using TrainworksReloaded.Base;
using TrainworksReloaded.Base.Extensions;
using TrainworksReloaded.Core;
using TrainworksReloaded.Core.Extensions;
using TrainworksReloaded.Core.Interfaces;
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("mt2_sandscourged.Plugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.5.0")]
[assembly: AssemblyInformationalVersion("0.5.5+eab37c84d8394b35488d284416c21dc05805ee34")]
[assembly: AssemblyProduct("mt2_sandscourged.Plugin")]
[assembly: AssemblyTitle("mt2_sandscourged.Plugin")]
[assembly: AssemblyVersion("0.5.5.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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;
		}
	}
}
[SearchWindowPath("Card Upgrade")]
public sealed class CardEffectAddTempUpgradeToCurrentCard : CardEffectBase
{
	public override bool CanPlayAfterBossDead => false;

	public override bool CanApplyInPreviewMode => false;

	public override PropDescriptions CreateEditorInspectorDescriptions()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0025: Expected O, but got Unknown
		//IL_0026: Expected O, but got Unknown
		PropDescriptions val = new PropDescriptions { };
		string fieldName;
		((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Card Upgrade", "", (Type)null, false);
		return val;
	}

	public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers, ISystemManagers sysManagers)
	{
		CardState playedCard = cardEffectParams.playedCard;
		if (playedCard == null)
		{
			yield break;
		}
		CardManager cardManager = coreGameManagers.GetCardManager();
		CardUpgradeState val = default(CardUpgradeState);
		if (CardUpgradeHelper.TryApplyUpgradeToCard(playedCard, playedCard, cardEffectState.GetParamCardUpgradeData(), true, cardEffectParams.isFromHiddenTrigger, coreGameManagers, ref val))
		{
			playedCard.UpdateCardBodyText((SaveManager)null);
			cardManager.RefreshCardInHand(playedCard, false, false, false);
			CardUI cardInHand = cardManager.GetCardInHand(playedCard);
			if ((Object)(object)cardInHand != (Object)null && (Object)(object)cardInHand != (Object)null)
			{
				cardInHand.ShowEnhanceFX();
			}
		}
	}

	public override void GetTooltipsStatusList(CardEffectState cardEffectState, ref List<string> outStatusIdList)
	{
		CardEffectAddUpgradeToCurrentCard.GetTooltipsStatusList(cardEffectState.GetSourceCardEffectData(), ref outStatusIdList);
	}

	public static void GetTooltipsStatusList(CardEffectData cardEffectData, ref List<string> outStatusIdList)
	{
		foreach (StatusEffectStackData statusEffectUpgrade in cardEffectData.GetParamCardUpgradeData().GetStatusEffectUpgrades())
		{
			outStatusIdList.Add(statusEffectUpgrade.statusId);
		}
	}
}
[SearchWindowPath("Cards")]
public sealed class CardEffectDrawTypeWithDiscardFix : CardEffectBase, ICardTargetingCardEffect
{
	private readonly List<CardState> toProcessCards = new List<CardState>();

	public override bool CanPlayAfterBossDead => false;

	public override bool CanApplyInPreviewMode => false;

	public override PropDescriptions CreateEditorInspectorDescriptions()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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_0024: Expected O, but got Unknown
		//IL_0024: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0044: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_0064: Expected O, but got Unknown
		//IL_0065: Expected O, but got Unknown
		PropDescriptions val = new PropDescriptions { };
		string fieldName;
		((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Num Cards", "", (Type)null, false);
		string fieldName2 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)18);
		((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("Card Filter", "Optional. If one is defined it will supercede other card type checking", (Type)null, false);
		string fieldName3 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)19);
		((Dictionary<string, PropDescription>)val)[fieldName3] = new PropDescription("Secondary Card Filter", "Optional. Only used if there is a primary card filter and it failed to find a match", (Type)null, false);
		return val;
	}

	public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers, ISystemManagers sysManagers)
	{
		CardManager cardManager = coreGameManagers.GetCardManager();
		RelicManager relicManager = coreGameManagers.GetRelicManager();
		toProcessCards.Clear();
		List<CardState> discardPile = cardManager.GetDiscardPile(true);
		ListExtensions.Shuffle<CardState>((IList<CardState>)discardPile, (RngId)5);
		toProcessCards.AddRange(discardPile);
		toProcessCards.AddRange(cardManager.GetDrawPile(false));
		int num = 0;
		int intInRange = cardEffectState.GetIntInRange();
		CardUpgradeMaskData paramCardFilter = cardEffectState.GetParamCardFilter();
		CardUpgradeMaskData paramCardFilterSecondary = cardEffectState.GetParamCardFilterSecondary();
		for (int num2 = toProcessCards.Count - 1; num2 >= 0 && num < intInRange; num2--)
		{
			CardState val = toProcessCards[num2];
			if (val == cardEffectParams.playedCard)
			{
				continue;
			}
			if ((Object)(object)paramCardFilter != (Object)null)
			{
				if (!paramCardFilter.FilterCard<CardState>(val, relicManager))
				{
					continue;
				}
			}
			else if (val.GetCardType() != cardEffectState.GetTargetCardType())
			{
				continue;
			}
			cardManager.DrawSpecificCard(val, false, (DrawSource)0, cardEffectState.GetParentCardState(), 1, 1);
			num++;
		}
		if (num != 0 || !((Object)(object)paramCardFilter != (Object)null) || !((Object)(object)paramCardFilterSecondary != (Object)null))
		{
			yield break;
		}
		int num3 = toProcessCards.Count - 1;
		while (num3 >= 0 && num < intInRange)
		{
			CardState val2 = toProcessCards[num3];
			if (val2 != cardEffectParams.playedCard && paramCardFilterSecondary.FilterCard<CardState>(val2, relicManager))
			{
				cardManager.DrawSpecificCard(val2, false, (DrawSource)0, cardEffectState.GetParentCardState(), 1, 1);
				num++;
			}
			num3--;
		}
	}

	public int GetNumCardTargets(CardState cardState, CardEffectState cardEffectState, CardStatistics cardStatistics)
	{
		//IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		StatValueData val = new StatValueData
		{
			cardState = cardState,
			trackedValue = (TrackedValueType)19,
			entryDuration = (EntryDuration)2,
			cardTypeTarget = cardStatistics.ConvertCardTypeToCardTargetType(cardEffectState.GetTargetCardType())
		};
		int statValue = cardStatistics.GetStatValue(val);
		val.trackedValue = (TrackedValueType)16;
		int statValue2 = cardStatistics.GetStatValue(val);
		return statValue + statValue2;
	}
}
public sealed class RoomStateAddStatusEffectOnAnyStatusApplied : RoomStateModifierBase, IRoomStateOnStatusEffectAppliedModifier, IRoomStateModifier, ILocalizationParamInt, ILocalizationParameterContext, IRoomStateOnCharacterTriggerModifier
{
	private static int trackingIdCounter;

	private int thisInstTrackingId;

	private bool buffsAllowed;

	private bool debuffsAllowed;

	private bool persistentAllowed;

	private bool abilitiesAllowed;

	private readonly List<Type> teamsAllowed = new List<Type>();

	private readonly List<StatusEffectStackData>? statusEffects = new List<StatusEffectStackData>();

	private readonly AddStatusEffectParams? addStatusEffectParams = new AddStatusEffectParams();

	public override void Initialize(RoomModifierData roomModifierData, SaveManager saveManager)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_0049: Expected O, but got Unknown
		((RoomStateModifierBase)this).Initialize(roomModifierData, saveManager);
		thisInstTrackingId = ++trackingIdCounter;
		StatusEffectStackData[] paramStatusEffects = roomModifierData.GetParamStatusEffects();
		foreach (StatusEffectStackData val in paramStatusEffects)
		{
			StatusEffectStackData item = new StatusEffectStackData
			{
				statusId = val.statusId,
				count = val.count
			};
			statusEffects?.Add(item);
		}
		int paramInt = roomModifierData.GetParamInt();
		buffsAllowed = (paramInt & 1) > 0;
		debuffsAllowed = (paramInt & 2) > 0;
		persistentAllowed = (paramInt & 4) > 0;
		abilitiesAllowed = (paramInt & 8) > 0;
		int paramInt2 = roomModifierData.GetParamInt2();
		if ((paramInt2 & 1) > 0)
		{
			teamsAllowed.Add((Type)2);
		}
		if ((paramInt2 & 2) > 0)
		{
			teamsAllowed.Add((Type)1);
		}
	}

	public void OnStatusEffectAppliedModification(CharacterState affectedCharacter, string statusId, AddStatusEffectParams addStatusEffectParams, ICoreGameManagers coreGameManagers)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		if (addStatusEffectParams.spawnEffect || addStatusEffectParams.fromRoomModifier || !teamsAllowed.Contains(affectedCharacter.GetTeamType()))
		{
			return;
		}
		StatusEffectData statusEffectDataById = StatusEffectManager.Instance.GetStatusEffectDataById(statusId, true);
		DisplayCategory? val = ((statusEffectDataById != null) ? new DisplayCategory?(statusEffectDataById.GetDisplayCategory()) : ((DisplayCategory?)null));
		if (val.HasValue && ((val == (DisplayCategory?)0 && !buffsAllowed) || (val == (DisplayCategory?)1 && !debuffsAllowed) || (val == (DisplayCategory?)2 && !persistentAllowed) || (val == (DisplayCategory?)3 && !abilitiesAllowed)))
		{
			return;
		}
		CombatManager combatManager = coreGameManagers.GetCombatManager();
		using List<StatusEffectStackData>.Enumerator enumerator = statusEffects.GetEnumerator();
		while (enumerator.MoveNext())
		{
			combatManager.QueueTrigger(affectedCharacter, (Trigger)57, (CharacterState)null, true, true, new FireTriggersData
			{
				paramString = enumerator.Current.statusId,
				paramInt = enumerator.Current.count,
				paramInt2 = thisInstTrackingId
			}, 1, (CharacterTriggerState)null);
		}
	}

	public IEnumerator ApplyCharacterTriggerModification(Trigger trigger, CharacterState affectedCharacter, FireTriggersData? fireTriggersData, ICoreGameManagers coreGameManagers)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if ((int)trigger == 57 && fireTriggersData != null && fireTriggersData.paramInt2 == thisInstTrackingId)
		{
			addStatusEffectParams.fromRoomModifier = true;
			affectedCharacter.AddStatusEffect(fireTriggersData.paramString, fireTriggersData.paramInt, addStatusEffectParams, (CharacterState)null, true, false, true, false, false);
		}
		yield break;
	}
}
public sealed class RoomStateAttackPerDebuffOnTeam : RoomStateModifierBase, IRoomStateDamageModifier, IRoomStateModifier, ILocalizationParamInt, ILocalizationParameterContext
{
	private int additionalDamagePerStack;

	private readonly List<Type> teamsAllowed = new List<Type>();

	public override void Initialize(RoomModifierData roomModifierData, SaveManager saveManager)
	{
		((RoomStateModifierBase)this).Initialize(roomModifierData, saveManager);
		additionalDamagePerStack = roomModifierData.GetParamInt();
		int paramInt = roomModifierData.GetParamInt2();
		if ((paramInt & 1) > 0)
		{
			teamsAllowed.Add((Type)2);
		}
		if ((paramInt & 2) > 0)
		{
			teamsAllowed.Add((Type)1);
		}
	}

	public override string GetTitleKey()
	{
		return ((object)this).GetType().Name;
	}

	public int GetModifiedMagicPowerDamage(ICoreGameManagers coreGameManagers)
	{
		return 0;
	}

	public int GetModifiedAttackDamage(Type damageType, CharacterState attackerState, bool requestingForCharacterStats, ICoreGameManagers coreGameManagers)
	{
		if (requestingForCharacterStats)
		{
			return ((RoomStateModifierBase)this).GetDynamicInt(attackerState);
		}
		return 0;
	}

	public override int GetDynamicInt(CharacterState characterContext)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		if (characterContext.GetRoomStateModifiers().Contains((IRoomStateModifier)(object)this) && characterContext.GetSpawnPoint(false) != null && (Object)(object)characterContext.GetCurrentRoom(false) != (Object)null)
		{
			RoomState currentRoom = characterContext.GetCurrentRoom(false);
			List<string> list = new List<string>();
			List<CharacterState> list3 = default(List<CharacterState>);
			UsingGenericPoolObject<List<CharacterState>> list2 = GenericPools.GetList<CharacterState>(ref list3);
			try
			{
				foreach (Type item in teamsAllowed)
				{
					currentRoom.AddCharactersToList(list3, item, false, true);
				}
				List<StatusEffectStack> source = default(List<StatusEffectStack>);
				foreach (CharacterState item2 in list3)
				{
					UsingGenericPoolObject<List<StatusEffectStack>> list4 = GenericPools.GetList<StatusEffectStack>(ref source);
					try
					{
						item2.GetStatusEffects(ref source, false);
						list.AddRange(from debuff in source
							where (int)debuff.State.GetDisplayCategory() == 1
							select debuff.State.GetStatusId());
					}
					finally
					{
						((IDisposable)list4/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
			finally
			{
				((IDisposable)list2/*cast due to .constrained prefix*/).Dispose();
			}
			return list.Distinct().Count() * additionalDamagePerStack;
		}
		return 0;
	}
}
namespace mt2_sandscourged.Plugin
{
	[HarmonyPatch(typeof(CombatManager), "ShowKillCam")]
	internal class AddUpgradeToDeadUnitsPatch
	{
		public static void Prefix(CombatManager __instance, CardManager ___cardManager)
		{
			if (CardEffectAddUpgradeToDeadUnits.consumedCards == null)
			{
				CardEffectAddUpgradeToDeadUnits.consumedCards = ___cardManager.GetExhaustedPile(true);
			}
		}
	}
	[HarmonyPatch(typeof(CombatManager), "StartCombat")]
	internal class ClearListOnStartOfBattlePatch
	{
		public static void Postfix(CombatManager __instance)
		{
			CardEffectAddUpgradeToDeadUnits.consumedCards = null;
		}
	}
	[SearchWindowPath("Card Upgrade")]
	public sealed class CardEffectAddUpgradeToDeadUnits : CardEffectBase
	{
		public static List<CardState>? consumedCards;

		public override bool CanPlayAfterBossDead => true;

		public override bool CanApplyInPreviewMode => false;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_0096: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00c0: Expected O, but got Unknown
			//IL_00c1: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Card Upgrade", "", (Type)null, false);
			string fieldName2 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)0);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("Upgrade Lifetime", CardUpgradeHelper.UpgradeLifetimeEditorTooltip, typeof(UnitUpgradeLifetime), false);
			string fieldName3 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)27);
			((Dictionary<string, PropDescription>)val)[fieldName3] = new PropDescription("Use Status Effect Stack Multiplier", "", typeof(bool), false);
			string fieldName4 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)20);
			((Dictionary<string, PropDescription>)val)[fieldName4] = new PropDescription("Status Effects to multiply by", "", (Type)null, false);
			string fieldName5 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)7);
			((Dictionary<string, PropDescription>)val)[fieldName5] = new PropDescription("Is From Celeberate", "", typeof(bool), false);
			return val;
		}

		public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers, ISystemManagers sysManagers)
		{
			if (cardEffectState.GetParamBool() && IEnumerableUtility.IsNullOrEmpty<CardState>(consumedCards))
			{
				Console.Write("No consumed cards found, skipping upgrade application.");
				yield break;
			}
			new List<CardState>();
			List<CardState> list = ((consumedCards == null) ? (from c in coreGameManagers.GetCardManager().GetExhaustedPile(false)
				where c.IsSpawnerCard()
				select c).ToList() : consumedCards.Where((CardState c) => c.IsSpawnerCard()).ToList());
			Console.Write(list.Count() + " dead units found for upgrade application.");
			cardEffectState.GetParamInt();
			int num = 1;
			if (cardEffectState.GetUseStatusEffectStackMultiplier())
			{
				if ((Object)(object)cardEffectParams.selfTarget == (Object)null)
				{
					Console.Write("No self target found, cannot apply status effect stack multiplier.");
					yield break;
				}
				string text = cardEffectState.GetParamStatusEffectStackData().FirstOrDefault()?.statusId;
				if (text == null)
				{
					Console.Write("No status effect found in upgrade data, cannot apply status effect stack multiplier.");
					yield break;
				}
				num = cardEffectParams.selfTarget.GetStatusEffectStacks(text);
				Console.Write("Status effect stack multiplier: " + num);
			}
			CardUpgradeData paramCardUpgradeData = cardEffectState.GetParamCardUpgradeData();
			int num2 = num * ((paramCardUpgradeData != null) ? paramCardUpgradeData.GetBonusDamage() : 0);
			int num3 = num * ((paramCardUpgradeData != null) ? paramCardUpgradeData.GetBonusHP() : 0);
			foreach (CardState item in list)
			{
				Console.Write(item.GetDebugName() + " is attempting upgrade.");
				item.GetCardStateModifiers().IncrementAdditionalDamage(num2);
				item.GetCardStateModifiers().IncrementAdditionalHP(num3);
			}
			consumedCards = null;
		}

		public override void GetTooltipsStatusList(CardEffectState cardEffectState, ref List<string> outStatusIdList)
		{
			CardEffectAddTempCardUpgradeToCardsInHand.GetTooltipsStatusList(cardEffectState.GetSourceCardEffectData(), ref outStatusIdList);
		}

		public static void GetTooltipsStatusList(CardEffectData cardEffectData, ref List<string> outStatusIdList)
		{
			foreach (StatusEffectStackData statusEffectUpgrade in cardEffectData.GetParamCardUpgradeData().GetStatusEffectUpgrades())
			{
				outStatusIdList.Add(statusEffectUpgrade.statusId);
			}
		}

		public override void CreateAdditionalTooltips(CardEffectState cardEffectState, TooltipContainer tooltipContainer, SaveManager saveManager)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CardUpgradeState val = new CardUpgradeState();
			val.Setup(cardEffectState.GetParamCardUpgradeData(), false, false);
			tooltipContainer.AddTooltipsCardUpgrade(CardState.None, val, saveManager);
			tooltipContainer.AddTooltipsUpgradedCardTraits(val);
		}
	}
	public sealed class CardEffectPurgeCardFromHand : CardEffectBase
	{
		private CardState? sourceCardState;

		public override bool CanPlayAfterBossDead => false;

		public override bool CanApplyInPreviewMode => false;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			//IL_002d: 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_0045: Expected O, but got Unknown
			//IL_0045: Expected O, but got Unknown
			//IL_0046: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("True = whitelist the subtype. False = blacklist the subtype.", "", (Type)null, false);
			string fieldName2 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)11);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("All subtypes to restrict by", "", (Type)null, false);
			return val;
		}

		public override void Setup(CardEffectState cardEffectState)
		{
			((CardEffectBase)this).Setup(cardEffectState);
			sourceCardState = cardEffectState.GetParentCardState();
		}

		public override bool TestEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			List<CardState> hand = coreGameManagers.GetCardManager().GetHand(false);
			if (hand.Count == 0)
			{
				return false;
			}
			List<CardState> list2 = default(List<CardState>);
			UsingGenericPoolObject<List<CardState>> list = GenericPools.GetList<CardState>(ref list2);
			try
			{
				foreach (CardState item in hand)
				{
					if (item != cardEffectParams.playedCard && !CardFilterFunc(item))
					{
						list2.Add(item);
					}
				}
				if (list2.Count == 0)
				{
					return false;
				}
				return true;
			}
			finally
			{
				((IDisposable)list/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers, ISystemManagers sysManagers)
		{
			yield return coreGameManagers.GetCardManager().SelectCardFromHand(new Params
			{
				descriptionKey = "PurgeCardFromHandKey",
				overrideActionKey = "PurgeCardFromHandActionKey",
				cardChosenCallback = new CardStateChosenDelegate(HandleChooseCard),
				filterCallback = new FilterCardStateDelegate(CardFilterFunc),
				instantApplyDelay = coreGameManagers.GetAllGameData().GetBalanceData().GetAnimationTimingData()
					.cardDrawAnimationDuration,
				disableIneligibleCards = true,
				selectionHandState = (CardUIState)9
			}, true);
		}

		private IEnumerator HandleChooseCard(CardState chosenCard, CardManager cardManager)
		{
			yield return cardManager.PurgeCardFromHand(new DiscardCardParams
			{
				overrideDiscardEffect = (DiscardEffect)3,
				discardCard = chosenCard,
				triggeredByCard = true,
				triggeredCard = sourceCardState,
				wasPlayed = false
			}, false);
			cardManager.RefreshHandCards(true, false);
		}

		private bool CardFilterFunc(CardState cardState)
		{
			return cardState.HasTrait<CardTraitUnpurgable>();
		}
	}
	public sealed class CardEffectSubtypeRestricted : CardEffectBase
	{
		private SubtypeData? subtypeToRestrict;

		private bool isWhitelist;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Expected O, but got Unknown
			//IL_0045: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("True = whitelist the subtype. False = blacklist the subtype.", "", (Type)null, false);
			string fieldName2 = CardEffectFieldNamesHelper.GetFieldName((CardEffectFieldNames)11);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("All subtypes to restrict by", "", (Type)null, false);
			return val;
		}

		public override void Setup(CardEffectState cardEffectState)
		{
			((CardEffectBase)this).Setup(cardEffectState);
			subtypeToRestrict = cardEffectState.GetParamSubtype();
			isWhitelist = cardEffectState.GetParamBool();
		}

		public override bool TestEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers)
		{
			if (subtypeToRestrict == null)
			{
				return false;
			}
			bool flag = false;
			foreach (CharacterState target in cardEffectParams.targets)
			{
				if (target.GetHasSubtype(subtypeToRestrict))
				{
					flag = true;
				}
			}
			return flag == isWhitelist;
		}

		public override IEnumerator ApplyEffect(CardEffectState cardEffectState, CardEffectParams cardEffectParams, ICoreGameManagers coreGameManagers, ISystemManagers sysManagers)
		{
			yield break;
		}
	}
	public sealed class CardTraitScalingAddBattleCardToHandFromPool : CardTraitState
	{
		public static CardPool? paramCardPool;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			return new PropDescriptions();
		}

		public override IEnumerator OnCardPlayed(CardState thisCard, ICoreGameManagers coreGameManagers)
		{
			int additionalCards = GetAdditionalCards(coreGameManagers.GetCardStatistics());
			CardManager cardManager = coreGameManagers.GetCardManager();
			int num = additionalCards;
			int num2 = cardManager.GetMaxHandSize() - cardManager.GetNumCardsInHand();
			if (num2 > 0)
			{
				num = Mathf.Min(num, num2);
			}
			AddCardUpgradingInfo val = null;
			CardUpgradeData cardUpgradeDataParam = ((CardTraitState)this).GetCardUpgradeDataParam();
			if ((Object)(object)cardUpgradeDataParam != (Object)null)
			{
				val = new AddCardUpgradingInfo();
				val.upgradeDatas.Add(cardUpgradeDataParam);
				val.tempCardUpgrade = true;
				val.upgradingCardSource = ((CardTraitState)this).GetCard();
				val.ignoreTempUpgrades = false;
				val.copyModifiersFromCard = ((CardTraitState)this).GetCard();
			}
			List<CardData> list2 = default(List<CardData>);
			UsingGenericPoolObject<List<CardData>> list = GenericPools.GetList<CardData>(ref list2);
			try
			{
				int num3 = 0;
				while (true)
				{
					int num4 = num3;
					CardPool? obj = paramCardPool;
					if (!(num4 < ((obj != null) ? new int?(obj.GetNumCards()) : ((int?)null))))
					{
						break;
					}
					CardData cardAtIndex = paramCardPool.GetCardAtIndex(num3);
					list2.Add(cardAtIndex);
					num3++;
				}
				for (int i = 0; i < num; i++)
				{
					int index = RandomManager.Range(0, list2.Count, (RngId)6);
					CardData val2 = list2[index];
					cardManager.AddNewCard(val2, (CardPile)3, false, false, val, true);
				}
			}
			finally
			{
				((IDisposable)list/*cast due to .constrained prefix*/).Dispose();
			}
			yield break;
		}

		private int GetAdditionalCards(CardStatistics cardStatistics)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!((CardTraitState)this).GetUseScalingParams())
			{
				return ((CardTraitState)this).GetParamInt();
			}
			StatValueData val = new StatValueData
			{
				cardState = ((CardTraitState)this).GetCard(),
				trackedValue = ((CardTraitState)this).GetParamTrackedValue(),
				entryDuration = ((CardTraitState)this).GetParamEntryDuration(),
				cardTypeTarget = ((CardTraitState)this).GetParamCardType(),
				paramSubtype = ((CardTraitState)this).GetParamSubtype(),
				forPreviewText = false
			};
			int statValue = cardStatistics.GetStatValue(val);
			return ((CardTraitState)this).GetParamInt() * statValue;
		}
	}
	public sealed class CardTraitScalingByHandCount : CardTraitState
	{
		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_002b: 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_0043: Expected O, but got Unknown
			//IL_0043: Expected O, but got Unknown
			//IL_0044: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Multiplier per card in hand", "", (Type)null, false);
			string fieldName2 = CardTraitFieldNamesHelper.GetFieldName((CardTraitFieldNames)2);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("Divider per card in hand", "", (Type)null, false);
			return val;
		}

		public override string GetCardTooltipTitle()
		{
			AllGameManagers instance = AllGameManagers.Instance;
			CombatManager val = ((instance != null) ? instance.GetCombatManager() : null);
			AllGameManagers instance2 = AllGameManagers.Instance;
			CardManager val2 = ((instance2 != null) ? instance2.GetCardManager() : null);
			if ((Object)(object)val != (Object)null && val.GetIsRunningCombat() && (Object)(object)val2 != (Object)null)
			{
				return string.Format(LocalizationExtensions.Localize("CardTraitScalingByHandCount_TooltipTitleInBattle", (ILocalizationParameterContext)null), val2.GetHand(false).Count);
			}
			return string.Format(LocalizationExtensions.Localize("CardTraitScalingByHandCount_TooltipTitleOutOfBattle", (ILocalizationParameterContext)null));
		}

		public override string GetCardTooltipText()
		{
			AllGameManagers instance = AllGameManagers.Instance;
			CombatManager val = ((instance != null) ? instance.GetCombatManager() : null);
			AllGameManagers instance2 = AllGameManagers.Instance;
			CardManager val2 = ((instance2 != null) ? instance2.GetCardManager() : null);
			if ((Object)(object)val != (Object)null && val.GetIsRunningCombat() && (Object)(object)val2 != (Object)null)
			{
				return string.Format(LocalizationExtensions.Localize("CardTraitScalingByHandCount_TooltipTextInBattle", (ILocalizationParameterContext)null), val2.GetHand(false).Count);
			}
			return string.Format(LocalizationExtensions.Localize("CardTraitScalingByHandCount_TooltipTextOutOfBattle", (ILocalizationParameterContext)null));
		}

		public override void OnApplyingCardUpgradeToUnit(CardState thisCard, CharacterState targetUnit, CharacterTriggerState? characterTriggerState, CardUpgradeState upgradeState, ICoreGameManagers coreGameManagers)
		{
			((CardTraitState)this).OnApplyingCardUpgradeToUnit(thisCard, targetUnit, characterTriggerState, upgradeState, coreGameManagers);
			int num = IEnumerableUtility.Count<CardState>(coreGameManagers.GetCardManager().GetHand(false), (Func<CardState, bool>)((CardState c) => c != thisCard));
			upgradeState.SetAttackDamage(((CardTraitState)this).GetParamInt() * num);
			upgradeState.SetAdditionalHP(((CardTraitState)this).GetParamInt2() * num);
		}

		public override int OnApplyingDamage(ApplyingDamageParameters damageParams, ICoreGameManagers coreGameManagers)
		{
			return coreGameManagers.GetCardManager().GetHand(false).Count() * ((CardTraitState)this).GetParamInt() / ((CardTraitState)this).GetParamInt2();
		}

		public override int OnStatusEffectApplied(CharacterState affectedCharacter, CardState thisCard, ICoreGameManagers coreGameManagers, string statusId, int sourceStacks = 0)
		{
			int num = IEnumerableUtility.Count<CardState>(coreGameManagers.GetCardManager().GetHand(false), (Func<CardState, bool>)((CardState c) => c != thisCard));
			return sourceStacks * (num * ((CardTraitState)this).GetParamInt() / ((CardTraitState)this).GetParamInt2()) - sourceStacks;
		}
	}
	public class CardTraitStatusEffectUpgradeMultiplier : CardTraitState
	{
		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Status to multiply by.", "", (Type)null, false);
			return val;
		}

		public override void OnApplyingCardUpgradeToUnit(CardState thisCard, CharacterState targetUnit, CharacterTriggerState? characterTriggerState, CardUpgradeState upgradeState, ICoreGameManagers coreGameManagers)
		{
			((CardTraitState)this).OnApplyingCardUpgradeToUnit(thisCard, targetUnit, characterTriggerState, upgradeState, coreGameManagers);
			string statusId = ((CardTraitState)this).GetParamStatusEffects().First().statusId;
			int statusEffectStacks = targetUnit.GetStatusEffectStacks(statusId);
			upgradeState.SetAttackDamage(upgradeState.GetAttackDamage() * statusEffectStacks);
			upgradeState.SetAdditionalHP(upgradeState.GetAdditionalHP() * statusEffectStacks);
		}
	}
	public sealed class RelicEffectApplyStatusEffectOnCardEarlyDiscard : RelicEffectBase, IOnDiscardRelicEffect, IRelicEffect, IStatusEffectRelicEffect
	{
		private Type sourceTeam;

		private TargetMode targetMode;

		private StatusEffectStackData[] statusEffectsToApply = Array.Empty<StatusEffectStackData>();

		private readonly AddStatusEffectParams addStatusEffectParams = new AddStatusEffectParams();

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Target Team", "", (Type)null, false);
			string fieldName2 = RelicEffectFieldNamesHelper.GetFieldName((RelicEffectFieldNames)17);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("Target Mode", "", (Type)null, false);
			string fieldName3 = RelicEffectFieldNamesHelper.GetFieldName((RelicEffectFieldNames)30);
			((Dictionary<string, PropDescription>)val)[fieldName3] = new PropDescription("Status Effects to apply", "", (Type)null, false);
			return val;
		}

		public override void Initialize(RelicState relicState, RelicData relicData, RelicEffectData relicEffectData)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			((RelicEffectBase)this).Initialize(relicState, relicData, relicEffectData);
			sourceTeam = relicEffectData.GetParamSourceTeam();
			targetMode = relicEffectData.GetTargetMode();
			statusEffectsToApply = relicEffectData.GetParamStatusEffects();
			addStatusEffectParams.sourceRelicState = ((RelicEffectBase)this).SourceRelicState;
		}

		public bool TestEffectOnCardDiscarded(CardDiscardedRelicEffectParams relicEffectParams, ICoreGameManagers coreGameManagers)
		{
			return relicEffectParams.discardCardParams.triggeredByCard;
		}

		public IEnumerator ApplyEffectOnCardDiscarded(CardDiscardedRelicEffectParams relicEffectParams, ICoreGameManagers coreGameManagers)
		{
			((RelicEffectBase)this).NotifyRelicTriggered(((RelicEffectParams)relicEffectParams).relicManager, (CharacterUI)null, "", false, 0f);
			int currentSelectedRoom = coreGameManagers.GetRoomManager().CurrentSelectedRoom;
			CollectTargetsData val = new CollectTargetsData
			{
				targetTeamType = sourceTeam,
				targetMode = targetMode,
				roomIndex = currentSelectedRoom,
				inCombat = false,
				isTesting = coreGameManagers.GetSaveManager().PreviewMode
			};
			List<CharacterState> list = new List<CharacterState>();
			UsingGenericPoolObject<List<CharacterState>> list2 = GenericPools.GetList<CharacterState>(ref list);
			try
			{
				TargetHelper.CollectTargets(val, coreGameManagers, ref list);
				foreach (CharacterState item in list)
				{
					StatusEffectStackData[] array = statusEffectsToApply;
					foreach (StatusEffectStackData val2 in array)
					{
						item.AddStatusEffect(val2.statusId, val2.count, addStatusEffectParams, (CharacterState)null, true, false, true, false, false);
					}
				}
			}
			finally
			{
				((IDisposable)list2/*cast due to .constrained prefix*/).Dispose();
			}
			((CollectTargetsData)(ref val)).Reset((TargetMode)0);
			yield break;
		}

		public StatusEffectStackData[]? GetStatusEffects()
		{
			return statusEffectsToApply;
		}
	}
	public sealed class RelicEffectCustomAddUpgrade : RelicEffectBase, ICardModifierRelicEffect, IRelicEffect, IStatusEffectRelicEffect
	{
		private Type _sourceTeam;

		private CardUpgradeData? _cardUpgradeData;

		private bool _applyToCardlessSpawns;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Source Team", "", (Type)null, false);
			string fieldName2 = RelicEffectFieldNamesHelper.GetFieldName((RelicEffectFieldNames)21);
			((Dictionary<string, PropDescription>)val)[fieldName2] = new PropDescription("Upgrade", "", (Type)null, false);
			string fieldName3 = RelicEffectFieldNamesHelper.GetFieldName((RelicEffectFieldNames)9);
			((Dictionary<string, PropDescription>)val)[fieldName3] = new PropDescription("Apply to Cardless Spawns", "", (Type)null, false);
			return val;
		}

		public override void Initialize(RelicState relicState, RelicData relicData, RelicEffectData relicEffectData)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((RelicEffectBase)this).Initialize(relicState, relicData, relicEffectData);
			_sourceTeam = relicEffectData.GetParamSourceTeam();
			_cardUpgradeData = relicEffectData.GetParamCardUpgradeData();
			_applyToCardlessSpawns = relicEffectData.GetParamBool();
		}

		public bool ApplyCardStateModifiers(CardState cardState, RelicManager relicManager, SaveManager saveManager, CardManager? cardManager)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			bool result = false;
			if ((Object)(object)_cardUpgradeData != (Object)null && ((Enum)_sourceTeam).HasFlag((Enum)(object)(Type)2))
			{
				foreach (CardUpgradeMaskData filter in _cardUpgradeData.GetFilters())
				{
					if (!filter.FilterCard<CardState>(cardState, relicManager))
					{
						return false;
					}
				}
				CardUpgradeState val = new CardUpgradeState();
				val.Setup(_cardUpgradeData, false, false);
				if (cardState.GetUpgradeData() == null)
				{
					return false;
				}
				if (val.IsUnique() && cardState.GetCardStateModifiers().HasUpgrade(((GameData)_cardUpgradeData).GetID()))
				{
					return false;
				}
				cardState.ApplyPermanentUpgrade(val, saveManager, true, (string)null);
				cardState.UpdateCardBodyText((SaveManager)null);
				if ((Object)(object)cardManager != (Object)null)
				{
					cardManager.RefreshCardInHand(cardState, true, false, false);
				}
				return true;
			}
			return result;
		}

		public override IEnumerator OnCharacterAdded(CharacterState characterState, CardState fromCard, ICoreGameManagers coreGameManagers)
		{
			RelicManager relicManager = coreGameManagers.GetRelicManager();
			if (!((Object)(object)_cardUpgradeData != (Object)null) || !((Enum)_sourceTeam).HasFlag((Enum)(object)characterState.GetTeamType()) || !characterState.HasStatusEffect("cardless") || characterState.GetIsClone() || !_applyToCardlessSpawns)
			{
				yield break;
			}
			foreach (CardUpgradeMaskData filter in _cardUpgradeData.GetFilters())
			{
				if (!filter.FilterCard<CardState>(fromCard, relicManager) || !filter.FilterCharacter(characterState, relicManager))
				{
					yield break;
				}
			}
			if (!_cardUpgradeData.IsUnique() || fromCard == null || (!fromCard.GetCardStateModifiers().HasUpgrade(((GameData)_cardUpgradeData).GetID()) && !fromCard.GetTemporaryCardStateModifiers().HasUpgrade(((GameData)_cardUpgradeData).GetID())))
			{
				CardUpgradeState val = new CardUpgradeState();
				val.Setup(_cardUpgradeData, false, false);
				yield return characterState.ApplyCardUpgrade(val, false, "", true, false, (CardState)null, (Action<UpgradeApplicationResult>)null, (TrainRoomAttachmentState)null, false);
			}
		}

		public bool GetTooltip(out string title, out string body)
		{
			title = string.Empty;
			body = string.Empty;
			return false;
		}

		public StatusEffectStackData[]? GetStatusEffects()
		{
			if ((Object)(object)_cardUpgradeData != (Object)null)
			{
				return _cardUpgradeData.GetStatusEffectUpgrades().ToArray();
			}
			return null;
		}
	}
	public sealed class RelicEffectDrawOnCardEarlyDiscard : RelicEffectBase, IOnDiscardRelicEffect, IRelicEffect
	{
		private int _cardsToDraw;

		public override PropDescriptions CreateEditorInspectorDescriptions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0024: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			PropDescriptions val = new PropDescriptions { };
			string fieldName;
			((Dictionary<string, PropDescription>)val)[fieldName] = new PropDescription("Num cards to draw", "", (Type)null, false);
			return val;
		}

		public override void Initialize(RelicState relicState, RelicData relicData, RelicEffectData relicEffectData)
		{
			((RelicEffectBase)this).Initialize(relicState, relicData, relicEffectData);
			_cardsToDraw = relicEffectData.GetParamInt();
		}

		public bool TestEffectOnCardDiscarded(CardDiscardedRelicEffectParams relicEffectParams, ICoreGameManagers coreGameManagers)
		{
			return relicEffectParams.discardCardParams.triggeredByCard;
		}

		public IEnumerator ApplyEffectOnCardDiscarded(CardDiscardedRelicEffectParams relicEffectParams, ICoreGameManagers coreGameManagers)
		{
			((RelicEffectBase)this).NotifyRelicTriggered(((RelicEffectParams)relicEffectParams).relicManager, (CharacterUI)null, "", false, 0f);
			coreGameManagers.GetCardManager().DrawCards(_cardsToDraw, (CardState)null, (CardType)4, -1);
			yield break;
		}
	}
	internal class StatusEffectHexState : StatusEffectState, IOnOtherStatusEffectAdded
	{
		public const string StatusId = "hex";

		public int OnOtherStatusEffectBeingAdded(int myStacks, string statusId, int numStacks)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if (statusId == "hex")
			{
				return numStacks;
			}
			StatusEffectData statusEffectDataById = StatusEffectManager.Instance.GetStatusEffectDataById(statusId, true);
			if (statusEffectDataById == null)
			{
				return numStacks;
			}
			if (statusEffectDataById.IsPropagatable() && (int)statusEffectDataById.GetDisplayCategory() == 1)
			{
				return numStacks + myStacks;
			}
			return numStacks;
		}
	}
	internal class StatusEffectScourgeState : StatusEffectState, IDamageStatusEffect
	{
		public const string StatusId = "scourge";

		private CharacterState? associatedCharacter;

		private int stacks;

		public override bool TestTrigger(InputTriggerParams inputTriggerParams, OutputTriggerParams outputTriggerParams, ICoreGameManagers coreGameManagers)
		{
			if ((Object)(object)inputTriggerParams.associatedCharacter != (Object)null && inputTriggerParams.associatedCharacter.IsAlive)
			{
				associatedCharacter = inputTriggerParams.associatedCharacter;
			}
			else
			{
				associatedCharacter = null;
			}
			CharacterState val = associatedCharacter;
			stacks = (((Object)(object)val != (Object)null) ? val.GetStatusEffectStacks(((StatusEffectState)this).GetStatusId()) : 0);
			if (stacks > 0)
			{
				return (Object)(object)associatedCharacter != (Object)null;
			}
			return false;
		}

		protected override IEnumerator OnTriggered(InputTriggerParams inputTriggerParams, OutputTriggerParams outputTriggerParams, ICoreGameManagers coreGameManagers)
		{
			CoreSignals.DamageAppliedPlaySound.Dispatch((Type)9);
			CombatManager combatManager = coreGameManagers.GetCombatManager();
			int damageAmount = GetDamageAmount(stacks);
			CharacterState val = associatedCharacter;
			ApplyDamageToTargetParameters val2 = new ApplyDamageToTargetParameters
			{
				damageType = (Type)0
			};
			StatusEffectData sourceStatusEffectData = ((StatusEffectState)this).GetSourceStatusEffectData();
			val2.affectedVfx = ((sourceStatusEffectData != null) ? sourceStatusEffectData.GetOnAffectedVFX() : null);
			val2.relicState = inputTriggerParams.suppressingRelic;
			yield return combatManager.ApplyDamageToTarget(damageAmount, val, val2);
		}

		public override int GetEffectMagnitude(int stacks = 1)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return (((StatusEffectState)this).GetParamInt() + base.relicManager.GetModifiedStatusMagnitudePerStack("mt2_sandscourged.plugin_scourge", ((StatusEffectState)this).GetAssociatedCharacter().GetTeamType())) * stacks;
		}

		private int GetDamageAmount(int stacks)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			List<StatusEffectStack> source = new List<StatusEffectStack>();
			UsingGenericPoolObject<List<StatusEffectStack>> list = GenericPools.GetList<StatusEffectStack>(ref source);
			try
			{
				((StatusEffectState)this).GetAssociatedCharacter().GetStatusEffects(ref source, false);
				num = source.Where((StatusEffectStack s) => (int)s.State.GetDisplayCategory() == 1).Count();
			}
			finally
			{
				((IDisposable)list/*cast due to .constrained prefix*/).Dispose();
			}
			return (((StatusEffectState)this).GetParamInt() + base.relicManager.GetModifiedStatusMagnitudePerStack("mt2_sandscourged.plugin_scourge", ((StatusEffectState)this).GetAssociatedCharacter().GetTeamType())) * num * stacks;
		}
	}
	public static class TrackedValueFunctions
	{
		internal static int CountCardsInHand(StatValueData _, IReadOnlyDictionary<CardState, CardStatsEntry> deckStats, ICoreGameManagers coreGameManagers)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return IEnumerableUtility.Count<CardState>(coreGameManagers.GetCardManager().GetHand(false), (Func<CardState, bool>)((CardState c) => c != _.cardState));
		}

		internal static int HalfCountCardsInHand(StatValueData _, IReadOnlyDictionary<CardState, CardStatsEntry> deckStats, ICoreGameManagers coreGameManagers)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return CountCardsInHand(_, deckStats, coreGameManagers) / 2;
		}
	}
	[BepInPlugin("mt2_sandscourged.Plugin", "mt2_sandscourged.Plugin", "0.5.5")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static TrackedValueGetter <0>__CountCardsInHand;

			public static TrackedValueGetter <1>__HalfCountCardsInHand;
		}

		internal static ManualLogSource Logger = new ManualLogSource("mt2_sandscourged.Plugin");

		public void Awake()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Railhead.GetBuilder().Configure("mt2_sandscourged.Plugin", (Action<IConfigurationBuilder>)delegate(IConfigurationBuilder c)
			{
				ConfigurationExtensions.AddMergedJsonFile(c, new List<string>(68)
				{
					"json/plugin.json", "json/class.json", "json/champions/champion_Pharaoh.json", "json/champions/champion_Vizier.json", "json/units/unit_OverseerEternal.json", "json/units/unit_ReveredScarab.json", "json/units/unit_GildedScarab.json", "json/units/unit_CursedScarab.json", "json/units/unit_ScarabSwarm.json", "json/units/unit_Wretch.json",
					"json/units/unit_PearlHost.json", "json/units/unit_SphinxHierarch.json", "json/units/unit_TwistedHusk.json", "json/units/unit_ForgottenHulk.json", "json/units/unit_PriestOfLostThoughts.json", "json/units/unit_Revenant.json", "json/units/unit_SuperiorEgo.json", "json/units/unit_Evermaw.json", "json/spells/card_Pitfall.json", "json/spells/card_OblivionSands.json",
					"json/spells/card_Sandstorm.json", "json/spells/card_Rancor.json", "json/spells/card_InMemoriam.json", "json/spells/card_TormentA.json", "json/spells/card_TormentB.json", "json/spells/card_TormentC.json", "json/spells/card_TormentD.json", "json/spells/card_TormentE.json", "json/spells/card_Desiccate.json", "json/spells/card_Efface.json",
					"json/spells/card_Beseech.json", "json/spells/card_Jinx.json", "json/spells/card_Malediction.json", "json/spells/card_SpikeOfTheScourged.json", "json/spells/card_Idolize.json", "json/spells/card_Expose.json", "json/spells/card_PartTheStorm.json", "json/spells/card_GravenRite.json", "json/spells/card_ForgottenTome.json", "json/spells/card_SelectiveMemory.json",
					"json/spells/card_PainfulMemories.json", "json/equipments/equipment_ScryingEye.json", "json/equipments/equipment_PearlTap.json", "json/equipments/equipment_SpearOfTheDeserted.json", "json/equipments/equipment_CorruptedSceptre.json", "json/rooms/room_OblivionChamber.json", "json/rooms/room_ScarabPit.json", "json/blights/card_PlagueOfScarabs.json", "json/blights/card_PlagueOfBlood.json", "json/blights/card_PlagueOfGnarling.json",
					"json/scourges/card_Vexation.json", "json/relics/relic_WornHourglass.json", "json/relics/relic_CarnelianMask.json", "json/relics/relic_CursedTablet.json", "json/relics/relic_BrokenSeal.json", "json/relics/relic_EvokingFlute.json", "json/relics/relic_OblivionCrook.json", "json/relics/relic_ShiningPearl.json", "json/relics/relic_TwistedReed.json", "json/relics/relic_CanopicJar.json",
					"json/relics/relic_PolishedIdol.json", "json/relics/relic_SandBowl.json", "json/enhancers/enhancer_Scarabstone.json", "json/status_effects/hex.json", "json/status_effects/scourge.json", "json/card_effects/PurgeCardFromHand.json", "json/card_traits/ScalingByHandCount.json", "json/tracked_values/tracked_values.json"
				});
			});
			Logger.LogInfo((object)"Plugin mt2_sandscourged.Plugin is loaded!");
			Railend.ConfigurePostAction((Action<Container>)delegate(Container c)
			{
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Expected O, but got Unknown
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: 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_015f: Expected O, but got Unknown
				IRegister<CardPool> instance = c.GetInstance<IRegister<CardPool>>();
				string id = StringExtensions.GetId("mt2_sandscourged.Plugin", "CardPool", "TormentPool");
				CardTraitScalingAddBattleCardToHandFromPool.paramCardPool = IEnumerableUtility.GetValueOrDefault<string, CardPool>((IDictionary<string, CardPool>)instance, id, (CardPool)null);
				SaveManager val = default(SaveManager);
				IRegister<TrackedValueType> trackedValueRegister;
				if (!c.GetInstance<GameDataClient>().TryGetProvider<SaveManager>(ref val))
				{
					Logger.LogError((object)"Failed to get SaveManager instance please report this https://github.com/Monster-Train-2-Modding-Group/Balance-Configurator/issues");
				}
				else
				{
					AllGameData allGameData = val.GetAllGameData();
					List<CardData> list = new List<CardData>(4)
					{
						allGameData.FindCardDataByName("mt2_sandscourged.Plugin-Card-Vexation"),
						allGameData.FindCardDataByName("mt2_sandscourged.Plugin-Card-PlagueOfBlood"),
						allGameData.FindCardDataByName("mt2_sandscourged.Plugin-Card-PlagueOfScarabs"),
						allGameData.FindCardDataByName("mt2_sandscourged.Plugin-Card-PlagueOfGnarling")
					};
					BalanceData balanceData = allGameData.GetBalanceData();
					object obj = SafeGetField(balanceData, "cardsThatResolveSimultaneouslyOnUnplayed");
					List<CardData> simultaneousReserveCards = obj as List<CardData>;
					if (simultaneousReserveCards == null)
					{
						Logger.LogError((object)"Couldn't find simultaneous reserve cards");
					}
					else
					{
						list.ForEach(delegate(CardData? val6)
						{
							IEnumerableUtility.AddIfNotNull<CardData>(simultaneousReserveCards, val6);
						});
						SafeSetField<BalanceData>(balanceData, "cardsThatResolveSimultaneouslyOnUnplayed", simultaneousReserveCards);
						trackedValueRegister = c.GetInstance<IRegister<TrackedValueType>>();
						TrackedValueType val2 = GetTrackedValueType("CardsInHand");
						object obj2 = <>O.<0>__CountCardsInHand;
						if (obj2 == null)
						{
							TrackedValueGetter val3 = TrackedValueFunctions.CountCardsInHand;
							<>O.<0>__CountCardsInHand = val3;
							obj2 = (object)val3;
						}
						TrackedValueTypeExtensions.SetTrackedValueGetter(val2, (TrackedValueGetter)obj2);
						TrackedValueType val4 = GetTrackedValueType("HalfCardsInHand");
						object obj3 = <>O.<1>__HalfCountCardsInHand;
						if (obj3 == null)
						{
							TrackedValueGetter val5 = TrackedValueFunctions.HalfCountCardsInHand;
							<>O.<1>__HalfCountCardsInHand = val5;
							obj3 = (object)val5;
						}
						TrackedValueTypeExtensions.SetTrackedValueGetter(val4, (TrackedValueGetter)obj3);
					}
				}
				TrackedValueType GetTrackedValueType(string text)
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					return IEnumerableUtility.GetValueOrDefault<string, TrackedValueType>((IDictionary<string, TrackedValueType>)trackedValueRegister, StringExtensions.GetId("mt2_sandscourged.Plugin", "TrackedValueTypeEnum", text), (TrackedValueType)0);
				}
			});
			Utilities.SetupTraitTooltips(((object)this).GetType().Assembly);
			Utilities.SetupCardEffectTooltips(((object)this).GetType().Assembly);
			new Harmony("mt2_sandscourged.Plugin").PatchAll();
		}

		private void SafeSetField<T>(T? data, string field, object? obj)
		{
			if (data == null)
			{
				Logger.LogError((object)"Internal Error data is null");
				throw new ArgumentNullException("data");
			}
			if (obj == null)
			{
				Logger.LogWarning((object)("Not setting " + typeof(T).Name + " field " + field + " because the value to set is null (value specified may be invalid or field not present)"));
				return;
			}
			try
			{
				Logger.LogDebug((object)$"Setting {typeof(T).Name} field {field} to {obj}");
				AccessTools.Field(data.GetType(), field).SetValue(data, obj);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not set " + typeof(T).Name + " field " + field + " because of an exception " + ex.Message));
			}
		}

		private object? SafeGetField(BalanceData balanceData, string field)
		{
			try
			{
				Logger.LogDebug((object)("Getting BalanceData field " + field));
				return AccessTools.Field(((object)balanceData).GetType(), field).GetValue(balanceData);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not get BalanceData field " + field + " because of an exception " + ex.Message));
			}
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mt2_sandscourged.Plugin";

		public const string PLUGIN_NAME = "mt2_sandscourged.Plugin";

		public const string PLUGIN_VERSION = "0.5.5";
	}
}