Decompiled source of TenkyuChimata v0.0.1

TenkyuChimata_windows.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using JetBrains.Annotations;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Battle.Interactions;
using LBoL.Core.Cards;
using LBoL.Core.Dialogs;
using LBoL.Core.Randoms;
using LBoL.Core.Stations;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.Cards;
using LBoL.EntityLib.Cards.Character.Cirno;
using LBoL.EntityLib.Cards.Character.Koishi;
using LBoL.EntityLib.Cards.Character.Marisa;
using LBoL.EntityLib.Cards.Character.Reimu;
using LBoL.EntityLib.Cards.Character.Sakuya;
using LBoL.EntityLib.Cards.Neutral.Black;
using LBoL.EntityLib.Cards.Neutral.TwoColor;
using LBoL.EntityLib.Cards.Neutral.White;
using LBoL.EntityLib.EnemyUnits.Character;
using LBoL.EntityLib.EnemyUnits.Lore;
using LBoL.EntityLib.EnemyUnits.Normal;
using LBoL.EntityLib.EnemyUnits.Normal.Drones;
using LBoL.EntityLib.EnemyUnits.Normal.Maoyus;
using LBoL.EntityLib.EnemyUnits.Normal.Ravens;
using LBoL.EntityLib.EnemyUnits.Normal.Shenlings;
using LBoL.EntityLib.EnemyUnits.Normal.Yinyangyus;
using LBoL.EntityLib.Exhibits;
using LBoL.EntityLib.StatusEffects.Basic;
using LBoL.EntityLib.StatusEffects.Enemy;
using LBoL.EntityLib.StatusEffects.Enemy.Seija;
using LBoL.EntityLib.StatusEffects.ExtraTurn;
using LBoL.EntityLib.StatusEffects.Others;
using LBoL.Presentation;
using LBoL.Presentation.UI.Panels;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Resource;
using LBoLEntitySideloader.Utils;
using TMPro;
using TenkyuChimataMod.BattleActions;
using TenkyuChimataMod.Cards;
using TenkyuChimataMod.Cards.Template;
using TenkyuChimataMod.Casino;
using TenkyuChimataMod.Config;
using TenkyuChimataMod.Enemies.Template;
using TenkyuChimataMod.GunName;
using TenkyuChimataMod.ImageLoader;
using TenkyuChimataMod.Localization;
using TenkyuChimataMod.Patches;
using TenkyuChimataMod.StatusEffects;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.UI;
using YamlDotNet.Serialization;

