Decompiled source of BossChallengeMod v0.4.0

BossChallengeMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BossChallengeMod.BossPatches;
using BossChallengeMod.BossPatches.TargetPatches;
using BossChallengeMod.Configuration;
using BossChallengeMod.Configuration.Fields;
using BossChallengeMod.Configuration.Holders;
using BossChallengeMod.Configuration.Repositories;
using BossChallengeMod.CustomActions;
using BossChallengeMod.CustomMonsterStates;
using BossChallengeMod.CustomMonsterStates.Configuration;
using BossChallengeMod.Extensions;
using BossChallengeMod.Global;
using BossChallengeMod.Helpers;
using BossChallengeMod.Interfaces;
using BossChallengeMod.KillCounting;
using BossChallengeMod.Modifiers;
using BossChallengeMod.Modifiers.Managers;
using BossChallengeMod.ObjectProviders;
using BossChallengeMod.PatchResolver;
using BossChallengeMod.PatchResolver.Initializers;
using BossChallengeMod.Patches;
using BossChallengeMod.Preloading;
using BossChallengeMod.UI;
using BossChallengeMod.UI.QueueUI;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using MonoMod.Utils;
using MonsterLove.StateMachine;
using NineSolsAPI;
using NineSolsAPI.Utils;
using RCGFSM.Monster;
using RCGMaker.AddressableAssets;
using RCGMaker.Core;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BossChallengeMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Bosses don't die")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+84963a1f3258e07348ad31d1563dccb6be34f7c1")]
[assembly: AssemblyProduct("BossChallengeMod")]
[assembly: AssemblyTitle("BossChallengeMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace BossChallengeMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("BossChallengeMod", "BossChallengeMod", "1.0.0")]
	public class BossChallengeMod : BaseUnityPlugin
	{
		public const string PluginGUID = "BossChallengeMod";

		private int versionNotificationCounter = 3;

		private bool isToastsDisplayed;

		private bool UnloadRequested;

		private Harmony harmony;

		private ModConfig _modConfig;

		private bool isVersionValid;

		public CustomMonsterStateValuesResolver MonsterStateValuesResolver { get; private set; }

		public EventTypesResolver EventTypesResolver { get; private set; }

		public MonsterPatchResolver RegularMonstersPatchResolver { get; private set; }

		public MonsterPatchResolver BossesPatchResolver { get; private set; }

		public UIController UIController { get; private set; }

		public MonsterUIController MonsterUIController { get; private set; }

		public ChallengeConfigurationManager ChallengeConfigurationManager { get; private set; }

		public GlobalModifiersController GlobalModifiersFlags { get; private set; }

		public UIConfiguration UIConfiguration { get; private set; }

		private Preloader Preloader { get; set; }

		private BepInExModConfigurationHandler BepInExModConfigurationHandler { get; set; }

		public ShieldProvider ShieldProvider { get; private set; }

		public YanlaoGunProvider YanlaoGunProvider { get; private set; }

		public BombProvider BombShooterProvider { get; private set; }

		public static ModifiersStore Modifiers { get; private set; }

		public static BossChallengeMod Instance { get; private set; }

		public static Random Random { get; private set; }

		protected ChallengeConfiguration ConfigurationToUse => ChallengeConfigurationManager.ChallengeConfiguration;

		public BossChallengeMod()
		{
			MonsterStateValuesResolver = new CustomMonsterStateValuesResolver();
			EventTypesResolver = new EventTypesResolver();
		}

		private void Awake()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
			Random = new Random();
			Preloader = new Preloader();
			ShieldProvider = new ShieldProvider();
			YanlaoGunProvider = new YanlaoGunProvider();
			BombShooterProvider = new BombProvider();
			Modifiers = new ModifiersStore();
			AssignPreloadingTargets();
			SetupModifiers(Modifiers);
			LocalizationResolver.LoadLanguage(GetLanguageCode());
			IRecordsRepository recordsRepository = new JsonRecordsRepository();
			ChallengeConfigurationManager = new ChallengeConfigurationManager(recordsRepository);
			UIConfiguration = new UIConfiguration();
			GlobalModifiersFlags = new GlobalModifiersController();
			LocalizationManager.OnLocalizeEvent += new OnLocalizeCallback(OnLocalizationChange);
			BepInExModConfigurationHandler = new BepInExModConfigurationHandler(((BaseUnityPlugin)this).Config, ChallengeConfigurationManager, UIConfiguration);
			BepInExModConfigurationHandler.InitChallengeConfiguration();
			BepInExModConfigurationHandler.HandleChallengeConfigurationValues();
			BepInExModConfigurationHandler.InitializeUIConfiguration();
			UIController = new UIController(UIConfiguration);
			BepInExModConfigurationHandler.HandleUIConfigurationValues();
			MonsterUIController = new MonsterUIController();
			RegularMonstersPatchResolver = new RegularEnemiesPatchesInitializer(MonsterStateValuesResolver).MonsterPatchResolver;
			BossesPatchResolver = new BossesPatchesInitializer(MonsterStateValuesResolver).MonsterPatchResolver;
			SceneManager.sceneLoaded += OnSceneLoaded;
			harmony = Harmony.CreateAndPatchAll(typeof(BossChallengeMod).Assembly, (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BossChallengeMod is loaded1!");
		}

		private void Start()
		{
			ProcessModConfig();
			if (isVersionValid)
			{
				((MonoBehaviour)this).StartCoroutine(Preloader.Preload());
			}
		}

		private void ProcessModConfig()
		{
			_modConfig = AssemblyUtils.GetEmbeddedJson<ModConfig>("BossChallengeMod.Resources.ModConfig.modconfig.json");
			if (ConfigManager.Instance.Version.Trim() == _modConfig?.ValidVersion)
			{
				isVersionValid = true;
			}
		}

		private void AssignPreloadingTargets()
		{
			string scene = "A5_S5_JieChuanHall";
			string path = "Shield(Effect Receiver)_Shield Sphere Version";
			Preloader.AddPreload(scene, path, ShieldProvider);
			string scene2 = "A4_S4_Container_Final";
			string path2 = "ZGun FSM Object Variant";
			Preloader.AddPreload(scene2, path2, YanlaoGunProvider);
			string scene3 = "A1_S3_InnerHumanDisposal_Final";
			string path3 = "Shooter_GrenadeUp";
			Preloader.AddPreload(scene3, path3, BombShooterProvider);
		}

		private string GetLanguageCode()
		{
			return LocalizationManager.CurrentLanguageCode switch
			{
				"ru" => "ru-ru", 
				"en-US" => "en-us", 
				"zh-CN" => "zh-cn", 
				"zh-TW" => "zh-tw", 
				_ => "en-us", 
			};
		}

		private void OnLocalizationChange()
		{
			LocalizationResolver.LoadLanguage(GetLanguageCode());
		}

		private void OnDestroy()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			UnloadRequested = true;
			UIController.Unload();
			LocalizationManager.OnLocalizeEvent -= new OnLocalizeCallback(OnLocalizationChange);
			SceneManager.sceneLoaded -= OnSceneLoaded;
			harmony.UnpatchSelf();
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			UIController.FixUI();
			GlobalModifiersFlags.ValidateAll();
			if (!isToastsDisplayed)
			{
				isToastsDisplayed = true;
				((MonoBehaviour)this).StartCoroutine(ShowToasts());
			}
			if (versionNotificationCounter > 0 && !isVersionValid && SingletonBehaviour<GameCore>.IsAvailable())
			{
				versionNotificationCounter--;
				SingletonBehaviour<GameCore>.Instance.notificationUI.ShowNotification("Boss Challenge mod version is built for different game version: " + _modConfig.ValidVersion + ". Some features were disabled.", (RCGAssetReference)null, (PlayerInfoPanelType)(-1), (Action)null);
			}
		}

		private IEnumerator ShowToasts()
		{
			yield return (object)new WaitForSeconds(5f);
			for (int i = 1; i < 5; i++)
			{
				if (UnloadRequested)
				{
					break;
				}
				ToastManager.Toast((object)LocalizationResolver.Localize($"toast_message{i}"));
				yield return (object)new WaitForSeconds(4f);
			}
		}

		private void SetupModifiers(ModifiersStore modifiersStore)
		{
			modifiersStore.CreateModifierBuilder<SpeedModifier>("speed_temp", "SpeedModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsSpeedModifierEnabled).BuildAndAdd();
			modifiersStore.CreateModifierBuilder<TimerModifier>("timer", "TimerModifier").AddConditionPredicate((ModifierConfig _) => ApplicationCore.IsInBossMemoryMode).AddCanBeRolledConditionPredicate((ModifierConfig _, int iteration) => iteration > 0 && ConfigurationToUse.IsTimerModifierEnabled)
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[4] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<ScalingSpeedModifier>("speed_perm", "SpeedScalingModifier").SetPersistance(isPersistent: true).BuildAndAdd();
			modifiersStore.CreateModifierBuilder<ParryDirectDamageModifier>("parry_damage", "ParryDamageModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsParryDamageModifierEnabled).BuildAndAdd();
			modifiersStore.CreateModifierBuilder<DamageBuildupModifier>("damage_buildup", "DamageBuildupModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsDamageBuildupModifierEnabled).AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[2] { "parry_damage", "qi_overload" }))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<RegenerationModifier>("regeneration", "RegenerationModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsRegenerationModifierEnabled).AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<KnockbackModifier>("knockback", "KnockbackModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsKnockbackModifierEnabled).BuildAndAdd();
			modifiersStore.CreateModifierBuilder<RandomArrowModifier>("random_arrow", "RandomArrowModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsRandomArrowModifierEnabled && Player.i.mainAbilities.ArrowAbility.IsActivated).AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			Func<bool, bool> randomTalismanCondition = delegate(bool isEnabled)
			{
				Player i = Player.i;
				bool flag = ((GameFlagDescriptable)i.mainAbilities.FooExplodeAllStyle.AbilityData).IsAcquired || ((GameFlagDescriptable)i.mainAbilities.FooExplodeAllStyleUpgrade.AbilityData).IsAcquired;
				bool flag2 = ((GameFlagDescriptable)i.mainAbilities.FooExplodeAutoStyle.AbilityData).IsAcquired || ((GameFlagDescriptable)i.mainAbilities.FooExplodeAutoStyleUpgrade.AbilityData).IsAcquired;
				bool flag3 = ((GameFlagDescriptable)i.mainAbilities.FooExplodeConsecutiveStyle.AbilityData).IsAcquired || ((GameFlagDescriptable)i.mainAbilities.FooExplodeConsecutiveStyleUpgrade.AbilityData).IsAcquired;
				return (!(flag ^ flag2 ^ flag3) || (flag && flag3 && flag3)) && isEnabled;
			};
			modifiersStore.CreateModifierBuilder<RandomTaliModifier>("random_talisman", "RandomTalismanModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => randomTalismanCondition(ConfigurationToUse.IsRandomTalismanModifierEnabled)).AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<EnduranceModifier>("endurance", "EnduranceModifier").AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[5] { "StealthGameMonster_Boss_ButterFly Variant", "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)" })).AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsEnduranceModifierEnabled)
				.BuildAndAdd();
			Func<bool, bool> shieldsCondition = (bool isEnabled) => Player.i.mainAbilities.ChargedAttackAbility.IsActivated && isEnabled && isVersionValid;
			modifiersStore.CreateModifierBuilder<QiShieldModifier>("qi_shield", "QiShieldModifer").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => shieldsCondition(ConfigurationToUse.IsQiShieldModifierEnabled)).AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[2] { "timer_shield", "distance_shield" }))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[7] { "StealthGameMonster_Boss_ButterFly Variant", "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_SpearHorseMan", "Monster_GiantMechClaw" }))
				.AddCombinationModifiers(new <>z__ReadOnlySingleElementList<string>("shield_break_bomb"))
				.AddController(typeof(MonsterShieldController), isShared: true)
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<TimedShieldModifier>("timer_shield", "CooldownShieldModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => shieldsCondition(ConfigurationToUse.IsCooldownShieldModifierEnabled)).AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[2] { "qi_shield", "distance_shield" }))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[7] { "StealthGameMonster_Boss_ButterFly Variant", "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_SpearHorseMan", "Monster_GiantMechClaw" }))
				.AddCombinationModifiers(new <>z__ReadOnlySingleElementList<string>("shield_break_bomb"))
				.AddController(typeof(MonsterShieldController), isShared: true)
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<DistanceShieldModifier>("distance_shield", "DistanceShieldModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => shieldsCondition(ConfigurationToUse.IsDistanceShieldModifierEnabled)).AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[2] { "timer_shield", "qi_shield" }))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[8] { "StealthGameMonster_Boss_ButterFly Variant", "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_伏羲_新", "StealthGameMonster_SpearHorseMan", "Monster_GiantMechClaw" }))
				.AddCombinationModifiers(new <>z__ReadOnlySingleElementList<string>("shield_break_bomb"))
				.AddController(typeof(MonsterShieldController), isShared: true)
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<QiOverloadModifier>("qi_overload", "QiOverloadModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsQiOverloadModifierEnabled).AddIncompatibles(new <>z__ReadOnlySingleElementList<string>("damage_buildup"))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<YanlaoGunModifier>("ya_gun", "YanlaoGunModifier").AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[5] { "shield_break_bomb", "qi_bomb", "qi_overload_bomb", "qi_depletion_bomb", "cooldown_bomb" })).AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => ConfigurationToUse.IsYanlaoGunModifierEnabled && isVersionValid)
				.AddController(typeof(MonsterYanlaoGunController), isShared: true)
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
			Func<bool, bool> bombCondition = (bool switchValue) => switchValue && isVersionValid;
			modifiersStore.CreateModifierBuilder<QiBombModifier>("qi_bomb", "QiBombModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => bombCondition(ConfigurationToUse.IsQiBombModifierEnabled)).AddController(typeof(MonsterBombController), isShared: true)
				.AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[4] { "ya_gun", "shield_break_bomb", "qi_overload_bomb", "qi_depletion_bomb" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<ShieldBreakBombModifier>("shield_break_bomb", "ShieldBreakBombModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => bombCondition(ConfigurationToUse.IsShieldBreakBombModifierEnabled)).AddController(typeof(MonsterBombController), isShared: true)
				.SetIsCombination(isCombination: true)
				.AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[4] { "qi_bomb", "ya_gun", "qi_overload_bomb", "qi_depletion_bomb" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<QiOverloadBombModifier>("qi_overload_bomb", "QiOverloadBombModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => bombCondition(ConfigurationToUse.IsQiOverloadBombModifierEnabled)).AddController(typeof(MonsterBombController), isShared: true)
				.AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[4] { "ya_gun", "shield_break_bomb", "qi_bomb", "qi_depletion_bomb" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<QiDepletionBombModifier>("qi_depletion_bomb", "QiDepletionBombModifier").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => bombCondition(ConfigurationToUse.IsQiDepletionBombModifierEnabled)).AddController(typeof(MonsterBombController), isShared: true)
				.AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[4] { "ya_gun", "shield_break_bomb", "qi_bomb", "qi_overload_bomb" }))
				.BuildAndAdd();
			modifiersStore.CreateModifierBuilder<CooldownBombModifier>("cooldown_bomb", "CooldownBomb").AddCanBeRolledConditionPredicate((ModifierConfig _, int _) => bombCondition(ConfigurationToUse.IsCooldownBombModifierEnabled)).AddController(typeof(MonsterBombController), isShared: true)
				.AddIncompatibles(new <>z__ReadOnlyArray<string>(new string[5] { "ya_gun", "shield_break_bomb", "qi_bomb", "qi_overload_bomb", "qi_depletion_bomb" }))
				.AddIgnoredMonsters(new <>z__ReadOnlyArray<string>(new string[6] { "StealthGameMonster_Boss_ButterFly Variant (1)", "StealthGameMonster_Boss_ButterFly Variant (2)", "StealthGameMonster_Boss_ButterFly Variant (3)", "StealthGameMonster_Boss_ButterFly Variant (4)", "StealthGameMonster_BossZombieSpear", "StealthGameMonster_BossZombieHammer" }))
				.BuildAndAdd();
		}
	}
	public class ChallengeMonsterController : MonoBehaviour, IResettableComponent
	{
		private int _killCounter;

		private MonsterBase _monster;

		public Action? OnRevivalStateEnter;

		public Action? OnRevivalStateExit;

		public Action? OnDie;

		public Action? OnEngage;

		public Action? OnDisengage;

		public List<States> DieHandelingStates = new List<States>();

		public int KillCounter { get; private set; }

		private void Awake()
		{
			_monster = ((Component)this).GetComponent<MonsterBase>();
		}

		public void ProcessRevivalStateEnter()
		{
			KillCounter++;
			OnRevivalStateEnter?.Invoke();
		}

		public void ProcessDeath()
		{
			KillCounter++;
			OnDie?.Invoke();
		}

		public void HandleMaxCyclesChange()
		{
		}

		public int GetPriority()
		{
			return -1;
		}

		public void ResetComponent()
		{
			KillCounter = 0;
			_monster.postureSystem.DieHandleingStates.Clear();
			_monster.postureSystem.DieHandleingStates.AddRange(DieHandelingStates);
			_monster.postureSystem.GenerateCurrentDieHandleStacks();
		}
	}
	internal static class Log
	{
		private static ManualLogSource? logSource;

		internal static void Init(ManualLogSource logSource)
		{
			Log.logSource = logSource;
		}

		internal static void Debug(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogError(data);
			}
		}

		internal static void Fatal(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogFatal(data);
			}
		}

		internal static void Info(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogInfo(data);
			}
		}

		internal static void Message(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogMessage(data);
			}
		}

		internal static void Warning(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogWarning(data);
			}
		}
	}
	internal class ModConfig
	{
		public string ValidVersion { get; set; } = string.Empty;

	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BossChallengeMod";

		public const string PLUGIN_NAME = "BossChallengeMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BossChallengeMod.UI
{
	public class CurrentTalismanUIContoller : MonoBehaviour
	{
		private Image talismanImage;

		public void Awake()
		{
			talismanImage = CreateImage();
			ValidateImage();
		}

		public void UpdateCurrentTalisman(Sprite sprite)
		{
			_ = Player.i;
			talismanImage.sprite = sprite;
			ValidateImage();
		}

		private Image CreateImage()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CurrentTalisman");
			val.transform.SetParent(((Component)this).transform, false);
			Image obj = val.AddComponent<Image>();
			((Transform)((Graphic)obj).rectTransform).localScale = new Vector3(1.5f, 1.5f, 1f);
			return obj;
		}

		private Sprite GetTalismanSprite(AbilityWrapper style, AbilityWrapper upgrade, Sprite baseSprite, Sprite upgradedSprite)
		{
			if (((AbilityWrapper)(ref style)).IsActivated)
			{
				if (!((AbilityWrapper)(ref upgrade)).IsActivated)
				{
					return baseSprite;
				}
				return upgradedSprite;
			}
			return null;
		}

		private void ValidateImage()
		{
			((Behaviour)talismanImage).enabled = (Object)(object)talismanImage.sprite != (Object)null;
		}
	}
	public class KillCounterController : MonoBehaviour
	{
		private TMP_FontAsset font;

		private bool needToShow;

		private bool needToShowExpanded;

		public TMP_Text MainCounterText;

		public TMP_Text HightScoreText;

		public TMP_Text LastAttemptText;

		public float labelSpacing = 10f;

		public float animationChangeDuration = 1f;

		public float labelTextAnimationShowDuration = 1f;

		public float labelTextAnimationHideDuration = 1f;

		public float labelTextDefaultAlpha = 1f;

		public float expandedTextAnimationShowDuration = 1f;

		public float expandedTextAnimationHideDuration = 1f;

		public float expandedTextDefaultAlpha = 1f;

		public UIControllerAnimationState UIControllerAnimationState { get; set; }

		public void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			font = LoadFont();
			MainCounterText = UIController.InitializeText(Vector2.zero, ((Component)this).gameObject, string.Format("{0} {1}", LocalizationResolver.Localize("kill_counter"), 0), active: false, 32, font, (TextAlignmentOptions)260);
			HightScoreText = UIController.InitializeText(new Vector2(0f, -36f), ((Component)this).gameObject, string.Format("{0} {1}", LocalizationResolver.Localize("kill_counter_hs"), 0), active: false, 20, font, (TextAlignmentOptions)260);
			LastAttemptText = UIController.InitializeText(new Vector2(0f, -56f), ((Component)this).gameObject, string.Format("{0} {1}", LocalizationResolver.Localize("kill_counter_last"), 0), active: false, 20, font, (TextAlignmentOptions)260);
			labelTextDefaultAlpha = MainCounterText.alpha;
			expandedTextDefaultAlpha = HightScoreText.alpha;
			MainCounterText.alpha = 0f;
		}

		public void ChangeNumber(int number)
		{
			MainCounterText.text = LocalizationResolver.Localize("kill_counter") + " " + number;
		}

		public void Show()
		{
			needToShow = true;
			((MonoBehaviour)this).StartCoroutine(AnimateTextShow(MainCounterText, needToShow, labelTextDefaultAlpha, labelTextAnimationShowDuration, EasingFunctions.Linear));
		}

		public void Hide(Action? callback = null)
		{
			needToShow = false;
			((MonoBehaviour)this).StartCoroutine(AnimateTextHide(MainCounterText, needToShow, labelTextDefaultAlpha, labelTextAnimationHideDuration, EasingFunctions.Linear, callback));
		}

		public void UpdateHighScore(int number)
		{
			HightScoreText.text = LocalizationResolver.Localize("kill_counter_hs") + " " + number;
		}

		public void UpdatePrevResult(int number)
		{
			LastAttemptText.text = LocalizationResolver.Localize("kill_counter_last") + " " + number;
		}

		public void ShowExtraText(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.ModifiersLowered)
			{
				needToShowExpanded = true;
				((MonoBehaviour)this).StartCoroutine(AnimateTextShow(HightScoreText, needToShowExpanded, expandedTextDefaultAlpha, expandedTextAnimationShowDuration, EasingFunctions.Linear, callback));
				((MonoBehaviour)this).StartCoroutine(AnimateTextShow(LastAttemptText, needToShowExpanded, expandedTextDefaultAlpha, expandedTextAnimationShowDuration, EasingFunctions.Linear));
			}
		}

		public void HideExtraText(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.KillCounterExpanded)
			{
				needToShowExpanded = false;
				((MonoBehaviour)this).StartCoroutine(AnimateTextHide(HightScoreText, needToShowExpanded, expandedTextDefaultAlpha, expandedTextAnimationHideDuration, EasingFunctions.Linear, callback));
				((MonoBehaviour)this).StartCoroutine(AnimateTextHide(LastAttemptText, needToShowExpanded, expandedTextDefaultAlpha, expandedTextAnimationHideDuration, EasingFunctions.Linear));
			}
		}

		private IEnumerator AnimateTextShow(TMP_Text text, bool flag, float defaultAlpha, float showDuration, Func<float, float> easingFunction, Action? callback = null)
		{
			if (flag)
			{
				((Component)text).gameObject.SetActive(true);
				float startingAlpha = text.alpha;
				float num = startingAlpha / defaultAlpha;
				float elapsedTime = showDuration * num;
				while (flag && elapsedTime < showDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float arg = elapsedTime / showDuration;
					text.alpha = Mathf.Lerp(startingAlpha, defaultAlpha, easingFunction(arg));
					yield return null;
				}
				if (flag)
				{
					callback?.Invoke();
				}
			}
		}

		private IEnumerator AnimateTextHide(TMP_Text text, bool flag, float defaultAlpha, float hideDuration, Func<float, float> easingFunction, Action? callback = null)
		{
			if (!flag)
			{
				float startingAlpha = text.alpha;
				float num = 1f - startingAlpha / defaultAlpha;
				float elapsedTime = hideDuration * num;
				while (!flag && elapsedTime < hideDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float arg = elapsedTime / hideDuration;
					text.alpha = Mathf.Lerp(startingAlpha, 0f, easingFunction(arg));
					yield return null;
				}
				if (!flag)
				{
					((Component)text).gameObject.SetActive(false);
					callback?.Invoke();
				}
			}
		}

		private TMP_FontAsset? LoadFont()
		{
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name == "LiberationSans SDF")
				{
					return val;
				}
			}
			return null;
		}
	}
	public class ModifiersUIController : MonoBehaviour
	{
		private enum ModifiersUIState
		{
			Hidden,
			UnfoldingLine,
			LineUnfolded,
			UnfoldingModifiers,
			ModifiersUnfolded,
			CollapsingModifiers,
			ModifiersCollapsed,
			CollapsingLine
		}

		private RectTransform line;

		private List<string> modifiers = new List<string>();

		private List<TMP_Text> items = new List<TMP_Text>();

		public float lineDefaultLength = 200f;

		public float lineUnfoldAnimationDuration = 0.75f;

		public float lineFoldAnimationDuration = 0.75f;

		public float modifierTextAnimationShowDuration = 0.7f;

		public float modifierTextAnimationHideDuration = 0.7f;

		public float modifierTextDefaultAlpha = 0.79f;

		private float modifiersDefaultHeight = -21f;

		private float modifiersLoweredHeight = -66f;

		private float modifiersRaisingAnimationDuration = 1f;

		private float modifiersLoweringAnimationDuration = 1f;

		private bool forceHide;

		public UIControllerAnimationState UIControllerAnimationState;

		private ModifiersUIState currentState;

		private ModifiersUIState CurrentState
		{
			get
			{
				return currentState;
			}
			set
			{
				switch (value)
				{
				case ModifiersUIState.Hidden:
					currentState = value;
					break;
				case ModifiersUIState.UnfoldingLine:
					currentState = value;
					break;
				case ModifiersUIState.LineUnfolded:
					currentState = value;
					if (modifiers.Any())
					{
						((MonoBehaviour)this).StartCoroutine(UnfoldModifiers());
					}
					else
					{
						((MonoBehaviour)this).StartCoroutine(CollapseLineAnimation());
					}
					break;
				case ModifiersUIState.UnfoldingModifiers:
					currentState = value;
					break;
				case ModifiersUIState.ModifiersUnfolded:
					currentState = value;
					break;
				case ModifiersUIState.CollapsingModifiers:
					currentState = value;
					break;
				case ModifiersUIState.ModifiersCollapsed:
					currentState = value;
					if (modifiers.Any() && !forceHide)
					{
						((MonoBehaviour)this).StartCoroutine(UnfoldModifiers());
					}
					else
					{
						((MonoBehaviour)this).StartCoroutine(CollapseLineAnimation());
					}
					break;
				case ModifiersUIState.CollapsingLine:
					currentState = value;
					break;
				default:
					currentState = value;
					break;
				}
			}
		}

		public void Awake()
		{
			line = CreateLine();
			((Component)line).gameObject.SetActive(false);
		}

		public void Show(bool force = false)
		{
			if (modifiers.Any() || force)
			{
				forceHide = false;
				switch (CurrentState)
				{
				case ModifiersUIState.Hidden:
					((MonoBehaviour)this).StartCoroutine(UnfoldLineAnimation());
					break;
				case ModifiersUIState.CollapsingLine:
					((MonoBehaviour)this).StartCoroutine(UnfoldLineAnimation());
					break;
				case ModifiersUIState.UnfoldingLine:
				case ModifiersUIState.LineUnfolded:
				case ModifiersUIState.UnfoldingModifiers:
				case ModifiersUIState.ModifiersUnfolded:
				case ModifiersUIState.CollapsingModifiers:
				case ModifiersUIState.ModifiersCollapsed:
					break;
				}
			}
		}

		public void Hide(bool force = false)
		{
			forceHide = force;
			switch (CurrentState)
			{
			case ModifiersUIState.UnfoldingLine:
				CurrentState = ModifiersUIState.CollapsingLine;
				break;
			case ModifiersUIState.LineUnfolded:
				((MonoBehaviour)this).StartCoroutine(CollapseLineAnimation());
				break;
			case ModifiersUIState.UnfoldingModifiers:
				CurrentState = ModifiersUIState.CollapsingModifiers;
				break;
			case ModifiersUIState.ModifiersUnfolded:
				((MonoBehaviour)this).StartCoroutine(CollapseModifiers());
				break;
			case ModifiersUIState.Hidden:
			case ModifiersUIState.CollapsingModifiers:
			case ModifiersUIState.ModifiersCollapsed:
			case ModifiersUIState.CollapsingLine:
				break;
			}
		}

		public void SetModifiers(IEnumerable<string> modifiers)
		{
			this.modifiers.Clear();
			this.modifiers.AddRange(modifiers);
			Hide();
		}

		public void Reset()
		{
			SetModifiers(Array.Empty<string>());
		}

		public void RaiseModifiers(Action? callback = null)
		{
			((MonoBehaviour)this).StartCoroutine(AnimateModifiersRaising(callback));
		}

		public void LowerModifiers(Action? callback = null)
		{
			((MonoBehaviour)this).StartCoroutine(AnimateModifiersLowering(callback));
		}

		private IEnumerator UnfoldModifiers()
		{
			if (CurrentState == ModifiersUIState.LineUnfolded || CurrentState == ModifiersUIState.ModifiersCollapsed || CurrentState == ModifiersUIState.CollapsingModifiers)
			{
				CurrentState = ModifiersUIState.UnfoldingModifiers;
				Queue<string> modifiersQueue = new Queue<string>(modifiers);
				int counter = 1;
				while (items.Any())
				{
					yield return (object)new WaitForSecondsRealtime(0.1f);
				}
				while (modifiersQueue.Any() && CurrentState == ModifiersUIState.UnfoldingModifiers)
				{
					string key = modifiersQueue.Dequeue();
					TMP_Text val = UIController.InitializeText(new Vector2(0f, (float)(-31 * counter)), ((Component)this).gameObject, LocalizationResolver.Localize(key), active: true, 21, null, (TextAlignmentOptions)260);
					counter++;
					val.alpha = 0f;
					items.Add(val);
					((MonoBehaviour)this).StartCoroutine(AnimateModifierShow(val, !modifiersQueue.Any()));
					yield return (object)new WaitForSecondsRealtime(0.25f);
				}
			}
		}

		private IEnumerator CollapseModifiers()
		{
			if (CurrentState == ModifiersUIState.ModifiersUnfolded || CurrentState == ModifiersUIState.UnfoldingModifiers)
			{
				CurrentState = ModifiersUIState.CollapsingModifiers;
				while (items.Any())
				{
					TMP_Text textItem = ListExtensions.Pop<TMP_Text>(items);
					((MonoBehaviour)this).StartCoroutine(AnimateModifierHide(textItem, !items.Any()));
					yield return (object)new WaitForSecondsRealtime(0.33f);
				}
			}
		}

		private IEnumerator UnfoldLineAnimation()
		{
			if (CurrentState == ModifiersUIState.Hidden || CurrentState == ModifiersUIState.CollapsingLine)
			{
				CurrentState = ModifiersUIState.UnfoldingLine;
				((Component)line).gameObject.SetActive(true);
				float startingLength = line.sizeDelta.x;
				float num = startingLength / lineDefaultLength;
				float elapsedTime = lineUnfoldAnimationDuration * num;
				while (CurrentState == ModifiersUIState.UnfoldingLine && elapsedTime < lineUnfoldAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / lineUnfoldAnimationDuration;
					float num2 = Mathf.Lerp(startingLength, lineDefaultLength, EasingFunctions.EaseOut(t));
					line.sizeDelta = new Vector2(num2, line.sizeDelta.y);
					yield return null;
				}
				if (CurrentState == ModifiersUIState.UnfoldingLine)
				{
					CurrentState = ModifiersUIState.LineUnfolded;
				}
			}
		}

		private IEnumerator CollapseLineAnimation()
		{
			if (CurrentState == ModifiersUIState.LineUnfolded || CurrentState == ModifiersUIState.UnfoldingLine || CurrentState == ModifiersUIState.ModifiersCollapsed)
			{
				CurrentState = ModifiersUIState.CollapsingLine;
				float startingLength = line.sizeDelta.x;
				float num = 1f - startingLength / lineDefaultLength;
				float elapsedTime = lineFoldAnimationDuration * num;
				while (CurrentState == ModifiersUIState.CollapsingLine && elapsedTime < lineFoldAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / lineFoldAnimationDuration;
					float num2 = Mathf.Lerp(startingLength, 0f, EasingFunctions.EaseOut(t));
					line.sizeDelta = new Vector2(num2, line.sizeDelta.y);
					yield return null;
				}
				if (CurrentState == ModifiersUIState.CollapsingLine)
				{
					CurrentState = ModifiersUIState.Hidden;
				}
			}
		}

		private IEnumerator AnimateModifierShow(TMP_Text textItem, bool last = false)
		{
			if (CurrentState == ModifiersUIState.UnfoldingModifiers)
			{
				((Component)textItem).gameObject.SetActive(true);
				float startingAlpha = textItem.alpha;
				float num = startingAlpha / modifierTextDefaultAlpha;
				float elapsedTime = modifierTextAnimationShowDuration * num;
				while (CurrentState == ModifiersUIState.UnfoldingModifiers && elapsedTime < modifierTextAnimationShowDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float num2 = elapsedTime / modifierTextAnimationShowDuration;
					textItem.alpha = Mathf.Lerp(startingAlpha, modifierTextDefaultAlpha, num2);
					yield return null;
				}
				if (CurrentState == ModifiersUIState.UnfoldingModifiers && last)
				{
					CurrentState = ModifiersUIState.ModifiersUnfolded;
				}
			}
		}

		private IEnumerator AnimateModifierHide(TMP_Text textItem, bool last = false)
		{
			float startingAlpha = textItem.alpha;
			float num = 1f - startingAlpha / modifierTextDefaultAlpha;
			float elapsedTime = modifierTextAnimationHideDuration * num;
			while (elapsedTime < modifierTextAnimationHideDuration)
			{
				elapsedTime += Time.unscaledDeltaTime;
				float num2 = elapsedTime / modifierTextAnimationHideDuration;
				textItem.alpha = Mathf.Lerp(startingAlpha, 0f, num2);
				yield return null;
			}
			if (CurrentState == ModifiersUIState.CollapsingModifiers && last)
			{
				CurrentState = ModifiersUIState.ModifiersCollapsed;
			}
			Object.Destroy((Object)(object)((Component)textItem).gameObject);
		}

		private IEnumerator AnimateModifiersLowering(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.KillCounterCollapsed)
			{
				float elapsedTime = 0f;
				Vector3 localPosition = default(Vector3);
				while (elapsedTime < modifiersLoweringAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / modifiersLoweringAnimationDuration;
					((Vector3)(ref localPosition))..ctor(((Component)this).transform.localPosition.x, Mathf.Lerp(modifiersDefaultHeight, modifiersLoweredHeight, EasingFunctions.EaseOut(t)));
					((Component)this).transform.localPosition = localPosition;
					yield return null;
				}
				if (UIControllerAnimationState == UIControllerAnimationState.KillCounterCollapsed)
				{
					callback?.Invoke();
				}
			}
		}

		private IEnumerator AnimateModifiersRaising(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.KillCounterExpandedTextHidden)
			{
				float elapsedTime = 0f;
				Vector3 localPosition = default(Vector3);
				while (elapsedTime < modifiersRaisingAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / modifiersRaisingAnimationDuration;
					((Vector3)(ref localPosition))..ctor(((Component)this).transform.localPosition.x, Mathf.Lerp(modifiersLoweredHeight, modifiersDefaultHeight, EasingFunctions.EaseOut(t)));
					((Component)this).transform.localPosition = localPosition;
					yield return null;
				}
				if (UIControllerAnimationState == UIControllerAnimationState.KillCounterExpandedTextHidden)
				{
					callback?.Invoke();
				}
			}
		}

		private RectTransform CreateLine()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Color color = default(Color);
			((Color)(ref color))..ctor(0.941f, 0.862f, 0.588f, 0.79f);
			float num = 1f;
			float num2 = 0f;
			GameObject val = new GameObject("HorizontalLine");
			val.transform.SetParent(((Component)this).transform, false);
			((Graphic)val.AddComponent<Image>()).color = color;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(num2, num);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(1f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			val.transform.localPosition = Vector2.op_Implicit(new Vector2(100f, 0f));
			return component;
		}
	}
	public class MonsterUIController
	{
		private MonsterKillCounter? trackedKillCounter;

		private MonsterModifierController? trackedModifiersController;

		private readonly List<MonsterModifierController> compositeModifierControllers = new List<MonsterModifierController>();

		private UIController UIController = BossChallengeMod.Instance.UIController;

		private bool isHidingKillCounter;

		private bool isHidingRecordsText;

		public bool IsHidingKillCounter
		{
			get
			{
				return isHidingKillCounter;
			}
			set
			{
				isHidingKillCounter = value;
				if ((Object)(object)trackedKillCounter != (Object)null && !isHidingKillCounter)
				{
					UpdateKillCounterUI();
				}
			}
		}

		public bool IsHidingRecordsText
		{
			get
			{
				return isHidingRecordsText;
			}
			set
			{
				isHidingRecordsText = value;
				if ((Object)(object)trackedKillCounter != (Object)null && !isHidingRecordsText)
				{
					UpdateKillCounterUI();
				}
			}
		}

		public MonsterUIController()
		{
			UIController uIController = UIController;
			uIController.OnModifiersRaisedAnimationDone = (Action)Delegate.Combine(uIController.OnModifiersRaisedAnimationDone, (Action)delegate
			{
				IsHidingRecordsText = false;
			});
			SceneManager.sceneUnloaded += ValidateOnSceneUnload;
		}

		public void ChangeKillCounter(MonsterKillCounter? monsterKillCounter)
		{
			if (!((Object)(object)monsterKillCounter != (Object)null) || monsterKillCounter.CanBeTracked)
			{
				if ((Object)(object)trackedKillCounter != (Object)null)
				{
					MonsterKillCounter? monsterKillCounter2 = trackedKillCounter;
					monsterKillCounter2.OnUpdate = (Action)Delegate.Remove(monsterKillCounter2.OnUpdate, new Action(UpdateKillCounterUI));
					MonsterKillCounter? monsterKillCounter3 = trackedKillCounter;
					monsterKillCounter3.OnDestroyActions = (Action)Delegate.Remove(monsterKillCounter3.OnDestroyActions, new Action(ResetKillCounter));
				}
				trackedKillCounter = monsterKillCounter;
				if ((Object)(object)trackedKillCounter != (Object)null)
				{
					MonsterKillCounter? monsterKillCounter4 = trackedKillCounter;
					monsterKillCounter4.OnUpdate = (Action)Delegate.Combine(monsterKillCounter4.OnUpdate, new Action(UpdateKillCounterUI));
					MonsterKillCounter? monsterKillCounter5 = trackedKillCounter;
					monsterKillCounter5.OnDestroyActions = (Action)Delegate.Combine(monsterKillCounter5.OnDestroyActions, new Action(ResetKillCounter));
				}
				UpdateKillCounterUI();
			}
		}

		public void ChangeModifiersController(MonsterModifierController? monsterModifierController)
		{
			if (!((Object)(object)monsterModifierController != (Object)null) || monsterModifierController.CanBeTracked)
			{
				if ((Object)(object)trackedModifiersController != (Object)null)
				{
					MonsterModifierController? monsterModifierController2 = trackedModifiersController;
					monsterModifierController2.OnModifiersChange = (Action)Delegate.Remove(monsterModifierController2.OnModifiersChange, new Action(UpdateModifierUI));
					MonsterModifierController? monsterModifierController3 = trackedModifiersController;
					monsterModifierController3.OnDestroyActions = (Action)Delegate.Remove(monsterModifierController3.OnDestroyActions, new Action(ResetModifierController));
				}
				trackedModifiersController = monsterModifierController;
				if ((Object)(object)trackedModifiersController != (Object)null)
				{
					MonsterModifierController? monsterModifierController4 = trackedModifiersController;
					monsterModifierController4.OnModifiersChange = (Action)Delegate.Combine(monsterModifierController4.OnModifiersChange, new Action(UpdateModifierUI));
					MonsterModifierController? monsterModifierController5 = trackedModifiersController;
					monsterModifierController5.OnDestroyActions = (Action)Delegate.Combine(monsterModifierController5.OnDestroyActions, new Action(ResetModifierController));
				}
				UpdateModifierUI();
			}
		}

		public void AddCompositeModifierController(MonsterModifierController monsterModifierController)
		{
			if (monsterModifierController.UseCompositeTracking)
			{
				compositeModifierControllers.Add(monsterModifierController);
				monsterModifierController.OnModifiersChange = (Action)Delegate.Combine(monsterModifierController.OnModifiersChange, new Action(UpdateModifierUI));
				UpdateModifierUI();
			}
		}

		public void RemoveCompositeModifierController(MonsterModifierController monsterModifierController)
		{
			compositeModifierControllers.Remove(monsterModifierController);
			monsterModifierController.OnModifiersChange = (Action)Delegate.Remove(monsterModifierController.OnModifiersChange, new Action(UpdateModifierUI));
			UpdateModifierUI();
		}

		private void UpdateKillCounterUI()
		{
			if ((Object)(object)trackedKillCounter == (Object)null)
			{
				IsHidingKillCounter = true;
				UIController.HideText(delegate
				{
					IsHidingKillCounter = false;
				});
				if (UIController.CurrentAnimationState != 0)
				{
					IsHidingRecordsText = true;
					UIController.HideExpandedKillNumbersText();
				}
				return;
			}
			if (!isHidingKillCounter)
			{
				UIController.UpdateBossCounterNumber(trackedKillCounter.KillCounter);
				UIController.ShowText();
			}
			if (!isHidingRecordsText && (trackedKillCounter.BestCount > 0 || trackedKillCounter.LastCount > 0))
			{
				UIController.UpdateBossRecordValues(trackedKillCounter.BestCount, trackedKillCounter.LastCount);
				UIController.ShowExpandedKillNumbersText();
			}
		}

		private void UpdateModifierUI()
		{
			try
			{
				if ((Object)(object)trackedModifiersController == (Object)null)
				{
					MonoNodeExtension.RemoveAllNull<MonsterModifierController>(compositeModifierControllers);
					if (compositeModifierControllers.Any())
					{
						UIController.UpdateModifiers((from controller in compositeModifierControllers
							from config in controller.Activated
							select new
							{
								CombinedKey = HashCode.Combine(((object)controller).GetHashCode(), config.GetHashCode()),
								ConfigKey = config.Key
							}).ToDictionary(x => x.CombinedKey, x => x.ConfigKey));
					}
					else
					{
						UIController.UpdateModifiers(new Dictionary<int, string>());
					}
				}
				else if (trackedModifiersController.Activated.Any())
				{
					UIController.UpdateModifiers(trackedModifiersController.Activated.ToDictionary((ModifierConfig config) => HashCode.Combine(((object)trackedModifiersController).GetHashCode(), config.GetHashCode()), (ModifierConfig config) => config.Key));
				}
				else
				{
					UIController.UpdateModifiers(new Dictionary<int, string>());
				}
			}
			catch (Exception ex)
			{
				Log.Error(ex.Message + ", " + ex.StackTrace);
			}
		}

		public void ResetKillCounter()
		{
			ChangeKillCounter(null);
		}

		public void ResetModifierController()
		{
			ChangeModifiersController(null);
		}

		public void ValidateOnSceneUnload(Scene scene)
		{
		}

		public void Unload()
		{
			SceneManager.sceneUnloaded -= ValidateOnSceneUnload;
		}
	}
	public class QueueUISystem : MonoBehaviour
	{
		protected Queue<IEnumerator> operationsQueue = new Queue<IEnumerator>();

		private bool _isProcessing;

		protected Action? OnOperationProcessed;

		public void EnqueueOperation(IEnumerator uiOperation)
		{
			operationsQueue.Enqueue(uiOperation);
			if (!_isProcessing)
			{
				((MonoBehaviour)this).StartCoroutine(ProcessQueue());
			}
		}

		private IEnumerator ProcessQueue()
		{
			_isProcessing = true;
			while (operationsQueue.Count > 0)
			{
				IEnumerator enumerator = operationsQueue.Dequeue();
				yield return ((MonoBehaviour)this).StartCoroutine(enumerator);
				OnOperationProcessed?.Invoke();
			}
			_isProcessing = false;
		}
	}
	public class TimerController : MonoBehaviour
	{
		private enum UIAnimationStates
		{
			Show,
			Hide
		}

		private TMP_Text timerText;

		private TMP_FontAsset font;

		private float animationShowDuration = 0.75f;

		private float animationHideDuration = 0.75f;

		private float hiddenYPosition;

		private float visibleYPosition;

		private UIAnimationStates state = UIAnimationStates.Hide;

		public void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			font = LoadFont();
			timerText = UIController.InitializeText(Vector2.zero, ((Component)this).gameObject, "00:00:000", active: false, 32, font, (TextAlignmentOptions)514);
			visibleYPosition = GetVisiblePosition();
			hiddenYPosition = GetHiddenPosition();
			timerText.transform.localPosition = new Vector3(timerText.transform.localPosition.x, hiddenYPosition);
		}

		public void Show()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			state = UIAnimationStates.Show;
			if (BossChallengeMod.Instance.UIConfiguration.UseCustomTimerPosition)
			{
				((Component)timerText).gameObject.SetActive(true);
				timerText.transform.localPosition = new Vector3(timerText.transform.localPosition.x, visibleYPosition);
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(AnimateTimerShow());
			}
		}

		public void Hide()
		{
			state = UIAnimationStates.Hide;
			if (BossChallengeMod.Instance.UIConfiguration.UseCustomTimerPosition)
			{
				((Component)timerText).gameObject.SetActive(false);
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(AnimateTimerHide());
			}
		}

		public void UpdateTimer(int milliseconds)
		{
			timerText.text = FormatMilliseconds(milliseconds);
		}

		private string FormatMilliseconds(int milliseconds)
		{
			TimeSpan timeSpan = TimeSpan.FromMilliseconds(milliseconds);
			return $"{timeSpan.Minutes:D2}:{timeSpan.Seconds:D2}.{timeSpan.Milliseconds:D3}";
		}

		private IEnumerator AnimateTimerShow()
		{
			if (state == UIAnimationStates.Show && timerText.transform.localPosition.y != visibleYPosition)
			{
				((Component)timerText).gameObject.SetActive(true);
				float elapsedTime = 0f;
				while (elapsedTime < animationShowDuration && state == UIAnimationStates.Show)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / animationShowDuration;
					float num = Mathf.Lerp(hiddenYPosition, visibleYPosition, EasingFunctions.EaseOut(t));
					timerText.transform.localPosition = new Vector3(timerText.transform.localPosition.x, num);
					yield return null;
				}
				timerText.transform.localPosition = new Vector3(timerText.transform.localPosition.x, visibleYPosition);
			}
		}

		private IEnumerator AnimateTimerHide()
		{
			if (state == UIAnimationStates.Hide)
			{
				float elapsedTime = 0f;
				while (elapsedTime < animationHideDuration && state == UIAnimationStates.Hide)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / animationShowDuration;
					float num = Mathf.Lerp(visibleYPosition, hiddenYPosition, EasingFunctions.EaseOut(t));
					timerText.transform.localPosition = new Vector3(timerText.transform.localPosition.x, num);
					yield return null;
				}
				if (state == UIAnimationStates.Hide)
				{
					((Component)timerText).gameObject.SetActive(false);
				}
			}
		}

		private TMP_FontAsset? LoadFont()
		{
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name == "LiberationSans SDF")
				{
					return val;
				}
			}
			return null;
		}

		private float GetVisiblePosition()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ((Component)((Component)NineSolsAPICore.FullscreenCanvas).transform).GetComponent<RectTransform>().rect;
			return ((Rect)(ref rect)).height * 0.03f;
		}

		private float GetHiddenPosition()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return 0f - ((Component)this).transform.position.y - timerText.preferredHeight;
		}
	}
	public class UIController
	{
		private KillCounterController bossCounterTextController;

		private global::BossChallengeMod.UI.QueueUI.ModifiersUIController modifiersController;

		private TimerController timerController;

		private CurrentTalismanUIContoller talismanUIController;

		public Action? OnModifiersRaisedAnimationDone;

		private UIConfiguration _configuration;

		private UIControllerAnimationState animationState;

		private RectTransform rightPanel;

		private RectTransform bottomPanel;

		private RectTransform bottomLeftPanel;

		public UIControllerAnimationState CurrentAnimationState
		{
			get
			{
				return animationState;
			}
			private set
			{
				animationState = value;
				modifiersController.UIControllerAnimationState = value;
				bossCounterTextController.UIControllerAnimationState = value;
				switch (value)
				{
				case UIControllerAnimationState.ModifiersLowered:
					bossCounterTextController.ShowExtraText(delegate
					{
						CurrentAnimationState = UIControllerAnimationState.KillCounterExpanded;
					});
					break;
				case UIControllerAnimationState.KillCounterExpandedTextHidden:
					modifiersController.RaiseModifiers(delegate
					{
						CurrentAnimationState = UIControllerAnimationState.KillCounterCollapsed;
						OnModifiersRaisedAnimationDone?.Invoke();
					});
					break;
				case UIControllerAnimationState.KillCounterCollapsed:
				case UIControllerAnimationState.KillCounterExpanded:
					break;
				}
			}
		}

		public UIController(UIConfiguration configuration)
		{
			rightPanel = CreateRightPanelObject();
			bottomPanel = CreateBottomPanelObject();
			bottomLeftPanel = CreateBottomLeftPanelObject();
			bossCounterTextController = MonoNodeExtension.AddChildrenComponent<KillCounterController>(((Component)rightPanel).gameObject, "KillCounter");
			modifiersController = CreateModifiersControllerGUI();
			timerController = MonoNodeExtension.AddChildrenComponent<TimerController>(((Component)bottomPanel).gameObject, "TimerUI");
			talismanUIController = MonoNodeExtension.AddChildrenComponent<CurrentTalismanUIContoller>(((Component)bottomLeftPanel).gameObject, "TalismanUI");
			_configuration = configuration;
			ResolveConfigurationEvents(_configuration);
		}

		private void RestoreUI()
		{
			rightPanel = CreateRightPanelObject();
			bottomPanel = CreateBottomPanelObject();
			bottomLeftPanel = CreateBottomLeftPanelObject();
			bossCounterTextController = MonoNodeExtension.AddChildrenComponent<KillCounterController>(((Component)rightPanel).gameObject, "KillCounter");
			modifiersController = CreateModifiersControllerGUI();
			timerController = MonoNodeExtension.AddChildrenComponent<TimerController>(((Component)bottomPanel).gameObject, "TimerUI");
			talismanUIController = MonoNodeExtension.AddChildrenComponent<CurrentTalismanUIContoller>(((Component)bottomLeftPanel).gameObject, "TalismanUI");
		}

		public RectTransform CreateRightPanelObject()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)NineSolsAPICore.FullscreenCanvas).transform;
			GameObject val = new GameObject("BossChallenge_RightPanelUI");
			val.transform.SetParent(transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			RectTransform component = ((Component)transform).GetComponent<RectTransform>();
			CalculateRightPanelPosition(component, out var coordsX, out var coordsY);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 0f);
			obj.pivot = new Vector2(0f, 0f);
			obj.anchoredPosition = new Vector2(coordsX, coordsY);
			obj.sizeDelta = new Vector2(300f, 200f);
			return obj;
		}

		private void CalculateRightPanelPosition(RectTransform canvasRect, out float coordsX, out float coordsY)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = canvasRect.rect;
			float width = ((Rect)(ref rect)).width;
			rect = canvasRect.rect;
			float height = ((Rect)(ref rect)).height;
			CalculateRightPanelPosition(width, height, out coordsX, out coordsY);
		}

		private void CalculateRightPanelPosition(float width, float height, out float coordsX, out float coordsY)
		{
			coordsX = width - width / 9f;
			coordsY = height - height / 4.5f;
		}

		public RectTransform CreateBottomPanelObject()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)NineSolsAPICore.FullscreenCanvas).transform;
			GameObject val = new GameObject("BossChallenge_BottomPanelUI");
			val.transform.SetParent(transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			RectTransform component = ((Component)transform).GetComponent<RectTransform>();
			CalculateBottomPanelPosition(component, out var coordsX, out var coordsY);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 0f);
			obj.pivot = new Vector2(0f, 0f);
			obj.anchoredPosition = new Vector2(coordsX, coordsY);
			obj.sizeDelta = new Vector2(100f, 100f);
			return obj;
		}

		private void CalculateBottomPanelPosition(RectTransform canvasRect, out float coordsX, out float coordsY)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = canvasRect.rect;
			float width = ((Rect)(ref rect)).width;
			rect = canvasRect.rect;
			float height = ((Rect)(ref rect)).height;
			CalculateBottomPanelPosition(width, height, out coordsX, out coordsY);
		}

		private void CalculateBottomPanelPosition(float width, float height, out float coordsX, out float coordsY)
		{
			coordsX = width - width / 2f;
			coordsY = height / 10f;
		}

		public RectTransform CreateBottomLeftPanelObject()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)NineSolsAPICore.FullscreenCanvas).transform;
			GameObject val = new GameObject("BossChallenge_BottomLeftPanelUI");
			val.transform.SetParent(transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			RectTransform component = ((Component)transform).GetComponent<RectTransform>();
			CalculateBottomLeftPanelPosition(component, out var coordsX, out var coordsY);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 0f);
			obj.pivot = new Vector2(0f, 0f);
			obj.anchoredPosition = new Vector2(coordsX, coordsY);
			obj.sizeDelta = new Vector2(100f, 100f);
			return obj;
		}

		private void CalculateBottomLeftPanelPosition(RectTransform canvasRect, out float coordsX, out float coordsY)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = canvasRect.rect;
			float width = ((Rect)(ref rect)).width;
			rect = canvasRect.rect;
			float height = ((Rect)(ref rect)).height;
			CalculateBottomLeftPanelPosition(width, height, out coordsX, out coordsY);
		}

		private void CalculateBottomLeftPanelPosition(float width, float height, out float coordsX, out float coordsY)
		{
			coordsX = width / 13.71f;
			coordsY = height / 4.15f;
		}

		private global::BossChallengeMod.UI.QueueUI.ModifiersUIController CreateModifiersControllerGUI()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			global::BossChallengeMod.UI.QueueUI.ModifiersUIController modifiersUIController = MonoNodeExtension.AddChildrenComponent<global::BossChallengeMod.UI.QueueUI.ModifiersUIController>(((Component)rightPanel).gameObject, "ModifiersUI");
			((Component)modifiersUIController).transform.localPosition = new Vector3(0f, -21f);
			return modifiersUIController;
		}

		public static TMP_Text InitializeText(Vector2 localPosition, GameObject parent, string text = "Test", bool active = false, int fontSize = 32, TMP_FontAsset? font = null, TextAlignmentOptions alignment = 260)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = MonoNodeExtension.AddChildrenComponent<TextMeshProUGUI>(((Component)((Component)NineSolsAPICore.FullscreenCanvas).transform).gameObject, "BossCounter_Text");
			((TMP_Text)val).fontSize = fontSize;
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val).font = font;
			}
			((Graphic)val).color = new Color(0.941f, 0.862f, 0.588f, 0.79f);
			((TMP_Text)val).alignment = alignment;
			((TMP_Text)val).text = text;
			((Component)val).GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 50f);
			((TMP_Text)val).transform.localPosition = Vector2.op_Implicit(localPosition);
			((TMP_Text)val).transform.SetParent(parent.transform, false);
			MonoLifeTimeExtension.SetActive((MonoBehaviour)(object)val, active);
			return (TMP_Text)(object)val;
		}

		public void UpdateTalisman(Sprite sprite)
		{
			talismanUIController.UpdateCurrentTalisman(sprite);
		}

		public void UpdateBossCounterNumber(int number)
		{
			if ((Object)(object)rightPanel == (Object)null || (Object)(object)bottomPanel == (Object)null || (Object)(object)timerController == (Object)null)
			{
				RestoreUI();
			}
			bossCounterTextController.ChangeNumber(number);
			ShowText();
		}

		public void UpdateModifiers(Dictionary<int, string> modifiers)
		{
			modifiersController.SetModifiers(modifiers);
		}

		public void HideModifiers()
		{
			modifiersController.Reset();
		}

		public void ShowText()
		{
			bossCounterTextController.Show();
		}

		public void HideText(Action? callback = null)
		{
			bossCounterTextController.Hide(callback);
		}

		public void ShowExpandedKillNumbersText()
		{
			modifiersController.LowerModifiers(delegate
			{
				CurrentAnimationState = UIControllerAnimationState.ModifiersLowered;
			});
		}

		public void HideExpandedKillNumbersText(Action? callback = null)
		{
			Action callback2 = callback;
			bossCounterTextController.HideExtraText(delegate
			{
				CurrentAnimationState = UIControllerAnimationState.KillCounterExpandedTextHidden;
				callback2?.Invoke();
			});
		}

		public void UpdateBossRecordValues(int highScore, int prevResult)
		{
			if ((Object)(object)rightPanel == (Object)null || (Object)(object)bottomPanel == (Object)null || (Object)(object)timerController == (Object)null)
			{
				RestoreUI();
			}
			bossCounterTextController.UpdateHighScore(highScore);
			bossCounterTextController.UpdatePrevResult(prevResult);
		}

		public void ShowTimer()
		{
			timerController.Show();
		}

		public void HideTimer()
		{
			timerController.Hide();
		}

		public void UpdateTimer(int milliseconds)
		{
			timerController.UpdateTimer(milliseconds);
		}

		private TMP_FontAsset? LoadFont()
		{
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name == "LiberationSans SDF")
				{
					return val;
				}
			}
			return null;
		}

		public void Unload()
		{
			UnsubscribeConfigurationEvents(_configuration);
			if ((Object)(object)rightPanel != (Object)null)
			{
				Object.Destroy((Object)(object)rightPanel);
			}
			if ((Object)(object)bottomPanel != (Object)null)
			{
				Object.Destroy((Object)(object)bottomPanel);
			}
			if ((Object)(object)bottomLeftPanel != (Object)null)
			{
				Object.Destroy((Object)(object)bottomLeftPanel);
			}
			if ((Object)(object)modifiersController != (Object)null)
			{
				Object.Destroy((Object)(object)modifiersController);
			}
			if (OnModifiersRaisedAnimationDone != null)
			{
				OnModifiersRaisedAnimationDone = null;
			}
		}

		public void FixUI()
		{
			if ((Object)(object)rightPanel == (Object)null || (Object)(object)bottomPanel == (Object)null || (Object)(object)timerController == (Object)null)
			{
				RestoreUI();
			}
		}

		private void ResolveConfigurationEvents(UIConfiguration configuration)
		{
			configuration.OnCounterUIEnabledChanged += ToggleCounterUI;
			configuration.OnUseCustomCounterPositionChanged += ToggleCustomCounterUIPosition;
			configuration.OnCounterXPosChanged += ChangeCounterXPosition;
			configuration.OnCounterYPosChanged += ChangeCounterYPosition;
			configuration.OnCounterUIScaleChanged += ChangeCounterScale;
			configuration.OnEnableTimerUIChanged += ToggleTimerUI;
			configuration.OnUseCustomTimerPositionChanged += ToggleCustomTimerUIPosition;
			configuration.OnTimerXPosChanged += ChangeTimerXPosition;
			configuration.OnTimerYPosChanged += ChangeTimerYPosition;
			configuration.OnTimerUIScaleChanged += ChangeTimerScale;
			configuration.OnEnableTalismanModeUIChanged += ToggleTalismanModeUI;
			configuration.OnUseCustomTalismanModePositionChanged += ToggleCustomTalismanModeUIPosition;
			configuration.OnTalismanModeXPosChanged += ChangeTalismanModeXPosition;
			configuration.OnTalismanModeYPosChanged += ChangeTalismanModeYPosition;
			configuration.OnTalismanUIScaleChanged += ChangeTalismanScale;
		}

		private void UnsubscribeConfigurationEvents(UIConfiguration configuration)
		{
			configuration.OnCounterUIEnabledChanged -= ToggleCounterUI;
			configuration.OnUseCustomCounterPositionChanged -= ToggleCustomCounterUIPosition;
			configuration.OnCounterXPosChanged -= ChangeCounterXPosition;
			configuration.OnCounterYPosChanged -= ChangeCounterYPosition;
			configuration.OnCounterUIScaleChanged -= ChangeCounterScale;
			configuration.OnEnableTimerUIChanged -= ToggleTimerUI;
			configuration.OnUseCustomTimerPositionChanged -= ToggleCustomTimerUIPosition;
			configuration.OnTimerXPosChanged -= ChangeTimerXPosition;
			configuration.OnTimerYPosChanged -= ChangeTimerYPosition;
			configuration.OnTimerUIScaleChanged -= ChangeTimerScale;
			configuration.OnEnableTalismanModeUIChanged -= ToggleTalismanModeUI;
			configuration.OnUseCustomTalismanModePositionChanged -= ToggleCustomTalismanModeUIPosition;
			configuration.OnTalismanModeXPosChanged -= ChangeTalismanModeXPosition;
			configuration.OnTalismanModeYPosChanged -= ChangeTalismanModeYPosition;
			configuration.OnTalismanUIScaleChanged -= ChangeTalismanScale;
		}

		public void ToggleCounterUI(bool toggle)
		{
			((Component)rightPanel).gameObject.SetActive(toggle);
		}

		public void ToggleCustomCounterUIPosition(bool toggle)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rightPanel != (Object)null)
			{
				if (toggle)
				{
					float counterXPos = _configuration.CounterXPos;
					float counterYPos = _configuration.CounterYPos;
					rightPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(counterXPos, counterYPos));
				}
				else
				{
					RectTransform component = ((Component)((Component)NineSolsAPICore.FullscreenCanvas).transform).GetComponent<RectTransform>();
					CalculateRightPanelPosition(component, out var coordsX, out var coordsY);
					rightPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX, coordsY));
				}
			}
		}

		public void ChangeCounterXPosition(float posX)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rightPanel != (Object)null && _configuration.UseCustomCounterPosition)
			{
				float counterYPos = _configuration.CounterYPos;
				rightPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(posX, counterYPos));
			}
		}

		public void ChangeCounterYPosition(float posY)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rightPanel != (Object)null && _configuration.UseCustomCounterPosition)
			{
				float counterXPos = _configuration.CounterXPos;
				rightPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(counterXPos, posY));
			}
		}

		public void ChangeCounterScale(float scale)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rightPanel != (Object)null)
			{
				((Transform)rightPanel).localScale = new Vector3(scale, scale);
			}
		}

		public void ToggleTimerUI(bool toggle)
		{
			((Component)timerController).gameObject.SetActive(toggle);
		}

		public void ToggleCustomTimerUIPosition(bool toggle)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomPanel != (Object)null)
			{
				if (toggle)
				{
					float counterXPos = _configuration.CounterXPos;
					float counterYPos = _configuration.CounterYPos;
					((Component)bottomPanel).transform.position = new Vector3(counterXPos, counterYPos);
				}
				else
				{
					RectTransform component = ((Component)((Component)NineSolsAPICore.FullscreenCanvas).transform).GetComponent<RectTransform>();
					CalculateBottomPanelPosition(component, out var coordsX, out var coordsY);
					bottomPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX, coordsY));
				}
			}
		}

		public void ChangeTimerXPosition(float posX)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomPanel != (Object)null && _configuration.UseCustomTimerPosition)
			{
				float timerYPos = _configuration.TimerYPos;
				bottomPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(posX, timerYPos));
			}
		}

		public void ChangeTimerYPosition(float posY)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomPanel != (Object)null && _configuration.UseCustomTimerPosition)
			{
				float timerXPos = _configuration.TimerXPos;
				bottomPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(timerXPos, posY));
			}
		}

		public void ChangeTimerScale(float scale)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomPanel != (Object)null)
			{
				((Transform)bottomPanel).localScale = new Vector3(scale, scale);
			}
		}

		public void ToggleTalismanModeUI(bool toggle)
		{
			((Component)bottomLeftPanel).gameObject.SetActive(toggle);
		}

		public void ToggleCustomTalismanModeUIPosition(bool toggle)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomLeftPanel != (Object)null)
			{
				if (toggle)
				{
					float talismanModeXPos = _configuration.TalismanModeXPos;
					float talismanModeYPos = _configuration.TalismanModeYPos;
					((Component)bottomLeftPanel).transform.position = new Vector3(talismanModeXPos, talismanModeYPos);
				}
				else
				{
					RectTransform component = ((Component)((Component)NineSolsAPICore.FullscreenCanvas).transform).GetComponent<RectTransform>();
					CalculateBottomLeftPanelPosition(component, out var coordsX, out var coordsY);
					bottomLeftPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX, coordsY));
				}
			}
		}

		public void ChangeTalismanModeXPosition(float posX)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomLeftPanel != (Object)null && _configuration.UseCustomTalismanModePosition)
			{
				float talismanModeYPos = _configuration.TalismanModeYPos;
				bottomLeftPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(posX, talismanModeYPos));
			}
		}

		public void ChangeTalismanModeYPosition(float posY)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomLeftPanel != (Object)null && _configuration.UseCustomTalismanModePosition)
			{
				float talismanModeXPos = _configuration.TalismanModeXPos;
				bottomLeftPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(talismanModeXPos, posY));
			}
		}

		public void ChangeTalismanScale(float scale)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bottomLeftPanel != (Object)null)
			{
				((Transform)bottomLeftPanel).localScale = new Vector3(scale, scale);
			}
		}

		public void RecalculatePositions(int width, int height)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (!_configuration.UseCustomCounterPosition)
			{
				CalculateRightPanelPosition(width, height, out var coordsX, out var coordsY);
				rightPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX, coordsY));
			}
			if (!_configuration.UseCustomTimerPosition)
			{
				CalculateBottomPanelPosition(width, height, out var coordsX2, out var coordsY2);
				bottomPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX2, coordsY2));
			}
			if (!_configuration.UseCustomTalismanModePosition)
			{
				CalculateBottomLeftPanelPosition(width, height, out var coordsX3, out var coordsY3);
				bottomLeftPanel.anchoredPosition = Vector2.op_Implicit(new Vector3(coordsX3, coordsY3));
			}
		}
	}
	public enum UIControllerAnimationState
	{
		KillCounterCollapsed,
		ModifiersLowered,
		KillCounterExpanded,
		KillCounterExpandedTextHidden
	}
}
namespace BossChallengeMod.UI.QueueUI
{
	public class ModifiersUIController : QueueUISystem
	{
		private class ModifierTextItem
		{
			public int Id { get; }

