Decompiled source of AiQueOdio v1.8.6

AiqueOdio.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Artifacts;
using On.RoR2.UI;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
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("AiqueOdio")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Ai Que Odio Difficulty")]
[assembly: AssemblyFileVersion("1.8.6.0")]
[assembly: AssemblyInformationalVersion("1.8.6+b07a79928276770ea8d1ecaf82792178084d4448")]
[assembly: AssemblyProduct("AiqueOdio")]
[assembly: AssemblyTitle("AiqueOdio")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AiqueOdio
{
	public sealed class LegendaryDroneShop : MonoBehaviour
	{
		public List<DroneIndex> choices;
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct PlayPitiMessage : INetMessage, ISerializableObject
	{
		public void Serialize(NetworkWriter writer)
		{
		}

		public void Deserialize(NetworkReader reader)
		{
		}

		public void OnReceived()
		{
			AiqueOdioPlugin.PlayPitiLocal();
		}
	}
	public struct ShowMonsterItemMessage : INetMessage, ISerializableObject
	{
		private int itemIndex;

		private int sequence;

		public ShowMonsterItemMessage(ItemIndex itemIndex, int sequence)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			this.itemIndex = (int)itemIndex;
			this.sequence = sequence;
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(itemIndex);
			writer.Write(sequence);
		}

		public void Deserialize(NetworkReader reader)
		{
			itemIndex = reader.ReadInt32();
			sequence = reader.ReadInt32();
		}

		public void OnReceived()
		{
			AiqueOdioPlugin.ShowMonsterItemLocal((ItemIndex)itemIndex, sequence);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.seuusuario.aiqueodio", "Ai Que Odio Difficulty", "1.8.6")]
	public sealed class AiqueOdioPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Run, RuleBook> <0>__OnRunSetRuleBookGlobal;

			public static Action<Run> <1>__OnRunStartGlobal;

			public static Action<Run> <2>__OnRunDestroyGlobal;

			public static Action<Stage> <3>__OnStageStartGlobal;

			public static Action<SpawnResult> <4>__OnSpawnedServerGlobal;

			public static Action <5>__OnFixedUpdate;

			public static Action<CharacterBody> <6>__OnBodyStartGlobal;

			public static hook_OnGenerateInteractableCardSelection <7>__ModifyCommandInteractables;

			public static hook_CreateTerminals <8>__ExpandDroneShop;

			public static hook_Start <9>__ConfigureDroneShop;

			public static hook_ShouldDisplayHologram <10>__ShouldDisplayDroneShopPrice;

			public static hook_SetCloseOnTerminalPurchase <11>__KeepDroneShopSinglePurchase;

			public static hook_EnsureMonsterTeamItemCount <12>__SuppressAutomaticEvolutionItems;

			public static hook_UpdateDisplay <13>__UpdateDisplayWithTonicIndicator;

			public static hook_GetLocalizedStringByToken <14>__GetLocalizedStringByToken;
		}

		public const string PluginGuid = "com.seuusuario.aiqueodio";

		public const string PluginName = "Ai Que Odio Difficulty";

		public const string PluginVersion = "1.8.6";

		private const float DifficultyScaling = 4f;

		private const float FirstItemTimeSeconds = 1f;

		private const float ItemIntervalSeconds = 60f;

		private const float ItemIntervalReductionPerStage = 2f;

		private const float MinimumItemIntervalSeconds = 15f;

		private const int PermanentTonicStage = 5;

		private const int IrradiantPearlStartStage = 4;

		private const int IndividualDronePrices = -1;

		private const float DuplicateSoundWindowSeconds = 0.5f;

		private const float ItemVisualFadeInSeconds = 0.35f;

		private const float ItemVisualShowcaseSeconds = 4f;

		private const float ItemVisualTravelSeconds = 0.85f;

		private const string AudioFileName = "GabiDandoPiti.wav";

		private const string ScrapperAddress = "RoR2/Base/Scrapper/iscScrapper.asset";

		private const string TripleDroneShopAddress = "RoR2/DLC3/TripleDroneShop/iscTripleDroneShop.asset";

		private const string MonsterInventoryPrefabPath = "Prefabs/NetworkedObjects/MonsterTeamGainsItemsArtifactInventory";

		private const uint SndAsync = 1u;

		private const uint SndNoDefault = 2u;

		private const uint SndFileName = 131072u;

		private static readonly string[] ChatMessages = new string[4] { "<color=#ff69b4> Os monstros entraram na puberdade e ganharam um {0}!</color>", "<color=#ff69b4> Os monstros estão de TPM e roubaram um {0}!</color>", "<color=#ff69b4> Os monstros gritam por atenção empunhando um {0}!</color>", "<color=#ff69b4> Os monstros estão no cio e acharam um {0}!</color>" };

		private static readonly string[] DeathQuotes = new string[8] { "\"AI, QUE MOD DIFÍCIL!!! AI, QUE ÓDIO!!!\"", "\"Nmrl, tem um mod que abre o jogo e aparece 'Vitória', não?\"", "\"Não tem um mod que dá pra jogar enquanto eu durmo não? pprt.\"", "\"Tá a fim de botar na dificuldade Sunny não?\"", "\"Slk, mod mó cota esse, pprt 67\"", "\"Eu vô vê e te aviso o dia que vou entrar de novo, pdc?\"", "\"Experimente tomar cápsulas de ômega 3\"", "\"Mod bucha pprt\"" };

		private static readonly string[] AllowedBossItemNames = new string[7] { "lightninggland", "conductor", "shinypearl", "fireballsonhit", "parentegg", "bleedonhitandexplode", "knurl" };

		private static readonly string[] AllowedFoodItemNames = new string[3] { "Stew", "BonusHealthBoost", "CookedSteak" };

		private static readonly string[] BlockedWhiteItemNames = new string[7] { "tooth", "barrieronkill", "sprintbonus", "increasedamageonmultikill", "igniteonkill", "healwhilesafe", "crowbar" };

		private static readonly string[] BlockedGreenItemNames = new string[11]
		{
			"seed", "infusion", "movespeedonkill", "huntersharpoon", "bandolier", "jumpboost", "sprintarmor", "warcryonmultikill", "attackspeedonmultikill", "bonusgoldpackonkill",
			"explodeondeath"
		};

		private static readonly string[] AllowedRedItemNames = new string[3] { "Duplicator", "MoreMissile", "ImmuneToDebuff" };

		private static readonly string[] BlockedRedItemNames = new string[5] { "ghostonkill", "plant", "laserturbine", "randomequipmenttrigger", "utilityskillmagazine" };

		private static readonly string[] StationaryTurretNames = new string[2] { "turret1", "gunnerturret" };

		private static DifficultyDef difficultyDef;

		private static DifficultyIndex difficultyIndex;

		private static ArtifactDef esmaltePinkArtifactDef;

		private static InteractableSpawnCard scrapperSpawnCard;

		private static InteractableSpawnCard tripleDroneShopSpawnCard;

		private static GameObject monsterItemDisplayObject;

		private static Inventory monsterItemDisplayInventory;

		private static EnemyInfoPanelInventoryProvider monsterItemDisplayProvider;

		private static readonly Dictionary<ItemIndex, int> MonsterItemStacks = new Dictionary<ItemIndex, int>();

		private static string pitiAudioPath;

		private static float lastPitiPlayTime = float.NegativeInfinity;

		private static int itemsGivenByTime;

		private static int lastIrradiantPearlGrantStage;

		private static float lastItemGrantTime;

		private static float nextItemGrantTime;

		private static bool tonicDisplayAdded;

		private static bool tonicBuffConfirmed;

		private static readonly Dictionary<SpawnCard, InteractableSpawnCard> DroneShopSpawnCards = new Dictionary<SpawnCard, InteractableSpawnCard>();

		private static readonly HashSet<SpawnCard> LegendaryDroneShopSpawnCards = new HashSet<SpawnCard>();

		private static readonly Queue<(ItemIndex itemIndex, int displayCount)> MonsterItemVisualQueue = new Queue<(ItemIndex, int)>();

		private static AiqueOdioPlugin instance;

		private static Coroutine monsterItemVisualCoroutine;

		private static GameObject monsterItemVisualCanvas;

		private static int monsterItemVisualSequence;

		private static int lastMonsterItemVisualSequence;

		private static uint pendingPanelRunId;

		private static uint pendingPanelInventoryId;

		private static bool pendingPanelTonicActive;

		private static float nextPanelSyncRequestTime;

		private static float nextPanelBindTime;

		private static bool stoneFluxStageActive;

		private static Texture tonicPanelTexture;

		private static readonly FieldInfo DisplayIconsField = typeof(ItemInventoryDisplay).GetField("itemIcons", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly MethodInfo DisplayIconCountChanged = typeof(ItemInventoryDisplay).GetMethod("OnIconCountChanged", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly MethodInfo DisplayLayoutIcons = typeof(ItemInventoryDisplay).GetMethod("LayoutAllIcons", BindingFlags.Instance | BindingFlags.NonPublic);

		[DllImport("winmm.dll", CharSet = CharSet.Unicode, EntryPoint = "PlaySoundW", SetLastError = true)]
		[return: MarshalAs(UnmanagedType.Bool)]
		private static extern bool PlaySoundNative(string soundPath, IntPtr module, uint flags);

		private void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			LoadAudioPath();
			NetworkingAPI.RegisterMessageType<PlayPitiMessage>();
			NetworkingAPI.RegisterMessageType<ShowMonsterItemMessage>();
			NetworkingAPI.RegisterMessageType<MonsterPanelStateMessage>();
			NetworkingAPI.RegisterMessageType<RequestMonsterPanelStateMessage>();
			LoadDefinitions();
			RegisterLanguageTokens();
			difficultyIndex = DifficultyAPI.AddDifficulty(difficultyDef);
			ContentAddition.AddArtifactDef(esmaltePinkArtifactDef);
			SubscribeHooks();
			Log.Info("AI, QUE ÓDIO!!! v1.8.6 carregado com sucesso!");
		}

		private void OnDestroy()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			Run.onRunSetRuleBookGlobal -= OnRunSetRuleBookGlobal;
			Run.onRunStartGlobal -= OnRunStartGlobal;
			Run.onRunDestroyGlobal -= OnRunDestroyGlobal;
			Stage.onStageStartGlobal -= OnStageStartGlobal;
			SpawnCard.onSpawnedServerGlobal -= OnSpawnedServerGlobal;
			RoR2Application.onFixedUpdate -= OnFixedUpdate;
			CharacterBody.onBodyStartGlobal -= OnBodyStartGlobal;
			object obj = <>O.<7>__ModifyCommandInteractables;
			if (obj == null)
			{
				hook_OnGenerateInteractableCardSelection val = ModifyCommandInteractables;
				<>O.<7>__ModifyCommandInteractables = val;
				obj = (object)val;
			}
			CommandArtifactManager.OnGenerateInteractableCardSelection -= (hook_OnGenerateInteractableCardSelection)obj;
			object obj2 = <>O.<8>__ExpandDroneShop;
			if (obj2 == null)
			{
				hook_CreateTerminals val2 = ExpandDroneShop;
				<>O.<8>__ExpandDroneShop = val2;
				obj2 = (object)val2;
			}
			DroneVendorMultiShopController.CreateTerminals -= (hook_CreateTerminals)obj2;
			object obj3 = <>O.<9>__ConfigureDroneShop;
			if (obj3 == null)
			{
				hook_Start val3 = ConfigureDroneShop;
				<>O.<9>__ConfigureDroneShop = val3;
				obj3 = (object)val3;
			}
			DroneVendorMultiShopController.Start -= (hook_Start)obj3;
			object obj4 = <>O.<10>__ShouldDisplayDroneShopPrice;
			if (obj4 == null)
			{
				hook_ShouldDisplayHologram val4 = ShouldDisplayDroneShopPrice;
				<>O.<10>__ShouldDisplayDroneShopPrice = val4;
				obj4 = (object)val4;
			}
			DroneVendorMultiShopController.ShouldDisplayHologram -= (hook_ShouldDisplayHologram)obj4;
			object obj5 = <>O.<11>__KeepDroneShopSinglePurchase;
			if (obj5 == null)
			{
				hook_SetCloseOnTerminalPurchase val5 = KeepDroneShopSinglePurchase;
				<>O.<11>__KeepDroneShopSinglePurchase = val5;
				obj5 = (object)val5;
			}
			DroneVendorMultiShopController.SetCloseOnTerminalPurchase -= (hook_SetCloseOnTerminalPurchase)obj5;
			object obj6 = <>O.<12>__SuppressAutomaticEvolutionItems;
			if (obj6 == null)
			{
				hook_EnsureMonsterTeamItemCount val6 = SuppressAutomaticEvolutionItems;
				<>O.<12>__SuppressAutomaticEvolutionItems = val6;
				obj6 = (object)val6;
			}
			MonsterTeamGainsItemsArtifactManager.EnsureMonsterTeamItemCount -= (hook_EnsureMonsterTeamItemCount)obj6;
			object obj7 = <>O.<13>__UpdateDisplayWithTonicIndicator;
			if (obj7 == null)
			{
				hook_UpdateDisplay val7 = UpdateDisplayWithTonicIndicator;
				<>O.<13>__UpdateDisplayWithTonicIndicator = val7;
				obj7 = (object)val7;
			}
			ItemInventoryDisplay.UpdateDisplay -= (hook_UpdateDisplay)obj7;
			object obj8 = <>O.<14>__GetLocalizedStringByToken;
			if (obj8 == null)
			{
				hook_GetLocalizedStringByToken val8 = GetLocalizedStringByToken;
				<>O.<14>__GetLocalizedStringByToken = val8;
				obj8 = (object)val8;
			}
			Language.GetLocalizedStringByToken -= (hook_GetLocalizedStringByToken)obj8;
			ClearMonsterItemVisuals();
			DestroyMonsterItemDisplay();
			MonsterItemStacks.Clear();
			foreach (InteractableSpawnCard value in DroneShopSpawnCards.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			DroneShopSpawnCards.Clear();
			LegendaryDroneShopSpawnCards.Clear();
			tripleDroneShopSpawnCard = null;
			if ((Object)(object)instance == (Object)(object)this)
			{
				instance = null;
			}
		}

		private void LoadAudioPath()
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, "GabiDandoPiti.wav");
			if (!File.Exists(text))
			{
				pitiAudioPath = null;
				Log.Error("[AiQueOdio] GabiDandoPiti.wav não foi encontrado ao lado da DLL: " + text);
			}
			else
			{
				pitiAudioPath = text;
				Log.Info("[AiQueOdio] WAV pronto para reprodução pelo áudio nativo do Windows.");
			}
		}

		internal static void PlayPitiLocal()
		{
			if (string.IsNullOrEmpty(pitiAudioPath) || !File.Exists(pitiAudioPath))
			{
				Log.Warning("[AiQueOdio] O áudio não tocou porque o WAV não está disponível.");
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup - lastPitiPlayTime < 0.5f)
			{
				return;
			}
			lastPitiPlayTime = realtimeSinceStartup;
			try
			{
				if (PlaySoundNative(pitiAudioPath, IntPtr.Zero, 131075u))
				{
					Log.Info("[AiQueOdio] Reprodução do Piti iniciada.");
				}
				else
				{
					Log.Error("[AiQueOdio] O Windows recusou o WAV. Código: " + Marshal.GetLastWin32Error());
				}
			}
			catch (Exception ex)
			{
				Log.Error("[AiQueOdio] Falha na reprodução do WAV: " + ex);
			}
		}

		private static void SubscribeHooks()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			Run.onRunSetRuleBookGlobal += OnRunSetRuleBookGlobal;
			Run.onRunStartGlobal += OnRunStartGlobal;
			Run.onRunDestroyGlobal += OnRunDestroyGlobal;
			Stage.onStageStartGlobal += OnStageStartGlobal;
			SpawnCard.onSpawnedServerGlobal += OnSpawnedServerGlobal;
			RoR2Application.onFixedUpdate += OnFixedUpdate;
			CharacterBody.onBodyStartGlobal += OnBodyStartGlobal;
			object obj = <>O.<7>__ModifyCommandInteractables;
			if (obj == null)
			{
				hook_OnGenerateInteractableCardSelection val = ModifyCommandInteractables;
				<>O.<7>__ModifyCommandInteractables = val;
				obj = (object)val;
			}
			CommandArtifactManager.OnGenerateInteractableCardSelection += (hook_OnGenerateInteractableCardSelection)obj;
			object obj2 = <>O.<8>__ExpandDroneShop;
			if (obj2 == null)
			{
				hook_CreateTerminals val2 = ExpandDroneShop;
				<>O.<8>__ExpandDroneShop = val2;
				obj2 = (object)val2;
			}
			DroneVendorMultiShopController.CreateTerminals += (hook_CreateTerminals)obj2;
			object obj3 = <>O.<9>__ConfigureDroneShop;
			if (obj3 == null)
			{
				hook_Start val3 = ConfigureDroneShop;
				<>O.<9>__ConfigureDroneShop = val3;
				obj3 = (object)val3;
			}
			DroneVendorMultiShopController.Start += (hook_Start)obj3;
			object obj4 = <>O.<10>__ShouldDisplayDroneShopPrice;
			if (obj4 == null)
			{
				hook_ShouldDisplayHologram val4 = ShouldDisplayDroneShopPrice;
				<>O.<10>__ShouldDisplayDroneShopPrice = val4;
				obj4 = (object)val4;
			}
			DroneVendorMultiShopController.ShouldDisplayHologram += (hook_ShouldDisplayHologram)obj4;
			object obj5 = <>O.<11>__KeepDroneShopSinglePurchase;
			if (obj5 == null)
			{
				hook_SetCloseOnTerminalPurchase val5 = KeepDroneShopSinglePurchase;
				<>O.<11>__KeepDroneShopSinglePurchase = val5;
				obj5 = (object)val5;
			}
			DroneVendorMultiShopController.SetCloseOnTerminalPurchase += (hook_SetCloseOnTerminalPurchase)obj5;
			object obj6 = <>O.<12>__SuppressAutomaticEvolutionItems;
			if (obj6 == null)
			{
				hook_EnsureMonsterTeamItemCount val6 = SuppressAutomaticEvolutionItems;
				<>O.<12>__SuppressAutomaticEvolutionItems = val6;
				obj6 = (object)val6;
			}
			MonsterTeamGainsItemsArtifactManager.EnsureMonsterTeamItemCount += (hook_EnsureMonsterTeamItemCount)obj6;
			object obj7 = <>O.<13>__UpdateDisplayWithTonicIndicator;
			if (obj7 == null)
			{
				hook_UpdateDisplay val7 = UpdateDisplayWithTonicIndicator;
				<>O.<13>__UpdateDisplayWithTonicIndicator = val7;
				obj7 = (object)val7;
			}
			ItemInventoryDisplay.UpdateDisplay += (hook_UpdateDisplay)obj7;
			object obj8 = <>O.<14>__GetLocalizedStringByToken;
			if (obj8 == null)
			{
				hook_GetLocalizedStringByToken val8 = GetLocalizedStringByToken;
				<>O.<14>__GetLocalizedStringByToken = val8;
				obj8 = (object)val8;
			}
			Language.GetLocalizedStringByToken += (hook_GetLocalizedStringByToken)obj8;
		}

		private void LoadDefinitions()
		{
			//IL_0044: 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)
			//IL_0059: Expected O, but got Unknown
			Sprite val = LoadEmbeddedSprite("Dificuldade.png");
			Sprite smallIconSelectedSprite = LoadEmbeddedSprite("Esmalte.png");
			Sprite smallIconDeselectedSprite = LoadEmbeddedSprite("EsmalteApagado.png");
			difficultyDef = new DifficultyDef(4f, "AIQUEODIO_NAME", "AIQUEODIO_ICON", "AIQUEODIO_DESCRIPTION", new Color(1f, 0.4f, 0.7f), "od", true);
			if ((Object)(object)val != (Object)null)
			{
				difficultyDef.foundIconSprite = true;
				difficultyDef.iconSprite = val;
			}
			esmaltePinkArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>();
			esmaltePinkArtifactDef.cachedName = "ESMALTE_PINK";
			esmaltePinkArtifactDef.nameToken = "ESMALTE_PINK_NAME";
			esmaltePinkArtifactDef.descriptionToken = "ESMALTE_PINK_DESCRIPTION";
			esmaltePinkArtifactDef.smallIconSelectedSprite = smallIconSelectedSprite;
			esmaltePinkArtifactDef.smallIconDeselectedSprite = smallIconDeselectedSprite;
		}

		private static Sprite LoadEmbeddedSprite(string fileName)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = "AiqueOdio." + fileName;
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
				if (stream == null)
				{
					Log.Error("[AiQueOdio] Recurso não encontrado: " + text);
					return null;
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				Texture2D val = new Texture2D(2, 2)
				{
					name = Path.GetFileNameWithoutExtension(fileName)
				};
				if (!ImageConversion.LoadImage(val, memoryStream.ToArray()))
				{
					Object.Destroy((Object)(object)val);
					Log.Error("[AiQueOdio] Não foi possível decodificar " + fileName + ".");
					return null;
				}
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			catch (Exception ex)
			{
				Log.Error("[AiQueOdio] Erro ao carregar " + fileName + ": " + ex.Message);
				return null;
			}
		}

		private static void RegisterLanguageTokens()
		{
			LanguageAPI.Add("AIQUEODIO_NAME", "AI, QUE ÓDIO!!!");
			LanguageAPI.Add("AIQUEODIO_DESCRIPTION", "ARTEFATO DA AUTORIDADE DEIXA O JOGO MUITO FÁCIL, AI QUE ÓDIO!!!<style=cStack>\n>Regeneração de Vida: <style=cIsHealth>-40%</style>\n>Escalonamento Base: <style=cIsHealth>+150%</style>\n>Artefatos Automáticos: <style=cIsUtility>Autoridade e Esmalte Pink</style>");
			LanguageAPI.Add("ESMALTE_PINK_NAME", "Artefato do Esmalte Pink");
			LanguageAPI.Add("ESMALTE_PINK_DESCRIPTION", "Monstros ganham <style=cIsDamage>1 item no primeiro segundo</style>; depois, a cada <style=cIsDamage>60s, 58s, 54s, 48s... (-2s adicionais por fase, mínimo 15s)</style>.\nEstágio 2: Itens Verdes ativados.\nEstágio 3: Itens Vermelhos e Amarelos ativados, incluindo Irradiant Pearl, Substandard Duplicator, Pocket I.C.B.M. e Ben's Raincoat.\nEstágio 4: Hearty Stew, Quick Fix e Seared Steak entram nos sorteios. Monstros também recebem 1 Irradiant Pearl nesta fase, mais 2 na fase 5, mais 3 na fase 6, e assim por diante.\nEstágio 5: Tônico Permanente.\nEstágio 6: Microrrobôs e 1 Stone Flux Pauldron (o Pauldron é removido ao sair da fase 6).\nDio's Best Friend só pode ser sorteado uma vez por partida.");
			LanguageAPI.Add("AIQUEODIO_TONIC_DISPLAY_NAME", "Tônico Espinélio Permanente");
			LanguageAPI.Add("AIQUEODIO_TONIC_DISPLAY_DESCRIPTION", "A partir do estágio 5, todos os monstros recebem permanentemente o efeito do Tônico Espinélio.");
		}

		private static string GetLocalizedStringByToken(orig_GetLocalizedStringByToken orig, Language self, string token)
		{
			if (IsAiqueOdioRun(Run.instance) && !string.IsNullOrEmpty(token) && token.StartsWith("PLAYER_DEATH_QUOTE_", StringComparison.Ordinal))
			{
				int num = (token.GetHashCode() & 0x7FFFFFFF) % DeathQuotes.Length;
				return DeathQuotes[num];
			}
			return orig.Invoke(self, token);
		}

		private static void OnRunSetRuleBookGlobal(Run run, RuleBook ruleBook)
		{
			if (IsAiqueOdioRun(run))
			{
				Run.ambientLevelCap = int.MaxValue;
			}
		}

		private static void OnRunStartGlobal(Run run)
		{
			ClearMonsterItemVisuals();
			monsterItemVisualSequence = 0;
			lastMonsterItemVisualSequence = 0;
			itemsGivenByTime = 0;
			lastIrradiantPearlGrantStage = 0;
			lastItemGrantTime = 0f;
			nextItemGrantTime = 1f;
			tonicDisplayAdded = false;
			tonicBuffConfirmed = false;
			stoneFluxStageActive = false;
			MonsterItemStacks.Clear();
			difficultyDef.scalingValue = 4f;
			ResetMonsterPanelSync();
			if (!IsAiqueOdioRun(run))
			{
				return;
			}
			LoadTonicPanelTexture();
			if (!NetworkServer.active)
			{
				RequestMonsterPanelState();
				return;
			}
			Log.Info("[AiQueOdio] Partida iniciada na dificuldade AI, QUE ÓDIO!!!");
			RunArtifactManager val = RunArtifactManager.instance;
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("[AiQueOdio] RunArtifactManager indisponível no início da partida.");
				return;
			}
			val.SetArtifactEnabledServer(esmaltePinkArtifactDef, true);
			val.SetArtifactEnabledServer(Artifacts.Command, true);
			CreateMonsterItemDisplay();
		}

		private static void OnRunDestroyGlobal(Run run)
		{
			ClearMonsterItemVisuals();
			DestroyMonsterItemDisplay();
			MonsterItemStacks.Clear();
			tonicDisplayAdded = false;
			tonicBuffConfirmed = false;
			stoneFluxStageActive = false;
			ResetMonsterPanelSync();
		}

		private static void CreateMonsterItemDisplay()
		{
			DestroyMonsterItemDisplay();
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/MonsterTeamGainsItemsArtifactInventory");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("[AiQueOdio] Não foi possível carregar o painel de itens dos monstros.");
				return;
			}
			monsterItemDisplayObject = Object.Instantiate<GameObject>(val);
			monsterItemDisplayInventory = monsterItemDisplayObject.GetComponent<Inventory>();
			monsterItemDisplayProvider = monsterItemDisplayObject.GetComponent<EnemyInfoPanelInventoryProvider>();
			TeamFilter component = monsterItemDisplayObject.GetComponent<TeamFilter>();
			if ((Object)(object)monsterItemDisplayInventory == (Object)null || (Object)(object)monsterItemDisplayProvider == (Object)null || (Object)(object)component == (Object)null)
			{
				Log.Error("[AiQueOdio] O painel de itens dos monstros está incompleto.");
				Object.Destroy((Object)(object)monsterItemDisplayObject);
				monsterItemDisplayObject = null;
				monsterItemDisplayInventory = null;
				monsterItemDisplayProvider = null;
			}
			else
			{
				ConfigureMonsterPanelObject(monsterItemDisplayObject);
				monsterItemDisplayObject.SetActive(true);
				NetworkServer.Spawn(monsterItemDisplayObject);
				RefreshMonsterItemDisplay();
				SendMonsterPanelState();
				Log.Info("[AiQueOdio] Painel de itens dos monstros preparado sem ativar a Evolução.");
			}
		}

		private static void DestroyMonsterItemDisplay()
		{
			if ((Object)(object)monsterItemDisplayObject != (Object)null && NetworkServer.active)
			{
				NetworkServer.Destroy(monsterItemDisplayObject);
			}
			monsterItemDisplayObject = null;
			monsterItemDisplayInventory = null;
			monsterItemDisplayProvider = null;
		}

		private static void SuppressAutomaticEvolutionItems(orig_EnsureMonsterTeamItemCount orig, int itemCount)
		{
			if (!IsAiqueOdioRun(Run.instance) || IsArtifactEnabled(Artifacts.MonsterTeamGainsItems))
			{
				orig.Invoke(itemCount);
			}
		}

		private static void OnSpawnedServerGlobal(SpawnResult spawnResult)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAiqueOdioRun(Run.instance) || (Object)(object)spawnResult.spawnedInstance == (Object)null)
			{
				return;
			}
			if ((Object)(object)spawnResult.spawnRequest?.spawnCard != (Object)null && LegendaryDroneShopSpawnCards.Contains(spawnResult.spawnRequest.spawnCard) && (Object)(object)spawnResult.spawnedInstance.GetComponent<DroneVendorMultiShopController>() != (Object)null)
			{
				spawnResult.spawnedInstance.AddComponent<LegendaryDroneShop>().choices = GetEligibleLegendaryDroneChoices();
			}
			CharacterMaster component = spawnResult.spawnedInstance.GetComponent<CharacterMaster>();
			UpdateMonsterStoneFlux(component);
			if (IsArtifactEnabled(Artifacts.MonsterTeamGainsItems) || !((Object)(object)component != (Object)null) || (int)component.teamIndex != 2 || !((Object)(object)component.inventory != (Object)null))
			{
				return;
			}
			foreach (KeyValuePair<ItemIndex, int> monsterItemStack in MonsterItemStacks)
			{
				component.inventory.GiveItemPermanent(monsterItemStack.Key, monsterItemStack.Value);
			}
		}

		private static void ModifyCommandInteractables(orig_OnGenerateInteractableCardSelection orig, SceneDirector sceneDirector, DirectorCardCategorySelection selection)
		{
			orig.Invoke(sceneDirector, selection);
			if (IsAiqueOdioRun(Run.instance) && selection?.categories != null)
			{
				ReplaceRepairableDronesWithShops(selection);
			}
		}

		private static void ReplaceRepairableDronesWithShops(DirectorCardCategorySelection selection)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Invalid comparison between Unknown and I4
			if (tripleDroneShopSpawnCard == null)
			{
				tripleDroneShopSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC3/TripleDroneShop/iscTripleDroneShop.asset").WaitForCompletion();
			}
			if ((Object)(object)tripleDroneShopSpawnCard == (Object)null || !new DirectorCard
			{
				spawnCard = (SpawnCard)(object)tripleDroneShopSpawnCard
			}.IsAvailable())
			{
				Log.Warning("[AiQueOdio] A loja de drones não está disponível nesta partida; os drones quebrados foram preservados.");
				return;
			}
			int num = 0;
			bool flag = GetEligibleLegendaryDroneChoices().Count > 0;
			for (int i = 0; i < selection.categories.Length; i++)
			{
				Category val = selection.categories[i];
				if (val.cards == null)
				{
					continue;
				}
				DirectorCard[] array = (DirectorCard[])(object)new DirectorCard[val.cards.Length];
				bool flag2 = false;
				for (int j = 0; j < val.cards.Length; j++)
				{
					DirectorCard val2 = val.cards[j];
					SpawnCard val3 = ((val2 != null) ? val2.GetSpawnCard() : null);
					DroneDef val4 = FindConvertibleDrone(val3);
					bool flag3 = (Object)(object)val4 != (Object)null && (int)val4.tier == 2;
					if ((Object)(object)val4 == (Object)null || !val2.IsAvailable() || (flag3 && (!flag || !(val3 is InteractableSpawnCard))))
					{
						array[j] = val2;
						continue;
					}
					InteractableSpawnCard orCreateDroneShopSpawnCard = GetOrCreateDroneShopSpawnCard(val3, flag3);
					array[j] = CloneDirectorCard(val2, (SpawnCard)(object)orCreateDroneShopSpawnCard);
					flag2 = true;
					num++;
				}
				if (flag2)
				{
					val.cards = array;
					selection.categories[i] = val;
				}
			}
			Log.Info($"[AiQueOdio] {num} carta(s) de drone quebrado convertida(s) " + "em lojas com uma escolha de cada drone elegível.");
		}

		private static DroneDef FindConvertibleDrone(SpawnCard spawnCard)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			if ((Object)(object)spawnCard == (Object)null)
			{
				return null;
			}
			foreach (DroneDef allDroneDef in DroneCatalog.allDroneDefs)
			{
				if ((Object)(object)allDroneDef != (Object)null && !IsStationaryTurret(allDroneDef) && ((allDroneDef.canCombine && ((int)allDroneDef.tier == 0 || (int)allDroneDef.tier == 1)) || ((int)allDroneDef.tier == 2 && (Object)(object)GetDroneRepairPurchase(allDroneDef) != (Object)null)) && (Object)(object)allDroneDef.droneBrokenSpawnCard == (Object)(object)spawnCard)
				{
					return allDroneDef;
				}
			}
			return null;
		}

		private static InteractableSpawnCard GetOrCreateDroneShopSpawnCard(SpawnCard originalSpawnCard, bool legendary)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (DroneShopSpawnCards.TryGetValue(originalSpawnCard, out var value))
			{
				return value;
			}
			value = Object.Instantiate<InteractableSpawnCard>((InteractableSpawnCard)((!legendary) ? ((object)tripleDroneShopSpawnCard) : ((object)(InteractableSpawnCard)originalSpawnCard)));
			((SpawnCard)value).prefab = ((SpawnCard)tripleDroneShopSpawnCard).prefab;
			((Object)value).name = "iscAiQueOdioDroneShop_" + ((Object)originalSpawnCard).name;
			((SpawnCard)value).directorCreditCost = originalSpawnCard.directorCreditCost;
			InteractableSpawnCard val = (InteractableSpawnCard)(object)((originalSpawnCard is InteractableSpawnCard) ? originalSpawnCard : null);
			if (val != null)
			{
				value.maxSpawnsPerStage = val.maxSpawnsPerStage;
			}
			DroneShopSpawnCards.Add(originalSpawnCard, value);
			if (legendary)
			{
				LegendaryDroneShopSpawnCards.Add((SpawnCard)(object)value);
			}
			return value;
		}

		private static DirectorCard CloneDirectorCard(DirectorCard original, SpawnCard replacementSpawnCard)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			return new DirectorCard
			{
				spawnCard = replacementSpawnCard,
				selectionWeight = original.selectionWeight,
				spawnDistance = original.spawnDistance,
				preventOverhead = original.preventOverhead,
				minimumStageCompletions = original.minimumStageCompletions,
				requiredUnlockableDef = original.requiredUnlockableDef,
				forbiddenUnlockableDef = original.forbiddenUnlockableDef
			};
		}

		private static void ConfigureDroneShop(orig_Start orig, DroneVendorMultiShopController self)
		{
			orig.Invoke(self);
			if (!NetworkServer.active || !IsAiqueOdioRun(Run.instance))
			{
				return;
			}
			if (self.doCloseOnTerminalPurchase != null)
			{
				for (int i = 0; i < self.doCloseOnTerminalPurchase.Length; i++)
				{
					self.doCloseOnTerminalPurchase[i] = true;
				}
			}
			if ((Object)(object)((Component)self).GetComponent<LegendaryDroneShop>() != (Object)null)
			{
				ConfigureLegendaryDronePrices(self);
			}
			DroneVendorTerminalBehavior[] terminals = self._terminals;
			Log.Info("[AiQueOdio] Loja de drones preparada com " + $"{((terminals != null) ? terminals.Length : 0)} escolha(s) única(s).");
		}

		private static void ExpandDroneShop(orig_CreateTerminals orig, DroneVendorMultiShopController shop)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !IsAiqueOdioRun(Run.instance))
			{
				orig.Invoke(shop);
				return;
			}
			LegendaryDroneShop component = ((Component)shop).GetComponent<LegendaryDroneShop>();
			ItemTier val = (ItemTier)(((Object)(object)component != (Object)null) ? 2 : ((int)SelectDroneShopTier(shop)));
			List<DroneIndex> list = (((Object)(object)component != (Object)null) ? component.choices : GetEligibleDroneChoices(shop, val));
			if ((int)val == 1 && list != null && list.Count == 0)
			{
				val = (ItemTier)0;
				list = GetEligibleDroneChoices(shop, val);
			}
			if (list == null || list.Count == 0 || shop.terminalPositions == null || shop.terminalPositions.Length == 0)
			{
				Log.Warning("[AiQueOdio] A loja não pôde ser ampliada; usando o comportamento padrão.");
				orig.Invoke(shop);
				return;
			}
			RangeFloat tier1Chance = shop.tier1Chance;
			RangeFloat tier2Chance = shop.tier2Chance;
			RangeFloat tier3Chance = shop.tier3Chance;
			ExplicitPickupDropTable excludedDronesDropTable = shop.excludedDronesDropTable;
			shop.terminalPositions = CreateDroneTerminalPositions(shop, list.Count);
			SetFixedDroneShopTier(shop, val);
			if ((Object)(object)component != (Object)null)
			{
				shop.excludedDronesDropTable = null;
			}
			try
			{
				orig.Invoke(shop);
			}
			finally
			{
				shop.tier1Chance = tier1Chance;
				shop.tier2Chance = tier2Chance;
				shop.tier3Chance = tier3Chance;
				shop.excludedDronesDropTable = excludedDronesDropTable;
			}
			AssignEveryDroneOnce(shop, list);
		}

		private static PurchaseInteraction GetDroneRepairPurchase(DroneDef droneDef)
		{
			GameObject val = droneDef?.droneBrokenSpawnCard?.prefab;
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.GetComponent<PurchaseInteraction>();
		}

		private static List<DroneIndex> GetEligibleLegendaryDroneChoices()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_0059: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			List<DroneIndex> list = new List<DroneIndex>();
			Run val = Run.instance;
			if ((Object)(object)val == (Object)null)
			{
				return list;
			}
			foreach (DroneDef allDroneDef in DroneCatalog.allDroneDefs)
			{
				if (!((Object)(object)allDroneDef == (Object)null) && (int)allDroneDef.tier == 2 && !((Object)(object)allDroneDef.bodyPrefab == (Object)null) && val.IsDroneAvailable(allDroneDef.droneIndex) && !list.Contains(allDroneDef.droneIndex))
				{
					PurchaseInteraction droneRepairPurchase = GetDroneRepairPurchase(allDroneDef);
					ExpansionDef requiredExpansion = allDroneDef.GetRequiredExpansion();
					if (!((Object)(object)droneRepairPurchase == (Object)null) && (!((Object)(object)allDroneDef.requiredExpansion != (Object)null) || val.IsExpansionEnabled(allDroneDef.requiredExpansion)) && (!((Object)(object)requiredExpansion != (Object)null) || val.IsExpansionEnabled(requiredExpansion)) && (!((Object)(object)droneRepairPurchase.requiredExpansion != (Object)null) || val.IsExpansionEnabled(droneRepairPurchase.requiredExpansion)))
					{
						list.Add(allDroneDef.droneIndex);
					}
				}
			}
			return list;
		}

		private static void ConfigureLegendaryDronePrices(DroneVendorMultiShopController shop)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Invalid comparison between Unknown and I4
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			shop.Networkcost = -1;
			if (shop._terminals == null)
			{
				return;
			}
			DroneVendorTerminalBehavior[] terminals = shop._terminals;
			foreach (DroneVendorTerminalBehavior obj in terminals)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(obj.CurrentPickupIndex);
				DroneDef val = ((pickupDef != null) ? DroneCatalog.GetDroneDef(pickupDef.droneIndex) : null);
				PurchaseInteraction droneRepairPurchase = GetDroneRepairPurchase(val);
				PurchaseInteraction purchaseInteraction = obj.purchaseInteraction;
				if ((Object)(object)droneRepairPurchase == (Object)null || (Object)(object)purchaseInteraction == (Object)null)
				{
					if ((Object)(object)purchaseInteraction != (Object)null)
					{
						purchaseInteraction.Networkavailable = false;
					}
					Log.Warning("[AiQueOdio] Opção lendária desativada: preço de reparo indisponível.");
				}
				else
				{
					purchaseInteraction.NetworkcostType = droneRepairPurchase.costType;
					bool flag = (int)droneRepairPurchase.costType == 1 || droneRepairPurchase.automaticallyScaleCostWithDifficulty;
					purchaseInteraction.Networkcost = (flag ? Run.instance.GetDifficultyScaledCost(droneRepairPurchase.cost) : droneRepairPurchase.cost);
					purchaseInteraction.solitudeCost = purchaseInteraction.cost;
					Log.Info($"[AiQueOdio] Loja lendária: {((Object)val).name}, preço {purchaseInteraction.cost} ({purchaseInteraction.costType}).");
				}
			}
		}

		private static bool ShouldDisplayDroneShopPrice(orig_ShouldDisplayHologram orig, DroneVendorMultiShopController shop, GameObject viewer)
		{
			if (!IsAiqueOdioRun(Run.instance) || shop.cost != -1)
			{
				return orig.Invoke(shop, viewer);
			}
			return false;
		}

		private static ItemTier SelectDroneShopTier(DroneVendorMultiShopController shop)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Run.instance.stageClearCount >= 3)
			{
				float num = EvaluateDroneTierChance(shop.tier1Chance);
				float num2 = EvaluateDroneTierChance(shop.tier2Chance);
				float num3 = num + num2;
				if (!(num3 <= 0f))
				{
					if (shop.rng.nextNormalizedFloat * num3 < num)
					{
						return (ItemTier)0;
					}
					return (ItemTier)1;
				}
				return (ItemTier)0;
			}
			return (ItemTier)0;
		}

		private static float EvaluateDroneTierChance(RangeFloat chance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(Run.instance.difficultyCoefficient, 0f, 10f);
			return chance.min + num / 10f * (chance.max - chance.min);
		}

		private static List<DroneIndex> GetEligibleDroneChoices(DroneVendorMultiShopController shop, ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			List<DroneIndex> obj = (((int)tier == 1) ? Run.instance.availableTier2DroneList : Run.instance.availableTier1DroneList);
			List<DroneIndex> list = new List<DroneIndex>(obj.Count);
			foreach (DroneIndex item in obj)
			{
				DroneDef droneDef = DroneCatalog.GetDroneDef(item);
				if (!list.Contains(item) && !IsStationaryTurret(droneDef) && !IsDroneExcluded(shop, item))
				{
					list.Add(item);
				}
			}
			return list;
		}

		private static bool IsStationaryTurret(DroneDef droneDef)
		{
			if ((Object)(object)droneDef != (Object)null)
			{
				if (!ContainsAny(((Object)droneDef).name, StationaryTurretNames))
				{
					GameObject bodyPrefab = droneDef.bodyPrefab;
					if (!ContainsAny((bodyPrefab != null) ? ((Object)bodyPrefab).name : null, StationaryTurretNames))
					{
						SpawnCard droneBrokenSpawnCard = droneDef.droneBrokenSpawnCard;
						return ContainsAny((droneBrokenSpawnCard != null) ? ((Object)droneBrokenSpawnCard).name : null, StationaryTurretNames);
					}
				}
				return true;
			}
			return false;
		}

		private static void SetFixedDroneShopTier(DroneVendorMultiShopController shop, ItemTier selectedTier)
		{
			//IL_0001: 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)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			shop.tier1Chance = CreateFixedRange(((int)selectedTier == 0) ? 1f : 0f);
			shop.tier2Chance = CreateFixedRange(((int)selectedTier == 1) ? 1f : 0f);
			shop.tier3Chance = CreateFixedRange(((int)selectedTier == 2) ? 1f : 0f);
		}

		private static RangeFloat CreateFixedRange(float value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new RangeFloat
			{
				min = value,
				max = value
			};
		}

		private static Transform[] CreateDroneTerminalPositions(DroneVendorMultiShopController shop, int terminalCount)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			Transform[] terminalPositions = shop.terminalPositions;
			Transform[] array = (Transform[])(object)new Transform[terminalCount];
			if (terminalCount <= terminalPositions.Length)
			{
				if (terminalCount == 1)
				{
					array[0] = terminalPositions[terminalPositions.Length / 2];
					return array;
				}
				for (int i = 0; i < terminalCount; i++)
				{
					int num = Mathf.RoundToInt((float)i * ((float)terminalPositions.Length - 1f) / ((float)terminalCount - 1f));
					array[i] = terminalPositions[num];
				}
				return array;
			}
			Array.Copy(terminalPositions, array, terminalPositions.Length);
			Vector3 val = Vector3.zero;
			Transform[] array2 = terminalPositions;
			foreach (Transform val2 in array2)
			{
				val += val2.position;
			}
			val /= (float)terminalPositions.Length;
			Vector3 val3 = ((terminalPositions.Length > 1) ? (terminalPositions[^1].position - terminalPositions[0].position) : ((Component)shop).transform.right);
			val3.y = 0f;
			if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
			{
				val3 = ((Component)shop).transform.right;
			}
			((Vector3)(ref val3)).Normalize();
			float num2 = ((terminalPositions.Length > 1) ? (Vector3.Distance(terminalPositions[0].position, terminalPositions[^1].position) / (float)(terminalPositions.Length - 1)) : 1.25f);
			num2 = Mathf.Max(num2, 1.25f);
			int num3 = terminalCount - terminalPositions.Length;
			float num4 = num2 * (float)(terminalPositions.Length - 1) * 0.5f;
			Quaternion rotation = terminalPositions[terminalPositions.Length / 2].rotation;
			for (int k = 0; k < num3; k++)
			{
				int num5 = k / 2 + 1;
				float num6 = ((k % 2 == 0) ? 1f : (-1f));
				Vector3 position = val + val3 * num6 * (num4 + num2 * (float)num5);
				GameObject val4 = new GameObject($"AiQueOdioDroneTerminalPosition{k + 1}");
				val4.transform.position = position;
				val4.transform.rotation = rotation;
				val4.transform.SetParent(((Component)shop).transform, true);
				array[terminalPositions.Length + k] = val4.transform;
			}
			return array;
		}

		private static void AssignEveryDroneOnce(DroneVendorMultiShopController shop, List<DroneIndex> candidates)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (shop._terminals == null || shop._terminals.Length != candidates.Count)
			{
				Log.Warning("[AiQueOdio] A quantidade de terminais não corresponde às opções de drones.");
				return;
			}
			List<DroneIndex> list = new List<DroneIndex>(candidates);
			DroneVendorTerminalBehavior[] terminals = shop._terminals;
			UniquePickup val2 = default(UniquePickup);
			foreach (DroneVendorTerminalBehavior obj in terminals)
			{
				DroneIndex val = shop.rng.NextElementUniform<DroneIndex>(list);
				list.Remove(val);
				((UniquePickup)(ref val2))..ctor(PickupCatalog.FindPickupIndex(val));
				val2.upgradeValue = shop.droneUpgradeCount;
				UniquePickup val3 = val2;
				obj.SetPickup(val3, false);
			}
		}

		private static bool IsDroneExcluded(DroneVendorMultiShopController shop, DroneIndex droneIndex)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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 (shop.excludedDronesDropTable?.pickupEntries == null)
			{
				return false;
			}
			PickupDefEntry[] pickupEntries = shop.excludedDronesDropTable.pickupEntries;
			for (int i = 0; i < pickupEntries.Length; i++)
			{
				Object pickupDef = pickupEntries[i].pickupDef;
				DroneDef val = (DroneDef)(object)((pickupDef is DroneDef) ? pickupDef : null);
				if (val != null && val.droneIndex == droneIndex)
				{
					return true;
				}
			}
			return false;
		}

		private static void KeepDroneShopSinglePurchase(orig_SetCloseOnTerminalPurchase orig, DroneVendorMultiShopController self, PurchaseInteraction purchaseInteraction, bool closeOnPurchase)
		{
			orig.Invoke(self, purchaseInteraction, IsAiqueOdioRun(Run.instance) || closeOnPurchase);
		}

		private static void OnStageStartGlobal(Stage stage)
		{
			if (!IsAiqueOdioRun(Run.instance))
			{
				return;
			}
			if (!NetworkServer.active)
			{
				RequestMonsterPanelState();
				RefreshMonsterItemDisplay();
				return;
			}
			string text = (((Object)(object)stage.sceneDef != (Object)null) ? stage.sceneDef.baseSceneName : string.Empty);
			StartSafeAreaScrapper(stage);
			UpdateStageStoneFlux(stage);
			if (!string.Equals(text, "bazaar", StringComparison.Ordinal))
			{
				int num = Run.instance.stageClearCount + 1;
				if (num >= 4 && num > lastIrradiantPearlGrantStage)
				{
					int num2 = num - 4 + 1;
					GiveSpecificItemToMonsters(Items.ShinyPearl, num2);
					lastIrradiantPearlGrantStage = num;
					Broadcast($"<color=#ffff00>Os monstros receberam {num2} Irradiant Pearl nesta fase!</color>");
				}
				if (num >= 5)
				{
					EnsurePermanentTonicOnExistingMonsters();
					AddTonicDisplayItems();
				}
				if (num == 6 || text.StartsWith("moon", StringComparison.OrdinalIgnoreCase))
				{
					GiveSpecificItemToMonsters(Items.CaptainDefenseMatrix, 1);
					Broadcast("<color=#ff0000>ALERTA DE ODIO: Os monstros instalaram Microrrobôs Defensivos!</color>");
				}
			}
		}

		private static void OnBodyStartGlobal(CharacterBody body)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			if ((Object)(object)body != (Object)null)
			{
				UpdateMonsterStoneFlux(body.master);
			}
			if (NetworkServer.active && IsAiqueOdioRun(Run.instance) && !((Object)(object)body.teamComponent == (Object)null) && (int)body.teamComponent.teamIndex == 2 && Run.instance.stageClearCount + 1 >= 5)
			{
				EnsurePermanentTonic(body);
			}
		}

		private static void EnsurePermanentTonicOnExistingMonsters()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if ((Object)(object)readOnlyInstances != (Object)null && (int)readOnlyInstances.teamIndex == 2)
				{
					EnsurePermanentTonic(readOnlyInstances.GetBody());
				}
			}
		}

		private static void EnsurePermanentTonic(CharacterBody body)
		{
			if (!((Object)(object)body == (Object)null) && !body.HasBuff(Buffs.TonicBuff))
			{
				body.AddBuff(Buffs.TonicBuff);
				if (!tonicBuffConfirmed && body.HasBuff(Buffs.TonicBuff))
				{
					tonicBuffConfirmed = true;
					Log.Info("[AiQueOdio] Verificação concluída: o Tônico permanente está ativo nos monstros.");
				}
			}
		}

		private static void AddTonicDisplayItems()
		{
			if (!tonicDisplayAdded && !((Object)(object)monsterItemDisplayInventory == (Object)null))
			{
				tonicDisplayAdded = true;
				AddDisplayOnlyItem(Items.AutoCastEquipment, 4);
				RefreshMonsterItemDisplay();
				SendMonsterPanelState();
				Broadcast("<color=#ff0000>ALERTA DE ODIO: os monstros ativaram o combo permanente de Tônico Espinélio + 4 Gestos dos Afogados!</color>");
				Log.Info($"[AiQueOdio] Painel da fase {5} atualizado com 1 Tônico e 4 Gestos " + "(somente indicadores visuais).");
			}
		}

		private static void AddDisplayOnlyItem(ItemDef itemDef, int count)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)monsterItemDisplayInventory == (Object)null) && !((Object)(object)itemDef == (Object)null) && count > 0)
			{
				monsterItemDisplayInventory.GiveItemPermanent(itemDef.itemIndex, count);
			}
		}

		private static void OnFixedUpdate()
		{
			UpdateMonsterPanelClient();
			Run val = Run.instance;
			if (!NetworkServer.active || (Object)(object)val == (Object)null || !IsArtifactEnabled(esmaltePinkArtifactDef))
			{
				return;
			}
			float runStopwatch = val.GetRunStopwatch();
			float monsterItemInterval = GetMonsterItemInterval(val);
			if (itemsGivenByTime > 0)
			{
				nextItemGrantTime = lastItemGrantTime + monsterItemInterval;
			}
			int num = 0;
			while (runStopwatch >= nextItemGrantTime)
			{
				num++;
				itemsGivenByTime++;
				if (itemsGivenByTime == 1)
				{
					lastItemGrantTime = 0f;
				}
				else
				{
					lastItemGrantTime = nextItemGrantTime;
				}
				monsterItemInterval = GetMonsterItemInterval(val);
				nextItemGrantTime = lastItemGrantTime + monsterItemInterval;
			}
			if (num > 0)
			{
				GiveRandomItemToMonsters(val, num);
			}
		}

		private static float GetMonsterItemInterval(Run run)
		{
			int num = run.stageClearCount + 1;
			int num2 = Mathf.Max(0, num - 1);
			float num3 = (float)(num2 * (num2 + 1)) * 2f * 0.5f;
			return Mathf.Max(15f, 60f - num3);
		}

		private static void GiveSpecificItemToMonsters(ItemDef itemDef, int count)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Run.instance != (Object)null && (Object)(object)itemDef != (Object)null)
			{
				GiveItemToMonsterTeam(itemDef.itemIndex, count, updateDisplayImmediately: false);
			}
		}

		private static void GiveRandomItemToMonsters(Run run, int count)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> validMonsterItems = GetValidMonsterItems(run);
			if (validMonsterItems.Count == 0)
			{
				Log.Warning("[AiQueOdio] Nenhum item válido estava disponível.");
				return;
			}
			PickupDef val = null;
			for (int i = 0; i < count; i++)
			{
				if (validMonsterItems.Count == 0)
				{
					break;
				}
				PickupIndex val2 = run.treasureRng.NextElementUniform<PickupIndex>(validMonsterItems);
				PickupDef pickup = PickupCatalog.GetPickupDef(val2);
				if (pickup == null || (int)pickup.itemIndex == -1)
				{
					continue;
				}
				GiveItemToMonsterTeam(pickup.itemIndex, 1, updateDisplayImmediately: false);
				val = pickup;
				if (!CanRollMonsterItem(pickup.itemIndex))
				{
					validMonsterItems.RemoveAll((PickupIndex candidate) => PickupCatalog.GetPickupDef(candidate)?.itemIndex == (ItemIndex?)pickup.itemIndex);
				}
			}
			if (val == null)
			{
				return;
			}
			string text = Language.GetString(val.nameToken);
			string text2 = "#" + ColorUtility.ToHtmlStringRGB(val.baseColor);
			Broadcast(string.Format(ChatMessages[Random.Range(0, ChatMessages.Length)], "<color=" + text2 + ">" + text + "</color>"));
			PlayPitiLocal();
			try
			{
				NetMessageExtensions.Send((INetMessage)(object)default(PlayPitiMessage), (NetworkDestination)1);
			}
			catch (Exception ex)
			{
				Log.Error("[AiQueOdio] Falha ao enviar o áudio aos Clients: " + ex);
			}
		}

		private static List<PickupIndex> GetValidMonsterItems(Run run)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Invalid comparison between Unknown and I4
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> list = new List<PickupIndex>(run.availableTier1DropList);
			int num = run.stageClearCount + 1;
			if (num >= 2)
			{
				list.AddRange(run.availableTier2DropList);
			}
			if (num >= 3)
			{
				list.AddRange(run.availableTier3DropList);
				list.AddRange(run.availableBossDropList);
				AddExplicitMonsterItemCandidate(run, list, Items.ShinyPearl);
			}
			if (num >= 4)
			{
				string[] allowedFoodItemNames = AllowedFoodItemNames;
				for (int i = 0; i < allowedFoodItemNames.Length; i++)
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(allowedFoodItemNames[i]));
					if ((Object)(object)itemDef != (Object)null && (int)itemDef.tier == 10)
					{
						AddExplicitMonsterItemCandidate(run, list, itemDef);
					}
				}
			}
			List<PickupIndex> list2 = new List<PickupIndex>(list.Count);
			foreach (PickupIndex item in list)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(item);
				ItemDef val = ((pickupDef != null && (int)pickupDef.itemIndex != -1) ? ItemCatalog.GetItemDef(pickupDef.itemIndex) : null);
				if (IsAllowedMonsterItem(val, num) && CanRollMonsterItem(val.itemIndex))
				{
					list2.Add(item);
				}
			}
			return list2;
		}

		private static void AddExplicitMonsterItemCandidate(Run run, List<PickupIndex> candidates, ItemDef item)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)item == (Object)null) && run.IsItemAvailable(item.itemIndex) && (!((Object)(object)item.requiredExpansion != (Object)null) || run.IsExpansionEnabled(item.requiredExpansion)))
			{
				PickupIndex val = PickupCatalog.FindPickupIndex(item.itemIndex);
				if (val != PickupIndex.none && !candidates.Contains(val))
				{
					candidates.Add(val);
				}
			}
		}

		private static bool IsAllowedMonsterItem(ItemDef item, int currentStage)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_0098: 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)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected I4, but got Unknown
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if ((int)item.tier == 10)
			{
				if (currentStage >= 4)
				{
					return Array.Exists(AllowedFoodItemNames, (string name) => string.Equals(((Object)item).name, name, StringComparison.OrdinalIgnoreCase));
				}
				return false;
			}
			if (item.ContainsTag((ItemTag)10))
			{
				return false;
			}
			if ((int)item.tier == 2 && Array.Exists(AllowedRedItemNames, (string name) => string.Equals(((Object)item).name, name, StringComparison.OrdinalIgnoreCase)))
			{
				return true;
			}
			if (item.ContainsTag((ItemTag)4))
			{
				return false;
			}
			ItemTier tier = item.tier;
			switch ((int)tier)
			{
			case 0:
				return !ContainsAny(((Object)item).name, BlockedWhiteItemNames);
			case 1:
				return !ContainsAny(((Object)item).name, BlockedGreenItemNames);
			case 2:
				return !ContainsAny(((Object)item).name, BlockedRedItemNames);
			case 4:
				if (currentStage >= 3)
				{
					return ContainsAny(((Object)item).name, AllowedBossItemNames);
				}
				return false;
			default:
				return true;
			}
		}

		private static bool ContainsAny(string value, string[] fragments)
		{
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			foreach (string value2 in fragments)
			{
				if (value.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static void GiveItemToMonsterTeam(ItemIndex itemIndex, int count, bool updateDisplayImmediately = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if ((int)itemIndex == -1 || count <= 0)
			{
				return;
			}
			MonsterItemStacks.TryGetValue(itemIndex, out var value);
			count = GetMonsterItemGrantCount(itemIndex, count, value);
			if (count == 0)
			{
				return;
			}
			MonsterItemStacks[itemIndex] = value + count;
			if (updateDisplayImmediately)
			{
				AddItemToMonsterDisplay(itemIndex, count);
			}
			else
			{
				AnnounceMonsterItemVisual(itemIndex, count);
			}
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if ((Object)(object)readOnlyInstances != (Object)null && (int)readOnlyInstances.teamIndex == 2)
				{
					Inventory inventory = readOnlyInstances.inventory;
					if (inventory != null)
					{
						inventory.GiveItemPermanent(itemIndex, count);
					}
				}
			}
		}

		private static void AddItemToMonsterDisplay(ItemIndex itemIndex, int count)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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 ((Object)(object)monsterItemDisplayInventory == (Object)null)
			{
				Log.Warning("[AiQueOdio] O painel não recebeu o item porque seu inventário não existe.");
				return;
			}
			if ((Object)(object)Items.HalfSpeedDoubleHealth != (Object)null && itemIndex == Items.HalfSpeedDoubleHealth.itemIndex)
			{
				if (!stoneFluxStageActive)
				{
					return;
				}
				count = Mathf.Min(count, 1 - monsterItemDisplayInventory.GetItemCountPermanent(itemIndex));
				if (count <= 0)
				{
					return;
				}
			}
			monsterItemDisplayInventory.GiveItemPermanent(itemIndex, count);
			RefreshMonsterItemDisplay();
		}

		private static void AnnounceMonsterItemVisual(ItemIndex itemIndex, int displayCount)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			int sequence = ++monsterItemVisualSequence;
			ShowMonsterItemLocal(itemIndex, sequence, displayCount);
			try
			{
				NetMessageExtensions.Send((INetMessage)(object)new ShowMonsterItemMessage(itemIndex, sequence), (NetworkDestination)1);
			}
			catch (Exception ex)
			{
				Log.Error("[AiQueOdio] Falha ao enviar a animação do item aos Clients: " + ex);
			}
		}

		internal static void ShowMonsterItemLocal(ItemIndex itemIndex, int sequence, int displayCount = 0)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (sequence > lastMonsterItemVisualSequence && IsAiqueOdioRun(Run.instance) && !((Object)(object)ItemCatalog.GetItemDef(itemIndex) == (Object)null))
			{
				lastMonsterItemVisualSequence = sequence;
				MonsterItemVisualQueue.Enqueue((itemIndex, displayCount));
				if ((Object)(object)instance != (Object)null && monsterItemVisualCoroutine == null)
				{
					monsterItemVisualCoroutine = ((MonoBehaviour)instance).StartCoroutine(ProcessMonsterItemVisuals());
				}
			}
		}

		private static IEnumerator ProcessMonsterItemVisuals()
		{
			try
			{
				yield return null;
				while (MonsterItemVisualQueue.Count > 0)
				{
					(ItemIndex itemIndex, int displayCount) visual = MonsterItemVisualQueue.Dequeue();
					Run originatingRun = Run.instance;
					IEnumerator animation = ShowMonsterItemVisual(visual.itemIndex);
					try
					{
						while (true)
						{
							object current;
							try
							{
								if (!animation.MoveNext())
								{
									break;
								}
								current = animation.Current;
								goto IL_00cb;
							}
							catch (Exception arg)
							{
								Log.Error($"[AiQueOdio] Falha na animação do item {visual.itemIndex}: {arg}");
							}
							break;
							IL_00cb:
							yield return current;
						}
					}
					finally
					{
						(animation as IDisposable)?.Dispose();
						DestroyMonsterItemVisualCanvas();
						if (NetworkServer.active && (Object)(object)Run.instance == (Object)(object)originatingRun && visual.displayCount > 0)
						{
							AddItemToMonsterDisplay(visual.itemIndex, visual.displayCount);
						}
					}
				}
			}
			finally
			{
				monsterItemVisualCoroutine = null;
			}
		}

		private static IEnumerator ShowMonsterItemVisual(ItemIndex itemIndex)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
			if ((Object)(object)itemDef == (Object)null || (Object)(object)itemDef.pickupIconSprite == (Object)null)
			{
				yield break;
			}
			GameObject canvasObject = (monsterItemVisualCanvas = new GameObject("AiQueOdioMonsterItemVisual", new Type[4]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(CanvasGroup)
			}));
			Object.DontDestroyOnLoad((Object)(object)canvasObject);
			Canvas component = canvasObject.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.overrideSorting = true;
			component.sortingOrder = 32767;
			CanvasScaler component2 = canvasObject.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 0.5f;
			CanvasGroup canvasGroup = canvasObject.GetComponent<CanvasGroup>();
			canvasGroup.alpha = 0f;
			canvasGroup.interactable = false;
			canvasGroup.blocksRaycasts = false;
			GameObject val = new GameObject("Item", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(canvasObject.transform, false);
			RectTransform iconRoot = val.GetComponent<RectTransform>();
			iconRoot.anchorMin = new Vector2(0.5f, 0.5f);
			iconRoot.anchorMax = new Vector2(0.5f, 0.5f);
			iconRoot.pivot = new Vector2(0.5f, 0.5f);
			iconRoot.sizeDelta = new Vector2(84.375f, 84.375f);
			Image component3 = val.GetComponent<Image>();
			((Graphic)component3).color = new Color(0.025f, 0.025f, 0.035f, 0.92f);
			((Graphic)component3).raycastTarget = false;
			Outline outline = val.AddComponent<Outline>();
			ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier);
			Color itemColor = (((Object)(object)itemTierDef != (Object)null) ? Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.colorIndex)) : Color.white);
			((Shadow)outline).effectColor = new Color(itemColor.r, itemColor.g, itemColor.b, 0.95f);
			((Shadow)outline).effectDistance = new Vector2(3f, -3f);
			((Shadow)outline).useGraphicAlpha = true;
			GameObject val2 = new GameObject("Icon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent((Transform)(object)iconRoot, false);
			RectTransform component4 = val2.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.5f, 0.5f);
			component4.anchorMax = new Vector2(0.5f, 0.5f);
			component4.sizeDelta = new Vector2(70.875f, 70.875f);
			Image component5 = val2.GetComponent<Image>();
			component5.sprite = itemDef.pickupIconSprite;
			component5.preserveAspect = true;
			((Graphic)component5).raycastTarget = false;
			yield return null;
			if ((Object)(object)canvasObject == (Object)null)
			{
				yield break;
			}
			RectTransform canvasRect = canvasObject.GetComponent<RectTransform>();
			Rect rect = canvasRect.rect;
			Vector2 showcasePosition = (iconRoot.anchoredPosition = new Vector2(0f, ((Rect)(ref rect)).height * 0.33f));
			((Transform)iconRoot).localScale = Vector3.one * 0.7f;
			float elapsed = 0f;
			while (elapsed < 0.35f)
			{
				if ((Object)(object)canvasObject == (Object)null || (Object)(object)iconRoot == (Object)null || (Object)(object)canvasGroup == (Object)null)
				{
					yield break;
				}
				elapsed += Time.unscaledDeltaTime;
				float num = Mathf.Clamp01(elapsed / 0.35f);
				float num2 = (canvasGroup.alpha = 1f - Mathf.Pow(1f - num, 3f));
				((Transform)iconRoot).localScale = Vector3.one * Mathf.Lerp(0.7f, 1f, num2);
				yield return null;
			}
			elapsed = 0.35f;
			while (elapsed < 4f)
			{
				if ((Object)(object)canvasObject == (Object)null || (Object)(object)iconRoot == (Object)null || (Object)(object)outline == (Object)null)
				{
					yield break;
				}
				elapsed += Time.unscaledDeltaTime;
				SetSquarePulse(iconRoot, outline, itemColor, elapsed);
				yield return null;
			}
			if (!((Object)(object)canvasRect == (Object)null))
			{
				Vector2 targetPosition = FindMonsterItemPanelPosition(canvasRect);
				elapsed = 0f;
				while (elapsed < 0.85f && !((Object)(object)canvasObject == (Object)null) && !((Object)(object)iconRoot == (Object)null) && !((Object)(object)canvasGroup == (Object)null))
				{
					elapsed += Time.unscaledDeltaTime;
					float num4 = Mathf.Clamp01(elapsed / 0.85f);
					float num5 = num4 * num4 * (3f - 2f * num4);
					iconRoot.anchoredPosition = Vector2.Lerp(showcasePosition, targetPosition, num5);
					((Transform)iconRoot).localScale = Vector3.one * Mathf.Lerp(1f, 0.28f, num5);
					canvasGroup.alpha = Mathf.Lerp(1f, 0.35f, num5);
					yield return null;
				}
			}
		}

		private static void SetSquarePulse(RectTransform iconRoot, Outline outline, Color itemColor, float time)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.5f + 0.5f * Mathf.Sin(time * 7f);
			((Transform)iconRoot).localScale = Vector3.one * (1f + 0.055f * num);
			((Shadow)outline).effectColor = new Color(itemColor.r, itemColor.g, itemColor.b, Mathf.Lerp(0.65f, 1f, num));
		}

		private static Vector2 FindMonsterItemPanelPosition(RectTransform canvasRect)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			ItemInventoryDisplay[] array = Object.FindObjectsOfType<ItemInventoryDisplay>();
			Vector2 result = default(Vector2);
			foreach (ItemInventoryDisplay val in array)
			{
				if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || (Object)(object)((Component)val).GetComponentInParent<EnemyInfoPanel>() == (Object)null)
				{
					continue;
				}
				Transform transform = ((Component)val).transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>();
					Vector2 val3 = RectTransformUtility.WorldToScreenPoint(((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null, ((Transform)val2).position);
					if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, val3, (Camera)null, ref result))
					{
						return result;
					}
				}
			}
			Rect rect = canvasRect.rect;
			float num = ((Rect)(ref rect)).width * 0.38f;
			rect = canvasRect.rect;
			return new Vector2(num, ((Rect)(ref rect)).height * 0.18f);
		}

		private static void ClearMonsterItemVisuals()
		{
			MonsterItemVisualQueue.Clear();
			if (monsterItemVisualCoroutine != null && (Object)(object)instance != (Object)null)
			{
				((MonoBehaviour)instance).StopCoroutine(monsterItemVisualCoroutine);
			}
			monsterItemVisualCoroutine = null;
			DestroyMonsterItemVisualCanvas();
		}

		private static void DestroyMonsterItemVisualCanvas()
		{
			if ((Object)(object)monsterItemVisualCanvas != (Object)null)
			{
				Object.Destroy((Object)(object)monsterItemVisualCanvas);
				monsterItemVisualCanvas = null;
			}
		}

		private static void RefreshMonsterItemDisplay()
		{
			EnemyInfoPanelInventoryProvider obj = monsterItemDisplayProvider;
			if (obj != null)
			{
				obj.Refresh();
			}
			EnemyInfoPanel.RefreshAll();
		}

		private static bool IsAiqueOdioRun(Run run)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)run != (Object)null)
			{
				return run.selectedDifficulty == difficultyIndex;
			}
			return false;
		}

		private static bool IsArtifactEnabled(ArtifactDef artifact)
		{
			if ((Object)(object)artifact != (Object)null && (Object)(object)RunArtifactManager.instance != (Object)null)
			{
				return RunArtifactManager.instance.IsArtifactEnabled(artifact);
			}
			return false;
		}

		private static void Broadcast(string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = message
			});
		}

		private static void ResetMonsterPanelSync()
		{
			pendingPanelRunId = 0u;
			pendingPanelInventoryId = 0u;
			pendingPanelTonicActive = false;
			nextPanelSyncRequestTime = 0f;
			nextPanelBindTime = 0f;
		}

		internal static void SendMonsterPanelState()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Run val = Run.instance;
			if (!NetworkServer.active || !IsAiqueOdioRun(val) || (Object)(object)monsterItemDisplayInventory == (Object)null)
			{
				return;
			}
			NetworkInstanceId netId = ((NetworkBehaviour)monsterItemDisplayInventory).netId;
			if (((NetworkInstanceId)(ref netId)).Value == 0)
			{
				return;
			}
			try
			{
				netId = ((NetworkBehaviour)val).netId;
				uint value = ((NetworkInstanceId)(ref netId)).Value;
				netId = ((NetworkBehaviour)monsterItemDisplayInventory).netId;
				NetMessageExtensions.Send((INetMessage)(object)new MonsterPanelStateMessage(value, ((NetworkInstanceId)(ref netId)).Value, tonicDisplayAdded), (NetworkDestination)1);
			}
			catch (Exception ex)
			{
				Log.Warning("[AiQueOdio] Não foi possível sincronizar o painel: " + ex.Message);
			}
		}

		internal static void ReceiveMonsterPanelState(uint runId, uint inventoryId, bool tonicActive)
		{
			if (!NetworkServer.active && runId != 0 && inventoryId != 0)
			{
				pendingPanelRunId = runId;
				pendingPanelInventoryId = inventoryId;
				pendingPanelTonicActive = tonicActive;
				nextPanelBindTime = 0f;
			}
		}

		private static void RequestMonsterPanelState()
		{
			if (NetworkServer.active || !NetworkClient.active || !IsAiqueOdioRun(Run.instance))
			{
				return;
			}
			nextPanelSyncRequestTime = Time.realtimeSinceStartup + 2f;
			try
			{
				NetMessageExtensions.Send((INetMessage)(object)default(RequestMonsterPanelStateMessage), (NetworkDestination)2);
			}
			catch (Exception ex)
			{
				Log.Warning("[AiQueOdio] Aguardando conexão para sincronizar o painel: " + ex.Message);
			}
		}

		private static void UpdateMonsterPanelClient()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			Run val = Run.instance;
			if (NetworkServer.active || !NetworkClient.active || !IsAiqueOdioRun(val))
			{
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			uint num = pendingPanelRunId;
			NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
			if (num == ((NetworkInstanceId)(ref netId)).Value && pendingPanelInventoryId != 0 && realtimeSinceStartup >= nextPanelBindTime)
			{
				nextPanelBindTime = realtimeSinceStartup + 0.5f;
				GameObject val2 = ClientScene.FindLocalObject(new NetworkInstanceId(pendingPanelInventoryId));
				if ((Object)(object)val2 != (Object)null)
				{
					bool flag = (Object)(object)monsterItemDisplayObject != (Object)(object)val2;
					bool flag2 = tonicDisplayAdded != pendingPanelTonicActive;
					monsterItemDisplayObject = val2;
					monsterItemDisplayInventory = val2.GetComponent<Inventory>();
					monsterItemDisplayProvider = val2.GetComponent<EnemyInfoPanelInventoryProvider>();
					if ((Object)(object)monsterItemDisplayInventory != (Object)null && (Object)(object)monsterItemDisplayProvider != (Object)null)
					{
						tonicDisplayAdded = pendingPanelTonicActive;
						if (flag || !((Behaviour)monsterItemDisplayProvider).enabled)
						{
							ConfigureMonsterPanelObject(val2);
						}
						if (flag || flag2)
						{
							LoadTonicPanelTexture();
							RefreshMonsterItemDisplay();
						}
					}
				}
			}
			if ((Object)(object)monsterItemDisplayInventory == (Object)null && realtimeSinceStartup >= nextPanelSyncRequestTime)
			{
				RequestMonsterPanelState();
			}
		}

		private static void ConfigureMonsterPanelObject(GameObject panelObject)
		{
			ArtifactEnabledResponse[] componentsInChildren = panelObject.GetComponentsInChildren<ArtifactEnabledResponse>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
			panelObject.GetComponent<TeamFilter>().teamIndex = (TeamIndex)2;
			EnemyInfoPanelInventoryProvider component = panelObject.GetComponent<EnemyInfoPanelInventoryProvider>();
			((Behaviour)component).enabled = false;
			((Behaviour)component).enabled = true;
			Object.DontDestroyOnLoad((Object)(object)panelObject);
			component.Refresh();
		}

		private static void StartSafeAreaScrapper(Stage stage)
		{
			if (!((Object)(object)stage == (Object)null) && !((Object)(object)stage.sceneDef == (Object)null) && NetworkServer.active && IsAiqueOdioRun(Run.instance) && !((Object)(object)instance == (Object)null))
			{
				string baseSceneName = stage.sceneDef.baseSceneName;
				if ((!(baseSceneName != "bazaar") || !(baseSceneName != "computationalexchange")) && !((Object)(object)((Component)stage).GetComponent<SafeAreaScrapperState>() != (Object)null))
				{
					SafeAreaScrapperState safeAreaScrapperState = ((Component)stage).gameObject.AddComponent<SafeAreaScrapperState>();
					safeAreaScrapperState.newtReady = baseSceneName != "bazaar";
					((MonoBehaviour)instance).StartCoroutine(PrepareSafeArea(stage, safeAreaScrapperState, Run.instance, baseSceneName));
				}
			}
		}

		private static IEnumerator PrepareSafeArea(Stage stage, SafeAreaScrapperState state, Run run, string sceneName)
		{
			yield return null;
			string newtFailure = "objeto original do Newt ainda indisponível";
			string scrapperFailure = "pontos de referência ainda indisponíveis";
			for (int attempt = 0; attempt < 40; attempt++)
			{
				if ((Object)(object)stage == (Object)null || (Object)(object)state == (Object)null || (Object)(object)Stage.instance != (Object)(object)stage || (Object)(object)Run.instance != (Object)(object)run || !NetworkServer.active || !IsAiqueOdioRun(run))
				{
					yield break;
				}
				Scene sceneByName = SceneManager.GetSceneByName(sceneName);
				if (((Scene)(ref sceneByName)).IsValid() && ((Scene)(ref sceneByName)).isLoaded)
				{
					if (!state.newtReady)
					{
						try
						{
							state.newtReady = EnsureBazaarNewt(sceneByName, out newtFailure);
						}
						catch (Exception ex)
						{
							newtFailure = ex.ToString();
						}
					}
					if ((Object)(object)state.scrapper == (Object)null)
					{
						try
						{
							Physics.SyncTransforms();
							if (TryFindSafeAreaScrapperPosition(sceneByName, out var position))
							{
								state.scrapper = SpawnSafeAreaScrapper(sceneByName, position);
								scrapperFailure = "a criação do Scrapper não retornou um objeto";
							}
							else
							{
								scrapperFailure = "nenhum chão livre encontrado junto aos pontos de referência";
							}
						}
						catch (Exception ex2)
						{
							scrapperFailure = ex2.ToString();
						}
					}
					if (state.newtReady && (Object)(object)state.scrapper != (Object)null)
					{
						yield break;
					}
				}
				yield return (object)new WaitForSecondsRealtime(0.25f);
			}
			if (!state.newtReady)
			{
				Log.Warning("[AiQueOdio] Não foi possível confirmar o Newt: " + newtFailure);
			}
			if ((Object)(object)state.scrapper == (Object)null)
			{
				Log.Warning("[AiQueOdio] Scrapper não criado em " + sceneName + ": " + scrapperFailure);
			}
		}

		private static bool EnsureBazaarNewt(Scene scene, out string failure)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			failure = "ShopkeeperMaster original não encontrado";
			Transform val = FindSafeAreaTransform(scene, "ShopkeeperPosition");
			CharacterMaster val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<CharacterMaster>(true) : null);
			if ((Object)(object)val2 == (Object)null || ((Object)val2).name != "ShopkeeperMaster" || (Object)(object)val2.bodyPrefab == (Object)null)
			{
				return false;
			}
			if ((Object)(object)val2.GetBody() == (Object)null)
			{
				if (!((Component)val2).gameObject.activeSelf)
				{
					((Component)val2).gameObject.SetActive(true);
				}
				if (!((Component)val2).gameObject.activeInHierarchy)
				{
					failure = "um objeto pai do Newt está desativado";
					return false;
				}
				NetworkIdentity component = ((Component)val2).GetComponent<NetworkIdentity>();
				if ((Object)(object)component == (Object)null)
				{
					failure = "ShopkeeperMaster sem NetworkIdentity";
					return false;
				}
				if (component.netId == NetworkInstanceId.Invalid)
				{
					NetworkServer.Spawn(((Component)val2).gameObject);
				}
				val2.SpawnBodyHere();
			}
			if ((Object)(object)val2.GetBody() == (Object)null)
			{
				failure = "SpawnBodyHere não criou o corpo do Newt";
				return false;
			}
			OnPlayerEnterEvent[] componentsInChildren = ((Component)val).GetComponentsInChildren<OnPlayerEnterEvent>(true);
			foreach (OnPlayerEnterEvent val3 in componentsInChildren)
			{
				if (((Object)val3).name == "SpawnShopkeeperTrigger" && val3.action != null && ((UnityEventBase)val3.action).GetPersistentEventCount() == 1 && ((UnityEventBase)val3.action).GetPersistentTarget(0) == (Object)(object)val2 && ((UnityEventBase)val3.action).GetPersistentMethodName(0) == "SpawnBodyHere")
				{
					((Component)val3).gameObject.SetActive(false);
				}
			}
			Log.Info($"[AiQueOdio] Newt confirmado no Bazar em {val2.GetBody().transform.position}.");
			return true;
		}

		private static bool TryFindSafeAreaScrapperPosition(Scene scene, out Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023