Decompiled source of KraftsCardBalancer v0.11.0

KraftsCardBalancer.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using CardsPlusPlugin.Cards.Cyberpunk;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RarityLib.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("KraftsCardBalancer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KraftsCardBalancer")]
[assembly: AssemblyTitle("KraftsCardBalancer")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace CardBalance
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Card.Balance", "Card Balance", "0.11.0")]
	[BepInProcess("Rounds.exe")]
	public class CardBalance : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(QuickhackMenuOption))]
		public static class QuickhackMenuOptionPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("Awake")]
			public static void AwakePrefix()
			{
				QuickhackMenuOption.Costs[(QuickhackType)1] = 2;
				QuickhackMenuOption.Costs[(QuickhackType)4] = 4;
			}
		}

		[HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")]
		private class Patch_ApplyCardStats_ApplyStats
		{
			private static void Prefix(ApplyCardStats __instance)
			{
				CardInfo component = ((Component)__instance).GetComponent<CardInfo>();
				FieldRef<ApplyCardStats, Player> val = AccessTools.FieldRefAccess<ApplyCardStats, Player>("playerToUpgrade");
				Player val2 = val.Invoke(__instance);
				if ((Object)(object)component != (Object)null && (Object)(object)val2 != (Object)null)
				{
					UpdateCardStats(component);
				}
			}

			private static void Postfix(ApplyCardStats __instance)
			{
				CardInfo component = ((Component)__instance).GetComponent<CardInfo>();
				FieldRef<ApplyCardStats, Player> val = AccessTools.FieldRefAccess<ApplyCardStats, Player>("playerToUpgrade");
				Player val2 = val.Invoke(__instance);
				Gun componentInChildren = ((Component)component).GetComponentInChildren<Gun>();
				Gun component2 = ((Component)((Component)val2).GetComponent<Holding>().holdable).GetComponent<Gun>();
			}
		}

		private const string ModId = "Card.Balance";

		private const string ModName = "Card Balance";

		public const string Version = "0.11.0";

		public static bool isDebug = false;

		private static Dictionary<string, List<CardInfoStat>> OriginalStats = new Dictionary<string, List<CardInfoStat>>();

		private static Dictionary<string, string> OriginalDescriptions = new Dictionary<string, string>();

		public static Dictionary<string, ConfigEntry<string>> CardRarities = new Dictionary<string, ConfigEntry<string>>();

		public static Dictionary<string, Rarity> DefaultRarities = new Dictionary<string, Rarity>();

		public static Dictionary<string, TextMeshProUGUI> CardRaritysTexts = new Dictionary<string, TextMeshProUGUI>();

		public static Dictionary<string, List<CardInfo>> ModCards = new Dictionary<string, List<CardInfo>>();

		private static readonly Dictionary<string, Action<CardInfo>> CardModifiers = new Dictionary<string, Action<CardInfo>>(StringComparer.InvariantCultureIgnoreCase)
		{
			["BARRAGE"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "DMG", "-25%");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.75f;
			},
			["BOMBS AWAY"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Health", "60%");
				CharacterStatModifiers componentInChildren22 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren22.health *= 1.23f;
			},
			["BOUNCY"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Bullet Bounces", "+3");
				Gun componentInChildren21 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren21.reflects++;
			},
			["BUCKSHOT"] = delegate(CardInfo card)
			{
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Bullets", "+10");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "Ammo", "+10");
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "DMG", "-10%");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.9f;
				((Component)card).GetComponentInChildren<Gun>().numberOfProjectiles = 10;
				((Component)card).GetComponentInChildren<Gun>().destroyBulletAfter = 0.15f;
				((Component)card).GetComponentInChildren<Gun>().ammo = 10;
				card.rarity = (Rarity)2;
				card.allowMultiple = false;
			},
			["BURST"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "DMG", "-20%");
				Gun componentInChildren20 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren20.bulletDamageMultiplier *= 2f;
			},
			["CHASE"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), -1, true, "Speed", "+25%");
				CharacterStatModifiers componentInChildren19 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren19.movementSpeed *= 1.25f;
			},
			["CHILLING PRESENCE"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)1;
			},
			["DECAY"] = delegate(CardInfo card)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)2;
			},
			["DEFENDER"] = delegate(CardInfo card)
			{
				Block componentInChildren18 = ((Component)card).GetComponentInChildren<Block>();
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-70%");
				componentInChildren18.cdMultiplier = 0.3f;
				card.allowMultiple = false;
			},
			["Demonic pact"] = delegate(CardInfo card)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)1;
			},
			["EMP"] = delegate(CardInfo card)
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-30%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "HP", "+30%");
				((Component)card).GetComponentInChildren<Block>().cdMultiplier = 0.7f;
				card.rarity = (Rarity)0;
			},
			["EMPOWER"] = delegate(CardInfo card)
			{
				card.cardDestription = "Blocking empowers the next shot";
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Movement Speed", "+35%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, true, "DMG", "+35%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.25s");
				CharacterStatModifiers componentInChildren16 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren16.movementSpeed *= 1.35f;
				Gun componentInChildren17 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren17.damage *= 1.35f;
				card.allowMultiple = false;
			},
			["Frost slam"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+50%");
				CharacterStatModifiers componentInChildren15 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren15.health *= 1.15f;
			},
			["GROW"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)2;
				card.allowMultiple = false;
			},
			["Healing field"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-30%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "HP", "+30%");
				((Component)card).GetComponentInChildren<Block>().cdMultiplier = 0.7f;
				((Component)card).GetComponentInChildren<Block>().cdAdd = 0f;
			},
			["HOMING"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "DMG", "+10%");
				((Component)card).GetComponentInChildren<Gun>().damage = 1.1f;
			},
			["HUGE"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+100%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Size", "+25%");
				CharacterStatModifiers componentInChildren13 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren13.health *= 1.11f;
				CharacterStatModifiers componentInChildren14 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren14.sizeMultiplier *= 1.05f;
			},
			["IMPLODE"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "DMG", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.25s");
				Gun componentInChildren12 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren12.damage *= 1.5f;
			},
			["LIFESTEAL"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)1;
			},
			["PARASITE"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "DMG", "+60%");
				((Component)card).GetComponentInChildren<Gun>().damage = 1.6f;
			},
			["PHOENIX"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, false, "HP", "-80%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 0.2f;
				CharacterStatModifiers componentInChildren11 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren11.sizeMultiplier *= 1.15f;
				card.allowMultiple = false;
			},
			["POISON"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "Bullets", "-2");
				Gun componentInChildren10 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren10.ammo -= 2;
			},
			["Radar shot"] = delegate(CardInfo card)
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-30%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "HP", "+30%");
				((Component)card).GetComponentInChildren<Block>().cdMultiplier = 0.7f;
				card.rarity = (Rarity)0;
			},
			["Radiance"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)1;
			},
			["Refresh"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)0;
			},
			["Remote"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+100%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "Bullet Speed", "-40%");
				CharacterStatModifiers componentInChildren9 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren9.health *= 2f;
				((Component)card).GetComponentInChildren<Gun>().reloadTimeAdd = 0f;
			},
			["Riccochet"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "DMG", "+60%");
				Gun componentInChildren8 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren8.damage *= 1.6f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 1f;
			},
			["Scavenger"] = delegate(CardInfo card)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				card.rarity = (Rarity)2;
				card.allowMultiple = false;
			},
			["Shield Charge"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+40%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.25s");
				CharacterStatModifiers componentInChildren7 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren7.health *= 1.4f;
			},
			["Shields Up"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "Reload time", "+0.5s");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.5s");
				CharacterStatModifiers componentInChildren6 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren6.health *= 1.5f;
			},
			["Shockwave"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "Movement Speed", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.25s");
				CharacterStatModifiers componentInChildren5 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren5.movementSpeed *= 1.5f;
			},
			["Sneaky"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "DMG", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Reload time", "+0.25s");
				((Component)card).GetComponentInChildren<Gun>().damage = 1.5f;
			},
			["Tactical Reload"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Movement Speed", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block cooldown", "+0.25s");
				CharacterStatModifiers componentInChildren4 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
				componentInChildren4.movementSpeed *= 1.5f;
			},
			["Teleport"] = delegate(CardInfo card)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-50%");
				((Component)card).GetComponentInChildren<Block>().cdMultiplier = 0.5f;
				card.rarity = (Rarity)1;
				card.allowMultiple = false;
			},
			["Actual Bullets"] = delegate(CardInfo card)
			{
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Bullet Speed", "+1200%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "DMG", "-25%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Reload Time", "+0.75s");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.75f;
				card.rarity = (Rarity)1;
				card.allowMultiple = false;
			},
			["Ammunition Crate"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Ammo", "+10");
				((Component)card).GetComponentInChildren<Gun>().ammo = 4;
			},
			["Atomic Rounds"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Ammo", "1");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "ATKSPD", "-95%");
				((Component)card).GetComponentInChildren<Gun>().ammo = -1000;
				((Component)card).GetComponentInChildren<Gun>().damage = 5f;
				((Component)card).GetComponentInChildren<Gun>().explodeNearEnemyRange = 0f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 30f;
				((Component)card).GetComponentInChildren<Gun>().dontAllowAutoFire = true;
			},
			["Firepower Tonic"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 3, true, "Reload Time", "-30%");
				((Component)card).GetComponentInChildren<Gun>().reloadTime = 0.7f;
				Gun componentInChildren3 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren3.ammo = componentInChildren3.ammo;
			},
			["Health Tonic"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "HP", "+70%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, true, "Reload Time", "-15%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 1.7f;
				((Component)card).GetComponentInChildren<Gun>().reloadTime = 0.85f;
			},
			["Pack-A-Power"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, false, "HP", "-50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "Block Cooldown", "+1s");
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "All stats", "Power Up");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, true, "", "");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1.5f;
				((Component)card).GetComponentInChildren<Block>().cdAdd = 1f;
				((Component)card).GetComponentInChildren<Gun>().damage = 1.5f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 0.75f;
				((Component)card).GetComponentInChildren<Gun>().reloadTimeAdd = 0f;
				((Component)card).GetComponentInChildren<Gun>().reloadTime = 0.8f;
				Gun componentInChildren = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren.numberOfProjectiles -= 2;
				Gun componentInChildren2 = ((Component)card).GetComponentInChildren<Gun>();
				componentInChildren2.spread *= 0f;
			},
			["Sawed Off Barrel"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Movement Speed", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "DMG", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "ATKSPD", "+75%");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, false, "Spread", "+10%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1.5f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().jump = 1f;
				((Component)card).GetComponentInChildren<Gun>().damage = 1.5f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 0.66f;
				((Component)card).GetComponentInChildren<Gun>().spread = 0.1f;
			},
			["AA-12 Shotgun"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "ATKSPD", "+25%");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, false, "DMG", "-50%");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.5f;
				((Component)card).GetComponentInChildren<Gun>().projectileSpeed = 2.5f;
				((Component)card).GetComponentInChildren<Gun>().destroyBulletAfter = 0.1f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 0.75f;
				((Component)card).GetComponentInChildren<Gun>().gravity = 1f;
				card.allowMultiple = false;
			},
			["Ammo Enthusiast"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Ammo", "+20");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "Reload Time", "+1s");
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "", "");
				((Component)card).GetComponentInChildren<Gun>().ammo = 20;
				((Component)card).GetComponentInChildren<Gun>().reloadTimeAdd = 1f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1f;
			},
			["Angelic Burst"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "Reload Time", "0.75s");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, true, "", "");
				((Component)card).GetComponentInChildren<Gun>().damage = 1f;
			},
			["Anti Material Rifle"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "Bullet Speed", "+1000%");
				ModifyInfoStat(card, card.cardStats.ToList(), 4, false, "ATKSPD", "-80%");
				((Component)card).GetComponentInChildren<Gun>().reloadTime = 1f;
				((Component)card).GetComponentInChildren<Gun>().projectileSpeed = 10f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 5f;
				((Component)card).GetComponentInChildren<Gun>().damage = 1f;
				((Component)card).GetComponentInChildren<Gun>().bulletDamageMultiplier = 4f;
			},
			["Big Bang"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "DMG", "+150%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "ATKSPD", "-75%");
				((Component)card).GetComponentInChildren<Gun>().damage = 2.5f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 4f;
			},
			["Coilgun"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "", "");
				((Component)card).GetComponentInChildren<Gun>().damage = 1f;
			},
			["No Scope"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "DMG", "+100%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "Bullet Speed", "+200%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Spread", "+50%");
				((Component)card).GetComponentInChildren<Gun>().damage = 2f;
				((Component)card).GetComponentInChildren<Gun>().spread = 0.5f;
			},
			["Nuclear"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "DMG", "+400%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "ATKSPD", "-90%");
				((Component)card).GetComponentInChildren<Gun>().damage = 5f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 10f;
			},
			["P90"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "Projectile Speed", "+250%");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, false, "DMG", "-85%");
				ModifyInfoStat(card, card.cardStats.ToList(), 4, false, "Relaod Time", "+33%");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.85f;
				((Component)card).GetComponentInChildren<Gun>().projectileSpeed = 2.5f;
			},
			["Vector"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 2, false, "DMG", "-75%");
				((Component)card).GetComponentInChildren<Gun>().damage = 0.25f;
			},
			["Purple Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Life Steal", "+250%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().lifeSteal = 2.5f;
			},
			["Red Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Damage", "+75%");
				((Component)card).GetComponentInChildren<Gun>().damage = 1.75f;
			},
			["Yellow Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "ATKSPD", "+150%");
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 0.4f;
			},
			["Green Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Movement Speed", "+60%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1.6f;
			},
			["Blue Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Health", "+80%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 1.8f;
			},
			["White Pill"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Block cooldown", "-50%");
				((Component)card).GetComponentInChildren<Block>().cdMultiplier = 0.5f;
			},
			["Black Tar Heroin"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Health", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, true, "Movement Speed", "+50%");
				ModifyInfoStat(card, card.cardStats.ToList(), 2, true, "Damage", "+30%");
				ModifyInfoStat(card, card.cardStats.ToList(), 3, true, "ATKSPD", "+75%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().lifeSteal = 0f;
				((Component)card).GetComponentInChildren<Gun>().damage = 1.3f;
				((Component)card).GetComponentInChildren<Gun>().attackSpeed = 0.625f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1.5f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().jump = 1f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 1.5f;
			},
			["Short Circuit"] = delegate(CardInfo card)
			{
				card.cardDestription = "Shroomy Made me do it\n<color=\"purple\">Quickhack</color>\n<color=\"red\">3 RAM</color>\nStun target for 1 seconds";
			},
			["QuickReflexes"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, false, "Health", "-50%");
				ModifyInfoStat(card, card.cardStats.ToList(), -1, false, "Block Cooldown", "+3s");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 0.5f;
				((Component)card).GetComponentInChildren<Block>().cdAdd = 3f;
			},
			["Turtle"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), 0, true, "Damage Taken", "-70%");
				ModifyInfoStat(card, card.cardStats.ToList(), 1, false, "Movement Speed", "-40%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().health = 3.33f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().sizeMultiplier = 0.83f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 0.6f;
				((Component)card).GetComponentInChildren<Block>().cooldown = 0f;
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().jump = 0.75f;
			},
			["Low Gravity"] = delegate(CardInfo card)
			{
				ModifyInfoStat(card, card.cardStats.ToList(), -1, true, "Movement Speed", "+50%");
				((Component)card).GetComponentInChildren<CharacterStatModifiers>().movementSpeed = 1.5f;
			}
		};

		private static readonly Regex sanitizeRegex = new Regex("[\\n\\t\\\\\"'\\[\\]]+", RegexOptions.Compiled);

		public static List<CardInfo> allCards
		{
			get
			{
				List<CardInfo> list = CardManager.cards.Values.Select((Card v) => v.cardInfo).ToList();
				list.Sort((CardInfo c1, CardInfo c2) => c1.cardName.CompareTo(c2.cardName));
				return list;
			}
			set
			{
			}
		}

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Card.Balance").PatchAll();
		}

		public void Start()
		{
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 60, (Action)delegate
			{
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				foreach (CardInfo card in allCards)
				{
					try
					{
						if (!OriginalStats.ContainsKey(card.cardName))
						{
							OriginalStats[card.cardName] = card.cardStats.ToList();
							OriginalDescriptions[card.cardName] = card.cardDestription;
						}
						string text = ((IEnumerable<Card>)CardManager.cards.Values).FirstOrDefault((Func<Card, bool>)((Card c) => (Object)(object)c.cardInfo == (Object)(object)card))?.category ?? "Unknown";
						string text2 = SanitizeText(((Object)card).name);
						UpdateCardStats(card);
						CardRarities[text2] = ((BaseUnityPlugin)this).Config.Bind<string>("Card.Balance", text2, "DEFAULT", "Rarity value of card " + card.cardName + " from " + text);
						DefaultRarities[text2] = card.rarity;
						Rarity val = RarityUtils.GetRarity(CardRarities[text2].Value);
						if ((int)val == 0 && CardRarities[text2].Value != "Common")
						{
							val = DefaultRarities[text2];
							CardRarities[text2].Value = "DEFAULT";
						}
						card.rarity = val;
						if (!ModCards.ContainsKey(text))
						{
							ModCards.Add(text, new List<CardInfo>());
						}
						ModCards[text].Add(card);
					}
					catch (Exception arg)
					{
						if (isDebug)
						{
							Debug.LogError((object)$"[CardBalancer] Failed processing card {card?.cardName}: {arg}");
						}
					}
				}
			});
		}

		public static void UpdateCardStats(CardInfo card)
		{
			if (OriginalStats.ContainsKey(card.cardName))
			{
				card.cardStats = OriginalStats[card.cardName].ToList().ToArray();
			}
			else
			{
				card.cardStats = card.cardStats.ToList().ToArray();
			}
			card.cardDestription = (OriginalDescriptions.ContainsKey(card.cardName) ? OriginalDescriptions[card.cardName] : card.cardDestription);
			if (CardModifiers.TryGetValue(card.cardName, out Action<CardInfo> value))
			{
				value(card);
			}
			if (isDebug)
			{
				displayStatChanges(card);
			}
		}

		private static bool AreEqual(object obj1, object obj2)
		{
			if (obj1 is Array array && obj2 is Array array2)
			{
				return array.Length == array2.Length && array.Cast<object>().SequenceEqual(array2.Cast<object>());
			}
			if (obj1 is IEnumerable<object> first && obj2 is IEnumerable<object> second)
			{
				return first.SequenceEqual(second);
			}
			return obj1.Equals(obj2);
		}

		public static void displayStatChanges(CardInfo card)
		{
			CardInfo val = ((IEnumerable<CardInfo>)allCards).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => c.cardName == "QUICK RELOAD"));
			Gun componentInChildren = ((Component)card).GetComponentInChildren<Gun>();
			Gun componentInChildren2 = ((Component)val).GetComponentInChildren<Gun>();
			componentInChildren2.reloadTime = 1f;
			CharacterStatModifiers componentInChildren3 = ((Component)card).GetComponentInChildren<CharacterStatModifiers>();
			CharacterStatModifiers componentInChildren4 = ((Component)val).GetComponentInChildren<CharacterStatModifiers>();
			Gun componentInChildren5 = ((Component)card).GetComponentInChildren<Gun>();
			Gun componentInChildren6 = ((Component)val).GetComponentInChildren<Gun>();
			Debug.Log((object)("\n--------------- Card: " + card.cardName + "-------------------------\n"));
			if ((Object)(object)componentInChildren5 != (Object)null)
			{
				FieldInfo[] fields = ((object)componentInChildren5).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo[] array = fields;
				foreach (FieldInfo fieldInfo in array)
				{
					object value = fieldInfo.GetValue(componentInChildren5);
					object value2 = fieldInfo.GetValue(componentInChildren6);
					if (value != null && value2 != null && !AreEqual(value, value2))
					{
						Debug.Log((object)$"Gun Stat: {fieldInfo.Name} = {value} Default = {value2}");
					}
				}
			}
			else
			{
				Debug.Log((object)"No component found on this card.");
			}
		}

		public static void ModifyInfoStat(CardInfo card, List<CardInfoStat> stats, int index, bool? isPositive = null, string stat = null, string amount = null)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00c1: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			if (stat == "" || amount == "")
			{
				stats.RemoveAt(index);
			}
			else if (index == -1)
			{
				stats.Add(new CardInfoStat
				{
					positive = (isPositive ?? true),
					stat = stat,
					amount = amount,
					simepleAmount = (SimpleAmount)0
				});
			}
			else
			{
				stats[index] = new CardInfoStat
				{
					positive = (isPositive ?? stats[index].positive),
					stat = (stat ?? stats[index].stat),
					amount = (amount ?? stats[index].amount),
					simepleAmount = (SimpleAmount)0
				};
			}
			card.cardStats = stats.ToArray();
		}

		internal static string SanitizeText(string text)
		{
			return sanitizeRegex.Replace(text, "");
		}
	}
	[HarmonyPatch(typeof(Block), "Cooldown")]
	public class Block_Cooldown_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(ref float __result, Block __instance)
		{
			__result = __instance.cooldown * __instance.cdMultiplier + __instance.cdAdd;
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(ToggleCardsMenuHandler), "UpdateVisualsCardObj")]
	public class Patch
	{
		public static void Prefix(GameObject cardObject)
		{
			GameObject cardObject2 = cardObject;
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 15, (Action)delegate
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Expected O, but got Unknown
				if (ToggleCardsMenuHandler.cardMenuCanvas.gameObject.activeSelf)
				{
					string text = ((Object)cardObject2.GetComponentInChildren<CardInfo>()).name.Substring(0, ((Object)cardObject2.GetComponentInChildren<CardInfo>()).name.Length - 7);
					string key = CardBalance.SanitizeText(text);
					CardInfo componentInChildren = cardObject2.GetComponentInChildren<CardInfo>();
					componentInChildren.rarity = ((CardBalance.CardRarities[key].Value != "DEFAULT") ? RarityUtils.GetRarity(CardBalance.CardRarities[key].Value) : CardBalance.DefaultRarities[key]);
					List<CardInfoStat> list = new List<CardInfoStat>(componentInChildren.cardStats);
					CardBalance.UpdateCardStats(componentInChildren);
					cardObject2.GetComponentsInChildren<CardRarityColor>().ToList().ForEach(delegate(CardRarityColor r)
					{
						r.Toggle(true);
					});
					if (list.Count > 0)
					{
						CardInfoDisplayer componentInChildren2 = cardObject2.GetComponentInChildren<CardInfoDisplayer>();
						if ((Object)(object)componentInChildren2 != (Object)null && componentInChildren.cardStats != null)
						{
							foreach (Transform item in componentInChildren2.grid.transform)
							{
								Transform val = item;
								if ((Object)(object)val != (Object)(object)((TMP_Text)componentInChildren2.effectText).transform)
								{
									Object.Destroy((Object)(object)((Component)val).gameObject);
								}
							}
							componentInChildren2.DrawCard(componentInChildren.cardStats, componentInChildren.cardName, componentInChildren.cardDestription, componentInChildren.sprite, false);
						}
					}
				}
			});
		}
	}
}