			public string Text { get; }

			public ModifierTextItem(int id, string text)
			{
				Id = id;
				Text = text;
			}
		}

		private class ModifierUIItem
		{
			public int Id { get; }

			public TMP_Text TextObj { get; }

			public ModifierUIItem(int id, TMP_Text textObj)
			{
				Id = id;
				TextObj = textObj;
			}
		}

		private class ModifierTextItemComparer : IEqualityComparer<ModifierTextItem>
		{
			public bool Equals(ModifierTextItem x, ModifierTextItem y)
			{
				return x.Id == y.Id;
			}

			public int GetHashCode(ModifierTextItem obj)
			{
				return obj.Id;
			}
		}

		private enum ModifiersUIState
		{
			Hidden,
			UnfoldingLine,
			LineUnfolded,
			UnfoldingModifiers,
			ModifiersUnfolded,
			CollapsingModifiers,
			ModifiersCollapsed,
			CollapsingLine
		}

		private RectTransform line;

		private List<ModifierTextItem> modifiers = new List<ModifierTextItem>();

		private List<ModifierUIItem> items = new List<ModifierUIItem>();

		public float lineDefaultLength = 200f;

		public float lineUnfoldAnimationDuration = 0.75f;

		public float lineFoldAnimationDuration = 0.75f;

