Decompiled source of LethalMon v0.0.1

plugins/LethalMon/LethalMon.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DigitalRuby.ThunderAndLightning;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalMon.AI;
using LethalMon.CatchableEnemy;
using LethalMon.Items;
using LethalMon.Patches;
using LethalMon.Throw;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.VFX;

[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("LethalMon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+da32020e99dc6e2b0fae7a6c11aa75cc92d699fa")]
[assembly: AssemblyProduct("LethalMon")]
[assembly: AssemblyTitle("LethalMon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalMon
{
	public static class Data
	{
		public static readonly Random Random = new Random();

		public static readonly double[][] CaptureProbabilities = new double[4][]
		{
			new double[10] { 0.95, 0.9, 0.8, 0.65, 0.5, 0.3, 0.1, 0.0, 0.0, 0.0 },
			new double[10] { 1.0, 0.97, 0.95, 0.85, 0.7, 0.5, 0.3, 0.2, 0.15, 0.1 },
			new double[10] { 1.0, 1.0, 1.0, 0.97, 0.95, 0.9, 0.8, 0.7, 0.6, 0.5 },
			new double[10] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }
		};

		public static readonly Dictionary<string, global::LethalMon.CatchableEnemy.CatchableEnemy> CatchableMonsters = new Dictionary<string, global::LethalMon.CatchableEnemy.CatchableEnemy>
		{
			{
				"Flowerman",
				new CatchableFlowerman()
			},
			{
				"HoarderBug",
				new CatchableHoarderBug()
			},
			{
				"RedLocustBees",
				new CatchableRedLocustBees()
			}
		};
	}
	[BepInPlugin("LethalMon", "LethalMon", "1.0.0")]
	public class LethalMon : BaseUnityPlugin
	{
		public static GameObject pokeballSpawnPrefab;

		public static GameObject greatBallSpawnPrefab;

		public static GameObject ultraBallSpawnPrefab;

		public static GameObject masterBallSpawnPrefab;

		public static LethalMon Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalmon"));
			SetupPokeball(assetBundle);
			SetupGreatball(assetBundle);
			SetupUltraball(assetBundle);
			SetupMasterball(assetBundle);
			Harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Harmony.PatchAll(typeof(PlayerControllerBPatch));
			Harmony.PatchAll(typeof(RedLocustBeesPatch));
			Harmony.PatchAll(typeof(StartOfRoundPatch));
			PokeballItem.InitializeRPCS();
			HoarderBugCustomAI.InitializeRPCS();
			PlayerControllerBPatch.InitializeRPCS();
			ThrowableItem.InitializeRPCS();
			RedLocustBeesCustomAI.InitializeRPCS();
			Logger.LogInfo((object)"LethalMon v1.0.0 has loaded!");
		}

		private void SetupPokeball(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Assets/Balls/Pokeball/Pokeball.asset");
			Pokeball pokeball = val.spawnPrefab.AddComponent<Pokeball>();
			((GrabbableObject)pokeball).itemProperties = val;
			((GrabbableObject)pokeball).grabbable = true;
			((GrabbableObject)pokeball).grabbableToEnemies = true;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 20, (LevelTypes)(-1));
			pokeballSpawnPrefab = val.spawnPrefab;
		}

		private void SetupGreatball(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Assets/Balls/Greatball/Greatball.asset");
			Greatball greatball = val.spawnPrefab.AddComponent<Greatball>();
			((GrabbableObject)greatball).itemProperties = val;
			((GrabbableObject)greatball).grabbable = true;
			((GrabbableObject)greatball).grabbableToEnemies = true;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 10, (LevelTypes)(-1));
			greatBallSpawnPrefab = val.spawnPrefab;
		}

		private void SetupUltraball(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Assets/Balls/Ultraball/Ultraball.asset");
			Ultraball ultraball = val.spawnPrefab.AddComponent<Ultraball>();
			((GrabbableObject)ultraball).itemProperties = val;
			((GrabbableObject)ultraball).grabbable = true;
			((GrabbableObject)ultraball).grabbableToEnemies = true;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 6, (LevelTypes)(-1));
			ultraBallSpawnPrefab = val.spawnPrefab;
		}

		private void SetupMasterball(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Assets/Balls/Masterball/Masterball.asset");
			Masterball masterball = val.spawnPrefab.AddComponent<Masterball>();
			((GrabbableObject)masterball).itemProperties = val;
			((GrabbableObject)masterball).grabbable = true;
			((GrabbableObject)masterball).grabbableToEnemies = true;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 2, (LevelTypes)(-1));
			masterBallSpawnPrefab = val.spawnPrefab;
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public class Utils
	{
		public static CustomAI? GetPlayerPet(PlayerControllerB player)
		{
			PlayerControllerB player2 = player;
			return Object.FindObjectsOfType<CustomAI>().FirstOrDefault((CustomAI customAi) => customAi.ownClientId == player2.playerClientId);
		}

		public static Vector3 GetPositionInFrontOfPlayerEyes(PlayerControllerB player)
		{
			//IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return player.playerEye.position + player.playerEye.forward * 2.5f;
		}

		public static Vector3 GetPositionBehindPlayer(PlayerControllerB player)
		{
			//IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)player).transform.position + ((Component)player).transform.forward * -2f;
		}

		public static EnemyAI? GetMostProbableAttackerEnemy(PlayerControllerB player, StackTrace stackTrace)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			StackFrame[] frames = stackTrace.GetFrames();
			StackFrame[] subArray = frames[1..];
			foreach (StackFrame stackFrame in subArray)
			{
				Type declaringType = stackFrame.GetMethod().DeclaringType;
				Debug.Log((object)("Stackframe type: " + declaringType));
				if (!declaringType.IsSubclassOf(typeof(EnemyAI)))
				{
					continue;
				}
				Debug.Log((object)"Class is assignable from EnemyAI");
				EnemyAI val = null;
				float? num = float.MaxValue;
				Collider[] array = Physics.OverlapSphere(((Component)player).transform.position, 10f);
				Collider[] array2 = array;
				foreach (Collider val2 in array2)
				{
					EnemyAI componentInParent = ((Component)val2).GetComponentInParent<EnemyAI>();
					if ((Object)(object)componentInParent != (Object)null && ((object)componentInParent).GetType() == declaringType)
					{
						float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)componentInParent).transform.position);
						if (num > num2)
						{
							val = componentInParent;
							num = num2;
						}
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalMon";

		public const string PLUGIN_NAME = "LethalMon";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalMon.Throw
{
	public class FallCurve
	{
		internal static readonly Keyframe[] fallCurveKeyframes = (Keyframe[])(object)new Keyframe[2]
		{
			new Keyframe(0f, 0f, 2f, 2f),
			new Keyframe(1f, 1f, 0f, 0f)
		};

		internal static readonly Keyframe[] verticalFallCurveKeyframes = (Keyframe[])(object)new Keyframe[5]
		{
			new Keyframe(0f, 0f, 0.116908506f, 0.116908506f, 0f, 0.27230743f),
			new Keyframe(0.49081117f, 1f, 4.1146584f, -1.81379f, 0.07234045f, 0.28319725f),
			new Keyframe(0.7587703f, 1f, 1.4123471f, -1.3678839f, 0.31997186f, 0.56917864f),
			new Keyframe(0.9393898f, 1f, 0.82654804f, -0.029021755f, 0.53747445f, 1f),
			new Keyframe(1f, 1f)
		};

		internal static readonly Keyframe[] verticalFallCurveNoBounceKeyFrames = (Keyframe[])(object)new Keyframe[4]
		{
			new Keyframe(0f, 0f, 0.116908506f, 0.116908506f, 0f, 0.27230743f),
			new Keyframe(0.69081116f, 1f, 0.1146584f, 0.06098772f, 0.07234045f, 0.20768756f),
			new Keyframe(0.9393898f, 1f, 0.06394797f, -0.029021755f, 0.1980713f, 1f),
			new Keyframe(1f, 1f)
		};

		internal static readonly AnimationCurve fallCurve = new AnimationCurve(fallCurveKeyframes);

		internal static readonly AnimationCurve verticalFallCurve = new AnimationCurve(verticalFallCurveKeyframes);

		internal static readonly AnimationCurve verticalFallCurveNoBounce = new AnimationCurve(verticalFallCurveNoBounceKeyFrames);
	}
	public abstract class ThrowableItem : GrabbableObject
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static RpcReceiveHandler <0>____rpc_handler_2055230283;
		}

		public AnimationCurve itemFallCurve;

		public AnimationCurve itemVerticalFallCurve;

		public AnimationCurve itemVerticalFallCurveNoBounce;

		public RaycastHit itemHit;

		public Ray itemThrowRay;

		public PlayerControllerB playerThrownBy;

		internal static void InitializeRPCS()
		{
			//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_0025: Expected O, but got Unknown
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table = NetworkManager.__rpc_func_table;
			object obj = <>O.<0>____rpc_handler_2055230283;
			if (obj == null)
			{
				RpcReceiveHandler val = __rpc_handler_2055230283;
				<>O.<0>____rpc_handler_2055230283 = val;
				obj = (object)val;
			}
			_rpc_func_table.Add(2055230283u, (RpcReceiveHandler)obj);
		}

		public void SendThrowPacket(NetworkObjectReference throwableItemNetworkObjectReference, NetworkObjectReference playerNetworkObjectReference)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0034: 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)
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2055230283u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref throwableItemNetworkObjectReference, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref playerNetworkObjectReference, default(ForNetworkSerializable));
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2055230283u, val, (RpcDelivery)0);
			Debug.Log((object)"SendThrowPacket server rpc send finished");
		}

		[ServerRpc]
		public void SendThrowRpc(NetworkObjectReference throwableItemNetworkObjectReference, NetworkObjectReference playerNetworkObjectReference)
		{
			Debug.Log((object)"SendThrowRpc server rpc received");
			NetworkObject val = default(NetworkObject);
			NetworkObject val2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref throwableItemNetworkObjectReference)).TryGet(ref val, (NetworkManager)null) && ((NetworkObjectReference)(ref playerNetworkObjectReference)).TryGet(ref val2, (NetworkManager)null))
			{
				ThrowableItem component = ((Component)val).GetComponent<ThrowableItem>();
				PlayerControllerB component2 = ((Component)val2).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					component.playerThrownBy = component2;
				}
				else
				{
					Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get throwable item or player component (SendThrowRpc)"));
				}
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (SendThrowRpc)"));
			}
		}

		private static void __rpc_handler_2055230283(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0049: 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_005b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening)
			{
				Debug.Log((object)("Execute RPC handler " + MethodBase.GetCurrentMethod().Name));
				NetworkObjectReference throwableItemNetworkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref throwableItemNetworkObjectReference, default(ForNetworkSerializable));
				NetworkObjectReference playerNetworkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref playerNetworkObjectReference, default(ForNetworkSerializable));
				((ThrowableItem)(object)target).SendThrowRpc(throwableItemNetworkObjectReference, playerNetworkObjectReference);
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0025: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner)
			{
				playerThrownBy = base.playerHeldBy;
				base.playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetItemThrowDestination(), true);
				SendThrowPacket(NetworkObjectReference.op_Implicit(((Component)this).GetComponent<NetworkObject>()), NetworkObjectReference.op_Implicit(((Component)playerThrownBy).GetComponent<NetworkObject>()));
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EnableItemMeshes(true);
			base.isPocketed = false;
		}

		public abstract void TouchGround();

		public override void FallWithCurve()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0026: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = base.startFallingPosition - base.targetFloorPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)this).transform.localPosition = Vector3.Lerp(base.startFallingPosition, base.targetFloorPosition, FallCurve.fallCurve.Evaluate(base.fallTime));
			if (magnitude > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), FallCurve.verticalFallCurveNoBounce.Evaluate(base.fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), FallCurve.verticalFallCurve.Evaluate(base.fallTime));
			}
			base.fallTime += Mathf.Abs(Time.deltaTime * 12f / magnitude);
			if (base.fallTime > 1f)
			{
				TouchGround();
				playerThrownBy = null;
			}
		}

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

		public Vector3 GetItemThrowDestination()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0075: 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_00c1: 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_00c6: 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)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Debug.DrawRay(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, Color.yellow, 15f);
			itemThrowRay = new Ray(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward);
			position = ((!Physics.Raycast(itemThrowRay, ref itemHit, 12f, 268437761, (QueryTriggerInteraction)1)) ? ((Ray)(ref itemThrowRay)).GetPoint(10f) : ((Ray)(ref itemThrowRay)).GetPoint(((RaycastHit)(ref itemHit)).distance - 0.05f));
			Debug.DrawRay(position, Vector3.down, Color.blue, 15f);
			itemThrowRay = new Ray(position, Vector3.down);
			if (Physics.Raycast(itemThrowRay, ref itemHit, 30f, 268437761, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref itemHit)).point + Vector3.up * (base.itemProperties.verticalOffset + 0.05f);
			}
			return ((Ray)(ref itemThrowRay)).GetPoint(30f);
		}
	}
}
namespace LethalMon.Patches
{
	public class PlayerControllerBPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static RpcReceiveHandler <0>____rpc_handler_346187524u;
		}

		private static bool lastTestPressed = false;

		private static int currentTestEnemyTypeIndex = 0;

		private static string[] testEnemyTypes = new List<string>(Data.CatchableMonsters.Keys).ToArray();

		internal static void InitializeRPCS()
		{
			//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_0025: Expected O, but got Unknown
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table = NetworkManager.__rpc_func_table;
			object obj = <>O.<0>____rpc_handler_346187524u;
			if (obj == null)
			{
				RpcReceiveHandler val = __rpc_handler_346187524u;
				<>O.<0>____rpc_handler_346187524u = val;
				obj = (object)val;
			}
			_rpc_func_table.Add(346187524u, (RpcReceiveHandler)obj);
		}

		public static void SendPetRetrievePacket(PlayerControllerB player)
		{
			//IL_0002: 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_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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = (FastBufferWriter)((object)player).GetType().GetMethod("__beginSendServerRpc", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[3]
			{
				346187524u,
				val,
				(object)(RpcDelivery)0
			});
			NetworkObjectReference val3 = NetworkObjectReference.op_Implicit(((Component)player).GetComponent<NetworkObject>());
			((object)player).GetType().GetMethod("__endSendServerRpc", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[4]
			{
				val2,
				346187524u,
				val,
				(object)(RpcDelivery)0
			});
			Debug.Log((object)"Send pet retrieve server rpc send finished");
		}

		private static void __rpc_handler_346187524u(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening)
			{
				Debug.Log((object)("Execute RPC handler " + MethodBase.GetCurrentMethod().Name));
				PlayerControllerB val = (PlayerControllerB)target;
				CustomAI playerPet = Utils.GetPlayerPet(val);
				if ((Object)(object)playerPet != (Object)null)
				{
					PetRetrieve(val, playerPet);
				}
				else
				{
					Debug.Log((object)("No custom AI found for " + ((object)val)?.ToString() + " but they sent a retrieve ball RPC"));
				}
			}
		}

		private static void PetRetrieve(PlayerControllerB player, CustomAI customAI)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Vector3 positionInFrontOfPlayerEyes = Utils.GetPositionInFrontOfPlayerEyes(player);
			PokeballItem pokeballItem = customAI.RetrieveInBall(positionInFrontOfPlayerEyes);
			Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
			bool flag = ((Bounds)(ref bounds)).Contains(positionInFrontOfPlayerEyes);
			player.SetItemInElevator(flag, flag, (GrabbableObject)(object)pokeballItem);
			((Component)pokeballItem).transform.SetParent(StartOfRound.Instance.elevatorTransform, true);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerControllerB __instance)
		{
			if (__instance == null || !__instance.isPlayerControlled || !((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if (InputControlExtensions.IsPressed((InputControl)(object)Keyboard.current[(Key)30], 0f))
			{
				Debug.Log((object)"P pressed");
				CustomAI playerPet = Utils.GetPlayerPet(__instance);
				if ((Object)(object)playerPet != (Object)null)
				{
					if (((NetworkBehaviour)__instance).NetworkManager.IsServer || ((NetworkBehaviour)__instance).NetworkManager.IsHost)
					{
						PetRetrieve(__instance, playerPet);
					}
					else
					{
						SendPetRetrievePacket(__instance);
					}
				}
			}
			else
			{
				if (!((Object)(object)StartOfRound.Instance.testRoom != (Object)null) || (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer))
				{
					return;
				}
				bool flag = InputControlExtensions.IsPressed((InputControl)(object)Keyboard.current[(Key)29], 0f);
				if (flag && !lastTestPressed)
				{
					lastTestPressed = true;
					GrabbableObject val = __instance.ItemSlots[__instance.currentItemSlot];
					if (!((Object)(object)val != (Object)null))
					{
						return;
					}
					PokeballItem component = ((Component)val).GetComponent<PokeballItem>();
					if ((Object)(object)component != (Object)null)
					{
						EnemyType val2 = Resources.FindObjectsOfTypeAll<EnemyType>().First((EnemyType enemyType) => ((Object)enemyType).name == testEnemyTypes[currentTestEnemyTypeIndex]);
						component.SetCaughtEnemy(val2);
						HUDManager.Instance.AddTextMessageClientRpc("Caught enemy: " + ((Object)val2).name);
						currentTestEnemyTypeIndex++;
						if (currentTestEnemyTypeIndex >= testEnemyTypes.Length)
						{
							currentTestEnemyTypeIndex = 0;
						}
					}
				}
				else if (!flag)
				{
					lastTestPressed = false;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")]
		[HarmonyPostfix]
		private static void TeleportPlayer(PlayerControllerB __instance, Vector3 pos)
		{
			//IL_0015: 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)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			CustomAI playerPet = Utils.GetPlayerPet(__instance);
			if ((Object)(object)playerPet != (Object)null)
			{
				Vector3 val = pos;
				Debug.Log((object)("Teleport CustomAI to " + ((object)(Vector3)(ref val)).ToString()));
				((Behaviour)((EnemyAI)playerPet).agent).enabled = false;
				((Component)playerPet).transform.position = pos;
				((Behaviour)((EnemyAI)playerPet).agent).enabled = true;
				((EnemyAI)playerPet).serverPosition = pos;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		[HarmonyPostfix]
		private static void KillPlayerPostfix(PlayerControllerB __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			CustomAI playerPet = Utils.GetPlayerPet(__instance);
			if ((Object)(object)playerPet != (Object)null)
			{
				Debug.Log((object)"Owner is dead, go back to the ball");
				playerPet.RetrieveInBall(((Component)playerPet).transform.position);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPostfix]
		private static void DamagePlayerPostfix(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force)
		{
			CustomAI playerPet = Utils.GetPlayerPet(__instance);
			if ((Object)(object)playerPet != (Object)null && ((object)playerPet).GetType() == typeof(RedLocustBeesCustomAI))
			{
				EnemyAI mostProbableAttackerEnemy = Utils.GetMostProbableAttackerEnemy(__instance, new StackTrace());
				if ((Object)(object)mostProbableAttackerEnemy != (Object)null)
				{
					((RedLocustBeesCustomAI)playerPet).AttackEnemyAI(mostProbableAttackerEnemy);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
		[HarmonyPostfix]
		private static void DamagePlayerFromOtherClientServerRpcPostFix(PlayerControllerB __instance, Vector3 hitDirection, int playerWhoHit)
		{
			//IL_0081: 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)
			if ((int)__instance.playerClientId == playerWhoHit)
			{
				return;
			}
			CustomAI playerPet = Utils.GetPlayerPet(__instance);
			if ((Object)(object)playerPet != (Object)null && ((object)playerPet).GetType() == typeof(RedLocustBeesCustomAI) && (((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost))
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerWhoHit];
				Debug.Log((object)("Player " + val.playerUsername + " hit " + __instance.playerUsername));
				if ((Object)(object)__instance != (Object)(object)val && Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position) < 5f)
				{
					((RedLocustBeesCustomAI)playerPet).AttackPlayer(val);
				}
			}
		}
	}
	public class RedLocustBeesPatch
	{
		public static Dictionary<int, DateTime> AngryUntil = new Dictionary<int, DateTime>();

		[HarmonyPatch(typeof(RedLocustBees), "IsHivePlacedAndInLOS")]
		[HarmonyPrefix]
		private static bool IsHivePlacedAndInLOSPrefix(RedLocustBees __instance, ref bool __result)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (AngryUntil.TryGetValue(instanceID, out var value))
			{
				if (value < DateTime.Now)
				{
					AngryUntil.Remove(instanceID);
					return true;
				}
				__result = false;
				Debug.Log((object)"ANGRY BEES!!!!");
				return false;
			}
			return true;
		}
	}
	public class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
		[HarmonyPrefix]
		private static void OnShipHasLeftPreFix(StartOfRound __instance)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			CustomAI[] array = Object.FindObjectsOfType<CustomAI>();
			Debug.Log((object)$"End of game, processing {array.Length} custom AIs");
			CustomAI[] array2 = array;
			foreach (CustomAI customAI in array2)
			{
				PlayerControllerB ownerPlayer = customAI.ownerPlayer;
				Debug.Log((object)("Player is in hangar ship room: " + ownerPlayer.isInHangarShipRoom));
				if (ownerPlayer.isInHangarShipRoom)
				{
					PokeballItem pokeballItem = customAI.RetrieveInBall(((Component)ownerPlayer).transform.position);
					ownerPlayer.SetItemInElevator(true, true, (GrabbableObject)(object)pokeballItem);
					((Component)pokeballItem).transform.SetParent(__instance.elevatorTransform, true);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
		[HarmonyPrefix]
		private static void OnPlayerDCPrefix(StartOfRound __instance, int playerObjectNumber, ulong clientId)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"Client with ID {clientId} disconnected. Starting to delete its pets");
			CustomAI[] array = Object.FindObjectsOfType<CustomAI>();
			CustomAI[] array2 = array;
			foreach (CustomAI customAI in array2)
			{
				if (customAI.ownClientId == clientId)
				{
					Debug.Log((object)("Found " + ((Object)((EnemyAI)customAI).enemyType).name + ", retrieving in ball"));
					customAI.RetrieveInBall(((Component)customAI).transform.position);
				}
			}
		}
	}
}
namespace LethalMon.Items
{
	public enum BallType
	{
		POKEBALL,
		GREAT_BALL,
		ULTRA_BALL,
		MASTER_BALL
	}
	public class Greatball : PokeballItem
	{
		public Greatball()
			: base(BallType.GREAT_BALL, 1)
		{
		}
	}
	public class Masterball : PokeballItem
	{
		public Masterball()
			: base(BallType.MASTER_BALL, 3)
		{
		}
	}
	public class Pokeball : PokeballItem
	{
		public Pokeball()
			: base(BallType.POKEBALL, 0)
		{
		}
	}
	public abstract class PokeballItem : ThrowableItem
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static RpcReceiveHandler <0>____rpc_handler_1173420115;

			public static RpcReceiveHandler <1>____rpc_handler_291057008;

			public static RpcReceiveHandler <2>____rpc_handler_626404720;
		}

		private EnemyAI? enemyAI;

		private EnemyType? enemyType;

		private global::LethalMon.CatchableEnemy.CatchableEnemy? catchableEnemy;

		private bool captureSuccess;

		private int captureRounds = 1;

		private int currentCaptureRound;

		private bool enemyCaptured;

		private int captureStrength;

		private BallType ballType;

		public PokeballItem(BallType ballType, int captureStrength)
		{
			this.ballType = ballType;
			this.captureStrength = captureStrength;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (StartOfRound.Instance.shipHasLanded || (Object)(object)StartOfRound.Instance.testRoom != (Object)null)
			{
				base.ItemActivate(used, buttonDown);
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			Debug.Log((object)("Collided with " + ((Object)((Component)other).gameObject).name));
			Debug.Log((object)("Pokeball has an enemy captured: " + enemyCaptured));
			Debug.Log((object)("Pokeball was thrown by: " + (object)playerThrownBy));
			if ((!((NetworkBehaviour)this).NetworkManager.IsHost && !((NetworkBehaviour)this).NetworkManager.IsServer) || enemyCaptured || !((Object)(object)playerThrownBy != (Object)null))
			{
				return;
			}
			EnemyAI componentInParent = ((Component)other).GetComponentInParent<EnemyAI>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				if (Data.CatchableMonsters.TryGetValue(((Object)componentInParent.enemyType).name, out global::LethalMon.CatchableEnemy.CatchableEnemy value))
				{
					CaptureEnemy(componentInParent, value);
				}
				else
				{
					Debug.Log((object)(((Object)componentInParent.enemyType).name + " is not catchable"));
				}
			}
		}

		internal new static void InitializeRPCS()
		{
			//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_0025: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_006e: 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_0079: Expected O, but got Unknown
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table = NetworkManager.__rpc_func_table;
			object obj = <>O.<0>____rpc_handler_1173420115;
			if (obj == null)
			{
				RpcReceiveHandler val = __rpc_handler_1173420115;
				<>O.<0>____rpc_handler_1173420115 = val;
				obj = (object)val;
			}
			_rpc_func_table.Add(1173420115u, (RpcReceiveHandler)obj);
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table2 = NetworkManager.__rpc_func_table;
			object obj2 = <>O.<1>____rpc_handler_291057008;
			if (obj2 == null)
			{
				RpcReceiveHandler val2 = __rpc_handler_291057008;
				<>O.<1>____rpc_handler_291057008 = val2;
				obj2 = (object)val2;
			}
			_rpc_func_table2.Add(291057008u, (RpcReceiveHandler)obj2);
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table3 = NetworkManager.__rpc_func_table;
			object obj3 = <>O.<2>____rpc_handler_626404720;
			if (obj3 == null)
			{
				RpcReceiveHandler val3 = __rpc_handler_626404720;
				<>O.<2>____rpc_handler_626404720 = val3;
				obj3 = (object)val3;
			}
			_rpc_func_table3.Add(626404720u, (RpcReceiveHandler)obj3);
		}

		public void SendPlayCaptureAnimationPacket(NetworkObjectReference enemy, int roundsNumber, bool catchSuccess)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1173420115u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref roundsNumber, default(ForPrimitives));
			int num = (catchSuccess ? 1 : 0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref num, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1173420115u, val, (RpcDelivery)0);
			Debug.Log((object)"Play capture animation client rpc send finished");
		}

		[ClientRpc]
		public void PlayCaptureAnimationClientRpc(NetworkObjectReference enemy, int roundsNumber, bool catchSuccess)
		{
			Debug.Log((object)"Play capture animation client rpc received");
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref enemy)).TryGet(ref val, (NetworkManager)null))
			{
				enemyAI = ((Component)val).gameObject.GetComponent<EnemyAI>();
				enemyType = enemyAI.enemyType;
				captureSuccess = catchSuccess;
				captureRounds = roundsNumber;
				currentCaptureRound = 0;
				PlayCaptureAnimation();
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Capture animation RPC)"));
			}
		}

		public void PlayCaptureAnimation()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).targetFloorPosition = ((Component)this).transform.localPosition;
			currentCaptureRound = 0;
			((GrabbableObject)this).grabbable = false;
			((GrabbableObject)this).grabbableToEnemies = false;
			((Component)enemyAI).gameObject.SetActive(false);
			PlayCaptureAnimationAnimator();
		}

		public void PlayCaptureAnimationAnimator()
		{
			Animator component = ((Component)this).GetComponent<Animator>();
			component.Play("Base Layer.Capture", 0);
		}

		private void CaptureEnemy(EnemyAI enemyAI, global::LethalMon.CatchableEnemy.CatchableEnemy catchable)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Start to capture " + ((Object)enemyAI).name));
			playerThrownBy = null;
			catchableEnemy = catchable;
			this.enemyAI = enemyAI;
			enemyType = enemyAI.enemyType;
			double captureProbability = catchable.GetCaptureProbability(captureStrength);
			captureSuccess = Data.Random.NextDouble() < captureProbability;
			captureRounds = (captureSuccess ? 3 : Data.Random.Next(1, 4));
			SendPlayCaptureAnimationPacket(NetworkObjectReference.op_Implicit(((Component)this.enemyAI).GetComponent<NetworkObject>()), captureRounds, captureSuccess);
		}

		public void CaptureEnd(string message)
		{
			Debug.Log((object)"Capture animation end");
			if (currentCaptureRound + 1 < captureRounds)
			{
				Debug.Log((object)"Play the animation again");
				currentCaptureRound++;
				PlayCaptureAnimationAnimator();
			}
			else if (captureSuccess)
			{
				Debug.Log((object)"Capture success");
				SetCaughtEnemy(enemyType);
				((GrabbableObject)this).FallToGround(false);
				playerThrownBy = null;
				((GrabbableObject)this).grabbable = true;
				((GrabbableObject)this).grabbableToEnemies = true;
			}
			else
			{
				Debug.Log((object)"Capture failed");
				if (((NetworkBehaviour)this).NetworkManager.IsServer || ((NetworkBehaviour)this).NetworkManager.IsHost)
				{
					((Component)this).GetComponent<NetworkObject>().Despawn(true);
				}
			}
		}

		public override void OnDestroy()
		{
			if (!captureSuccess && !enemyCaptured && (Object)(object)enemyAI != (Object)null)
			{
				((Component)enemyAI).gameObject.SetActive(true);
				if (((NetworkBehaviour)this).NetworkManager.IsServer || ((NetworkBehaviour)this).NetworkManager.IsHost)
				{
					catchableEnemy.CatchFailBehaviour(enemyAI, playerThrownBy);
				}
			}
			((NetworkBehaviour)this).OnDestroy();
		}

		private static void __rpc_handler_1173420115(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0067: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening)
			{
				Debug.Log((object)("Execute RPC handler " + MethodBase.GetCurrentMethod().Name));
				Traverse val = Traverse.Create((object)target).Field("__rpc_exec_stage");
				NetworkObjectReference enemy = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable));
				int roundsNumber = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref roundsNumber, default(ForPrimitives));
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				val.SetValue((object)(__RpcExecStage)2);
				((PokeballItem)(object)target).PlayCaptureAnimationClientRpc(enemy, roundsNumber, num == 1);
				val.SetValue((object)(__RpcExecStage)0);
			}
		}

		public void SendReplaceWithCustomAiPacket(NetworkObjectReference networkObjectReference, string customAiName, ulong ownerClientId)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(291057008u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe(customAiName, false);
			((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref ownerClientId, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 291057008u, val, (RpcDelivery)0);
			Debug.Log((object)"ReplaceWithCustomAi client rpc send finished");
		}

		[ClientRpc]
		public void ReplaceWithCustomAiClientRpc(NetworkObjectReference networkObjectReference, string customAiName, ulong ownerClientId)
		{
			Debug.Log((object)"ReplaceWithCustomAi client rpc received");
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref val, (NetworkManager)null))
			{
				EnemyAI component = ((Component)val).GetComponent<EnemyAI>();
				if (Data.CatchableMonsters.TryGetValue(customAiName, out global::LethalMon.CatchableEnemy.CatchableEnemy value))
				{
					CustomAI customAI = value.AddAiComponent(((Component)val).gameObject);
					((List<NetworkBehaviour>)((object)val).GetType().GetField("m_ChildNetworkBehaviours", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val)).Add((NetworkBehaviour)(object)customAI);
					CopyProperties(component, customAI);
					customAI.CopyProperties(component);
					customAI.ownClientId = ownerClientId;
					((Behaviour)component).enabled = false;
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				else
				{
					Debug.Log((object)"Custom AI name not found (maybe mod version mismatch)");
				}
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Capture animation RPC)"));
			}
		}

		private static void __rpc_handler_291057008(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening && !networkManager.IsServer && !networkManager.IsHost)
			{
				Debug.Log((object)("Execute RPC handler " + MethodBase.GetCurrentMethod().Name));
				NetworkObjectReference networkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				string customAiName = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref customAiName, false);
				ulong ownerClientId = default(ulong);
				((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref ownerClientId, default(ForPrimitives));
				((PokeballItem)(object)target).ReplaceWithCustomAiClientRpc(networkObjectReference, customAiName, ownerClientId);
			}
		}

		public void SyncContentPacket(NetworkObjectReference networkObjectReference, string enemyTypeName)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(626404720u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe(enemyTypeName, false);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 626404720u, val, (RpcDelivery)0);
			Debug.Log((object)"SyncContentPacket client rpc send finished");
		}

		[ClientRpc]
		public void SyncContentClientRpc(NetworkObjectReference networkObjectReference, string enemyTypeName)
		{
			string enemyTypeName2 = enemyTypeName;
			Debug.Log((object)"SyncContentPacket client rpc received");
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref val, (NetworkManager)null))
			{
				PokeballItem component = ((Component)val).GetComponent<PokeballItem>();
				EnemyType caughtEnemy = Resources.FindObjectsOfTypeAll<EnemyType>().First((EnemyType type) => ((Object)type).name == enemyTypeName2);
				component.SetCaughtEnemy(caughtEnemy);
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (SyncContentPacket RPC)"));
			}
		}

		private static void __rpc_handler_626404720(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening && !networkManager.IsServer && !networkManager.IsHost)
			{
				Debug.Log((object)("Execute RPC handler " + MethodBase.GetCurrentMethod().Name));
				NetworkObjectReference networkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				string enemyTypeName = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref enemyTypeName, false);
				((PokeballItem)(object)target).SyncContentClientRpc(networkObjectReference, enemyTypeName);
			}
		}

		public override void TouchGround()
		{
			//IL_0067: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Touch ground");
			if (((NetworkBehaviour)this).IsHost && (Object)(object)playerThrownBy != (Object)null && enemyCaptured)
			{
				if ((Object)(object)Utils.GetPlayerPet(playerThrownBy) != (Object)null)
				{
					HUDManager.Instance.AddTextMessageClientRpc("You already have a monster out!");
					return;
				}
				EnemyType val = enemyType;
				GameObject val2 = Object.Instantiate<GameObject>(val.enemyPrefab, ((Component)this).transform.position, Quaternion.Euler(new Vector3(0f, 0f, 0f)));
				EnemyAI component = val2.GetComponent<EnemyAI>();
				CustomAI customAI = catchableEnemy.AddAiComponent(val2);
				CopyProperties(component, customAI);
				customAI.CopyProperties(component);
				customAI.ownerPlayer = playerThrownBy;
				customAI.ownClientId = playerThrownBy.playerClientId;
				customAI.ballType = ballType;
				customAI.ballValue = ((GrabbableObject)this).scrapValue;
				customAI.scrapPersistedThroughRounds = ((GrabbableObject)this).scrapPersistedThroughRounds;
				customAI.alreadyCollectedThisRound = RoundManager.Instance.scrapCollectedThisRound.Contains((GrabbableObject)(object)this);
				((Behaviour)component).enabled = false;
				val2.GetComponentInChildren<NetworkObject>().Spawn(true);
				SendReplaceWithCustomAiPacket(NetworkObjectReference.op_Implicit(val2.GetComponent<NetworkObject>()), ((Object)enemyType).name, customAI.ownClientId);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public static void CopyProperties(object source, object destination)
		{
			if (source == null || destination == null)
			{
				throw new Exception("Source or/and Destination Objects are null");
			}
			Type type = destination.GetType();
			Type type2 = source.GetType();
			PropertyInfo[] properties = type2.GetProperties();
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				if (propertyInfo.CanRead)
				{
					PropertyInfo property = type.GetProperty(propertyInfo.Name);
					if (!(property == null) && property.CanWrite && (!(property.GetSetMethod(nonPublic: true) != null) || !property.GetSetMethod(nonPublic: true).IsPrivate) && (!(property.GetSetMethod() != null) || (property.GetSetMethod().Attributes & MethodAttributes.Static) == 0) && property.PropertyType.IsAssignableFrom(propertyInfo.PropertyType))
					{
						property.SetValue(destination, propertyInfo.GetValue(source, null), null);
					}
				}
			}
		}

		private void ChangeName()
		{
			string name = GetName();
			((Component)this).GetComponentInChildren<ScanNodeProperties>().headerText = name;
		}

		private string GetName()
		{
			return ((GrabbableObject)this).itemProperties.itemName + " (" + catchableEnemy.DisplayName + ")";
		}

		public override void SetControlTipsForItem()
		{
			string[] toolTips = ((GrabbableObject)this).itemProperties.toolTips;
			if (toolTips.Length < 1)
			{
				Debug.LogError((object)"Pokeball control tips array length is too short to set tips!");
				return;
			}
			if (enemyCaptured && (Object)(object)enemyType != (Object)null)
			{
				toolTips[0] = "Enemy captured: " + ((Object)enemyType).name;
			}
			else
			{
				toolTips[0] = "";
			}
			HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, ((GrabbableObject)this).itemProperties);
		}

		public void SetCaughtEnemy(EnemyType enemyType)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			this.enemyType = enemyType;
			catchableEnemy = Data.CatchableMonsters[((Object)this.enemyType).name];
			enemyCaptured = true;
			ChangeName();
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				SyncContentPacket(NetworkObjectReference.op_Implicit(((Component)this).GetComponent<NetworkObject>()), ((Object)this.enemyType).name);
			}
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			if (!enemyCaptured || catchableEnemy == null)
			{
				return -1;
			}
			return catchableEnemy.Id;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			if (Data.CatchableMonsters.Count<KeyValuePair<string, global::LethalMon.CatchableEnemy.CatchableEnemy>>((KeyValuePair<string, global::LethalMon.CatchableEnemy.CatchableEnemy> entry) => entry.Value.Id == saveData) != 0)
			{
				KeyValuePair<string, global::LethalMon.CatchableEnemy.CatchableEnemy> catchable = Data.CatchableMonsters.First<KeyValuePair<string, global::LethalMon.CatchableEnemy.CatchableEnemy>>((KeyValuePair<string, global::LethalMon.CatchableEnemy.CatchableEnemy> entry) => entry.Value.Id == saveData);
				EnemyType caughtEnemy = Resources.FindObjectsOfTypeAll<EnemyType>().First((EnemyType type) => ((Object)type).name == catchable.Key);
				SetCaughtEnemy(caughtEnemy);
			}
		}
	}
	public class Ultraball : PokeballItem
	{
		public Ultraball()
			: base(BallType.ULTRA_BALL, 2)
		{
		}
	}
}
namespace LethalMon.CatchableEnemy
{
	public abstract class CatchableEnemy
	{
		private readonly int _catchDifficulty;