[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 = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("TenkyuChimata_windows")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TenkyuChimata_windows")]
[assembly: AssemblyTitle("TenkyuChimata_windows")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TenkyuChimataMod
{
	[BepInPlugin("author.game.typeofmod.TenkyuChimata", "TenkyuChimataMod", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		public static string modUniqueID = "TenkyuChimataMod";

		public static string playerName = "TenkyuChimata";

		public static bool useInGameModel = false;

		public static string modelName = "TenkyuChimata";

		public static bool modelIsFlipped = true;

		public static List<ManaColor> offColors = new List<ManaColor> { (ManaColor)6 };

		public static ConfigEntry<bool> enableAct1Boss;

		public static CustomConfigEntry<bool> enableAct1BossEntry = new CustomConfigEntry<bool>(value: false, "EnableAct1Boss", "EnableAct1Boss", "Toggle the Act 1 boss. Default: Off");

		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		internal static BatchLocalization unitModelLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(UnitModelTemplate), false);

		internal static TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);

		internal static BatchLocalization exhibitLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(ExhibitTemplate), false);

		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static DirectorySource directorySource = new DirectorySource("author.game.typeofmod.TenkyuChimata", "");

		public static ConfigEntry<string> TenkyuChimataRecords;

		private static object TenkyuChimata()
		{
			throw new NotImplementedException();
		}

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony(modUniqueID);
			val.PatchAll();
			log = ((BaseUnityPlugin)this).Logger;
			enableAct1Boss = ((BaseUnityPlugin)this).Config.Bind<bool>(enableAct1BossEntry.Section, enableAct1BossEntry.Key, enableAct1BossEntry.Value, enableAct1BossEntry.Description);
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			CardIndexGenerator.PromiseClearIndexSet();
			EntityManager.RegisterSelf();
			TenkyuChimataRecords = ((BaseUnityPlugin)this).Config.Bind<string>("Records", "Records", "", "May cause an error if edited manually.");
			Func<Sprite> func = () => ResourceLoader.LoadSprite("BossIcon.png", (IResourceSource)(object)directorySource, (Rect?)null, 1, (Vector2?)null);
			EnemyUnitTemplate.AddBossNodeIcon("TenkyuChimataTakane", func, (Assembly)null);
			CasinoNPCReplacer.EnsureRunning();
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "author.game.typeofmod.TenkyuChimata";

		public const string Name = "TenkyuChimataMod";

		public const string version = "0.0.1";

		public static readonly Harmony harmony = new Harmony("author.game.typeofmod.TenkyuChimata");
	}
	public class TenkyuChimataLoadouts
	{
		public static string UltimateSkillA = "TenkyuChimataUltA";

		public static string UltimateSkillB = "TenkyuChimataUltB";

		public static string ExhibitA = "TenkyuChimataExhibitA";

		public static string ExhibitB = "TenkyuChimataExhibitB";

		public static List<string> DeckA = new List<string>
		{
			"Shoot", "Shoot", "Boundary", "Boundary", "TenkyuChimataAttackR", "TenkyuChimataAttackW", "TenkyuChimataBlockB", "TenkyuChimataBlockU", "TenkyuChimataGainExhibit", "TenkyuChimataCardGeneration",
			"TenkyuChimataCardGeneration2"
		};

		public static List<string> DeckB = new List<string>
		{
			"Shoot", "Shoot", "Boundary", "Boundary", "TenkyuChimataAttackR", "TenkyuChimataAttackW", "TenkyuChimataBlockU", "TenkyuChimataBlockB", "TenkyuChimataGainExhibit", "TenkyuChimataZhaiQuan",
			"TenkyuChimataCardGeneration2"
		};

		public static PlayerUnitConfig playerUnitConfig;

		static TenkyuChimataLoadouts()
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			string modUniqueID = BepinexPlugin.modUniqueID;
			int? num = 10;
			ManaGroup val = default(ManaGroup);
			((ManaGroup)(ref val)).White = 1;
			((ManaGroup)(ref val)).Blue = 1;
			((ManaGroup)(ref val)).Black = 1;
			((ManaGroup)(ref val)).Red = 1;
			((ManaGroup)(ref val)).Green = 0;
			((ManaGroup)(ref val)).Colorless = 0;
			((ManaGroup)(ref val)).Philosophy = 0;
			ManaGroup val2 = val;
			playerUnitConfig = new PlayerUnitConfig(modUniqueID, true, "", 0, 8, num, true, (int?)null, (ManaColor)7, (ManaColor)6, val2, "#1b01ffff", 82, 260, 0, UltimateSkillA, UltimateSkillB, ExhibitA, ExhibitB, (IReadOnlyList<string>)DeckA, (IReadOnlyList<string>)DeckB, 3, 2);
		}
	}
	public sealed class TenkyuChimataModDef : PlayerUnitTemplate
	{
		[EntityLogic(typeof(TenkyuChimataModDef))]
		public sealed class TenkyuChimataMod : PlayerUnit
		{
			public string LocShortcut(string key, bool decorated, bool required)
			{
				return ((GameEntity)this).LocalizeProperty(key, decorated, required);
			}

			protected override void OnEnterGameRun(GameRunController gameRun)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Expected O, but got Unknown
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				((GameEntity)this).GameRun.TrueEndingProviders.Add((GameEntity)(object)this);
				bool flag = gameRun.CurrentMap == null;
				GameObject shinObj = new GameObject("Sagume_Debut");
				Object.DontDestroyOnLoad((Object)(object)shinObj);
				if (flag)
				{
					SpriteRenderer val = shinObj.AddComponent<SpriteRenderer>();
					val.sprite = ResourceLoader.LoadSprite("TenkyuChimataSagume.png", (IResourceSource)(object)BepinexPlugin.directorySource, (Rect?)null, 168, (Vector2?)null);
					((Renderer)val).sortingLayerName = "Default";
					((Renderer)val).sortingOrder = 50;
					shinObj.transform.position = new Vector3(3.2f, 0.4f, 0f);
					shinObj.transform.localScale = new Vector3(-1f, 1f, 1f);
				}
				TenkyuChimataTextForcer tenkyuChimataTextForcer = shinObj.AddComponent<TenkyuChimataTextForcer>();
				tenkyuChimataTextForcer.adventureId = "Debut";
				((Unit)this).HandleGameRunEvent<StationEventArgs>(((GameEntity)this).GameRun.StationFinished, (GameEventHandler<StationEventArgs>)delegate
				{
					if ((Object)(object)shinObj != (Object)null)
					{
						Object.Destroy((Object)(object)shinObj);
					}
				});
				GameObject val2 = new GameObject("ShinDebutHandler");
				Object.DontDestroyOnLoad((Object)(object)val2);
				ShinmyoumaruDebutHandler shinmyoumaruDebutHandler = val2.AddComponent<ShinmyoumaruDebutHandler>();
				shinmyoumaruDebutHandler.gameRun = gameRun;
			}
		}

		public class TenkyuChimataTextForcer : MonoBehaviour
		{
			public string adventureId = "Debut";

			private bool _loaded = false;

			private List<(string target, string replacement)> _titleReps = new List<(string, string)>();

			private List<(string target, string replacement)> _npcReps = new List<(string, string)>();

			[Obsolete]
			private void Update()
			{
				if (!ChimataRunTracker.IsChimataRun)
				{
					return;
				}
				if (!CustomEventTextManager2.IsLoaded)
				{
					CustomEventTextManager2.LoadAllCustomYamls();
				}
				if (!_loaded && CustomEventTextManager2.IsLoaded)
				{
					_titleReps.Clear();
					_npcReps.Clear();
					foreach (Dictionary<string, string> value5 in CustomEventTextManager2.MasterTextDict.Values)
					{
						if (value5.TryGetValue("TargetTitle_" + adventureId, out var value) && value5.TryGetValue("Title_" + adventureId, out var value2))
						{
							_titleReps.Add((value.Trim(), value2.Trim()));
						}
						if (value5.TryGetValue("TargetNPC_" + adventureId, out var value3))
						{
							string value4 = null;
							if (!value5.TryGetValue("NPC_" + adventureId, out value4))
							{
								value5.TryGetValue("HostName_" + adventureId, out value4);
							}
							if (!string.IsNullOrEmpty(value4))
							{
								_npcReps.Add((value3.Trim(), value4.Trim()));
							}
						}
					}
					_loaded = true;
				}
				if (!_loaded || (_titleReps.Count == 0 && _npcReps.Count == 0))
				{
					return;
				}
				TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
				foreach (TextMeshProUGUI val in array)
				{
					if (string.IsNullOrWhiteSpace(((TMP_Text)val).text))
					{
						continue;
					}
					string text = Regex.Replace(((TMP_Text)val).text, "<.*?>", string.Empty).Replace("\ufeff", "").Trim();
					foreach (var titleRep in _titleReps)
					{
						if (text == titleRep.target)
						{
							((TMP_Text)val).text = ((TMP_Text)val).text.Replace(titleRep.target, titleRep.replacement);
						}
					}
					foreach (var npcRep in _npcReps)
					{
						if (text == npcRep.target)
						{
							((TMP_Text)val).text = ((TMP_Text)val).text.Replace(npcRep.target, npcRep.replacement);
						}
					}
				}
			}
		}

		public UniTask<Sprite>? LoadSpellPortraitAsync { get; private set; }

		public override IdContainer GetId()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit(BepinexPlugin.modUniqueID);
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)TenkyuChimataLocalization.PlayerUnitBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override PlayerImages LoadPlayerImages()
		{
			return TenkyuChimataImageLoader.LoadPlayerImages(BepinexPlugin.playerName);
		}

		public override PlayerUnitConfig MakeConfig()
		{
			return TenkyuChimataLoadouts.playerUnitConfig;
		}
	}
	[HarmonyPatch(typeof(GameRunController), "Create")]
	public class TrackerCreatePatch
	{
		private static void Postfix(GameRunController __result)
		{
			object obj;
			if (__result == null)
			{
				obj = null;
			}
			else
			{
				PlayerUnit player = __result.Player;
				obj = ((player != null) ? ((GameEntity)player).Id : null);
			}
			ChimataRunTracker.IsChimataRun = (string?)obj == BepinexPlugin.modUniqueID;
			ChimataRunTracker.CurrentRun = __result;
		}
	}
	[HarmonyPatch(typeof(GameRunController), "Restore")]
	public class TrackerRestorePatch
	{
		private static void Postfix(GameRunController __result)
		{
			object obj;
			if (__result == null)
			{
				obj = null;
			}
			else
			{
				PlayerUnit player = __result.Player;
				obj = ((player != null) ? ((GameEntity)player).Id : null);
			}
			ChimataRunTracker.IsChimataRun = (string?)obj == BepinexPlugin.modUniqueID;
			ChimataRunTracker.CurrentRun = __result;
		}
	}
	[HarmonyPatch(typeof(UnitModelConfig), "FromName")]
	public class EraseEirinPatch
	{
		private static void Prefix(ref string Name)
		{
			if (Name == "Eirin" && ChimataRunTracker.IsChimataRun)
			{
				Name = "ThisModelNameDoesNotExist_Null";
			}
		}
	}
	public class ShinmyoumaruDebutHandler : MonoBehaviour
	{
		public GameRunController gameRun;

		private GameObject canvasObj;

		private void Update()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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)
			if (gameRun == null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Station currentStation = gameRun.CurrentStation;
			AdventureStation val = (AdventureStation)(object)((currentStation is AdventureStation) ? currentStation : null);
			bool flag = val != null && val.Adventure.Id == "Debut";
			if (flag && (Object)(object)canvasObj == (Object)null)
			{
				canvasObj = new GameObject("Sagume_TopCanvas");
				Object.DontDestroyOnLoad((Object)(object)canvasObj);
				Canvas val2 = canvasObj.AddComponent<Canvas>();
				val2.renderMode = (RenderMode)0;
				val2.sortingOrder = 32767;
				CanvasScaler val3 = canvasObj.AddComponent<CanvasScaler>();
				val3.uiScaleMode = (ScaleMode)1;
				val3.referenceResolution = new Vector2(1920f, 1080f);
				GameObject val4 = new GameObject("Sagume_Image");
				val4.transform.SetParent(canvasObj.transform, false);
				Image val5 = val4.AddComponent<Image>();
				val5.sprite = ResourceLoader.LoadSprite("TenkyuChimataSagume.png", (IResourceSource)(object)BepinexPlugin.directorySource, (Rect?)null, 84, (Vector2?)null);
				((Graphic)val5).SetNativeSize();
				RectTransform component = val4.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.6f, 0.5f);
				component.anchorMax = new Vector2(0.6f, 0.5f);
				component.pivot = new Vector2(0.5f, 0.5f);
				component.anchoredPosition = Vector2.zero;
				((Transform)component).localScale = new Vector3(-1f, 1f, 1f);
			}
			else if (!flag && (Object)(object)canvasObj != (Object)null)
			{
				Object.Destroy((Object)(object)canvasObj);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if (gameRun.CurrentStage != null && gameRun.CurrentStage.Level > 1)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	[HarmonyPatch(typeof(GameRunController), "EnterMapNode")]
	public class EnterMapNode_Patch
	{
	}
}
namespace TenkyuChimataMod.TenkyuChimataUlt
{
	public sealed class TenkyuChimataUltADef : TenkyuChimataUltTemplate
	{
		public override UltimateSkillConfig MakeConfig()
		{
			UltimateSkillConfig defaulUltConfig = GetDefaulUltConfig();
			defaulUltConfig.Damage = 26;
			defaulUltConfig.Value1 = 50;
			defaulUltConfig.RelativeEffects = new List<string> { "TenkyuChimataShangJin" };
			return defaulUltConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataUltADef))]
	public sealed class TenkyuChimataUltA : UltimateSkill
	{
		public TenkyuChimataUltA()
		{
			((UltimateSkill)this).TargetType = (TargetType)2;
			((UltimateSkill)this).GunName = "ShendengSe2";
		}

		protected override IEnumerable<BattleAction> Actions(UnitSelector selector)
		{
			yield return (BattleAction)(object)PerformAction.Spell((Unit)(object)((UltimateSkill)this).Battle.Player, "弹幕收集狂的妄执");
			foreach (EnemyUnit enemy in ((UltimateSkill)this).Battle.AllAliveEnemies)
			{
				if (((Unit)enemy).IsAlive && !((UltimateSkill)this).Battle.BattleShouldEnd)
				{
					yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataShangJin>((Unit)(object)enemy, (int?)((UltimateSkill)this).Value1, (int?)null, (int?)null, (int?)null, 1f, true);
				}
			}
			yield return (BattleAction)new DamageAction((Unit)(object)((UltimateSkill)this).Owner, (IEnumerable<Unit>)((UltimateSkill)this).Battle.AllAliveEnemies, ((UltimateSkill)this).Damage, "ShendengSe2", (GunType)0);
		}
	}
	public sealed class TenkyuChimataUltBDef : TenkyuChimataUltTemplate
	{
		public override UltimateSkillConfig MakeConfig()
		{
			UltimateSkillConfig defaulUltConfig = GetDefaulUltConfig();
			defaulUltConfig.Damage = 50;
			return defaulUltConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataUltBDef))]
	public sealed class TenkyuChimataUltB : UltimateSkill
	{
		public int MoneyDamage => ((GameEntity)this).GameRun.Money / 10;

		public TenkyuChimataUltB()
		{
			((UltimateSkill)this).TargetType = (TargetType)1;
			((UltimateSkill)this).GunName = "QiannianShenqiSe2";
		}

		protected override IEnumerable<BattleAction> Actions(UnitSelector selector)
		{
			EnemyUnit enemy = selector.GetEnemy(((UltimateSkill)this).Battle);
			yield return (BattleAction)(object)PerformAction.Spell((Unit)(object)((UltimateSkill)this).Battle.Player, "高密度弹幕市场");
			yield return (BattleAction)(object)PerformAction.Animation((Unit)(object)((UltimateSkill)this).Battle.Player, "spell", 1f, (string)null, 0f, -1);
			yield return (BattleAction)new DamageAction((Unit)(object)((UltimateSkill)this).Owner, (Unit)(object)enemy, ((UltimateSkill)this).Damage, "QiannianShenqiSe2", (GunType)0);
			if (((Unit)enemy).IsAlive)
			{
				yield return (BattleAction)new DamageAction((Unit)(object)((UltimateSkill)this).Owner, (Unit)(object)enemy, DamageInfo.Reaction((float)MoneyDamage, false), "Instant", (GunType)0);
				yield return (BattleAction)new LoseMoneyAction(((GameEntity)this).GameRun.Money / 10);
			}
		}
	}
	public class TenkyuChimataUltTemplate : UltimateSkillTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0007: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit(TenkyuChimataDefaultConfig.DefaultID((EntityDefinition)(object)this));
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)TenkyuChimataLocalization.UltimateSkillsBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			return TenkyuChimataImageLoader.LoadUltLoader((UltimateSkillTemplate)(object)this);
		}

		public override UltimateSkillConfig MakeConfig()
		{
			throw new NotImplementedException();
		}

		public UltimateSkillConfig GetDefaulUltConfig()
		{
			return TenkyuChimataDefaultConfig.DefaultUltConfig();
		}
	}
}
namespace TenkyuChimataMod.StatusEffects
{
	public sealed class SihunYuSe1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(SihunYuSe1Def))]
	public sealed class SihunYuSe1 : StatusEffect
	{
		private readonly List<(Type, Type)> _twoPool = new List<(Type, Type)>
		{
			(typeof(RavenWen3), typeof(RavenGuo3)),
			(typeof(MaoyuBlack), typeof(MaoyuBlack))
		};

		private readonly List<Type> _onePool = new List<Type>
		{
			typeof(WhiteFairy),
			typeof(DollBlue),
			typeof(Yaoshi),
			typeof(Scout)
		};

		private readonly List<(Type, Type)> _twoPoolStrong = new List<(Type, Type)>
		{
			(typeof(YinyangyuRed), typeof(YinyangyuBlue)),
			(typeof(Purifier), typeof(Purifier)),
			(typeof(ShenlingWhite), typeof(ShenlingPurple))
		};

		private readonly List<Type> _onePoolStrong = new List<Type>
		{
			typeof(BlackFairy),
			typeof(Terminator),
			typeof(WaterGirl),
			typeof(LangTiangou),
			typeof(YaTiangou),
			typeof(SuwakoLimao)
		};

		private int Counter { get; set; }

		private bool IsStrong { get; set; }

		protected override void OnAdded(Unit unit)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			((StatusEffect)this).OnAdded(unit);
			Counter = 0;
			RandomGen val = new RandomGen(((GameEntity)this).GameRun.FinalBossSeed);
			CollectionsExtensions.Shuffle<(Type, Type)>((IList<(Type, Type)>)_twoPool, val);
			CollectionsExtensions.Shuffle<Type>((IList<Type>)_onePool, val);
			CollectionsExtensions.Shuffle<(Type, Type)>((IList<(Type, Type)>)_twoPoolStrong, val);
			CollectionsExtensions.Shuffle<Type>((IList<Type>)_onePoolStrong, val);
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnEnded, (EventSequencedReactor<UnitEventArgs>)OnOwnerTurnEnded);
			((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)PerformAction.Sfx("GuirenItem", 0f)));
			((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)PerformAction.EffectMessage(unit, "SeijaExhibitManager", "AddExhibit", (object)this)));
		}

		private IEnumerable<BattleAction> OnOwnerTurnEnded(UnitEventArgs args)
		{
			if (((StatusEffect)this).Battle.BattleShouldEnd)
			{
				yield break;
			}
			<>n__0();
			if (Counter % 3 == 0)
			{
				if (!IsStrong)
				{
					IsStrong = true;
					Counter = 0;
				}
				List<(Type, Type)> list = (IsStrong ? _twoPoolStrong : _twoPool);
				int index = Counter / 3 % list.Count;
				var (item, b) = list[index];
				if (!((StatusEffect)this).Battle.IsAnyoneInRootIndex(0))
				{
					yield return (BattleAction)new SpawnEnemyAction((EnemyUnit)((StatusEffect)this).Owner, item, 0, 0f, 0.3f, true);
				}
				if (!((StatusEffect)this).Battle.IsAnyoneInRootIndex(1))
				{
					yield return (BattleAction)new SpawnEnemyAction((EnemyUnit)((StatusEffect)this).Owner, b, 1, 0f, 0.3f, true);
				}
			}
			else
			{
				List<Type> list2 = (IsStrong ? _onePoolStrong : _onePool);
				int index2 = (Counter / 3 * 2 + Counter % 3 - 1) % list2.Count;
				Type enemyType = list2[index2];
				int rootIndex = Counter % 3 + 2;
				if (!((StatusEffect)this).Battle.IsAnyoneInRootIndex(rootIndex))
				{
					yield return (BattleAction)new SpawnEnemyAction((EnemyUnit)((StatusEffect)this).Owner, enemyType, rootIndex, 0f, 0.3f, true);
				}
			}
			int counter = Counter + 1;
			Counter = counter;
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public class TenkyuChimataStatusEffectTemplate : StatusEffectTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0007: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit(TenkyuChimataDefaultConfig.DefaultID((EntityDefinition)(object)this));
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)TenkyuChimataLocalization.StatusEffectsBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			return TenkyuChimataImageLoader.LoadStatusEffectLoader((StatusEffectTemplate)(object)this);
		}

		public override StatusEffectConfig MakeConfig()
		{
			return GetDefaultStatusEffectConfig();
		}

		public static StatusEffectConfig GetDefaultStatusEffectConfig()
		{
			return TenkyuChimataDefaultConfig.DefaultStatusEffectConfig();
		}
	}
	public sealed class TenkyuChimata1011Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimata1011Def))]
	public sealed class TenkyuChimata1011 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnTurnStarted);
		}

		private IEnumerable<BattleAction> OnTurnStarted(UnitEventArgs args)
		{
			<>n__0();
			Card[] array = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.OnlyUncommon, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)null);
			if (array.Length != 0)
			{
				Card[] array2 = array;
				foreach (Card card in array2)
				{
					card.IsExile = true;
				}
				yield return (BattleAction)new AddCardsToDrawZoneAction((IEnumerable<Card>)array, (DrawZoneTarget)2, (AddCardsType)0);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimata1012Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimata1012Def))]
	public sealed class TenkyuChimata1012 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnTurnStarted);
		}

		private IEnumerable<BattleAction> OnTurnStarted(UnitEventArgs args)
		{
			<>n__0();
			Card[] array = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.OnlyCommon, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)null);
			if (array.Length != 0)
			{
				Card[] array2 = array;
				foreach (Card card in array2)
				{
					card.IsExile = true;
				}
				yield return (BattleAction)new AddCardsToDrawZoneAction((IEnumerable<Card>)array, (DrawZoneTarget)2, (AddCardsType)0);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataBenJinDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataBenJinDef))]
	public sealed class TenkyuChimataBenJin : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<GameEventArgs>(((StatusEffect)this).Battle.BattleEnding, (EventSequencedReactor<GameEventArgs>)OnBattleEnding);
		}

		private IEnumerable<BattleAction> OnBattleEnding(GameEventArgs args)
		{
			yield return (BattleAction)new GainMoneyAction(((StatusEffect)this).Level, (SpecialSourceType)0);
		}
	}
	public sealed class TenkyuChimataChouKa1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataChouKa1Def))]
	public sealed class TenkyuChimataChouKa1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).Count = ((StatusEffect)this).Limit;
			((StatusEffect)this).HandleOwnerEvent<UnitEventArgs>(((Unit)((StatusEffect)this).Battle.Player).TurnStarting, (GameEventHandler<UnitEventArgs>)delegate
			{
				((StatusEffect)this).Count = ((StatusEffect)this).Limit;
				((StatusEffect)this).Highlight = ((StatusEffect)this).Count > 0;
			});
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			if (((GameEntity)this).GameRun.Money >= ((StatusEffect)this).Level && ((StatusEffect)this).Count >= 1)
			{
				int count = ((StatusEffect)this).Count;
				((StatusEffect)this).Count = count - 1;
				((StatusEffect)this).Highlight = ((StatusEffect)this).Count > 0;
				yield return (BattleAction)new LoseMoneyAction(((StatusEffect)this).Level);
				yield return (BattleAction)new DrawManyCardAction(1);
			}
			else
			{
				((StatusEffect)this).Highlight = false;
			}
		}
	}
	public sealed class TenkyuChimataChouYanDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataChouYanDef))]
	public sealed class TenkyuChimataChouYan : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnOwnerTurnStarted);
			((StatusEffect)this).HandleOwnerEvent<DamageEventArgs>(((Unit)((StatusEffect)this).Battle.Player).DamageTaking, (GameEventHandler<DamageEventArgs>)OnPlayerDamageTaking);
		}

		private IEnumerable<BattleAction> OnOwnerTurnStarted(UnitEventArgs args)
		{
			if (!((StatusEffect)this).Battle.BattleShouldEnd)
			{
				<>n__0();
				yield return (BattleAction)new HealAction((Unit)(object)((StatusEffect)this).Battle.Player, (Unit)(object)((StatusEffect)this).Battle.Player, ((StatusEffect)this).Level, (HealType)0, 0.2f);
				yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f);
			}
		}

		private void OnPlayerDamageTaking(DamageEventArgs args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			DamageInfo damageInfo = args.DamageInfo;
			int num = MathExtensions.RoundToInt(((DamageInfo)(ref damageInfo)).Damage);
			if (num > 0)
			{
				((GameEntity)this).React(Reactor.op_Implicit((BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f)));
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataDuShenDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.RelativeEffects = new List<string> { "TenkyuChimataShangJin", "CatchGoblinSe" };
			defaultStatusEffectConfig.Type = (StatusEffectType)1;
			defaultStatusEffectConfig.HasLevel = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataDuShenDef))]
	public sealed class TenkyuChimataDuShen : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<StatisticalDamageEventArgs>(((StatusEffect)this).Owner.StatisticalTotalDamageDealt, (EventSequencedReactor<StatisticalDamageEventArgs>)OnStatisticalDamageDealt);
		}

		private IEnumerable<BattleAction> OnStatisticalDamageDealt(StatisticalDamageEventArgs args)
		{
			Unit owner = ((StatusEffect)this).Owner;
			if (owner == null || !owner.IsAlive)
			{
				yield break;
			}
			foreach (var (_, source2) in args.ArgsTable)
			{
				foreach (DamageEventArgs item in source2.Where(delegate(DamageEventArgs amount)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					//IL_000f: Invalid comparison between Unknown and I4
					DamageInfo damageInfo2 = amount.DamageInfo;
					return (int)((DamageInfo)(ref damageInfo2)).DamageType == 2;
				}).Where(delegate(DamageEventArgs amount)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					DamageInfo damageInfo2 = amount.DamageInfo;
					return ((DamageInfo)(ref damageInfo2)).Damage > 0f;
				}))
				{
					DamageInfo damageInfo = item.DamageInfo;
					yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataShangJin>(owner, (int?)(MathExtensions.ToInt(((DamageInfo)(ref damageInfo)).Damage) * ((StatusEffect)this).Level), (int?)null, (int?)null, (int?)null, 0f, true);
				}
			}
		}
	}
	public sealed class TenkyuChimataHaoLing1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataHaoLing1Def))]
	public sealed class TenkyuChimataHaoLing1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<StatisticalDamageEventArgs>(((StatusEffect)this).Owner.StatisticalTotalDamageDealt, (EventSequencedReactor<StatisticalDamageEventArgs>)OnStatisticalDamageDealt);
		}

		private IEnumerable<BattleAction> OnStatisticalDamageDealt(StatisticalDamageEventArgs args)
		{
			foreach (EnemyUnit enemy in ((StatusEffect)this).Battle.AllAliveEnemies)
			{
				if (((Unit)enemy).HasStatusEffect<TenkyuChimataShangJin>() && !((StatusEffect)this).Battle.BattleShouldEnd)
				{
					yield return (BattleAction)new CastBlockShieldAction((Unit)(object)((StatusEffect)this).Battle.Player, (Unit)(object)((StatusEffect)this).Battle.Player, ((StatusEffect)this).Level, 0, (BlockShieldType)2, false);
					yield return (BattleAction)new CastBlockShieldAction((Unit)(object)((StatusEffect)this).Battle.Player, (Unit)(object)((StatusEffect)this).Battle.Player, 0, ((StatusEffect)this).Level, (BlockShieldType)2, false);
				}
			}
		}
	}
	public sealed class TenkyuChimataHayekHand1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataHayekHand1Def))]
	public sealed class TenkyuChimataHayekHand1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			<>n__0();
			if ((int)args.Card.CardType == 1)
			{
				Card[] attack = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 1));
				if (attack.Length != 0)
				{
					Card[] array = attack;
					foreach (Card card in array)
					{
						card.IsEthereal = true;
						card.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(attack);
				}
			}
			else if ((int)args.Card.CardType == 2)
			{
				Card[] defense = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 2));
				if (defense.Length != 0)
				{
					Card[] array2 = defense;
					foreach (Card card2 in array2)
					{
						card2.IsEthereal = true;
						card2.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(defense);
				}
			}
			else if ((int)args.Card.CardType == 4)
			{
				Card[] ability = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 4));
				if (ability.Length != 0)
				{
					Card[] array3 = ability;
					foreach (Card card3 in array3)
					{
						card3.IsEthereal = true;
						card3.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(ability);
				}
			}
			else if ((int)args.Card.CardType == 5)
			{
				Card[] friend = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 5));
				if (friend.Length != 0)
				{
					Card[] array4 = friend;
					foreach (Card card4 in array4)
					{
						card4.IsEthereal = true;
						card4.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(friend);
				}
			}
			else if ((int)args.Card.CardType == 8)
			{
				Card[] misfortune = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 8));
				if (misfortune.Length != 0)
				{
					Card[] array5 = misfortune;
					foreach (Card card5 in array5)
					{
						card5.IsEthereal = true;
						card5.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(misfortune);
				}
			}
			else if ((int)args.Card.CardType == 3)
			{
				Card[] skill = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 3));
				if (skill.Length != 0)
				{
					Card[] array6 = skill;
					foreach (Card card6 in array6)
					{
						card6.IsEthereal = true;
						card6.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(skill);
				}
			}
			else if ((int)args.Card.CardType == 7)
			{
				Card[] status = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 7));
				if (status.Length != 0)
				{
					Card[] array7 = status;
					foreach (Card card7 in array7)
					{
						card7.IsEthereal = true;
						card7.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(status);
				}
			}
			else if ((int)args.Card.CardType == 6)
			{
				Card[] tool = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 6));
				if (tool.Length != 0)
				{
					Card[] array8 = tool;
					foreach (Card card8 in array8)
					{
						card8.IsEthereal = true;
						card8.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(tool);
				}
			}
			else
			{
				if ((int)args.Card.CardType != 0)
				{
					yield break;
				}
				Card[] unknown = ((StatusEffect)this).Battle.RollCards(new CardWeightTable(RarityWeightTable.BattleCard, OwnerWeightTable.Valid, CardTypeWeightTable.CanBeLoot, false), ((StatusEffect)this).Level, (Predicate<CardConfig>)((CardConfig config) => (int)config.Type == 0));
				if (unknown.Length != 0)
				{
					Card[] array9 = unknown;
					foreach (Card card9 in array9)
					{
						card9.IsEthereal = true;
						card9.IsExile = true;
					}
					yield return (BattleAction)new AddCardsToHandAction(unknown);
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataHedgeFund1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataHedgeFund1Def))]
	public sealed class TenkyuChimataHedgeFund1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			int actualCost = args.Card.Config.MoneyCost.GetValueOrDefault();
			if (actualCost > 0)
			{
				yield return (BattleAction)new CastBlockShieldAction((Unit)(object)((StatusEffect)this).Battle.Player, new BlockInfo(((StatusEffect)this).Level * actualCost, (BlockShieldType)2), false);
				yield return (BattleAction)new CastBlockShieldAction((Unit)(object)((StatusEffect)this).Battle.Player, new ShieldInfo(((StatusEffect)this).Count * actualCost, (BlockShieldType)2), false);
			}
		}
	}
	public sealed class TenkyuChimataHuiKou1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataHuiKou1Def))]
	public sealed class TenkyuChimataHuiKou1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			Card playedCard = args.Card;
			int actualCost = playedCard.Config.MoneyCost.GetValueOrDefault();
			if (actualCost > 0 && ((StatusEffect)this).Count > 0 && !((StatusEffect)this).Battle.BattleShouldEnd)
			{
				<>n__0();
				int rebate = actualCost * 7 / 10;
				if (rebate > 0)
				{
					yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataBenJin>((Unit)(object)((StatusEffect)this).Battle.Player, (int?)rebate, (int?)null, (int?)null, (int?)null, 0f, true);
				}
				int nextCount = ((StatusEffect)this).Count - 1;
				if (nextCount <= 0)
				{
					yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f);
				}
				else
				{
					((StatusEffect)this).Count = nextCount;
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataJiDui1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataJiDui1Def))]
	public sealed class TenkyuChimataJiDui1 : StatusEffect
	{
		public ManaGroup Mana => ManaGroup.Single(CollectionsExtensions.Sample<ManaColor>((IEnumerable<ManaColor>)ManaColors.Colors, ((GameEntity)this).GameRun.BattleRng));

		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardEventArgs>(((StatusEffect)this).Battle.CardDrawn, (EventSequencedReactor<CardEventArgs>)OnCardDrawn);
		}

		private IEnumerable<BattleAction> OnCardDrawn(CardEventArgs args)
		{
			if (!((StatusEffect)this).Battle.BattleShouldEnd && ((StatusEffect)this).Battle.EnemyGroup.Alives != null && (int)args.Card.CardType == 7)
			{
				<>n__0();
				yield return (BattleAction)new GainManaAction(Mana);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataKeynesianismDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataKeynesianismDef))]
	public sealed class TenkyuChimataKeynesianism : StatusEffect
	{
		private static Dictionary<string, int?> _originalMoneyCosts = new Dictionary<string, int?>();

		protected override void OnAdded(Unit unit)
		{
			foreach (CardConfig item in CardConfig.AllConfig())
			{
				if (!_originalMoneyCosts.ContainsKey(item.Id))
				{
					_originalMoneyCosts[item.Id] = item.MoneyCost;
				}
				if (item.MoneyCost > 0)
				{
					item.MoneyCost = 21;
				}
			}
			foreach (Card item2 in ((StatusEffect)this).Battle.HandZone)
			{
				((GameEntity)item2).NotifyChanged();
			}
		}

		protected override void OnRemoved(Unit unit)
		{
			RestoreOriginalCosts();
		}

		private void RestoreOriginalCosts()
		{
			foreach (KeyValuePair<string, int?> originalMoneyCost in _originalMoneyCosts)
			{
				CardConfig val = CardConfig.FromId(originalMoneyCost.Key);
				if (val != null)
				{
					val.MoneyCost = originalMoneyCost.Value;
				}
			}
			_originalMoneyCosts.Clear();
			if (((StatusEffect)this).Battle == null)
			{
				return;
			}
			foreach (Card item in ((StatusEffect)this).Battle.HandZone)
			{
				((GameEntity)item).NotifyChanged();
			}
		}
	}
	public sealed class TenkyuChimataLiXiDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataLiXiDef))]
	public sealed class TenkyuChimataLiXi : StatusEffect
	{
		protected int lixi
		{
			get
			{
				if (!((Unit)((StatusEffect)this).Battle.Player).HasStatusEffect<TenkyuChimataBenJin>())
				{
					return 0;
				}
				TenkyuChimataBenJin statusEffect = ((Unit)((StatusEffect)this).Battle.Player).GetStatusEffect<TenkyuChimataBenJin>();
				double a = ((StatusEffect)statusEffect).Level / 100;
				return (int)Math.Ceiling(a);
			}
		}

		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnEnding, (EventSequencedReactor<UnitEventArgs>)OnOwnerTurnEnding);
		}

		private IEnumerable<BattleAction> OnOwnerTurnEnding(UnitEventArgs args)
		{
			if (!((StatusEffect)this).Battle.BattleShouldEnd)
			{
				<>n__0();
				if (((Unit)((StatusEffect)this).Battle.Player).HasStatusEffect<TenkyuChimataBenJin>())
				{
					yield return (BattleAction)new AddCardsToDiscardAction((IEnumerable<Card>)Library.CreateCards<TenkyuChimataToken>(lixi, false), (AddCardsType)0);
				}
				int level = ((StatusEffect)this).Level - 1;
				((StatusEffect)this).Level = level;
				if (((StatusEffect)this).Level == 0)
				{
					yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f);
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataNeiMuDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataNeiMuDef))]
	public sealed class TenkyuChimataNeiMu : StatusEffect
	{
		[UsedImplicitly]
		public ScryInfo Scry => new ScryInfo(((StatusEffect)this).Level);

		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((Unit)((StatusEffect)this).Battle.Player).TurnStarting, (EventSequencedReactor<UnitEventArgs>)OnPlayerTurnStarting);
		}

		private IEnumerable<BattleAction> OnPlayerTurnStarting(UnitEventArgs args)
		{
			<>n__0();
			yield return (BattleAction)new ScryAction(Scry);
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataPMJJ1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.RelativeEffects = new List<string> { "TenkyuChimataShangJin" };
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataPMJJ1Def))]
	public sealed class TenkyuChimataPMJJ1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnTurnStarted);
			foreach (EnemyUnit allAliveEnemy in ((StatusEffect)this).Battle.AllAliveEnemies)
			{
				if (allAliveEnemy != null && ((Unit)allAliveEnemy).IsAlive && !((StatusEffect)this).Battle.BattleShouldEnd)
				{
					TenkyuChimataShangJin statusEffect = ((Unit)allAliveEnemy).GetStatusEffect<TenkyuChimataShangJin>();
					if (statusEffect != null)
					{
						((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataShangJin>((Unit)(object)allAliveEnemy, (int?)((StatusEffect)statusEffect).Level, (int?)null, (int?)null, (int?)null, 0f, true)));
					}
				}
			}
		}

		private IEnumerable<BattleAction> OnTurnStarted(UnitEventArgs args)
		{
			<>n__0();
			int level = ((StatusEffect)this).Level - 1;
			((StatusEffect)this).Level = level;
			if (((StatusEffect)this).Level > 0)
			{
				yield break;
			}
			foreach (EnemyUnit enemy in ((StatusEffect)this).Battle.AllAliveEnemies)
			{
				TenkyuChimataShangJin TenkyuChimataShangJin = ((Unit)enemy).GetStatusEffect<TenkyuChimataShangJin>();
				if (TenkyuChimataShangJin != null)
				{
					yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)TenkyuChimataShangJin, true, 0.1f);
				}
			}
			yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f);
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataShangJinDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)1;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataShangJinDef))]
	public sealed class TenkyuChimataShangJin : StatusEffect
	{
		public string siji => ((GameEntity)this).LocalizeProperty("siji", false, true);

		public string long1 => ((GameEntity)this).LocalizeProperty("long1", false, true);

		protected override void OnAdded(Unit unit)
		{
			EnemyUnit val = (EnemyUnit)(object)((unit is EnemyUnit) ? unit : null);
			if (val != null && ((Unit)val).IsAlive && !((StatusEffect)this).Battle.BattleShouldEnd)
			{
				if (val is Siji)
				{
					((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)PerformAction.Chat((Unit)(object)val, siji, 3f, 0f, 0f, true)));
					((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)new ApplyStatusEffectAction<Firepower>((Unit)(object)val, (int?)10, (int?)0, (int?)0, (int?)0, 0.2f, true)));
				}
				else if (val is Long)
				{
					((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)PerformAction.Chat((Unit)(object)val, long1, 3f, 0f, 0f, true)));
					((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)new ApplyStatusEffectAction<Firepower>((Unit)(object)val, (int?)3, (int?)0, (int?)0, (int?)0, 0.2f, true)));
					((GameEntity)this).React(Reactor.op_Implicit((BattleAction)(object)new ApplyStatusEffectAction<Spirit>((Unit)(object)val, (int?)3, (int?)0, (int?)0, (int?)0, 0.2f, true)));
				}
				((StatusEffect)this).HandleOwnerEvent<DieEventArgs>(val.EnemyPointGenerating, (GameEventHandler<DieEventArgs>)delegate(DieEventArgs args)
				{
					args.Money += ((StatusEffect)this).Level;
				});
			}
		}
	}
	public sealed class TenkyuChimataSXF1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.RelativeEffects = new List<string> { "TenkyuChimataBenJin" };
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataSXF1Def))]
	public sealed class TenkyuChimataSXF1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			SetCount();
			((StatusEffect)this).HandleOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (GameEventHandler<CardUsingEventArgs>)delegate
			{
				SetCount();
			});
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((Unit)((StatusEffect)this).Battle.Player).TurnEnding, (EventSequencedReactor<UnitEventArgs>)OnPlayerTurnEnding);
		}

		private void SetCount()
		{
			((StatusEffect)this).Count = ((StatusEffect)this).Battle.TurnCardUsageHistory.Count * ((StatusEffect)this).Level;
		}

		private IEnumerable<BattleAction> OnPlayerTurnEnding(UnitEventArgs args)
		{
			if (((StatusEffect)this).Count > 0)
			{
				<>n__0();
				yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataBenJin>((Unit)(object)((StatusEffect)this).Battle.Player, (int?)((StatusEffect)this).Count, (int?)null, (int?)null, (int?)null, 0f, true);
				((StatusEffect)this).Count = 0;
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataTongZhangDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataTongZhangDef))]
	public sealed class TenkyuChimataTongZhang : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsing, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsing);
			SetCount();
			((StatusEffect)this).HandleOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (GameEventHandler<CardUsingEventArgs>)delegate
			{
				SetCount();
			});
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((Unit)((StatusEffect)this).Battle.Player).TurnEnding, (EventSequencedReactor<UnitEventArgs>)OnPlayerTurnEnding);
		}

		private void SetCount()
		{
			((StatusEffect)this).Count = ((StatusEffect)this).Battle.TurnCardUsageHistory.Count * ((StatusEffect)this).Level;
		}

		private IEnumerable<BattleAction> OnCardUsing(CardUsingEventArgs args)
		{
			if ((int)args.Card.CardType == 2)
			{
				args.PlayTwice = true;
			}
			else if ((int)args.Card.CardType == 1)
			{
				args.PlayTwice = true;
			}
			yield break;
		}

		private IEnumerable<BattleAction> OnPlayerTurnEnding(UnitEventArgs args)
		{
			if (((StatusEffect)this).Count > 0)
			{
				<>n__0();
				yield return (BattleAction)new LoseMoneyAction(((StatusEffect)this).Count);
				((StatusEffect)this).Count = 0;
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataTongZhang2Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataTongZhang2Def))]
	public sealed class TenkyuChimataTongZhang2 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<CardUsingEventArgs>(((StatusEffect)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			if ((int)args.Card.CardType == 2)
			{
				yield return (BattleAction)(object)new ApplyStatusEffectAction<Spirit>((Unit)(object)((StatusEffect)this).Battle.Player, (int?)((StatusEffect)this).Level, (int?)0, (int?)0, (int?)0, 0f, true);
			}
			else if ((int)args.Card.CardType == 1)
			{
				yield return (BattleAction)(object)new ApplyStatusEffectAction<Firepower>((Unit)(object)((StatusEffect)this).Battle.Player, (int?)((StatusEffect)this).Level, (int?)0, (int?)0, (int?)0, 0f, true);
			}
			else if ((int)args.Card.CardType == 3)
			{
				foreach (EnemyUnit enemy in ((StatusEffect)this).Battle.AllAliveEnemies)
				{
					if (((Unit)enemy).IsAlive && !((StatusEffect)this).Battle.BattleShouldEnd)
					{
						yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataShangJin>((Unit)(object)enemy, (int?)((StatusEffect)this).Count, (int?)0, (int?)0, (int?)0, 0f, true);
					}
				}
			}
			yield return (BattleAction)new LoseMoneyAction(5);
		}
	}
	public sealed class TenkyuChimataTurnGainSpiritSeDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataTurnGainSpiritSeDef))]
	public sealed class TenkyuChimataTurnGainSpiritSe : StatusEffect
	{
		public ManaGroup Mana => ManaGroup.Single((ManaColor)7);

		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnOwnerTurnStarted);
		}

		private IEnumerable<BattleAction> OnOwnerTurnStarted(UnitEventArgs args)
		{
			if (!((StatusEffect)this).Battle.BattleShouldEnd)
			{
				<>n__0();
				yield return (BattleAction)new GainManaAction(ManaGroup.Philosophies(((StatusEffect)this).Level));
				yield return (BattleAction)new LoseMoneyAction(((StatusEffect)this).Level * 3);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataVIPDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataVIPDef))]
	public sealed class TenkyuChimataVIP : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).HandleOwnerEvent<DieEventArgs>(((StatusEffect)this).Owner.Dying, (GameEventHandler<DieEventArgs>)OnDying);
		}

		private void OnDying(DieEventArgs args)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (((StatusEffect)this).Level > 0)
			{
				((StatusEffect)this).NotifyActivating();
				((GameEventArgs)args).CancelBy((GameEntity)(object)this);
				((GameEntity)this).GameRun.SetHpAndMaxHp(1, ((Unit)((StatusEffect)this).Battle.Player).MaxHp, false);
				((StatusEffect)this).Level = ((StatusEffect)this).Level - 1;
			}
			if (((StatusEffect)this).Level <= 0)
			{
				((GameEntity)this).React(Reactor.op_Implicit((BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)this, true, 0.1f)));
			}
		}
	}
	public sealed class TenkyuChimataYLBX1Def : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.RelativeEffects = new List<string> { "TenkyuChimataBenJin" };
			defaultStatusEffectConfig.Type = (StatusEffectType)0;
			defaultStatusEffectConfig.HasCount = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataYLBX1Def))]
	public sealed class TenkyuChimataYLBX1 : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<DamageEventArgs>(((Unit)((StatusEffect)this).Battle.Player).DamageReceived, (EventSequencedReactor<DamageEventArgs>)OnPlayerDamageReceived);
		}

		private IEnumerable<BattleAction> OnPlayerDamageReceived(DamageEventArgs args)
		{
			DamageInfo damageInfo = args.DamageInfo;
			int num = MathExtensions.RoundToInt(((DamageInfo)(ref damageInfo)).Damage);
			if (num >= 1)
			{
				<>n__0();
				yield return (BattleAction)(object)new ApplyStatusEffectAction<TenkyuChimataBenJin>((Unit)(object)((StatusEffect)this).Battle.Player, (int?)(num * ((StatusEffect)this).Level), (int?)null, (int?)null, (int?)null, 0f, true);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
	public sealed class TenkyuChimataZhaiWuDef : TenkyuChimataStatusEffectTemplate
	{
		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig defaultStatusEffectConfig = TenkyuChimataStatusEffectTemplate.GetDefaultStatusEffectConfig();
			defaultStatusEffectConfig.Type = (StatusEffectType)2;
			defaultStatusEffectConfig.HasCount = true;
			defaultStatusEffectConfig.HasLevel = true;
			return defaultStatusEffectConfig;
		}
	}
	[EntityLogic(typeof(TenkyuChimataZhaiWuDef))]
	public sealed class TenkyuChimataZhaiWu : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Owner.TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnOwnerTurnStarted);
			((StatusEffect)this).ReactOwnerEvent<GameEventArgs>(((StatusEffect)this).Battle.BattleEnded, (EventSequencedReactor<GameEventArgs>)OnBattleEnded);
		}

		private IEnumerable<BattleAction> OnOwnerTurnStarted(UnitEventArgs args)
		{
			<>n__0();
			if (((StatusEffect)this).Level > 950 && ((GameEntity)this).GameRun != null && ((GameEntity)this).GameRun.Money > 0)
			{
				int loseGold = Math.Min(50, ((GameEntity)this).GameRun.Money);
				yield return (BattleAction)new LoseMoneyAction(loseGold);
			}
			int nextLevel = ((StatusEffect)this).Level * 21 / 20;
			((StatusEffect)this).Level = nextLevel;
		}

		private IEnumerable<BattleAction> OnBattleEnded(GameEventArgs args)
		{
			if (((GameEntity)this).GameRun == null || ((StatusEffect)this).Battle == null || ((Unit)((StatusEffect)this).Battle.Player).IsDead)
			{
				yield break;
			}
			if (((GameEntity)this).GameRun.Money >= ((StatusEffect)this).Level && ((StatusEffect)this).Level < 400)
			{
				yield return (BattleAction)new LoseMoneyAction(((StatusEffect)this).Level);
				yield break;
			}
			if (((StatusEffect)this).Level >= 400)
			{
				int assetCardsCount = (((StatusEffect)this).Level + 500 - 1) / 500;
				if (assetCardsCount > 0)
				{
					yield return (BattleAction)new AddCardsToDeckAction((IEnumerable<Card>)Library.CreateCards<TenkyuChimataTokenCard3>(assetCardsCount, false));
				}
				yield break;
			}
			<>n__0();
			int playerCash = ((GameEntity)this).GameRun.Money;
			TenkyuChimataBenJin statusEffect = ((Unit)((StatusEffect)this).Battle.Player).GetStatusEffect<TenkyuChimataBenJin>();
			int playerBenJin = ((statusEffect != null) ? ((StatusEffect)statusEffect).Level : 0);
			int totalShangJin = 0;
			if (((StatusEffect)this).Battle.AllAliveEnemies != null)
			{
				foreach (EnemyUnit enemy in ((StatusEffect)this).Battle.AllAliveEnemies)
				{
					if (enemy != null && ((Unit)enemy).IsAlive)
					{
						TenkyuChimataShangJin statusEffect2 = ((Unit)enemy).GetStatusEffect<TenkyuChimataShangJin>();
						int enemyBounty = ((statusEffect2 != null) ? ((StatusEffect)statusEffect2).Level : 0);
						totalShangJin += enemyBounty;
					}
				}
			}
			if (playerCash > 0)
			{
				yield return (BattleAction)new LoseMoneyAction(playerCash);
			}
			int netDebt = ((StatusEffect)this).Level - playerCash - playerBenJin - totalShangJin;
			if (netDebt > 0)
			{
				int defaultCardsCount = (netDebt + 100 - 1) / 100;
				if (defaultCardsCount > 0)
				{
					yield return (BattleAction)new AddCardsToDeckAction((IEnumerable<Card>)Library.CreateCards<TenkyuChimataTokenCard2>(defaultCardsCount, false));
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0()
		{
			((StatusEffect)this).NotifyActivating();
		}
	}
}
namespace TenkyuChimataMod.Patches
{
	[HarmonyPatch]
	internal class CustomGameEventManager
	{
		public static GameEvent<BuffAttackEventArgs> PreCustomEvent { get; set; }

		public static GameEvent<BuffAttackEventArgs> PostCustomEvent { get; set; }

		[HarmonyPatch(typeof(GameRunController), "EnterBattle")]
		private static bool Prefix(GameRunController __instance)
		{
			PreCustomEvent = new GameEvent<BuffAttackEventArgs>();
			PostCustomEvent = new GameEvent<BuffAttackEventArgs>();
			return true;
		}
	}
	[HarmonyPatch(typeof(Stage), "CreateStation")]
	public class ReplaceFinalBossPatch
	{
		private static void Postfix(Stage __instance, MapNode node, ref Station __result)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			if (__instance.Level != 4 || !(((GameEntity)((GameEntity)__instance).GameRun.Player).Id == BepinexPlugin.modUniqueID) || (int)node.StationType != 10)
			{
				return;
			}
			Station obj = __result;
			BattleStation val = (BattleStation)(object)((obj is BattleStation) ? obj : null);
			if (val != null)
			{
				EnemyGroupEntry val2 = Library.TryGetEnemyGroupEntry("TenkyuChimataTakane");
				if (val2 != null)
				{
					val.EnemyGroupEntry = val2;
				}
			}
		}
	}
	public static class ChimataRunTracker
	{
		public static bool IsChimataRun;

		public static GameRunController CurrentRun;
	}
	[HarmonyPatch(typeof(SpellConfig), "FromId")]
	public static class CustomSpellConfigPatch
	{
		internal static readonly string[] CustomSpellNames = new string[3] { "弹幕收集狂的妄执", "高密度弹幕市场", "无道的弹幕领土" };

		internal static readonly Dictionary<string, Dictionary<Locale, string>> SpellNameTranslations = new Dictionary<string, Dictionary<Locale, string>>
		{
			["弹幕收集狂的妄执"] = new Dictionary<Locale, string>
			{
				{
					(Locale)1,
					"弹幕收集狂的妄执"
				},
				{
					(Locale)2,
					"彈幕收集狂的妄執"
				},
				{
					(Locale)0,
					"Bullet Collector's Obsession"
				},
				{
					(Locale)3,
					"弾幕収集狂の妄執"
				},
				{
					(Locale)10,
					"탄막 수집꾼의 망집"
				}
			},
			["高密度弹幕市场"] = new Dictionary<Locale, string>
			{
				{
					(Locale)1,
					"高密度弹幕市场"
				},
				{
					(Locale)2,
					"高密度彈幕市場"
				},
				{
					(Locale)0,
					"High-Density Bullet Market"
				},
				{
					(Locale)3,
					"高密度弾幕市場"
				},
				{
					(Locale)10,
					"고밀도 탄막 시장"
				}
			},
			["无道的弹幕领土"] = new Dictionary<Locale, string>
			{
				{
					(Locale)1,
					"无道的弹幕领土"
				},
				{
					(Locale)2,
					"無道的彈幕領土"
				},
				{
					(Locale)0,
					"The Tyrant's Bullet Territory"
				},
				{
					(Locale)3,
					"無道の弾幕領土"
				},
				{
					(Locale)10,
					"무도한 탄막 영토"
				}
			}
		};

		internal static string GetLocalizedSpellName(string key)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			if (SpellNameTranslations.TryGetValue(key, out var value))
			{
				Locale currentLocale = Localization.CurrentLocale;
				if (value.TryGetValue(currentLocale, out var value2))
				{
					return value2;
				}
				if ((int)currentLocale == 2 && value.TryGetValue((Locale)1, out var value3))
				{
					return value3;
				}
				if (value.TryGetValue((Locale)0, out var value4))
				{
					return value4;
				}
			}
			return key;
		}

		[HarmonyPrefix]
		public static bool FromIdPrefix(string Id, ref SpellConfig __result)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			string[] customSpellNames = CustomSpellNames;
			foreach (string text in customSpellNames)
			{
				if (Id == text)
				{
					SpellConfig val = (SpellConfig)FormatterServices.GetUninitializedObject(typeof(SpellConfig));
					typeof(SpellConfig).GetProperty("Id", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(val, text);
					typeof(SpellConfig).GetProperty("Resource", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(val, null);
					__result = val;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(SpellPanel), "SetSpellNameByKey")]
	public static class CustomSpellNameDisplayPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(SpellPanel __instance, string configKey, string spellKey)
		{
			string[] customSpellNames = CustomSpellConfigPatch.CustomSpellNames;
			foreach (string text in customSpellNames)
			{
				if (!(configKey == text))
				{
					continue;
				}
				FieldInfo field = typeof(SpellPanel).GetField("spellName", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					object? value = field.GetValue(__instance);
					TextMeshProUGUI val = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null);
					if ((Object)(object)val != (Object)null)
					{
						string localizedSpellName = CustomSpellConfigPatch.GetLocalizedSpellName(text);
						((TMP_Text)val).text = Localization.LocalizeFormat("UI.SpellUntitled", new object[1] { localizedSpellName });
					}
				}
				return false;
			}
			return true;
		}
	}
	public static class CustomEventTextManager2
	{
		public static Dictionary<string, Dictionary<string, string>> MasterTextDict = new Dictionary<string, Dictionary<string, string>>();

		public static bool IsLoaded = false;

		public static void LoadAllCustomYamls()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (IsLoaded)
			{
				return;
			}
			IsLoaded = true;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string path = Path.Combine(directoryName, "DirResources");
			if (!Directory.Exists(path))
			{
				return;
			}
			string[] files = Directory.GetFiles(path, "TenkyuChimata_*.yaml", SearchOption.AllDirectories);
			IDeserializer val = new DeserializerBuilder().IgnoreUnmatchedProperties().Build();
			string[] array = files;
			foreach (string text in array)
			{
				try
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
					string[] array2 = fileNameWithoutExtension.Split('_');
					string text2 = ((array2.Length > 1) ? array2[1] : "Unknown");
					string name = new DirectoryInfo(Path.GetDirectoryName(text)).Name;
					string text3 = "ZhHans";
					switch (name)
					{
					case "en":
						text3 = "En";
						break;
					case "ja":
						text3 = "Ja";
						break;
					case "ko":
						text3 = "Ko";
						break;
					case "zh-Hans":
						text3 = "ZhHans";
						break;
					default:
						if (array2.Length > 2)
						{
							text3 = array2[2];
						}
						break;
					}
					if (!MasterTextDict.ContainsKey(text3))
					{
						MasterTextDict[text3] = new Dictionary<string, string>();
					}
					string text4 = File.ReadAllText(text);
					Dictionary<string, string> dictionary = val.Deserialize<Dictionary<string, string>>(text4);
					if (dictionary == null)
					{
						continue;
					}
					Debug.Log((object)$"[TenkyuChimata_XRay_Load] 成功加载文件: {fileNameWithoutExtension}, 识别文件夹为: {name}, 划入语言包: {text3}, 共读取到词条: {dictionary.Count} 个");
					foreach (KeyValuePair<string, string> item in dictionary)
					{
						string text5 = item.Key.Replace("\ufeff", "").Trim();
						switch (text5)
						{
						default:
							if (!(text5 == "NPC"))
							{
								MasterTextDict[text3][text5] = item.Value;
								break;
							}
							goto case "Title";
						case "Title":
						case "HostName":
						case "TargetTitle":
						case "TargetNPC":
							MasterTextDict[text3][text5 + "_" + text2] = item.Value;
							break;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("[TenkyuChimata_XRay_Error] 文件读取失败: " + text + " 报错: " + ex.Message));
				}
			}
		}

		public static string DetectLanguageFromVanillaDict(IDictionary<string, string> dict)
		{
			if (dict == null || dict.Count == 0)
			{
				return "ZhHans";
			}
			int num = 0;
			int num2 = 0;
			foreach (string value in dict.Values)
			{
				if (!string.IsNullOrWhiteSpace(value))
				{
					if (Regex.IsMatch(value, "[\\uac00-\\ud7a3]"))
					{
						return "Ko";
					}
					if (Regex.IsMatch(value, "[\\u3040-\\u30ff]"))
					{
						return "Ja";
					}
					if (Regex.IsMatch(value, "[\\u4e00-\\u9fa5]"))
					{
						num++;
					}
					else
					{
						num2++;
					}
				}
			}
			string text = ((num > 0 && num >= num2 / 5) ? "ZhHans" : "En");
			Debug.Log((object)$"[TenkyuChimata_XRay_Detect] 语言嗅探 -> 中文条目数:{num}, 外文条目数:{num2} ===> 最终裁定当前游戏语言为: {text}");
			return text;
		}
	}
	[HarmonyPatch(typeof(DialogRunner), "LocalizeLine")]
	public class OverrideDialogLinePatch
	{
		private static readonly FieldInfo stringTableField = AccessTools.Field(typeof(DialogRunner), "_stringTable");

		private static bool _hasDiagnosed = false;

		private static void Prefix(DialogRunner __instance, string lineId)
		{
			if (!ChimataRunTracker.IsChimataRun)
			{
				return;
			}
			CustomEventTextManager2.LoadAllCustomYamls();
			string text = lineId.Replace("\ufeff", "").Replace("\r", "").Replace("\n", "")
				.Trim();
			IDictionary<string, string> dictionary = (IDictionary<string, string>)stringTableField.GetValue(__instance);
			if (dictionary != null)
			{
				string text2 = CustomEventTextManager2.DetectLanguageFromVanillaDict(dictionary);
				if (!_hasDiagnosed)
				{
					Debug.Log((object)$"[TenkyuChimata_XRay_Patch] 拦截到对话请求!系统需要语言: {text2}。 我们的字典里有这个语言包吗? => {CustomEventTextManager2.MasterTextDict.ContainsKey(text2)}");
					_hasDiagnosed = true;
				}
				if (CustomEventTextManager2.MasterTextDict.ContainsKey(text2))
				{
					if (CustomEventTextManager2.MasterTextDict[text2].TryGetValue(text, out var value))
					{
						dictionary[lineId] = value;
					}
					else
					{
						Debug.LogWarning((object)("[TenkyuChimata_XRay_Miss] 漏网之鱼:游戏请求翻译 Key [" + text + "],但在我们的 " + text2 + " 字典里找不到!"));
					}
				}
			}
			TextReplaceMonitor.EnsureRunning();
		}
	}
	public class TextReplaceMonitor : MonoBehaviour
	{
		public static void EnsureRunning()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (ChimataRunTracker.IsChimataRun)
			{
				TextReplaceMonitor textReplaceMonitor = Object.FindObjectOfType<TextReplaceMonitor>();
				if ((Object)(object)textReplaceMonitor == (Object)null)
				{
					GameObject val = new GameObject("TenkyuChimata_TextMonitor_Immortal");
					Object.DontDestroyOnLoad((Object)(object)val);
					textReplaceMonitor = val.AddComponent<TextReplaceMonitor>();
				}
			}
		}

		[Obsolete]
		private void Update()
		{
			if (!ChimataRunTracker.IsChimataRun || !CustomEventTextManager2.IsLoaded)
			{
				return;
			}
			GameRunController currentRun = ChimataRunTracker.CurrentRun;
			if (currentRun == null)
			{
				return;
			}
			Station currentStation = currentRun.CurrentStation;
			AdventureStation val = (AdventureStation)(object)((currentStation is AdventureStation) ? currentStation : null);
			if (val == null)
			{
				return;
			}
			string id = val.Adventure.Id;
			string text = null;
			string value = null;
			string text2 = null;
			string value2 = null;
			foreach (Dictionary<string, string> value5 in CustomEventTextManager2.MasterTextDict.Values)
			{
				if (value5.TryGetValue("TargetTitle_" + id, out var value3))
				{
					text = value3;
					value5.TryGetValue("Title_" + id, out value);
				}
				if (value5.TryGetValue("TargetNPC_" + id, out var value4))
				{
					text2 = value4;
					if (!value5.TryGetValue("NPC_" + id, out value2))
					{
						value5.TryGetValue("HostName_" + id, out value2);
					}
				}
			}
			string text3 = text?.Trim();
			string text4 = text2?.Trim();
			string text5 = value?.Trim();
			string text6 = value2?.Trim();
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			foreach (TextMeshProUGUI val2 in array)
			{
				if (!string.IsNullOrWhiteSpace(((TMP_Text)val2).text))
				{
					string text7 = Regex.Replace(((TMP_Text)val2).text, "<.*?>", string.Empty).Replace("\ufeff", "").Trim();
					if (!string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(text5) && text7 == text3)
					{
						((TMP_Text)val2).text = ((TMP_Text)val2).text.Replace(text3, text5);
					}
					if (!string.IsNullOrEmpty(text4) && !string.IsNullOrEmpty(text6) && text7 == text4)
					{
						((TMP_Text)val2).text = ((TMP_Text)val2).text.Replace(text4, text6);
					}
				}
			}
		}
	}
}
namespace TenkyuChimataMod.Casino
{
	public struct PokerCard
	{
		public int rawValue;