		public float modifierTextAnimationShowDuration = 0.5f;

		public float modifierTextAnimationHideDuration = 0.5f;

		public float modifierTextDefaultAlpha = 0.79f;

		private float modifiersDefaultHeight = -21f;

		private float modifiersLoweredHeight = -66f;

		private float modifiersRaisingAnimationDuration = 1f;

		private float modifiersLoweringAnimationDuration = 1f;

		private ModifiersUIState currentState;

		private List<List<ModifierTextItem>> pendingModifiersChanges = new List<List<ModifierTextItem>>();

		public UIControllerAnimationState UIControllerAnimationState;

		private ModifiersUIState CurrentState
		{
			get
			{
				return currentState;
			}
			set
			{
				currentState = value;
			}
		}

		public void Awake()
		{
			line = CreateLine();
			((Component)line).gameObject.SetActive(false);
			OnOperationProcessed = (Action)Delegate.Combine(OnOperationProcessed, new Action(ValidateModifiersShow));
		}

		public void SetModifiers(Dictionary<int, string> modifiers)
		{
			if (modifiers.Any() || pendingModifiersChanges.Any() || items.Any())
			{
				EnqueueOperation(UnfoldLineAnimation());
				pendingModifiersChanges.Add(modifiers.Select<KeyValuePair<int, string>, ModifierTextItem>((KeyValuePair<int, string> m) => new ModifierTextItem(m.Key, m.Value)).ToList());
				EnqueueOperation(SetModifiersJob());
			}
		}