		public string DisplayName { get; private set; }

		public int Id { get; }

		protected CatchableEnemy(int id, string displayName, int catchDifficulty)
		{
			Id = id;
			DisplayName = displayName;
			_catchDifficulty = catchDifficulty;
		}

		public double GetCaptureProbability(int ballStrength)
		{
			if (ballStrength < 0 || ballStrength >= Data.CaptureProbabilities.Length || _catchDifficulty < 0 || _catchDifficulty >= Data.CaptureProbabilities[0].Length)
			{
				return 0.0;
			}
			return Data.CaptureProbabilities[ballStrength][_catchDifficulty];
		}

		public abstract void CatchFailBehaviour(EnemyAI enemyAI, PlayerControllerB player);

		public abstract CustomAI AddAiComponent(GameObject gameObject);
	}
	public class CatchableFlowerman : CatchableEnemy
	{
		public CatchableFlowerman()
			: base(1, "Bracken", 9)
		{
		}

		public override void CatchFailBehaviour(EnemyAI enemyAI, PlayerControllerB player)
		{
			((FlowermanAI)((enemyAI is FlowermanAI) ? enemyAI : null)).AddToAngerMeter(float.MaxValue);
		}

		public override CustomAI AddAiComponent(GameObject gameObject)
		{
			return gameObject.AddComponent<FlowermanCustomAI>();
		}
	}
	public class CatchableHoarderBug : CatchableEnemy
	{
		public CatchableHoarderBug()
			: base(2, "Hoarding Bug", 3)
		{
		}

