Decompiled source of EnemyLoot v0.3.2

EnemyLoot/EnemyLoot.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnemyLoot.Behaviours;
using EnemyLoot.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EnemyLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("EnemyLoot")]
[assembly: AssemblyCopyright("Copyright © HP 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("723169ed-f41c-427a-af4c-ee8bc5e1bacb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EnemyLoot
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class Shop
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void loadShopHost()
		{
			EnemyLoot.Instance.mls.LogMessage((object)("areItemsInShop for Host? " + EnemyLoot.Config.areItemsInShop.Value));
			if (EnemyLoot.Config.areItemsInShop.Value)
			{
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				val.clearPreviousText = true;
				val.displayText = "Can be used for teleportation";
				Items.RegisterShopItem(EnemyLoot.blackOrb, (TerminalNode)null, (TerminalNode)null, val, 800);
				TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
				val2.clearPreviousText = true;
				val2.displayText = "Can be used to heal yourself";
				Items.RegisterShopItem(EnemyLoot.whiteOrb, (TerminalNode)null, (TerminalNode)null, val2, 200);
				TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
				val3.clearPreviousText = true;
				val3.displayText = "Gives unlimited stamina and more walk speed";
				Items.RegisterShopItem(EnemyLoot.orangeOrb, (TerminalNode)null, (TerminalNode)null, val3, 300);
				TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
				val4.clearPreviousText = true;
				val4.displayText = "Gives you semi-inviciblity";
				Items.RegisterShopItem(EnemyLoot.Spoon, (TerminalNode)null, (TerminalNode)null, val4, 900);
				TerminalNode val5 = ScriptableObject.CreateInstance<TerminalNode>();
				val5.clearPreviousText = true;
				val5.displayText = "@!&*@^*";
				Items.RegisterShopItem(EnemyLoot.WeirdHead, (TerminalNode)null, (TerminalNode)null, val5, 800);
				TerminalNode val6 = ScriptableObject.CreateInstance<TerminalNode>();
				val6.clearPreviousText = true;
				val6.displayText = "THE TOWN INSIDE ME";
				Items.RegisterShopItem(EnemyLoot.guiltyGearCase, (TerminalNode)null, (TerminalNode)null, val6, 50);
			}
		}
	}
	[BepInPlugin("SilasMeyer.EnemyLoot", "EnemyLoot", "0.3.2")]
	public class EnemyLoot : BaseUnityPlugin
	{
		public const string modGUID = "SilasMeyer.EnemyLoot";

		public const string modName = "EnemyLoot";

		public const string modVersion = "0.3.2";

		private readonly Harmony harmony = new Harmony("SilasMeyer.EnemyLoot");

		public static EnemyLoot Instance;

		public static MyConfig Config;

		public static Item spiderEgg;

		public static Item guiltyGearCase;

		public static Item blackOrb;

		public static Item whiteOrb;

		public static Item orangeOrb;

		public static Item Spoon;

		public static Item SnakeEgg;

		public static Item WeirdHead;

		public static Item Eye;

		public static AssetBundle bundle;

		internal static SpoonBehaviour ScriptSpoon;

		internal static AudioClip guiltyGearSFX;

		internal static AudioClip blackOrbSpawnSFX;

		internal static AudioClip blackOrbTeleportSFX;

		internal static AudioClip blackOrbCDSFX;

		internal static AudioClip whiteOrbActivationSFX;

		internal static AudioClip whiteOrbDestroySFX;

		internal static AudioClip whiteOrbCDSFX;

		internal static AudioClip orangeOrbCDSFX;

		internal static AudioClip orangeOrbActivationSFX;

		internal static AudioClip SpoonCDSFX;

		internal static AudioClip SpoonActivationSFX;

		internal static AudioClip WeirdHeadNoEnemySFX;

		internal static AudioClip WeirdHeadTeleportSFX;

		internal static AudioClip WeirdHeadCDSFX;

		internal static List<AudioClip> WeirdHeadWhistles = new List<AudioClip>();

		internal static List<AudioClip> WeirdHeadFlutes = new List<AudioClip>();

		internal static List<AudioClip> WeirdHeadVoices = new List<AudioClip>();

		internal static Sprite IconBase;

		internal static Sprite IconCD;

		internal static Sprite IconActive;

		public bool isOrangeOrbActive;

		internal ManualLogSource mls;

		private void Awake()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Config = new MyConfig(((BaseUnityPlugin)this).Config);
			mls = Logger.CreateLogSource("SilasMeyer.EnemyLoot");
			mls.LogMessage((object)"Loading EnemyLoot");
			bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "enemyloot"));
			IconBase = bundle.LoadAsset<Sprite>("Assets/Items/Icons/EnemyLootIconBase.png");
			IconCD = bundle.LoadAsset<Sprite>("Assets/Items/Icons/EnemyLootIconCD.png");
			IconActive = bundle.LoadAsset<Sprite>("Assets/Items/Icons/EnemyLootIconActive.png");
			spiderEgg = bundle.LoadAsset<Item>("Assets/Items/SpiderEggItem.asset");
			spiderEgg.positionOffset = new Vector3(-0.2f, 0f, 0.3f);
			spiderEgg.rotationOffset = new Vector3(-90f, 0f, -10f);
			NetworkPrefabs.RegisterNetworkPrefab(spiderEgg.spawnPrefab);
			Utilities.FixMixerGroups(spiderEgg.spawnPrefab);
			Items.RegisterScrap(spiderEgg, 0, (LevelTypes)(-1));
			guiltyGearCase = bundle.LoadAsset<Item>("Assets/Items/GuiltyGearCaseItem.asset");
			guiltyGearSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/GuiltyGearTownInsideMe.mp3");
			GuiltyGearCaseBehaviour guiltyGearCaseBehaviour = guiltyGearCase.spawnPrefab.AddComponent<GuiltyGearCaseBehaviour>();
			((GrabbableObject)guiltyGearCaseBehaviour).grabbable = true;
			((GrabbableObject)guiltyGearCaseBehaviour).grabbableToEnemies = true;
			((GrabbableObject)guiltyGearCaseBehaviour).itemProperties = guiltyGearCase;
			guiltyGearCase.rotationOffset = new Vector3(0f, 90f, 0f);
			guiltyGearCase.positionOffset = new Vector3(0.1f, 0f, -0.08f);
			NetworkPrefabs.RegisterNetworkPrefab(guiltyGearCase.spawnPrefab);
			Utilities.FixMixerGroups(guiltyGearCase.spawnPrefab);
			Items.RegisterScrap(guiltyGearCase, 3, (LevelTypes)(-1));
			blackOrb = bundle.LoadAsset<Item>("Assets/Items/BlackOrbItem.asset");
			blackOrbSpawnSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/BlackOrbSpawnSFX.mp3");
			blackOrbTeleportSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/BlackOrbTeleportSFX.mp3");
			blackOrbCDSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/BlackOrbCDSFX.mp3");
			BlackOrbBehaviour blackOrbBehaviour = blackOrb.spawnPrefab.AddComponent<BlackOrbBehaviour>();
			((GrabbableObject)blackOrbBehaviour).grabbable = true;
			((GrabbableObject)blackOrbBehaviour).grabbableToEnemies = true;
			((GrabbableObject)blackOrbBehaviour).itemProperties = blackOrb;
			blackOrb.rotationOffset = new Vector3(0f, 0f, 0f);
			blackOrb.positionOffset = new Vector3(-0.04f, 0.02f, -0.02f);
			NetworkPrefabs.RegisterNetworkPrefab(blackOrb.spawnPrefab);
			Utilities.FixMixerGroups(blackOrb.spawnPrefab);
			Items.RegisterScrap(blackOrb, 0, (LevelTypes)(-1));
			whiteOrb = bundle.LoadAsset<Item>("Assets/Items/WhiteOrbItem.asset");
			whiteOrbCDSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/WhiteOrbCDSFX.mp3");
			whiteOrbActivationSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/WhiteOrbHealSFX.mp3");
			whiteOrbDestroySFX = bundle.LoadAsset<AudioClip>("Assets/Audio/WhiteOrbDestroySFX.mp3");
			WhiteOrbBehaviour whiteOrbBehaviour = whiteOrb.spawnPrefab.AddComponent<WhiteOrbBehaviour>();
			((GrabbableObject)whiteOrbBehaviour).grabbable = true;
			((GrabbableObject)whiteOrbBehaviour).grabbableToEnemies = true;
			((GrabbableObject)whiteOrbBehaviour).itemProperties = whiteOrb;
			whiteOrb.rotationOffset = new Vector3(0f, 0f, 0f);
			whiteOrb.positionOffset = new Vector3(-0.04f, 0.02f, -0.02f);
			NetworkPrefabs.RegisterNetworkPrefab(whiteOrb.spawnPrefab);
			Utilities.FixMixerGroups(whiteOrb.spawnPrefab);
			Items.RegisterScrap(whiteOrb, 0, (LevelTypes)(-1));
			orangeOrb = bundle.LoadAsset<Item>("Assets/Items/OrangeOrbItem.asset");
			orangeOrbActivationSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/OrangeOrbActivationSFX.mp3");
			orangeOrbCDSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/OrangeOrbCDSFX.mp3");
			OrangeOrbBehaviour orangeOrbBehaviour = orangeOrb.spawnPrefab.AddComponent<OrangeOrbBehaviour>();
			((GrabbableObject)orangeOrbBehaviour).grabbable = true;
			((GrabbableObject)orangeOrbBehaviour).grabbableToEnemies = true;
			((GrabbableObject)orangeOrbBehaviour).itemProperties = orangeOrb;
			orangeOrb.rotationOffset = new Vector3(0f, 0f, 0f);
			orangeOrb.positionOffset = new Vector3(-0.04f, 0.02f, -0.02f);
			NetworkPrefabs.RegisterNetworkPrefab(orangeOrb.spawnPrefab);
			Utilities.FixMixerGroups(orangeOrb.spawnPrefab);
			Items.RegisterScrap(orangeOrb, 0, (LevelTypes)(-1));
			Spoon = bundle.LoadAsset<Item>("Assets/Items/SpoonItem.asset");
			SpoonActivationSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/SpoonActivateSFX.mp3");
			SpoonCDSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/SpoonCDSFX.mp3");
			ScriptSpoon = Spoon.spawnPrefab.AddComponent<SpoonBehaviour>();
			((GrabbableObject)ScriptSpoon).grabbable = true;
			((GrabbableObject)ScriptSpoon).grabbableToEnemies = true;
			((GrabbableObject)ScriptSpoon).itemProperties = Spoon;
			Spoon.rotationOffset = new Vector3(0f, -70f, 0f);
			Spoon.positionOffset = new Vector3(0.03f, 0.03f, -0.03f);
			NetworkPrefabs.RegisterNetworkPrefab(Spoon.spawnPrefab);
			Utilities.FixMixerGroups(Spoon.spawnPrefab);
			Items.RegisterScrap(Spoon, 0, (LevelTypes)(-1));
			WeirdHead = bundle.LoadAsset<Item>("Assets/Items/WeirdHeadItem.asset");
			WeirdHeadTeleportSFX = bundle.LoadAsset<AudioClip>("Assets/Audio/HeadSwapSFX.mp3");
			WeirdHeadWhistles.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadWhistle1.mp3"));
			WeirdHeadWhistles.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadWhistle2.mp3"));
			WeirdHeadWhistles.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadWhistle3.mp3"));
			WeirdHeadWhistles.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/Headwhistle4.mp3"));
			WeirdHeadFlutes.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadFlute1.mp3"));
			WeirdHeadFlutes.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadFlute2.mp3"));
			WeirdHeadFlutes.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadFlute3.mp3"));
			WeirdHeadFlutes.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadFlute4.mp3"));
			WeirdHeadFlutes.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadFlute5.mp3"));
			WeirdHeadVoices.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadVoiceNiceTry.mp3"));
			WeirdHeadVoices.Add(bundle.LoadAsset<AudioClip>("Assets/Audio/HeadVoiceEscape.mp3"));
			WeirdHeadBehaviour weirdHeadBehaviour = WeirdHead.spawnPrefab.AddComponent<WeirdHeadBehaviour>();
			((GrabbableObject)weirdHeadBehaviour).grabbable = true;
			((GrabbableObject)weirdHeadBehaviour).grabbableToEnemies = true;
			((GrabbableObject)weirdHeadBehaviour).itemProperties = WeirdHead;
			WeirdHead.rotationOffset = new Vector3(20f, 150f, 0f);
			WeirdHead.positionOffset = new Vector3(-0.04f, 0.02f, -0.02f);
			NetworkPrefabs.RegisterNetworkPrefab(WeirdHead.spawnPrefab);
			Utilities.FixMixerGroups(WeirdHead.spawnPrefab);
			Items.RegisterScrap(WeirdHead, 0, (LevelTypes)(-1));
			mls.LogMessage((object)"SilasMeyer.EnemyLoot has loaded succesfully.");
			harmony.PatchAll(typeof(Shop));
			harmony.PatchAll(typeof(EnemyLoot));
			harmony.PatchAll(typeof(MaskedDrop));
			harmony.PatchAll(typeof(SpiderDrop));
			harmony.PatchAll(typeof(HoarderBugDrop));
			harmony.PatchAll(typeof(SnareFleaDrop));
			harmony.PatchAll(typeof(BrakenDrop));
			harmony.PatchAll(typeof(ThumperDrop));
			harmony.PatchAll(typeof(SpoonPatch));
			harmony.PatchAll(typeof(ButlerDrop));
			harmony.PatchAll(typeof(OrangeOrbSprintMeterPatch));
			harmony.PatchAll(typeof(WeirdHeadSoundPatch));
			harmony.PatchAll(typeof(ManeaterDrop));
			harmony.PatchAll(typeof(PlayerTargetablePatch));
		}
	}
	public class MyConfig
	{
		public readonly ConfigEntry<float> DebugLevel;

		public readonly ConfigEntry<bool> areItemsInShop;

		public readonly ConfigEntry<bool> SpiderDropSpiderEgg;

		public readonly ConfigEntry<bool> MaskedDropMask;

		public readonly ConfigEntry<bool> HoarderDropGuiltyGear;

		public readonly ConfigEntry<bool> BrackenDropBlackOrb;

		public readonly ConfigEntry<bool> SnareFleaDropWhiteOrb;

		public readonly ConfigEntry<bool> ThumperDropOrangeOrb;

		public readonly ConfigEntry<bool> ButlerDropSpoon;

		public readonly ConfigEntry<int> GuiltyGearSpawnRate;

		public MyConfig(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			areItemsInShop = cfg.Bind<bool>("1. General", "Activate Items in shop", false, "Adds the new items to the shop");
			SpiderDropSpiderEgg = cfg.Bind<bool>("2. Drops", "Drop Spider Egg", true, "Spider drops egg on death");
			MaskedDropMask = cfg.Bind<bool>("2. Drops", "Drop Mask", true, "Masked drops mask on death");
			HoarderDropGuiltyGear = cfg.Bind<bool>("2. Drops", "Drop Guilty Gear Case", true, "Hoarder Bug can drop Guilty Gear Strive Case");
			BrackenDropBlackOrb = cfg.Bind<bool>("2. Drops", "Drop Black Orb", true, "Braken can drop Black Orb");
			SnareFleaDropWhiteOrb = cfg.Bind<bool>("2. Drops", "Drop White Orb", true, "Snare Flea can drop White Orb");
			ThumperDropOrangeOrb = cfg.Bind<bool>("2. Drops", "Drop Orange Orb", true, "Thumper can drop Orange Orb");
			ButlerDropSpoon = cfg.Bind<bool>("2. Drops", "Drop Spoon", true, "Butler can drop a spoon");
			GuiltyGearSpawnRate = cfg.Bind<int>("3. Spawnrates", "Guilty Gear Spawnrate", 60, "Spawnrate in percent of the Guilty Gear drop when killing a Hoarder Bug. Enter a number from 0-100.");
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			((Dictionary<ConfigDefinition, string>)AccessTools.Property(typeof(ConfigFile), "OrphanedEntries").GetValue(cfg)).Clear();
		}
	}
}
namespace EnemyLoot.Patches
{
	[HarmonyPatch(typeof(ButlerEnemyAI))]
	internal class ButlerDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(ButlerEnemyAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.ButlerDropSpoon.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating Spoon");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.Spoon.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(333, 444);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Spoon was created");
			}
		}
	}
	[HarmonyPatch(typeof(MouthDogAI))]
	internal class EyelessDogDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(MouthDogAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.SpiderDropSpiderEgg.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Try spawning eye");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.spiderEgg.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = 666;
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Eye was spawned");
			}
		}
	}
	[HarmonyPatch(typeof(CaveDwellerAI))]
	internal class ManeaterDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(CaveDwellerAI __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00aa: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating Weird Head");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.WeirdHead.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(400, 700);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Weird Head was created");
			}
		}
	}
	[HarmonyPatch(typeof(FlowerSnakeEnemy))]
	internal class SnakeDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(FlowerSnakeEnemy __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00a4: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Try spawning SnakeEgg");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.SnakeEgg.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(10, 15);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"SnakeEgg was spawned");
			}
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrakenDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(FlowermanAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.BrackenDropBlackOrb.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating Black Orb");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.blackOrb.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(350, 400);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				AudioSource component = val.GetComponent<AudioSource>();
				component.clip = EnemyLoot.blackOrbSpawnSFX;
				component.Play();
				EnemyLoot.Instance.mls.LogMessage((object)"Black Orb was created");
			}
		}
	}
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal class HawkDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(BaboonBirdAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.ThumperDropOrangeOrb.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating feather");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.orangeOrb.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(90, 120);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"feather was created");
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(HoarderBugAI __instance)
		{
			//IL_0064: 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_007d: 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_00d7: 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)
			if (EnemyLoot.Config.HoarderDropGuiltyGear.Value && NetworkManager.Singleton.IsServer && new Random().Next(1, 101) <= EnemyLoot.Config.GuiltyGearSpawnRate.Value)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Try spawning Guilty Gear Case");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.guiltyGearCase.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(50, 90);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Guilty Gear Case was spawned");
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskedDrop
	{
		private static Item _mask;

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(MaskedPlayerEnemy __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer && !EnemyLoot.Config.MaskedDropMask.Value)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Try getting Mask");
				GameObject val = Object.Instantiate<GameObject>(GetMask().spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(40, 60);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Mask was spawned");
			}
		}

		private static Item GetMask()
		{
			if ((Object)(object)_mask == (Object)null)
			{
				_mask = StartOfRound.Instance.allItemsList.itemsList.First((Item m) => ((Object)m).name == "ComedyMask");
			}
			EnemyLoot.Instance.mls.LogMessage((object)(((object)_mask)?.ToString() + ": Found Mask"));
			return _mask;
		}
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class SnareFleaDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(CentipedeAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.SnareFleaDropWhiteOrb.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating White Orb");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.whiteOrb.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(30, 50);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"White Orb was created");
			}
		}
	}
	[HarmonyPatch(typeof(SandSpiderAI))]
	internal class SpiderDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(SandSpiderAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.SpiderDropSpiderEgg.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Try spawning egg");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.spiderEgg.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(300, 350);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Egg was spawned");
			}
		}
	}
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class ThumperDrop
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void Patch(CrawlerAI __instance)
		{
			//IL_0043: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyLoot.Config.ThumperDropOrangeOrb.Value && NetworkManager.Singleton.IsServer)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Creating Orange Orb");
				GameObject val = Object.Instantiate<GameObject>(EnemyLoot.orangeOrb.spawnPrefab, ((Component)__instance).transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
				val.GetComponentInChildren<GrabbableObject>().fallTime = 0f;
				int scrapValue = new Random().Next(90, 120);
				val.GetComponentInChildren<GrabbableObject>().SetScrapValue(scrapValue);
				val.GetComponentInChildren<NetworkObject>().Spawn(false);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { val.GetComponent<GrabbableObject>().scrapValue });
				EnemyLoot.Instance.mls.LogMessage((object)"Orange Orb was created");
			}
		}
	}
}
namespace EnemyLoot.Behaviours
{
	internal class BlackOrbBehaviour : PhysicsProp
	{
		private int activationCounter;