		public void Reset()
		{
			EnqueueOperation(ResetModifiersJob());
		}

		private IEnumerator ResetModifiersJob()
		{
			modifiers.Clear();
			yield return RefreshModifiersItems();
		}

		public void RaiseModifiers(Action? callback = null)
		{
			((MonoBehaviour)this).StartCoroutine(AnimateModifiersRaising(callback));
		}

		public void LowerModifiers(Action? callback = null)
		{
			((MonoBehaviour)this).StartCoroutine(AnimateModifiersLowering(callback));
		}

		private IEnumerator SetModifiersJob()
		{
			List<ModifierTextItem> list = pendingModifiersChanges.LastOrDefault();
			if (list != null)
			{
				pendingModifiersChanges.Clear();
				List<ModifierTextItem> collection = list.Union(modifiers.Intersect(list, new ModifierTextItemComparer()), new ModifierTextItemComparer()).ToList();
				modifiers.Clear();
				modifiers.AddRange(collection);
			}
			yield return RefreshModifiersItems();
		}

		private RectTransform CreateLine()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Color color = default(Color);
			((Color)(ref color))..ctor(0.941f, 0.862f, 0.588f, 0.79f);
			float num = 1f;
			float num2 = 0f;
			GameObject val = new GameObject("HorizontalLine");
			val.transform.SetParent(((Component)this).transform, false);
			((Graphic)val.AddComponent<Image>()).color = color;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(num2, num);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(1f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			val.transform.localPosition = Vector2.op_Implicit(new Vector2(150f, 0f));
			return component;
		}