		public override void CatchFailBehaviour(EnemyAI enemyAI, PlayerControllerB player)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			HoarderBugAI val = (HoarderBugAI)enemyAI;
			val.angryTimer = 10f;
			val.angryAtPlayer = player;
		}

		public override CustomAI AddAiComponent(GameObject gameObject)
		{
			return gameObject.AddComponent<HoarderBugCustomAI>();
		}
	}
	public class CatchableRedLocustBees : CatchableEnemy
	{
		public CatchableRedLocustBees()
			: base(3, "Bees", 4)
		{
		}

		public override void CatchFailBehaviour(EnemyAI enemyAI, PlayerControllerB player)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			RedLocustBees val = (RedLocustBees)enemyAI;
			((EnemyAI)val).SetMovingTowardsTargetPlayer(player);
			((EnemyAI)val).SwitchToBehaviourState(2);
			RedLocustBeesPatch.AngryUntil.Add(((Object)val).GetInstanceID(), DateTime.Now.AddSeconds(10.0));
		}

		public override CustomAI AddAiComponent(GameObject gameObject)
		{
			return gameObject.AddComponent<RedLocustBeesCustomAI>();
		}
	}
}
namespace LethalMon.AI
{
	public class CustomAI : EnemyAI
	{
		public PlayerControllerB ownerPlayer;