		public int suit;

		public string GetValueName()
		{
			if (rawValue == 1)
			{
				return "A";
			}
			if (rawValue == 11)
			{
				return "J";
			}
			if (rawValue == 12)
			{
				return "Q";
			}
			if (rawValue == 13)
			{
				return "K";
			}
			return rawValue.ToString();
		}

		public bool IsRed()
		{
			return suit == 0 || suit == 1;
		}

		public string GetSuitSymbol()
		{
			return (new string[4] { "♥", "♦", "♣", "♠" })[suit];
		}
	}
	public class BlackjackManager : MonoBehaviour
	{
		private enum ResultType
		{
			Win,
			Lose,
			Blackjack,
			Bust,
			Push
		}

		private static GameObject blackjackPanel;

		private static int currentBet = 10;

		private const int MaxBet = 200;

		private const int MinBet = 10;

		private static List<PokerCard> playerHand = new List<PokerCard>();

		private static List<PokerCard> dealerHand = new List<PokerCard>();

		private static List<GameObject> spawnedCardObjects = new List<GameObject>();

		private static GameObject dealerHiddenCardObj;

		private static List<PokerCard> shoeDeck = new List<PokerCard>();

		private static List<GameObject> previewCardObjects = new List<GameObject>();

		private static bool isGameActive = false;