		private IEnumerator UnfoldLineAnimation()
		{
			if (CurrentState == ModifiersUIState.Hidden && !items.Any())
			{
				CurrentState = ModifiersUIState.UnfoldingLine;
				((Component)line).gameObject.SetActive(true);
				float startingLength = line.sizeDelta.x;
				float num = startingLength / lineDefaultLength;
				float elapsedTime = lineUnfoldAnimationDuration * num;
				while (elapsedTime < lineUnfoldAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / lineUnfoldAnimationDuration;
					float num2 = Mathf.Lerp(startingLength, lineDefaultLength, EasingFunctions.EaseOut(t));
					line.sizeDelta = new Vector2(num2, line.sizeDelta.y);
					yield return null;
				}
				line.sizeDelta = new Vector2(lineDefaultLength, line.sizeDelta.y);
				CurrentState = ModifiersUIState.LineUnfolded;
			}
		}

		private IEnumerator CollapseLineAnimation()
		{
			if (CurrentState == ModifiersUIState.LineUnfolded || CurrentState == ModifiersUIState.ModifiersCollapsed)
			{
				CurrentState = ModifiersUIState.CollapsingLine;
				float startingLength = line.sizeDelta.x;
				float num = 1f - startingLength / lineDefaultLength;
				float elapsedTime = lineFoldAnimationDuration * num;
				while (CurrentState == ModifiersUIState.CollapsingLine && elapsedTime < lineFoldAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / lineFoldAnimationDuration;
					float num2 = Mathf.Lerp(startingLength, 0f, EasingFunctions.EaseOut(t));
					line.sizeDelta = new Vector2(num2, line.sizeDelta.y);
					yield return null;
				}
				line.sizeDelta = new Vector2(0f, line.sizeDelta.y);
				CurrentState = ModifiersUIState.Hidden;
			}
		}