		public ulong ownClientId;

		public BallType ballType;

		protected Vector3 previousPosition;

		public int ballValue;

		public bool scrapPersistedThroughRounds;

		public bool alreadyCollectedThisRound;

		private static bool FindRaySphereIntersections(Vector3 rayOrigin, Vector3 rayDirection, Vector3 sphereCenter, float sphereRadius, out Vector3 intersection1, out Vector3 intersection2)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			intersection1 = Vector3.zero;
			intersection2 = Vector3.zero;
			Vector3 val = rayOrigin - sphereCenter;
			float num = Vector3.Dot(rayDirection, rayDirection);
			float num2 = 2f * Vector3.Dot(val, rayDirection);
			float num3 = Vector3.Dot(val, val) - sphereRadius * sphereRadius;
			float num4 = num2 * num2 - 4f * num * num3;
			if (num4 < 0f)
			{
				return false;
			}
			float num5 = Mathf.Sqrt(num4);
			float num6 = (0f - num2 - num5) / (2f * num);
			float num7 = (0f - num2 + num5) / (2f * num);
			intersection1 = rayOrigin + num6 * rayDirection;
			intersection2 = rayOrigin + num7 * rayDirection;
			return true;
		}

		public void FollowOwner()
		{
			//IL_0006: 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)
			//IL_005c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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)
			if (Vector3.Distance(((Component)this).transform.position, ((Component)ownerPlayer).transform.position) > 30f)
			{
				((Behaviour)base.agent).enabled = false;
				((Component)this).transform.position = Utils.GetPositionBehindPlayer(ownerPlayer);
				((Behaviour)base.agent).enabled = true;
				return;
			}
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = ((Component)ownerPlayer).transform.position - ((Component)this).transform.position;
			if (FindRaySphereIntersections(position, ((Vector3)(ref val)).normalized, ((Component)ownerPlayer).transform.position, 8f, out var intersection, out var intersection2))
			{
				float num = Vector3.Distance(((Component)this).transform.position, intersection);
				float num2 = Vector3.Distance(((Component)this).transform.position, intersection2);
				if (num > 4f && num2 > 4f)
				{
					previousPosition = ((Component)this).transform.position;
					((EnemyAI)this).SetDestinationToPosition((num < num2) ? intersection : intersection2, false);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (base.openDoorSpeedMultiplier > 0f)
			{
				Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 0.5f);
				Collider[] array2 = array;
				AnimatedObjectTrigger val2 = default(AnimatedObjectTrigger);
				foreach (Collider val in array2)
				{
					DoorLock componentInParent = ((Component)val).GetComponentInParent<DoorLock>();
					if ((Object)(object)componentInParent != (Object)null && !componentInParent.isDoorOpened && !componentInParent.isLocked)
					{
						Debug.Log((object)"CustomAI opens door");
						if (((Component)componentInParent).gameObject.TryGetComponent<AnimatedObjectTrigger>(ref val2))
						{
							val2.TriggerAnimationNonPlayer(false, true, false);
						}
						componentInParent.OpenDoorAsEnemyServerRpc();
					}
				}
			}
			((EnemyAI)this).DoAIInterval();
		}

		public override void Update()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00e6: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			if (base.stunnedIndefinitely <= 0)
			{
				if (base.stunNormalizedTimer >= 0f)
				{
					base.stunNormalizedTimer -= Time.deltaTime / base.enemyType.stunTimeMultiplier;
				}
				else
				{
					base.stunnedByPlayer = null;
					if (base.postStunInvincibilityTimer >= 0f)
					{
						base.postStunInvincibilityTimer -= Time.deltaTime * 5f;
					}
				}
			}
			if (!base.ventAnimationFinished)
			{
				base.ventAnimationFinished = true;
				if ((Object)(object)base.creatureAnimator != (Object)null)
				{
					base.creatureAnimator.SetBool("inSpawningAnimation", false);
				}
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).SetClientCalculatingAI(false);
				if (!base.inSpecialAnimation)
				{
					((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, base.serverPosition, ref base.tempVelocity, base.syncMovementSpeed);
					((Component)this).transform.eulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, Mathf.LerpAngle(((Component)this).transform.eulerAngles.y, base.targetYRotation, 15f * Time.deltaTime), ((Component)this).transform.eulerAngles.z);
				}
				base.timeSinceSpawn += Time.deltaTime;
				return;
			}
			if (base.isEnemyDead)
			{
				((EnemyAI)this).SetClientCalculatingAI(false);
				return;
			}
			if (!base.inSpecialAnimation)
			{
				((EnemyAI)this).SetClientCalculatingAI(true);
			}
			if (base.movingTowardsTargetPlayer && (Object)(object)base.targetPlayer != (Object)null)
			{
				if (base.setDestinationToPlayerInterval <= 0f)
				{
					base.setDestinationToPlayerInterval = 0.25f;
					base.destination = RoundManager.Instance.GetNavMeshPosition(((Component)base.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1);
					Debug.Log((object)"Set destination to target player A");
				}
				else
				{
					base.destination = new Vector3(((Component)base.targetPlayer).transform.position.x, base.destination.y, ((Component)base.targetPlayer).transform.position.z);
					Debug.Log((object)"Set destination to target player B");
					base.setDestinationToPlayerInterval -= Time.deltaTime;
				}
				if (base.addPlayerVelocityToDestination > 0f)
				{
					if ((Object)(object)base.targetPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						base.destination += Vector3.Normalize(base.targetPlayer.thisController.velocity * 100f) * base.addPlayerVelocityToDestination;
					}
					else if (base.targetPlayer.timeSincePlayerMoving < 0.25f)
					{
						base.destination += Vector3.Normalize((base.targetPlayer.serverPlayerPosition - base.targetPlayer.oldPlayerPosition) * 100f) * base.addPlayerVelocityToDestination;
					}
				}
			}
			if (base.inSpecialAnimation)
			{
				return;
			}
			if (base.updateDestinationInterval >= 0f)
			{
				base.updateDestinationInterval -= Time.deltaTime;
			}
			else
			{
				((EnemyAI)this).DoAIInterval();
				base.updateDestinationInterval = base.AIIntervalTime;
			}
			if (Mathf.Abs(base.previousYRotation - ((Component)this).transform.eulerAngles.y) > 6f)
			{
				base.previousYRotation = ((Component)this).transform.eulerAngles.y;
				base.targetYRotation = base.previousYRotation;
				if (((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).UpdateEnemyRotationClientRpc((short)base.previousYRotation);
				}
				else
				{
					((EnemyAI)this).UpdateEnemyRotationServerRpc((short)base.previousYRotation);
				}
			}
		}

		public override void Start()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				base.agent = ((Component)this).gameObject.GetComponentInChildren<NavMeshAgent>();
				base.skinnedMeshRenderers = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
				base.meshRenderers = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>();
				base.creatureAnimator = ((Component)this).gameObject.GetComponentInChildren<Animator>();
				base.thisNetworkObject = ((Component)this).gameObject.GetComponentInChildren<NetworkObject>();
				base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
				base.path1 = new NavMeshPath();
				base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier;
				base.serverPosition = ((Component)this).transform.position;
				previousPosition = ((Component)this).transform.position;
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).SyncPositionToClients();
				}
				else
				{
					((EnemyAI)this).SetClientCalculatingAI(false);
				}
				if ((Object)(object)base.creatureAnimator != (Object)null)
				{
					base.creatureAnimator.SetBool("inSpawningAnimation", false);
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error when initializing enemy variables for {((Object)((Component)this).gameObject).name} : {arg}");
			}
		}

		public virtual PokeballItem RetrieveInBall(Vector3 position)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (GameObject)(ballType switch
			{
				BallType.GREAT_BALL => Object.Instantiate<GameObject>(LethalMon.greatBallSpawnPrefab, position, Quaternion.Euler(new Vector3(0f, 0f, 0f))), 
				BallType.ULTRA_BALL => Object.Instantiate<GameObject>(LethalMon.ultraBallSpawnPrefab, position, Quaternion.Euler(new Vector3(0f, 0f, 0f))), 
				BallType.MASTER_BALL => Object.Instantiate<GameObject>(LethalMon.masterBallSpawnPrefab, position, Quaternion.Euler(new Vector3(0f, 0f, 0f))), 
				_ => Object.Instantiate<GameObject>(LethalMon.pokeballSpawnPrefab, position, Quaternion.Euler(new Vector3(0f, 0f, 0f))), 
			});
			PokeballItem component = val.GetComponent<PokeballItem>();
			((GrabbableObject)component).fallTime = 0f;
			((GrabbableObject)component).scrapPersistedThroughRounds = scrapPersistedThroughRounds || alreadyCollectedThisRound;
			((GrabbableObject)component).SetScrapValue(ballValue);
			val.GetComponent<NetworkObject>().Spawn(false);
			component.SetCaughtEnemy(base.enemyType);
			((GrabbableObject)component).FallToGround(false);
			((Component)this).GetComponent<NetworkObject>().Despawn(true);
			return component;
		}

		public virtual void CopyProperties(EnemyAI enemyAI)
		{
			base.enemyType = enemyAI.enemyType;
			base.creatureSFX = enemyAI.creatureSFX;
			base.creatureVoice = enemyAI.creatureVoice;
		}
	}
	public class FlowermanCustomAI : CustomAI
	{
		private Vector3 agentLocalVelocity;

		public Transform animationContainer;

		private float velX;

		private float velZ;

		public override void Start()
		{
			base.Start();
			((EnemyAI)this).creatureAnimator.SetBool("sneak", true);
			((EnemyAI)this).creatureAnimator.Play("Base Layer.CreepForward");
		}

		public override void DoAIInterval()
		{
			base.DoAIInterval();
			FollowOwner();
		}

		public override void Update()
		{
			base.Update();
			CalculateAnimationDirection();
		}

		private void CalculateAnimationDirection(float maxSpeed = 1f)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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)
			agentLocalVelocity = animationContainer.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
			velX = Mathf.Lerp(velX, agentLocalVelocity.x, 10f * Time.deltaTime);
			((EnemyAI)this).creatureAnimator.SetFloat("VelocityX", Mathf.Clamp(velX, 0f - maxSpeed, maxSpeed));
			velZ = Mathf.Lerp(velZ, 0f - agentLocalVelocity.y, 10f * Time.deltaTime);
			((EnemyAI)this).creatureAnimator.SetFloat("VelocityZ", Mathf.Clamp(velZ, 0f - maxSpeed, maxSpeed));
			Animator creatureAnimator = ((EnemyAI)this).creatureAnimator;
			Vector3 val = Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f);
			creatureAnimator.SetFloat("speedMultiplier", ((Vector3)(ref val)).sqrMagnitude / (Time.deltaTime / 4f));
			previousPosition = ((Component)this).transform.position;
		}

		public override void CopyProperties(EnemyAI enemyAI)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			base.CopyProperties(enemyAI);
			animationContainer = ((FlowermanAI)enemyAI).animationContainer;
		}
	}
	public class HoarderBugCustomAI : CustomAI
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static RpcReceiveHandler <0>____rpc_handler_1120862648;

			public static RpcReceiveHandler <1>____rpc_handler_1650981814;

			public static RpcReceiveHandler <2>____rpc_handler_2688306109;

			public static RpcReceiveHandler <3>____rpc_handler_713145915;
		}

		private Vector3 agentLocalVelocity;

		public Transform animationContainer;

		private float velX;

		private float velZ;

		public GrabbableObject targetItem;

		public HoarderBugItem heldItem;

		private bool sendingGrabOrDropRPC;

		public Transform grabTarget;

		public const int searchTimer = 10;

		public int currentTimer;

		public AudioClip bugFlySFX;

		public AudioClip[] chitterSFX;

		public override void Start()
		{
			base.Start();
			((EnemyAI)this).creatureAnimator.Play("Base Layer.Walking");
		}

		public override void DoAIInterval()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			base.DoAIInterval();
			if (!GrabTargetItemIfClose())
			{
				if (heldItem != null)
				{
					if (Vector3.Distance(((Component)this).transform.position, ((Component)ownerPlayer).transform.position) < 6f)
					{
						Debug.Log((object)"HoarderBugAI drops held item to the owner");
						DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>());
					}
					else
					{
						Debug.Log((object)"HoarderBugAI move held item to the owner");
						((EnemyAI)this).SetMovingTowardsTargetPlayer(ownerPlayer);
					}
					return;
				}
				if ((Object)(object)targetItem != (Object)null)
				{
					Debug.Log((object)"HoarderBugAI found an object and move towards it");
					SetGoTowardsTargetObject(((Component)targetItem).gameObject);
					return;
				}
				currentTimer++;
				if (currentTimer >= 10)
				{
					Debug.Log((object)"HoarderBugAI searches for items");
					currentTimer = 0;
					Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 15f);
					Debug.Log((object)("HoarderBugAI found " + array.Length + " colliders"));
					Collider[] array2 = array;
					RaycastHit val2 = default(RaycastHit);
					foreach (Collider val in array2)
					{
						GrabbableObject componentInParent = ((Component)val).GetComponentInParent<GrabbableObject>();
						if ((Object)(object)componentInParent != (Object)null)
						{
							Debug.Log((object)("HoarderBugAI grabbable item (isInShipRoom: " + componentInParent.isInShipRoom + ", isHeld: " + componentInParent.isHeld + "): " + ((Object)componentInParent).name));
							if (componentInParent != null && !componentInParent.isInShipRoom && !componentInParent.isHeld && Vector3.Distance(((Component)componentInParent).transform.position, ((Component)ownerPlayer).transform.position) > 8f && !Physics.Linecast(((Component)this).transform.position, ((Component)componentInParent).transform.position, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
							{
								Debug.Log((object)("HoarderBugAI found item: " + ((Object)componentInParent).name));
								targetItem = componentInParent;
								return;
							}
						}
					}
				}
				Debug.Log((object)"HoarderBugAI follows the owner");
				FollowOwner();
			}
			else
			{
				Debug.Log((object)"HoarderBugAI grabbed close item");
			}
		}

		public override void Update()
		{
			base.Update();
			CalculateAnimationDirection();
		}

		private void CalculateAnimationDirection(float maxSpeed = 1f)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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)
			agentLocalVelocity = animationContainer.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
			velX = Mathf.Lerp(velX, agentLocalVelocity.x, 10f * Time.deltaTime);
			((EnemyAI)this).creatureAnimator.SetFloat("VelocityX", Mathf.Clamp(velX, 0f - maxSpeed, maxSpeed));
			velZ = Mathf.Lerp(velZ, 0f - agentLocalVelocity.y, 10f * Time.deltaTime);
			((EnemyAI)this).creatureAnimator.SetFloat("VelocityZ", Mathf.Clamp(velZ, 0f - maxSpeed, maxSpeed));
			Animator creatureAnimator = ((EnemyAI)this).creatureAnimator;
			Vector3 val = Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f);
			creatureAnimator.SetFloat("speedMultiplier", ((Vector3)(ref val)).sqrMagnitude / (Time.deltaTime / 4f));
			previousPosition = ((Component)this).transform.position;
		}

		public override void CopyProperties(EnemyAI enemyAI)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			base.CopyProperties(enemyAI);
			HoarderBugAI val = (HoarderBugAI)enemyAI;
			animationContainer = val.animationContainer;
			grabTarget = val.grabTarget;
			bugFlySFX = val.bugFlySFX;
			chitterSFX = val.chitterSFX;
		}

		public override PokeballItem RetrieveInBall(Vector3 position)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (heldItem != null)
			{
				DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>());
			}
			return base.RetrieveInBall(position);
		}

		private void SetGoTowardsTargetObject(GameObject foundObject)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)this).SetDestinationToPosition(foundObject.transform.position, true))
			{
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Setting target object and going towards it."));
				targetItem = foundObject.GetComponent<GrabbableObject>();
			}
			else
			{
				targetItem = null;
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": i found an object but cannot reach it (or it has been taken by another bug): " + ((Object)foundObject).name));
			}
		}

		private bool GrabTargetItemIfClose()
		{
			//IL_001c: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetItem != (Object)null && heldItem == null && Vector3.Distance(((Component)this).transform.position, ((Component)targetItem).transform.position) < 0.75f)
			{
				NetworkObject component = ((Component)targetItem).GetComponent<NetworkObject>();
				GrabItem(component);
				sendingGrabOrDropRPC = true;
				GrabItemServerRpc(NetworkObjectReference.op_Implicit(component));
				return true;
			}
			return false;
		}

		private void GrabItem(NetworkObject item)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b3: Expected O, but got Unknown
			if (sendingGrabOrDropRPC)
			{
				sendingGrabOrDropRPC = false;
				return;
			}
			if (heldItem != null)
			{
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Trying to grab another item (" + ((Object)((Component)item).gameObject).name + ") while hands are already full with item (" + ((Object)((Component)heldItem.itemGrabbableObject).gameObject).name + "). Dropping the currently held one."));
				DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>());
			}
			targetItem = null;
			GrabbableObject component = ((Component)item).gameObject.GetComponent<GrabbableObject>();
			heldItem = new HoarderBugItem(component, (HoarderBugItemStatus)0, default(Vector3));
			component.parentObject = grabTarget;
			component.hasHitGround = false;
			component.GrabItemFromEnemy((EnemyAI)(object)this);
			component.EnablePhysics(false);
			((EnemyAI)this).creatureAnimator.SetBool("Chase", true);
			((EnemyAI)this).creatureSFX.clip = bugFlySFX;
			((EnemyAI)this).creatureSFX.Play();
			RoundManager.PlayRandomClip(((EnemyAI)this).creatureVoice, chitterSFX, true, 1f, 0, 1000);
		}

		private void DropItem(NetworkObject dropItemNetworkObject, Vector3 targetFloorPosition)
		{
			//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_008b: 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)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (sendingGrabOrDropRPC)
			{
				sendingGrabOrDropRPC = false;
				return;
			}
			if (heldItem == null)
			{
				Debug.LogError((object)"Hoarder bug: my held item is null when attempting to drop it!!");
				return;
			}
			GrabbableObject itemGrabbableObject = heldItem.itemGrabbableObject;
			itemGrabbableObject.parentObject = null;
			((Component)itemGrabbableObject).transform.SetParent(StartOfRound.Instance.propsContainer, true);
			itemGrabbableObject.EnablePhysics(true);
			itemGrabbableObject.fallTime = 0f;
			itemGrabbableObject.startFallingPosition = ((Component)itemGrabbableObject).transform.parent.InverseTransformPoint(((Component)itemGrabbableObject).transform.position);
			itemGrabbableObject.targetFloorPosition = ((Component)itemGrabbableObject).transform.parent.InverseTransformPoint(targetFloorPosition);
			itemGrabbableObject.floorYRot = -1;
			itemGrabbableObject.DiscardItemFromEnemy();
			heldItem = null;
			((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
			((EnemyAI)this).creatureAnimator.SetBool("Chase", false);
			((EnemyAI)this).creatureSFX.Stop();
			RoundManager.PlayRandomClip(((EnemyAI)this).creatureVoice, chitterSFX, true, 1f, 0, 1000);
		}

		private void DropItemAndCallDropRPC(NetworkObject dropItemNetworkObject)
		{
			//IL_0012: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_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)
			Vector3 targetFloorPosition = RoundManager.Instance.RandomlyOffsetPosition(heldItem.itemGrabbableObject.GetItemFloorPosition(default(Vector3)), 1.2f, 0.4f);
			DropItem(dropItemNetworkObject, targetFloorPosition);
			sendingGrabOrDropRPC = true;
			DropItemServerRpc(NetworkObjectReference.op_Implicit(dropItemNetworkObject), targetFloorPosition);
		}

		internal static void InitializeRPCS()
		{
			//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_0025: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_006e: 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_0079: Expected O, but got Unknown
			//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_00a3: Expected O, but got Unknown
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table = NetworkManager.__rpc_func_table;
			object obj = <>O.<0>____rpc_handler_1120862648;
			if (obj == null)
			{
				RpcReceiveHandler val = __rpc_handler_1120862648;
				<>O.<0>____rpc_handler_1120862648 = val;
				obj = (object)val;
			}
			_rpc_func_table.Add(1120862648u, (RpcReceiveHandler)obj);
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table2 = NetworkManager.__rpc_func_table;
			object obj2 = <>O.<1>____rpc_handler_1650981814;
			if (obj2 == null)
			{
				RpcReceiveHandler val2 = __rpc_handler_1650981814;
				<>O.<1>____rpc_handler_1650981814 = val2;
				obj2 = (object)val2;
			}
			_rpc_func_table2.Add(1650981814u, (RpcReceiveHandler)obj2);
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table3 = NetworkManager.__rpc_func_table;
			object obj3 = <>O.<2>____rpc_handler_2688306109;
			if (obj3 == null)
			{
				RpcReceiveHandler val3 = __rpc_handler_2688306109;
				<>O.<2>____rpc_handler_2688306109 = val3;
				obj3 = (object)val3;
			}
			_rpc_func_table3.Add(2688306109u, (RpcReceiveHandler)obj3);
			Dictionary<uint, RpcReceiveHandler> _rpc_func_table4 = NetworkManager.__rpc_func_table;
			object obj4 = <>O.<3>____rpc_handler_713145915;
			if (obj4 == null)
			{
				RpcReceiveHandler val4 = __rpc_handler_713145915;
				<>O.<3>____rpc_handler_713145915 = val4;
				obj4 = (object)val4;
			}
			_rpc_func_table4.Add(713145915u, (RpcReceiveHandler)obj4);
		}

		[ServerRpc]
		public void DropItemServerRpc(NetworkObjectReference objectRef, Vector3 targetFloorPosition)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Invalid comparison between Unknown and I4
			//IL_00a8: 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_0050: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2688306109u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetFloorPosition);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2688306109u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DropItemClientRpc(objectRef, targetFloorPosition);
			}
		}

		[ClientRpc]
		public void DropItemClientRpc(NetworkObjectReference objectRef, Vector3 targetFloorPosition)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_002e: 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_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)
			//IL_0048: 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_0065: Unknown result type (might be due to inva