		private static bool isAnimating = false;

		private static Text dealerScoreText;

		private static Text playerScoreText;

		private static Text statusText;

		private static Text betAmountText;

		private static Button btnHit;

		private static Button btnStand;

		private static Button btnStart;

		private static Button btnBetPlus;

		private static Button btnBetMinus;

		private static readonly Vector2 ShoeSourcePos = new Vector2(400f, 220f);

		private const float PreviewShiftX = 130f;

		private static ShopPanel CapturedShopPanel => CasinoManager.CapturedShopPanel;

		private static string Loc(string key, string fallback)
		{
			return CasinoManager.GetLocText(key, fallback);
		}

		public static void BuildTable(Transform parent)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)blackjackPanel != (Object)null)
			{
				Object.Destroy((Object)(object)blackjackPanel);
			}
			blackjackPanel = new GameObject("Blackjack_Table");
			blackjackPanel.transform.SetParent(parent, false);
			blackjackPanel.AddComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(Vector3.zero);
			Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
			dealerScoreText = CreateText(blackjackPanel.transform, "DScore", Loc("BJ.DealerScore", "庄家点数: ") + "0", new Vector2(0f, 220f), 28, builtinResource, Color.white, new Vector2(800f, 45f));
			playerScoreText = CreateText(blackjackPanel.transform, "PScore", Loc("BJ.PlayerScore", "您的点数: ") + "0", new Vector2(0f, -140f), 28, builtinResource, Color.white, new Vector2(800f, 45f));
			statusText = CreateText(blackjackPanel.transform, "Status", Loc("BJ.StatusStart", "请下注并开始游戏"), new Vector2(0f, 40f), 32, builtinResource, Color.cyan, new Vector2(900f, 70f));
			betAmountText = CreateText(blackjackPanel.transform, "BetAmt", Loc("BJ.CurrentBet", "当前赌注: ") + currentBet, new Vector2(0f, -185f), 26, builtinResource, Color.orange, new Vector2(300f, 40f));
			btnBetMinus = CreateButton(blackjackPanel.transform, "Minus", "-", new Vector2(-150f, -185f), new Vector2(45f, 35f), delegate
			{
				AdjustBet(-10);
			});
			btnBetPlus = CreateButton(blackjackPanel.transform, "Plus", "+", new Vector2(150f, -185f), new Vector2(45f, 35f), delegate
			{
				AdjustBet(10);
			});
			btnStart = CreateButton(blackjackPanel.transform, "Start", Loc("BJ.BtnStart", "发牌开局"), new Vector2(0f, -240f), new Vector2(180f, 55f), delegate
			{
				((MonoBehaviour)CapturedShopPanel).StartCoroutine(CoStartGame());
			});
			btnHit = CreateButton(blackjackPanel.transform, "Hit", Loc("BJ.BtnHit", "要牌 (Hit)"), new Vector2(-130f, -240f), new Vector2(140f, 55f), delegate
			{
				((MonoBehaviour)CapturedShopPanel).StartCoroutine(CoPlayerHit());
			});
			btnStand = CreateButton(blackjackPanel.transform, "Stand", Loc("BJ.BtnStand", "停牌 (Stand)"), new Vector2(130f, -240f), new Vector2(140f, 55f), delegate
			{
				((MonoBehaviour)CapturedShopPanel).StartCoroutine(CoPlayerStand());
			});
			CreateButton(blackjackPanel.transform, "BtnBackToLobby", Loc("BJ.BtnBack", "返回大厅"), new Vector2(0f, -340f), new Vector2(240f, 70f), (Action)delegate
			{
				if (isGameActive || isAnimating)
				{
					statusText.text = Loc("BJ.StatusMidGameError", "<color=orange>对局正在进行中,请先打完该把牌!</color>");
				}
				else
				{
					foreach (GameObject spawnedCardObject in spawnedCardObjects)
					{
						Object.Destroy((Object)(object)spawnedCardObject);
					}
					spawnedCardObjects.Clear();
					foreach (GameObject previewCardObject in previewCardObjects)
					{
						Object.Destroy((Object)(object)previewCardObject);
					}
					previewCardObjects.Clear();
					Object.Destroy((Object)(object)blackjackPanel);
					blackjackPanel = null;
					CasinoManager.ReturnToLobby();
				}
			}, (Color?)new Color(0.15f, 0.15f, 0.15f, 0.95f));
			RefillShoe();
			UpdateShoePreview();
			RefreshButtons();
		}

		private static void RefillShoe()
		{
			while (shoeDeck.Count < 12)
			{
				shoeDeck.Add(new PokerCard
				{
					rawValue = Random.Range(1, 14),
					suit = Random.Range(0, 4)
				});
			}
		}

		private static PokerCard RollCard()
		{
			RefillShoe();
			PokerCard result = shoeDeck[0];
			shoeDeck.RemoveAt(0);
			RefillShoe();
			return result;
		}

		private static void UpdateShoePreview()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject previewCardObject in previewCardObjects)
			{
				Object.Destroy((Object)(object)previewCardObject);
			}
			previewCardObjects.Clear();
			if (!CasinoManager.HasCheatRelic())
			{
				return;
			}
			RefillShoe();
			Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
			GameObject val = new GameObject("PreviewOrderHint");
			val.transform.SetParent(blackjackPanel.transform, false);
			previewCardObjects.Add(val);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchoredPosition = ShoeSourcePos + new Vector2(-5f, 55f);
			val2.sizeDelta = new Vector2(500f, 30f);
			Text val3 = val.AddComponent<Text>();
			val3.text = Loc("BJ.CheatOrderHint", "<color=#22FF22>◄── 老千透视:发牌流向 (右先发 / 左后发) ◄──</color>");
			val3.font = builtinResource;
			val3.fontSize = 16;
			val3.alignment = (TextAnchor)4;
			((Graphic)val3).raycastTarget = false;
			val3.horizontalOverflow = (HorizontalWrapMode)0;
			val3.verticalOverflow = (VerticalWrapMode)1;
			for (int i = 0; i < 5 && i < shoeDeck.Count; i++)
			{
				PokerCard pokerCard = shoeDeck[i];
				GameObject val4 = new GameObject($"GhostCard_{i}");
				val4.transform.SetParent(blackjackPanel.transform, false);
				previewCardObjects.Add(val4);
				RectTransform val5 = val4.AddComponent<RectTransform>();
				val5.sizeDelta = new Vector2(55f, 76f);
				val5.anchoredPosition = ShoeSourcePos + new Vector2(115f - (float)(i * 56), -22f);
				Image val6 = val4.AddComponent<Image>();
				((Graphic)val6).color = new Color(1f, 1f, 1f, 0.45f);
				((Graphic)val6).raycastTarget = false;
				Color c = (pokerCard.IsRed() ? new Color(0.85f, 0.15f, 0.15f, 0.55f) : new Color(0.15f, 0.15f, 0.15f, 0.55f));
				CreateText(val4.transform, "G_Suit", pokerCard.GetSuitSymbol(), new Vector2(0f, 10f), 22, builtinResource, c, new Vector2(55f, 30f));
				CreateText(val4.transform, "G_Num", pokerCard.GetValueName(), new Vector2(-15f, 23f), 14, builtinResource, c, new Vector2(25f, 20f));
				if (i == 0)
				{
					GameObject val7 = new GameObject("NextCardTag");
					val7.transform.SetParent(blackjackPanel.transform, false);
					previewCardObjects.Add(val7);
					RectTransform val8 = val7.AddComponent<RectTransform>();
					val8.anchoredPosition = val5.anchoredPosition + new Vector2(0f, 50f);
					val8.sizeDelta = new Vector2(100f, 20f);
					Text val9 = val7.AddComponent<Text>();
					val9.text = Loc("BJ.CheatNextTag", "【下一张】");
					val9.font = builtinResource;
					val9.fontSize = 14;
					((Graphic)val9).color = Color.yellow;
					val9.alignment = (TextAnchor)4;
					((Graphic)val9).raycastTarget = false;
				}
			}
		}

		private static void AdjustBet(int amt)
		{
			if (!isGameActive && !isAnimating)
			{
				int num = currentBet + amt;
				if (num >= 10 && num <= 200)
				{
					currentBet = num;
					betAmountText.text = Loc("BJ.CurrentBet", "当前赌注: ") + currentBet;
				}
			}
		}

		private static void RefreshButtons()
		{
			bool active = isGameActive && !isAnimating;
			bool active2 = !isGameActive && !isAnimating;
			((Component)btnStart).gameObject.SetActive(active2);
			((Component)btnBetPlus).gameObject.SetActive(active2);
			((Component)btnBetMinus).gameObject.SetActive(active2);
			((Component)btnHit).gameObject.SetActive(active);
			((Component)btnStand).gameObject.SetActive(active);
		}

		private static IEnumerator CoStartGame()
		{
			if (CasinoManager.IsKickedOut)
			{
				yield break;
			}
			GameRunController run = ChimataRunTracker.CurrentRun;
			if (run == null || run.Money < currentBet)
			{
				statusText.text = Loc("BJ.StatusBetError", "您兜里的金币不够下注!");
				yield break;
			}
			run.LoseMoney(currentBet);
			isGameActive = true;
			isAnimating = true;
			RefreshButtons();
			statusText.text = Loc("BJ.StatusDealing", "正在荷官洗牌发牌...");
			foreach (GameObject go in spawnedCardObjects)
			{
				Object.Destroy((Object)(object)go);
			}
			spawnedCardObjects.Clear();
			playerHand.Clear();
			dealerHand.Clear();
			dealerHiddenCardObj = null;
			yield return DealtSingleCard(toPlayer: true, RollCard(), faceDown: false);
			yield return DealtSingleCard(toPlayer: false, RollCard(), faceDown: false);
			yield return DealtSingleCard(toPlayer: true, RollCard(), faceDown: false);
			yield return DealtSingleCard(toPlayer: false, RollCard(), faceDown: true);
			isAnimating = false;
			RefreshButtons();
			if (CalcScore(playerHand) == 21)
			{
				EndGame(ResultType.Blackjack);
			}
			else
			{
				statusText.text = Loc("BJ.StatusYourTurn", "请做出您的抉择:要牌还是停牌?");
			}
		}

		private static IEnumerator CoPlayerHit()
		{
			if (isGameActive && !isAnimating)
			{
				isAnimating = true;
				RefreshButtons();
				yield return DealtSingleCard(toPlayer: true, RollCard(), faceDown: false);
				isAnimating = false;
				RefreshButtons();
				if (CalcScore(playerHand) > 21)
				{
					EndGame(ResultType.Bust);
				}
			}
		}

		private static IEnumerator CoPlayerStand()
		{
			if (isGameActive && !isAnimating)
			{
				isAnimating = true;
				RefreshButtons();
				statusText.text = Loc("BJ.StatusDealerReveal", "庄家正在掀开底牌...");
				yield return (object)new WaitForSeconds(0.5f);
				if (dealerHand.Count >= 2)
				{
					RevealDealerHiddenCard(dealerHand[1]);
				}
				RenderStaticTable(hideDealerSecond: false);
				yield return (object)new WaitForSeconds(0.3f);
				while (CalcScore(dealerHand) < 17)
				{
					statusText.text = Loc("BJ.StatusDealerHit", "庄家正在博牌...");
					yield return DealtSingleCard(toPlayer: false, RollCard(), faceDown: false);
				}
				int p = CalcScore(playerHand);
				int d = CalcScore(dealerHand);
				if (d > 21 || p > d)
				{
					EndGame(ResultType.Win);
				}
				else if (p < d)
				{
					EndGame(ResultType.Lose);
				}
				else
				{
					EndGame(ResultType.Push);
				}
			}
		}

		private static void RevealDealerHiddenCard(PokerCard cardData)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)dealerHiddenCardObj == (Object)null))
			{
				Image component = dealerHiddenCardObj.GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).color = Color.white;
				}
				Transform val = dealerHiddenCardObj.transform.Find("Back");
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
				Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
				CreateText(dealerHiddenCardObj.transform, "Suit", cardData.GetSuitSymbol(), new Vector2(0f, 20f), 34, builtinResource, cardData.IsRed() ? Color.red : Color.black, new Vector2(85f, 50f));
				CreateText(dealerHiddenCardObj.transform, "Num", cardData.GetValueName(), new Vector2(-22f, 38f), 20, builtinResource, cardData.IsRed() ? Color.red : Color.black, new Vector2(40f, 30f));
			}
		}

		private static IEnumerator DealtSingleCard(bool toPlayer, PokerCard cardData, bool faceDown)
		{
			if (toPlay