		private IEnumerator RefreshModifiersItems()
		{
			List<int> list = (from uiItem in items
				where !modifiers.Any((ModifierTextItem mod) => mod.Id == uiItem.Id)
				select uiItem.Id).ToList();
			List<ModifierTextItem> modifiersToCreate = modifiers.Where((ModifierTextItem mod) => !items.Any((ModifierUIItem uiItem) => uiItem.Id == mod.Id)).ToList();
			bool modifiersRemovedFlag = true;
			bool modifiersFixedFlag = false;
			bool modifiersCreatedFlag = true;
			if (list.Any())
			{
				modifiersRemovedFlag = false;
				yield return RemoveModifiersJob(list, delegate
				{
					modifiersRemovedFlag = true;
				});
			}
			yield return (object)new WaitUntil((Func<bool>)(() => modifiersRemovedFlag));
			FixModifiersPositionsJob(delegate
			{
				modifiersFixedFlag = true;
			});
			yield return (object)new WaitUntil((Func<bool>)(() => modifiersFixedFlag));
			if (modifiersToCreate.Any())
			{
				modifiersCreatedFlag = true;
				yield return CreateModifiersJob(modifiersToCreate, delegate
				{
					modifiersCreatedFlag = true;
				});
			}
			yield return (object)new WaitUntil((Func<bool>)(() => modifiersCreatedFlag));
		}