		private bool _isTimerRunning;

		private AudioSource audioSource;

		private PlayerControllerB player;

		private Vector3 playerShipTeleportPosition;

		private Vector3 playerOrbTeleportPosition;

		internal EntranceTeleport[] EntranceArray;

		private bool _wasInsideBeforeTeleport;

		private bool _isSavedTeleportPositionInside;

		private int EntranceIndex;

		private const int ExitIndex = 0;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			player = ((GrabbableObject)this).playerHeldBy;
			playerShipTeleportPosition = StartOfRound.Instance.playerSpawnPositions[0].position;
			EntranceArray = Object.FindObjectsOfType<EntranceTeleport>(false);
			EntranceIndex = EntranceArray.Length / 2;
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				if (!_isTimerRunning)
				{
					activationCounter++;
					((MonoBehaviour)this).StartCoroutine(orbTeleport());
				}
				else
				{
					audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
					audioSource.clip = EnemyLoot.blackOrbCDSFX;
					audioSource.Play();
				}
			}
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop Black Orb : [G]", "Activate Black Orb : [LMB]" };
			if (_isTimerRunning)
			{
				array[1] = "Black Orb on cooldown";
			}
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}

		private IEnumerator orbTeleport()
		{
			_isTimerRunning = true;
			audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			audioSource.clip = EnemyLoot.blackOrbTeleportSFX;
			audioSource.Play();
			yield return (object)new WaitForSeconds(4.5f);
			_wasInsideBeforeTeleport = player.isInsideFactory;
			if (activationCounter == 1)
			{
				playerOrbTeleportPosition = ((Component)player).transform.position;
				_isSavedTeleportPositionInside = _wasInsideBeforeTeleport;
				if (_wasInsideBeforeTeleport)
				{
					EntranceArray[0].TeleportPlayer();
				}
				player.TeleportPlayer(playerShipTeleportPosition, false, 0f, false, true);
			}
			else
			{
				if (_wasInsideBeforeTeleport && !_isSavedTeleportPositionInside)
				{
					EntranceArray[0].TeleportPlayer();
				}
				else if (!_wasInsideBeforeTeleport && _isSavedTeleportPositionInside)
				{
					EntranceArray[EntranceIndex].TeleportPlayer();
				}
				player.TeleportPlayer(playerOrbTeleportPosition, false, 0f, false, true);
				((GrabbableObject)this).SetControlTipsForItem();
				yield return (object)new WaitForSeconds(60f);
				activationCounter = 0;
			}
			_isTimerRunning = false;
		}
	}
	internal class WeirdHeadBehaviour : PhysicsProp
	{
		private int activationCounter;

		private bool _isTimerRunning;

		private AudioSource _audioSource;

		private PlayerControllerB _player;

		public Vector3 EnemyPosition;

		public Vector3 PlayerPosition;

		private static List<EnemyAI> _enemyList = new List<EnemyAI>();

		public EnemyAI Enemy;

		internal EntranceTeleport[] EntranceArray;

		private bool _wasInsideBeforeTeleport;

		private static Dictionary<int, AudioSource> _audioSourceMap = new Dictionary<int, AudioSource>();

		private static Random random = new Random();

		private int _searchCounter;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			_player = ((GrabbableObject)this).playerHeldBy;
			EntranceArray = Object.FindObjectsOfType<EntranceTeleport>(false);
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown)
			{
				return;
			}
			_enemyList = RoundManager.Instance.SpawnedEnemies;
			_searchCounter = 0;
			do
			{
				if (_enemyList == null || _enemyList.Count == 0)
				{
					EnemyLoot.Instance.mls.LogMessage((object)"No enemy exists");
					return;
				}
				int index = random.Next(_enemyList.Count);
				Enemy = _enemyList[index];
				EnemyLoot.Instance.mls.LogMessage((object)("Found: " + ((object)Enemy).GetType().Name + " | SearchCounter: " + _searchCounter));
			}
			while (!IsEnemyTypeValid(Enemy) && _searchCounter < 5);
			if (_searchCounter >= 5)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Tried finding valid enemy - failed");
				return;
			}
			if ((Object)(object)Enemy == (Object)null)
			{
				_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
				_audioSource.clip = EnemyLoot.WeirdHeadNoEnemySFX;
				return;
			}
			EnemyPosition = ((Component)Enemy).transform.position;
			PlayerPosition = ((Component)_player).transform.position;
			if (!_isTimerRunning)
			{
				activationCounter++;
				((MonoBehaviour)this).StartCoroutine(orbTeleport());
				return;
			}
			_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			int index2 = new Random().Next(EnemyLoot.WeirdHeadWhistles.Count);
			_audioSource.clip = EnemyLoot.WeirdHeadWhistles[index2];
			_audioSource.Play();
		}

		private bool IsEnemyTypeValid(EnemyAI _enemy)
		{
			_searchCounter++;
			switch (((object)_enemy).GetType().Name)
			{
			case "DoublewingAI":
			case "RedLocustBees":
			case "ButlerBeesEnemyAI":
			case "DocileLocustBeesAI":
			case "SandWormAI":
			case "DressGirlAI":
			case "FlowerSnakeEnemy":
				return false;
			default:
				return true;
			}
		}

		private IEnumerator orbTeleport()
		{
			_isTimerRunning = true;
			_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			_audioSource.clip = EnemyLoot.WeirdHeadTeleportSFX;
			_audioSource.Play();
			_wasInsideBeforeTeleport = _player.isInsideFactory;
			SpawnableEnemyWithRarity _enemyToSpawn = null;
			bool _IsOutsideEnemy = false;
			((GrabbableObject)this).SetControlTipsForItem();
			yield return (object)new WaitForSeconds(0.5f);
			if (_wasInsideBeforeTeleport && Enemy.isOutside)
			{
				EntranceArray[0].TeleportPlayer();
			}
			else if (!_wasInsideBeforeTeleport && !Enemy.isOutside)
			{
				EntranceArray[EntranceArray.Length / 2].TeleportPlayer();
			}
			_player.TeleportPlayer(EnemyPosition, false, 0f, false, true);
			RoundManager.Instance.DespawnEnemyOnServer(((NetworkBehaviour)Enemy).NetworkObject);
			if (!Enemy.enemyType.isOutsideEnemy)
			{
				foreach (SpawnableEnemyWithRarity enemy in RoundManager.Instance.currentLevel.Enemies)
				{
					EnemyLoot.Instance.mls.LogMessage((object)("Index of: " + ((Object)enemy.enemyType).name + " | " + RoundManager.Instance.currentLevel.Enemies.IndexOf(enemy)));
					if ((Object)(object)enemy.enemyType == (Object)(object)Enemy.enemyType)
					{
						_enemyToSpawn = enemy;
						break;
					}
				}
			}
			else
			{
				foreach (SpawnableEnemyWithRarity outsideEnemy in RoundManager.Instance.currentLevel.OutsideEnemies)
				{
					EnemyLoot.Instance.mls.LogMessage((object)("Index of: " + ((Object)outsideEnemy.enemyType).name + " | " + RoundManager.Instance.currentLevel.Enemies.IndexOf(outsideEnemy)));
					if ((Object)(object)outsideEnemy.enemyType == (Object)(object)Enemy.enemyType)
					{
						_enemyToSpawn = outsideEnemy;
						_IsOutsideEnemy = true;
						break;
					}
				}
			}
			if (_enemyToSpawn != null)
			{
				if (!_IsOutsideEnemy)
				{
					RoundManager.Instance.SpawnEnemyOnServer(PlayerPosition, PlayerPosition.y, RoundManager.Instance.currentLevel.Enemies.IndexOf(_enemyToSpawn));
				}
				EnemyLoot.Instance.mls.LogMessage((object)(Enemy.enemyType.enemyName + "should have been spawned"));
				EnemyLoot.Instance.mls.LogMessage((object)(((Object)_enemyToSpawn.enemyType).name + " was spawned"));
				((GrabbableObject)this).SetControlTipsForItem();
				yield return (object)new WaitForSeconds(10f);
			}
			else
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Wasn't able to spawn Enemy");
			}
			_isTimerRunning = false;
			((GrabbableObject)this).SetControlTipsForItem();
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			WeirdHeadSoundPatch.WasPickedUp = true;
			EnemyLoot.Instance.mls.LogMessage((object)"Picked Up Head");
			_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			int instanceID = ((Object)((Component)this).gameObject).GetInstanceID();
			_audioSourceMap[instanceID] = _audioSource;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
		}

		public static AudioSource GetRandomAudioSource()
		{
			if (_audioSourceMap.Count == 0)
			{
				return null;
			}
			Random random = new Random();
			return _audioSourceMap.ElementAt(random.Next(0, _audioSourceMap.Count)).Value;
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop Weird Head : [G]", "Weird Head is sleeping" };
			if (_isTimerRunning)
			{
				array[1] = "Weird Head on cooldown";
			}
			else if (RoundManager.Instance.SpawnedEnemies.Count > 0)
			{
				array[1] = "Activate Weird Head : [LMB]";
			}
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			WeirdHeadSoundPatch.WasPickedUp = false;
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			WeirdHeadSoundPatch.WasPickedUp = false;
			EnemyLoot.Instance.mls.LogMessage((object)"Drop Item");
		}
	}
	[HarmonyPatch(typeof(SoundManager))]
	internal class WeirdHeadSoundPatch
	{
		public static bool WasPickedUp;

		public static bool OnCooldown;

		public static AudioSource AudioSource;

		public static WeirdHeadBehaviour itemInPatch;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Patch()
		{
			if (WasPickedUp && !OnCooldown)
			{
				EnemyLoot.Instance.mls.LogMessage((object)"Playing Sound");
				((MonoBehaviour)SoundManager.Instance).StartCoroutine(PlayHeadSound());
			}
		}

		private static IEnumerator PlayHeadSound()
		{
			OnCooldown = true;
			int minValue = 60;
			int maxValue = 120;
			EnemyLoot.Instance.mls.LogMessage((object)"In Sound function");
			Random random = new Random();
			int counter = random.Next(minValue, maxValue);
			int index = random.Next(EnemyLoot.WeirdHeadFlutes.Count);
			NetworkManager _networkManager = NetworkManager.Singleton;
			yield return (object)new WaitForSeconds((float)(counter / 2));
			if (_networkManager.IsServer)
			{
				RpcPlaySoundOnServer(EnemyLoot.WeirdHeadFlutes[index]);
			}
			else
			{
				RpcPlaySoundOnClients(EnemyLoot.WeirdHeadFlutes[index]);
			}
			yield return (object)new WaitForSeconds((float)(counter / 2));
			OnCooldown = false;
		}

		[ClientRpc]
		private static void RpcPlaySoundOnClients(AudioClip audioClip)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			AudioSource obj = new GameObject("GlobalAudioSource").AddComponent<AudioSource>();
			obj.clip = audioClip;
			obj.spatialBlend = 0f;
			obj.volume = 1.2f;
			obj.Play();
			Object.Destroy((Object)(object)((Component)obj).gameObject, audioClip.length);
		}

		[ServerRpc]
		public static void RpcPlaySoundOnServer(AudioClip audioClip)
		{
			RpcPlaySoundOnClients(audioClip);
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	[HarmonyPatch("PlayerIsTargetable")]
	internal class PlayerTargetablePatch
	{
		private static bool Prefix(ref bool overrideInsideFactoryCheck)
		{
			overrideInsideFactoryCheck = true;
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	[HarmonyPatch("PlayerIsTargetable")]
	internal class PlayerInvinciblePatch
	{
		private static bool Prefix(ref bool __result)
		{
			__result = false;
			EnemyLoot.Instance.mls.LogMessage((object)"Player is invicible");
			return false;
		}
	}
	internal class SpoonBehaviour : GrabbableObject
	{
		private bool _isTimerRunning;

		private int _activationCounter;

		private AudioSource _audioSource;

		private PlayerControllerB _player;

		private int _healthBefore;

		public bool _isHoldingSpoon;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				_player = base.playerHeldBy;
				SpoonPatch.IsPlayerHoldingSpoon = true;
				if (!_isTimerRunning)
				{
					_activationCounter++;
					((MonoBehaviour)this).StartCoroutine(Activation());
				}
				else
				{
					_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
					_audioSource.clip = EnemyLoot.SpoonCDSFX;
					_audioSource.Play();
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			SpoonPatch.IsPlayerHoldingSpoon = true;
			if (SpoonPatch.IsSpoonActive)
			{
				_healthBefore = _player.health;
				_player.health = 100;
				HUDManager.Instance.UpdateHealthUI(_player.health, false);
			}
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop Spoon : [G]", "Activate Spoon : [LMB]" };
			if (SpoonPatch.IsSpoonActive)
			{
				array[1] = "Spoon is active";
			}
			else if (_isTimerRunning)
			{
				array[1] = "Spoon on cooldown";
			}
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}

		public PlayerControllerB GetHoldingPlayer()
		{
			return base.playerHeldBy;
		}

		private IEnumerator Activation()
		{
			_isTimerRunning = true;
			_audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			_audioSource.clip = EnemyLoot.SpoonActivationSFX;
			_audioSource.Play();
			_healthBefore = _player.health;
			if ((Object)(object)_player != (Object)null)
			{
				SpoonPatch.IsSpoonActive = true;
				SpoonPatch.Player = _player;
				SpoonPatch.IsPlayerHoldingSpoon = true;
				_player.health = 100;
				((GrabbableObject)EnemyLoot.ScriptSpoon).itemProperties.itemIcon = EnemyLoot.IconActive;
				((GrabbableObject)this).SetControlTipsForItem();
			}
			yield return (object)new WaitForSeconds(10f);
			if ((Object)(object)_player != (Object)null)
			{
				SpoonPatch.IsSpoonActive = false;
				SpoonPatch.Player = null;
				_player.health = _healthBefore;
				HUDManager.Instance.UpdateHealthUI(_player.health, false);
				((GrabbableObject)EnemyLoot.ScriptSpoon).itemProperties.itemIcon = EnemyLoot.IconCD;
				((GrabbableObject)this).SetControlTipsForItem();
			}
			yield return (object)new WaitForSeconds(30f);
			_isTimerRunning = false;
			((GrabbableObject)this).SetControlTipsForItem();
			((GrabbableObject)EnemyLoot.ScriptSpoon).itemProperties.itemIcon = EnemyLoot.IconBase;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class SpoonPatch
	{
		public static bool IsSpoonActive;

		public static PlayerControllerB Player;

		public static bool IsPlayerHoldingSpoon;

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPostfix]
		private static void Patch(int damageNumber)
		{
			if (IsSpoonActive && IsPlayerHoldingSpoon && (Object)(object)Player != (Object)null)
			{
				PlayerControllerB player = Player;
				player.health += damageNumber;
				HUDManager.Instance.UpdateHealthUI(Player.health, false);
			}
		}
	}
	internal class GuiltyGearCaseBehaviour : GrabbableObject
	{
		private bool isTimerRunning;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && !isTimerRunning)
			{
				((MonoBehaviour)this).StartCoroutine(play());
			}
		}

		private IEnumerator play()
		{
			isTimerRunning = true;
			((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(EnemyLoot.guiltyGearSFX);
			yield return (object)new WaitForSeconds(3.5f);
			isTimerRunning = false;
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop Guilty Gear Case : [G]", "Play music : [LMB]" };
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}
	}
	internal class OrangeOrbBehaviour : PhysicsProp
	{
		private bool isTimerRunning;

		private int activationCounter;

		private float bonusMovementSpeed;

		private AudioSource audioSource;

		private PlayerControllerB player;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				player = ((GrabbableObject)this).playerHeldBy;
				bonusMovementSpeed = player.movementSpeed * 0.5f;
				if (!isTimerRunning)
				{
					activationCounter++;
					((MonoBehaviour)this).StartCoroutine(Activation());
				}
				else
				{
					audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
					audioSource.clip = EnemyLoot.orangeOrbCDSFX;
					audioSource.Play();
				}
			}
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop Orange Orb : [G]", "Activate Orange Orb : [LMB]" };
			if (OrangeOrbSprintMeterPatch.IsOrangeOrbActive)
			{
				array[1] = "Orange Orb is active";
			}
			else if (isTimerRunning)
			{
				array[1] = "Orange on cooldown";
			}
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}

		private IEnumerator Activation()
		{
			isTimerRunning = true;
			audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			audioSource.clip = EnemyLoot.orangeOrbActivationSFX;
			audioSource.Play();
			if ((Object)(object)player != (Object)null)
			{
				PlayerControllerB obj = player;
				obj.movementSpeed += bonusMovementSpeed;
				player.sprintMeter = 1f;
				OrangeOrbSprintMeterPatch.IsOrangeOrbActive = true;
			}
			((GrabbableObject)this).SetControlTipsForItem();
			yield return (object)new WaitForSeconds(15f);
			if ((Object)(object)player != (Object)null)
			{
				PlayerControllerB obj2 = player;
				obj2.movementSpeed -= bonusMovementSpeed;
				OrangeOrbSprintMeterPatch.IsOrangeOrbActive = false;
			}
			((GrabbableObject)this).SetControlTipsForItem();
			yield return (object)new WaitForSeconds(45f);
			isTimerRunning = false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class OrangeOrbSprintMeterPatch
	{
		public static bool IsOrangeOrbActive;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infinite_Sprint_Patch(ref float ___sprintMeter)
		{
			if (IsOrangeOrbActive)
			{
				___sprintMeter = 1f;
			}
		}
	}
	internal class WhiteOrbBehaviour : GrabbableObject
	{
		private bool isTimerRunning;

		private int activationCounter;

		private AudioSource audioSource;

		private PlayerControllerB player;

		private int healAmount = 30;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown)
			{
				return;
			}
			player = base.playerHeldBy;
			if (activationCounter >= 2)
			{
				audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
				audioSource.clip = EnemyLoot.whiteOrbDestroySFX;
				audioSource.Play();
				((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			}
			else if (!isTimerRunning)
			{
				if (player.health < 100)
				{
					activationCounter++;
					((MonoBehaviour)this).StartCoroutine(heal());
				}
				else
				{
					CoolDown();
				}
			}
			else
			{
				CoolDown();
			}
		}

		private void CoolDown()
		{
			audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			audioSource.clip = EnemyLoot.whiteOrbCDSFX;
			audioSource.Play();
		}

		public override void SetControlTipsForItem()
		{
			string[] array = new string[2] { "Drop White Orb : [G]", "Activate White Orb : [LMB]" };
			HUDManager.Instance.ChangeControlTipMultiple(array, false, (Item)null);
		}

		private IEnumerator heal()
		{
			isTimerRunning = true;
			audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
			audioSource.clip = EnemyLoot.whiteOrbActivationSFX;
			audioSource.Play();
			yield return (object)new WaitForSeconds(2.2f);
			if ((Object)(object)player != (Object)null)
			{
				if (player.health + healAmount > 100)
				{
					player.health = 100;
				}
				else
				{
					PlayerControllerB obj = player;
					obj.health += healAmount;
				}
				HUDManager.Instance.UpdateHealthUI(player.health, false);
			}
			yield return (object)new WaitForSeconds(2.8f);
			if (activationCounter >= 2)
			{
				audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
				audioSource.clip = EnemyLoot.whiteOrbDestroySFX;
				audioSource.Play();
				yield return (object)new WaitForSeconds(4.2f);
				((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			}
			isTimerRunning = false;
		}
	}
}