		private IEnumerator RemoveModifiersJob(List<int> idsToRemove, Action? onDone = null)
		{
			List<ModifierUIItem> itemsToRemove = (from i in items
				join ir in idsToRemove on i.Id equals ir
				select i).ToList();
			if (!itemsToRemove.Any())
			{
				onDone?.Invoke();
			}
			while (itemsToRemove.Any())
			{
				ModifierUIItem modifierUIItem = ListExtensions.Pop<ModifierUIItem>(itemsToRemove);
				items.Remove(modifierUIItem);
				bool flag = !itemsToRemove.Any();
				((MonoBehaviour)this).StartCoroutine(AnimateModifierHide(modifierUIItem.TextObj, flag, onDone));
				if (!flag)
				{
					yield return (object)new WaitForSecondsRealtime(0.2f);
				}
			}
		}

		private void FixModifiersPositionsJob(Action onDone)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!items.Any())
			{
				onDone?.Invoke();
			}
			foreach (ModifierUIItem item in items)
			{
				Vector2 targetPosition = CalculatePosition(item);
				((MonoBehaviour)this).StartCoroutine(MoveItem(item.TextObj.transform, targetPosition, item == ListExtensions.Last<ModifierUIItem>(items), onDone));
			}
		}

		private IEnumerator MoveItem(Transform transform, Vector2 targetPosition, bool isLast = false, Action? onLastDone = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 startPos = Vector2.op_Implicit(transform.localPosition);
			float progress = 0f;
			float progressPerSecond = 1.5f;
			while (progress < 1f)
			{
				progress += progressPerSecond * Time.unscaledDeltaTime;
				transform.localPosition = Vector3.Lerp(Vector2.op_Implicit(startPos), Vector2.op_Implicit(targetPosition), progress);
				yield return null;
			}
			transform.localPosition = Vector2.op_Implicit(targetPosition);
			if (isLast)
			{
				onLastDone?.Invoke();
			}
		}

		private IEnumerator CreateModifiersJob(List<ModifierTextItem> newItems, Action onDone)
		{
			newItems.GetEnumerator();
			int counter = 1;
			if (!newItems.Any())
			{
				onDone?.Invoke();
			}
			foreach (ModifierTextItem newItem in newItems)
			{
				TMP_Text val = UIController.InitializeText(Vector2.zero, ((Component)this).gameObject, LocalizationResolver.Localize(newItem.Text), active: true, 21, null, (TextAlignmentOptions)260);
				counter++;
				val.alpha = 0f;
				ModifierUIItem modifierUIItem = new ModifierUIItem(newItem.Id, val);
				items.Add(modifierUIItem);
				val.transform.localPosition = Vector2.op_Implicit(CalculatePosition(modifierUIItem));
				bool flag = items.Count == modifiers.Count;
				((MonoBehaviour)this).StartCoroutine(AnimateModifierShow(val, flag));
				if (flag)
				{
					yield return (object)new WaitForSecondsRealtime(0.2f);
				}
			}
		}

		private Vector2 CalculatePosition(ModifierUIItem modifierUIItem)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			int num = items.IndexOf(modifierUIItem) + 1;
			return new Vector2(0f, (float)(-31 * num));
		}

		private IEnumerator AnimateModifierShow(TMP_Text textItem, bool isLast = false, Action? onDone = null)
		{
			((Component)textItem).gameObject.SetActive(true);
			float startingAlpha = textItem.alpha;
			float num = startingAlpha / modifierTextDefaultAlpha;
			float elapsedTime = modifierTextAnimationShowDuration * num;
			while (elapsedTime < modifierTextAnimationShowDuration)
			{
				elapsedTime += Time.unscaledDeltaTime;
				float num2 = elapsedTime / modifierTextAnimationShowDuration;
				textItem.alpha = Mathf.Lerp(startingAlpha, modifierTextDefaultAlpha, num2);
				yield return null;
			}
			if (isLast)
			{
				onDone?.Invoke();
			}
		}

		private IEnumerator CollapseModifiers()
		{
			if (CurrentState == ModifiersUIState.ModifiersUnfolded || CurrentState == ModifiersUIState.UnfoldingModifiers)
			{
				CurrentState = ModifiersUIState.CollapsingModifiers;
				while (items.Any())
				{
					ModifierUIItem modifierUIItem = ListExtensions.Pop<ModifierUIItem>(items);
					((MonoBehaviour)this).StartCoroutine(AnimateModifierHide(modifierUIItem.TextObj, !items.Any()));
					yield return (object)new WaitForSecondsRealtime(0.2f);
				}
			}
		}

		private IEnumerator AnimateModifierHide(TMP_Text textItem, bool isLast = false, Action? onLastDone = null)
		{
			float startingAlpha = textItem.alpha;
			float num = 1f - startingAlpha / modifierTextDefaultAlpha;
			float elapsedTime = modifierTextAnimationHideDuration * num;
			while (elapsedTime < modifierTextAnimationHideDuration)
			{
				elapsedTime += Time.unscaledDeltaTime;
				float num2 = elapsedTime / modifierTextAnimationHideDuration;
				textItem.alpha = Mathf.Lerp(startingAlpha, 0f, num2);
				yield return null;
			}
			if (isLast)
			{
				onLastDone?.Invoke();
			}
			Object.Destroy((Object)(object)((Component)textItem).gameObject);
		}

		private IEnumerator AnimateModifiersLowering(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.KillCounterCollapsed)
			{
				float elapsedTime = 0f;
				Vector3 localPosition = default(Vector3);
				while (elapsedTime < modifiersLoweringAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / modifiersLoweringAnimationDuration;
					((Vector3)(ref localPosition))..ctor(((Component)this).transform.localPosition.x, Mathf.Lerp(modifiersDefaultHeight, modifiersLoweredHeight, EasingFunctions.EaseOut(t)));
					((Component)this).transform.localPosition = localPosition;
					yield return null;
				}
				if (UIControllerAnimationState == UIControllerAnimationState.KillCounterCollapsed)
				{
					callback?.Invoke();
				}
			}
		}

		private IEnumerator AnimateModifiersRaising(Action? callback = null)
		{
			if (UIControllerAnimationState == UIControllerAnimationState.KillCounterExpandedTextHidden)
			{
				float elapsedTime = 0f;
				Vector3 localPosition = default(Vector3);
				while (elapsedTime < modifiersRaisingAnimationDuration)
				{
					elapsedTime += Time.unscaledDeltaTime;
					float t = elapsedTime / modifiersRaisingAnimationDuration;
					((Vector3)(ref localPosition))..ctor(((Component)this).transform.localPosition.x, Mathf.Lerp(modifiersLoweredHeight, modifiersDefaultHeight, EasingFunctions.EaseOut(t)));
					((Component)this).transform.localPosition = localPosition;
					yield return null;
				}
				if (UIControllerAnimationState == UIControllerAnimationState.KillCounterExpandedTextHidden)
				{
					callback?.Invoke();
				}
			}
		}

		private void ValidateModifiersShow()
		{
			if (!operationsQueue.Any() && !modifiers.Any() && CurrentState != 0)
			{
				EnqueueOperation(CollapseModifiers());
				EnqueueOperation(CollapseLineAnimation());
			}
		}
	}
}
namespace BossChallengeMod.Preloading
{
	public interface IPreloadTarget
	{
		void Set(GameObject? preloaded);
	}
	public class Preloader
	{
		private Dictionary<string, Dictionary<string, GameObject>> preloads = new Dictionary<string, Dictionary<string, GameObject>>();

		private Dictionary<string, Dictionary<string, List<IPreloadTarget>>> preloadConsumers = new Dictionary<string, Dictionary<string, List<IPreloadTarget>>>();

		public void AddPreload(string scene, string path, IPreloadTarget preloadTarget)
		{
			if (!preloadConsumers.TryGetValue(scene, out Dictionary<string, List<IPreloadTarget>> value))
			{
				value = new Dictionary<string, List<IPreloadTarget>>();
				preloadConsumers[scene] = value;
			}
			if (!preloadConsumers[scene].TryGetValue(path, out List<IPreloadTarget> value2))
			{
				value2 = new List<IPreloadTarget>();
				preloadConsumers[scene][path] = value2;
			}
			value2.Add(preloadTarget);
		}

		private IEnumerator PreloadScenes()
		{
			AssetBundle bundle = AssemblyUtils.GetEmbeddedAssetBundle("BossChallengeMod.Resources.Bundles.items.bundle");
			if ((Object)(object)bundle == (Object)null)
			{
				Log.Error("Items bundle not loaded");
				yield break;
			}
			try
			{
				List<AsyncOperation> ops = new List<AsyncOperation>();
				Action<string, Scene> add = delegate(string scenePath, Scene scene)
				{
					try
					{
						GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
						string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(scenePath);
						if (!preloadConsumers.TryGetValue(fileNameWithoutExtension, out Dictionary<string, List<IPreloadTarget>> value))
						{
							value = new Dictionary<string, List<IPreloadTarget>>();
						}
						if (!preloads.TryGetValue(fileNameWithoutExtension, out Dictionary<string, GameObject> value2))
						{
							value2 = new Dictionary<string, GameObject>();
							preloads[fileNameWithoutExtension] = value2;
						}
						GameObject[] array = rootGameObjects;
						foreach (GameObject obj in array)
						{
							try
							{
								Log.Info("Preloading " + ((Object)obj).name);
								if (value2.ContainsKey(((Object)obj).name) || value.ContainsKey(((Object)obj).name))
								{
									value2[((Object)obj).name] = obj;
									value[((Object)obj).name].ForEach(delegate(IPreloadTarget c)
									{
										c.Set(obj);
									});
									Log.Info("No consumers for " + ((Object)obj).name + " preload");
								}
								RCGLifeCycle.DontDestroyForever(obj);
								AutoAttributeManager.AutoReference(obj);
								AutoAttributeManager.AutoReferenceAllChildren(obj);
							}
							catch (Exception ex)
							{
								Log.Error(ex.Message + ", " + ex.StackTrace);
							}
						}
					}
					catch (Exception ex2)
					{
						Log.Error(ex2.Message + ", " + ex2.StackTrace);
					}
				};
				string[] allScenePaths = bundle.GetAllScenePaths();
				foreach (string scenePath2 in allScenePaths)
				{
					Scene sceneByPath = SceneManager.GetSceneByPath(scenePath2);
					if (((Scene)(ref sceneByPath)).isLoaded)
					{
						yield return SceneManager.UnloadSceneAsync(sceneByPath);
					}
					AsyncOperation val = SceneManager.LoadSceneAsync(scenePath2, (LoadSceneMode)1);
					if (val != null)
					{
						val.completed += delegate
						{
							//IL_0017: Unknown result type (might be due to invalid IL or missing references)
							add(scenePath2, SceneManager.GetSceneByPath(scenePath2));
						};
						ops.Add(val);
					}
				}
				foreach (AsyncOperation item in ops)
				{
					yield return item;
				}
			}
			finally
			{
				bundle.Unload(false);
			}
		}

		public IEnumerator Preload()
		{
			yield return PreloadScenes();
		}
	}
}
namespace BossChallengeMod.PatchResolver
{
	public class MonsterPatchResolver
	{
		private GeneralBossPatch? _defaultPatch;

		private Dictionary<string, GeneralBossPatch?> _patches = new Dictionary<string, GeneralBossPatch>();

		public void AddPatch(string name, GeneralBossPatch? patch)
		{
			_patches.TryAdd(name, patch);
		}

		public void AddDefaultPatch(GeneralBossPatch? generalBossPatch)
		{
			_defaultPatch = generalBossPatch;
		}

		public GeneralBossPatch? GetPatch(string name)
		{
			if (_patches.TryGetValue(name, out GeneralBossPatch value))
			{
				return value;
			}
			return _defaultPatch;
		}
	}
}
namespace BossChallengeMod.PatchResolver.Initializers
{
	public class BossesPatchesInitializer : PatchesResolverInitializerBase
	{
		protected CustomMonsterStateValuesResolver monsterStateValuesResolver;

		protected List<string> doNotPatch = new List<string>(14)
		{
			"AG_LeeEar_S0/Room/李耳教學大禮包 格擋/[FSM] 李耳教學 戰鬥+結束拿能力/FSM Animator/LogicRoot/StealthGameMonster_Boss_Lear", "AG_LeeEar_S1/Room/李耳教學大禮包/[FSM] 李耳教學 戰鬥+結束拿能力/FSM Animator/LogicRoot/StealthGameMonster_Boss_Lear", "AG_LeeEar_S1/Room/StealthMonster_GiantBlade_FireBlade", "AG_LeeEar_S1/StealthGameMonster_TutorialDummy Variant", "A5_S1/Room/FlashKill Binding/werw/FSM Animator/LogicRoot/---Boss---/BossShowHealthArea/StealthGameMonster_Boss_JieChuan", "A5_S2/Room/Prefab/EventBinder(摸過存擋點)/存擋點的節點開關/FSM Animator/LogicRoot/[On]Node/[觸發框架]/[MonsterBehavior