Decompiled source of Chirpling v2.0.2

Taskyy.Chirpling.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Chirpling.Mono;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreCompany.Cosmetics;
using MoreCompany.Utils;
using Taskyy.Chirpling.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Taskyy.Chirpling")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e38971ed128902249bd1c6f557efd76555a760f2")]
[assembly: AssemblyProduct("Chirpling")]
[assembly: AssemblyTitle("Taskyy.Chirpling")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 Chirpling
{
	internal class AssetLoader
	{
		private static AssetBundle mainBundle;

		private static AssetBundle cosmeticBundle;

		private static List<ChirplingData>? chirplingList;

		public static void Init()
		{
			mainBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Plugin).Namespace.Split(".")[0] + ".Resources.assets"));
			cosmeticBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Plugin).Namespace.Split(".")[0] + ".Resources.cosmetics"));
			chirplingList = LoadChirplingCSV();
			if (chirplingList != null && chirplingList.Count > 0)
			{
				PluginLogger.Log("Loaded " + chirplingList.Count + " names of Chirplings!");
			}
			else
			{
				PluginLogger.LogError("Something went wrong when reading the CSV with Chirpling names!");
			}
			List<Cosmetic> cosmetics = new List<Cosmetic>
			{
				new Cosmetic("tealthecockatielshoulder", "TealCosmeticShoulder", "TealIcon", (CosmeticType)2),
				new Cosmetic("tealthecockatielhead", "TealCosmeticHead", "TealIcon", (CosmeticType)0),
				new Cosmetic("chirpling", "ChirplingCosmeticRight", "ChirplingIcon", (CosmeticType)2)
			};
			LoadCosmetics(cosmetics);
			RegisterScrap(mainBundle, "ThrowableChirpling");
			RegisterScrap(mainBundle, "GroanTubeChirpling");
			RegisterScrap(mainBundle, "BigChirpling");
			TerminalKeyword terminalKeyword = RegisterTerminalNode(mainBundle, "ChirplingBeastiary", "chirpling");
			RegisterEnemy(mainBundle, "EnemyChirpling", terminalKeyword, 55);
		}

		public static TerminalKeyword RegisterTerminalNode(AssetBundle bundle, string str, string keyword, string assetPath = "Assets/Taskyy/ScriptableObject/TerminalNode/")
		{
			TerminalNode val = bundle.LoadAsset<TerminalNode>(assetPath + str + ".asset");
			return TerminalUtils.CreateTerminalKeyword(keyword, false, (CompatibleNoun[])null, val, (TerminalKeyword)null, false);
		}

		public static void RegisterEnemy(AssetBundle bundle, string str, TerminalKeyword terminalKeyword, int rarity = 1000, string assetPath = "Assets/Taskyy/ScriptableObject/Enemy/")
		{
			EnemyType val = bundle.LoadAsset<EnemyType>(assetPath + str + ".asset");
			EnemyAI component = val.enemyPrefab.GetComponent<EnemyAI>();
			component.enemyType = val;
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, rarity, (LevelTypes)(-1), (SpawnType)0, terminalKeyword.specialKeywordResult, terminalKeyword);
		}

		public static void RegisterScrap(AssetBundle bundle, string str, int rarity = 25, string assetPath = "Assets/Taskyy/ScriptableObject/Scrap/")
		{
			//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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Invalid comparison between Unknown and I4
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			//IL_009a: 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)
			//IL_00b2: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Invalid comparison between Unknown and I4
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Invalid comparison between Unknown and I4
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Invalid comparison between Unknown and I4
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			Item val = bundle.LoadAsset<Item>(assetPath + str + ".asset");
			GrabbableObject component = val.spawnPrefab.GetComponent<GrabbableObject>();
			component.grabbable = true;
			component.grabbableToEnemies = true;
			component.isInFactory = true;
			component.itemProperties = val;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			foreach (LevelTypes value in Enum.GetValues(typeof(LevelTypes)))
			{
				if ((int)value >= 4 && (int)value <= 16)
				{
					Items.RegisterScrap(val, Mathf.RoundToInt((float)rarity), value);
				}
				if (((int)value >= 32 && (int)value <= 64) || (int)value == 2048)
				{
					Items.RegisterScrap(val, Mathf.RoundToInt((float)rarity * 1.2f), value);
				}
				if (((int)value >= 128 && (int)value <= 512) || ((int)value >= 4096 && (int)value <= 8192) || (int)value == 1024)
				{
					Items.RegisterScrap(val, Mathf.RoundToInt((float)rarity * 1.4f), value);
				}
			}
			Items.RegisterScrap(val, Mathf.RoundToInt((float)rarity), (LevelTypes)(-1));
		}

		private static List<ChirplingData>? LoadChirplingCSV()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			List<ChirplingData> list = new List<ChirplingData>();
			string name = typeof(AssetLoader).Namespace + ".Resources.custom_chirplings_data.csv";
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
			{
				if (stream == null)
				{
					PluginLogger.LogError("Error trying to load Chirpling CSV!");
					return null;
				}
				using StreamReader streamReader = new StreamReader(stream);
				string text;
				Color value = default(Color);
				while ((text = streamReader.ReadLine()) != null)
				{
					string[] array = text.Split(',');
					if (array.Length != 3)
					{
						PluginLogger.LogError("Chirplings CSV length != 3, SKIPPING! line: " + text);
						continue;
					}
					string name2 = array[0];
					string text2 = array[1].Trim();
					Color? color = null;
					if (!string.IsNullOrEmpty(text2))
					{
						if (!ColorUtility.TryParseHtmlString(text2, ref value))
						{
							PluginLogger.LogError("Chirplings CSV failed to parse color code, SKIPPING! line: " + text);
							continue;
						}
						color = value;
					}
					int materialIndex = 0;
					if (!array[2].Equals(""))
					{
						if (!int.TryParse(array[2], out var result))
						{
							PluginLogger.LogError("Chirplings CSV failed to parse material index, SKIPPING! line: " + text);
							continue;
						}
						materialIndex = result;
					}
					list.Add(new ChirplingData(name2, color, materialIndex));
				}
			}
			return list;
		}

		public static List<ChirplingData> GetChirplingList()
		{
			if (chirplingList != null)
			{
				return chirplingList;
			}
			return new List<ChirplingData>();
		}

		private static void LoadCosmetics(IEnumerable<Cosmetic> cosmetics)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			foreach (Cosmetic cosmetic in cosmetics)
			{
				GameObject val = AssetBundleExtension.LoadPersistentAsset<GameObject>(cosmeticBundle, cosmetic.gameObjectPath);
				if ((Object)(object)val == (Object)null)
				{
					PluginLogger.LogError("Failed to load GameObject for \"" + cosmetic.cosmeticId + "\" at path: " + cosmetic.gameObjectPath);
					continue;
				}
				Texture2D val2 = AssetBundleExtension.LoadPersistentAsset<Texture2D>(cosmeticBundle, cosmetic.textureIconPath);
				if ((Object)(object)val2 == (Object)null)
				{
					PluginLogger.LogError("Failed to load Sprite for \"" + cosmetic.cosmeticId + "\" at path: " + cosmetic.textureIconPath);
					continue;
				}
				CosmeticInstance val3 = val.AddComponent<CosmeticInstance>();
				val3.cosmeticId = cosmetic.cosmeticId;
				val3.icon = val2;
				val3.cosmeticType = cosmetic.cosmeticType;
				CosmeticRegistry.cosmeticInstances.Add(cosmetic.cosmeticId, val3);
			}
		}
	}
	public class ChirplingData
	{
		public string name;

		public Color? color;

		public int materialIndex;

		public ChirplingData(string name, Color? color, int materialIndex)
		{
			this.name = name;
			this.color = color;
			this.materialIndex = materialIndex;
		}
	}
	internal class Cosmetic
	{
		public string cosmeticId;

		public string gameObjectPath;

		public string textureIconPath;

		public CosmeticType cosmeticType;

		public Cosmetic(string cosmeticId, string gameObjectPath, string textureIconPath, CosmeticType cosmeticType)
		{
			//IL_0046: 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)
			this.cosmeticId = "taskyy." + cosmeticId;
			this.gameObjectPath = "Assets/Taskyy/Cosmetic/Prefab/" + gameObjectPath + ".prefab";
			this.textureIconPath = "Assets/Taskyy/Cosmetic/Sprite/" + textureIconPath + ".png";
			this.cosmeticType = cosmeticType;
		}
	}
	[BepInPlugin("Taskyy.Chirpling", "Chirpling Scrap Item", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modID = "Taskyy.Chirpling";

		public const string modName = "Chirpling Scrap Item";

		public const string version = "2.0.0";

		private readonly Harmony harmony = new Harmony("Taskyy.Chirpling");

		private static Plugin Instance;

		private static PluginLogger pluginLogger;

		private void Awake()
		{
			pluginLogger = new PluginLogger();
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			AssetLoader.Init();
			NetcodePatcher();
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	internal class PluginLogger
	{
		private static ManualLogSource logSource;

		private static string errorSuffix = " (Tell Taskyy!)";

		public static bool devLogsEnabled { get; private set; }

		public PluginLogger()
		{
			logSource = Logger.CreateLogSource("Taskyy.Chirpling".Split(".")[1]);
			if (devLogsEnabled = File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "debug.txt")))
			{
				logSource.LogMessage((object)"Debug logs enabled.");
			}
		}

		public static void Log(string message)
		{
			logSource.LogMessage((object)message);
		}

		public static void LogWarning(string message)
		{
			logSource.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			logSource.LogError((object)(message + errorSuffix));
		}

		public static void LogDebug(string message)
		{
			if (devLogsEnabled)
			{
				logSource.Log((LogLevel)63, (object)("DEBUG: " + message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Taskyy.Chirpling";

		public const string PLUGIN_NAME = "Chirpling";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Chirpling.Mono
{
	internal class Util : NetworkBehaviour
	{
		private static bool debug = false;

		private static ulong auteruSteamId = 76561198049454324uL;

		public static PlayerControllerB? auteruPlayerController;

		private Util()
		{
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += OnClientConnectedDisconnectedCallback;
			((NetworkBehaviour)this).NetworkManager.OnClientDisconnectCallback += OnClientConnectedDisconnectedCallback;
		}

		public static bool PlayerIsAuteru(PlayerControllerB playerController)
		{
			return playerController.playerSteamId == auteruSteamId || debug;
		}

		public static bool AuteruIsPresent()
		{
			return (Object)(object)auteruPlayerController != (Object)null;
		}

		public static bool IsAuteruAlive()
		{
			if (debug)
			{
				return true;
			}
			if ((Object)(object)auteruPlayerController == (Object)null)
			{
				return false;
			}
			if (!auteruPlayerController.isPlayerDead && auteruPlayerController.isPlayerControlled && auteruPlayerController.isInsideFactory)
			{
				return true;
			}
			return false;
		}

		public virtual void OnClientConnectedDisconnectedCallback(ulong obj)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				FindAuteruServerRPC();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void FindAuteruServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2223880245u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2223880245u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					FindAuteruClientRPC();
				}
			}
		}

		[ClientRpc]
		private void FindAuteruClientRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2617375449u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2617375449u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			auteruPlayerController = null;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (val3.playerSteamId == auteruSteamId)
				{
					auteruPlayerController = val3;
					break;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Util()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2223880245u, new RpcReceiveHandler(__rpc_handler_2223880245));
			NetworkManager.__rpc_func_table.Add(2617375449u, new RpcReceiveHandler(__rpc_handler_2617375449));
		}

		private static void __rpc_handler_2223880245(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Util)(object)target).FindAuteruServerRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2617375449(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Util)(object)target).FindAuteruClientRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Util";
		}
	}
}
namespace Chirpling.MonoItems
{
	internal class BigChirpling : ChirplingBase
	{
		[SerializeField]
		private AudioClip biteSound;

		[SerializeField]
		private AudioClip[] voiceClips;

		private int biteChance = 4;

		private int biteDamage = 5;

		private Coroutine biteCouroutine;

		public override void Awake()
		{
			base.Awake();
		}

		public override void GrabItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && Util.PlayerIsAuteru(((GrabbableObject)this).playerHeldBy) && Random.Range(0, biteChance) == 0 && ((GrabbableObject)this).playerHeldBy.health >= 80)
			{
				BiteAuteruServerRPC();
			}
			base.GrabItem();
		}

		public override void DiscardItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && biteCouroutine != null)
			{
				BiteAuteruServerRPC(cancel: true);
			}
			base.DiscardItem();
		}

		[ServerRpc(RequireOwnership = false)]
		private void BiteAuteruServerRPC(bool cancel = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2150650518u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref cancel, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2150650518u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (cancel)
				{
					BiteAuteruClientRPC(-1, cancel);
					return;
				}
				int index = Random.Range(0, voiceClips.Length);
				BiteAuteruClientRPC(index, cancel);
			}
		}

		[ClientRpc]
		private void BiteAuteruClientRPC(int index = -1, bool cancel = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3539742180u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref cancel, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3539742180u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (cancel)
				{
					((MonoBehaviour)this).StopCoroutine(biteCouroutine);
					skinnedMeshRenderer.SetBlendShapeWeight(0, 0f);
					aso.Stop();
				}
				else
				{
					biteCouroutine = ((MonoBehaviour)this).StartCoroutine(BiteCouroutine(index));
				}
			}
		}

		private IEnumerator BiteCouroutine(int index)
		{
			int samples = 128;
			float[] array = new float[samples];
			float smooth = 0f;
			aso.PlayOneShot(voiceClips[index]);
			while (aso.isPlaying)
			{
				aso.GetSpectrumData(array, 0, (FFTWindow)5);
				float currentPeak2 = 0f;
				for (int i = 0; i < samples; i++)
				{
					currentPeak2 += array[i];
				}
				currentPeak2 /= (float)samples;
				smooth = Mathf.Lerp(smooth, currentPeak2, Time.deltaTime / 0.1f);
				float blendShapeValue = Mathf.Clamp(smooth * 40000f, 0f, 100f);
				skinnedMeshRenderer.SetBlendShapeWeight(0, blendShapeValue);
				yield return null;
			}
			skinnedMeshRenderer.SetBlendShapeWeight(0, 0f);
			yield return (object)new WaitForSeconds(0.25f);
			float elapsedTime = 0f;
			while (elapsedTime < 0.15f)
			{
				skinnedMeshRenderer.SetBlendShapeWeight(0, 100f * (elapsedTime / 0.15f));
				elapsedTime += Time.deltaTime;
				yield return null;
			}
			skinnedMeshRenderer.SetBlendShapeWeight(0, 100f);
			yield return (object)new WaitForSeconds(0.05f);
			aso.PlayOneShot(biteSound);
			if (((NetworkBehaviour)this).IsOwner)
			{
				((GrabbableObject)this).playerHeldBy.DamagePlayer(biteDamage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			}
			elapsedTime = 0f;
			while (elapsedTime < 0.05f)
			{
				skinnedMeshRenderer.SetBlendShapeWeight(0, 100f * (1f - elapsedTime / 0.05f));
				elapsedTime += Time.deltaTime;
				yield return null;
			}
			while (aso.isPlaying)
			{
				yield return null;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				((GrabbableObject)this).playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
			}
			skinnedMeshRenderer.SetBlendShapeWeight(0, 0f);
			yield return null;
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BigChirpling()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2150650518u, new RpcReceiveHandler(__rpc_handler_2150650518));
			NetworkManager.__rpc_func_table.Add(3539742180u, new RpcReceiveHandler(__rpc_handler_3539742180));
		}

		private static void __rpc_handler_2150650518(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool cancel = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cancel, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BigChirpling)(object)target).BiteAuteruServerRPC(cancel);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3539742180(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				bool cancel = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cancel, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BigChirpling)(object)target).BiteAuteruClientRPC(index, cancel);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BigChirpling";
		}
	}
	internal class ChirplingBase : GrabbableObject
	{
		protected Random random;

		protected AudioSource aso;

		protected bool hasLoadedSave;

		protected int animationIndex;

		protected int chirplingNameIndex;

		protected int chirplingScale;

		protected int chirplingExtra;

		protected int numOfAnimations = 9;

		protected int scaleRange = 2;

		protected float scaleMultiplier = 0.08f;

		[SerializeField]
		protected Animator animator;

		[SerializeField]
		protected SkinnedMeshRenderer skinnedMeshRenderer;

		[SerializeField]
		protected AudioClip[] cockatielSounds;

		[SerializeField]
		protected Material[] chirplingMaterials;

		protected ScanNodeProperties scanNode;

		private Material defaultMaterial;

		private Vector3 defaultScale;

		private Vector3 dropPosition;

		private static List<ChirplingBase> allChirplings = new List<ChirplingBase>();

		private float lastCheck = 0f;

		private float checkInterval = 0.5f;

		private bool scatter;

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

		public virtual void Awake()
		{
			//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)
			random = new Random();
			aso = ((Component)this).GetComponent<AudioSource>();
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			skinnedMeshRenderer = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>();
			defaultMaterial = ((Renderer)skinnedMeshRenderer).material;
			animator = ((Component)this).GetComponentInChildren<Animator>();
			defaultScale = ((Component)animator).gameObject.transform.localScale;
			allChirplings.Add(this);
		}

		public override void PlayDropSFX()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.itemProperties.dropSFX != (Object)null && (Object)(object)aso != (Object)null)
			{
				AudioClip val = cockatielSounds[random.Next(0, cockatielSounds.Length)];
				aso.PlayOneShot(val);
				WalkieTalkie.TransmitOneShotAudio(aso, val, 1f);
				if (((NetworkBehaviour)this).IsOwner)
				{
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.5f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 941);
				}
			}
			base.hasHitGround = true;
		}

		protected virtual void GetNewChirpling()
		{
			animationIndex = Random.Range(0, numOfAnimations);
			chirplingNameIndex = Random.Range(0, AssetLoader.GetChirplingList().Count);
			chirplingScale = Random.Range(0, scaleRange * 2 + 1);
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += OnClientConnectedCallback;
			if (((NetworkBehaviour)this).IsServer && !hasLoadedSave)
			{
				GetNewChirpling();
				SyncChirplingServerRPC(animationIndex, chirplingNameIndex, chirplingScale, chirplingExtra);
			}
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback -= OnClientConnectedCallback;
			((NetworkBehaviour)this).OnDestroy();
			allChirplings.Remove(this);
		}

		public override int GetItemDataToSave()
		{
			return PackIntegers(animationIndex, chirplingNameIndex, chirplingScale, chirplingExtra);
		}

		public override void LoadItemSaveData(int saveData)
		{
			((MonoBehaviour)this).StartCoroutine(NetworkSafeLoadItemSaveData(saveData));
		}

		private IEnumerator NetworkSafeLoadItemSaveData(int saveData)
		{
			yield return ((NetworkBehaviour)this).IsSpawned;
			if (((NetworkBehaviour)this).IsServer)
			{
				<>n__0(saveData);
				(animationIndex, chirplingNameIndex, chirplingScale, chirplingExtra) = UnpackIntegers(saveData);
				if (animationIndex > numOfAnimations - 1 || chirplingNameIndex > AssetLoader.GetChirplingList().Count)
				{
					PluginLogger.LogWarning("Chirpling data invalid, generating a new one.");
					GetNewChirpling();
				}
				SyncChirplingServerRPC(animationIndex, chirplingNameIndex, chirplingScale, chirplingExtra);
				hasLoadedSave = true;
			}
		}

		protected virtual void OnClientConnectedCallback(ulong obj)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				SyncChirplingServerRPC(animationIndex, chirplingNameIndex, chirplingScale, chirplingExtra);
			}
		}

		private int PackIntegers(int int1 = 0, int int2 = 0, int int3 = 0, int int4 = 0)
		{
			int1 = Mathf.Clamp(int1, 0, 31);
			int2 = Mathf.Clamp(int2, 0, 255);
			int3 = Mathf.Clamp(int3, 0, 15);
			int4 = Mathf.Clamp(int4, 0, 15);
			return (int1 << 21) | (int2 << 13) | (int3 << 9) | int4;
		}

		private (int int1, int int2, int int3, int int4) UnpackIntegers(int combined)
		{
			int item = combined >> 21;
			int item2 = (combined >> 13) & 0xFF;
			int item3 = (combined >> 9) & 0xF;
			int item4 = combined & 0xF;
			return (item, item2, item3, item4);
		}

		public override void GrabItem()
		{
			SyncAnimationIndexServerRPC(0);
			((GrabbableObject)this).GrabItem();
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			base.isHeldByEnemy = true;
			SyncAnimationIndexServerRPC(0);
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
		}

		public override void DiscardItem()
		{
			SyncAnimationIndexServerRPC(animationIndex);
			((GrabbableObject)this).DiscardItem();
		}

		public override void DiscardItemFromEnemy()
		{
			base.isHeldByEnemy = false;
			SyncAnimationIndexServerRPC(animationIndex);
			((GrabbableObject)this).DiscardItemFromEnemy();
		}

		protected virtual void SyncChirpling(int animationIndex, int chirpling, int scale, int extraData)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			ChirplingData chirplingData = AssetLoader.GetChirplingList()[chirpling];
			Material val = new Material((!chirplingData.color.HasValue) ? defaultMaterial : chirplingMaterials[chirplingData.materialIndex]);
			scanNode.headerText = chirplingData.name;
			if (chirplingData.color.HasValue && chirplingData.materialIndex != 1)
			{
				val.SetColor("_Color", chirplingData.color.Value);
			}
			((Renderer)skinnedMeshRenderer).material = val;
			animator.SetInteger("index", animationIndex);
			((Component)animator).gameObject.transform.localScale = defaultScale * (1f + (float)(scale - scaleRange) * scaleMultiplier);
		}

		[ServerRpc(RequireOwnership = false)]
		private void SyncChirplingServerRPC(int animationIndex, int chirpling, int scale, int extra)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2496892786u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, animationIndex);
					BytePacker.WriteValueBitPacked(val2, chirpling);
					BytePacker.WriteValueBitPacked(val2, scale);
					BytePacker.WriteValueBitPacked(val2, extra);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2496892786u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SyncChirplingClientRPC(animationIndex, chirpling, scale, extra);
				}
			}
		}

		[ClientRpc]
		private void SyncChirplingClientRPC(int animationIndex, int chirpling, int scale, int extra)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1375749639u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, animationIndex);
					BytePacker.WriteValueBitPacked(val2, chirpling);
					BytePacker.WriteValueBitPacked(val2, scale);
					BytePacker.WriteValueBitPacked(val2, extra);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1375749639u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SyncChirpling(animationIndex, chirpling, scale, extra);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SyncAnimationIndexServerRPC(int animationIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1389204015u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, animationIndex);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1389204015u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SyncAnimationIndexClientRPC(animationIndex);
				}
			}
		}

		[ClientRpc]
		private void SyncAnimationIndexClientRPC(int animationIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3310836248u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, animationIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3310836248u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					animator.SetInteger("index", animationIndex);
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ChirplingBase()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2496892786u, new RpcReceiveHandler(__rpc_handler_2496892786));
			NetworkManager.__rpc_func_table.Add(1375749639u, new RpcReceiveHandler(__rpc_handler_1375749639));
			NetworkManager.__rpc_func_table.Add(1389204015u, new RpcReceiveHandler(__rpc_handler_1389204015));
			NetworkManager.__rpc_func_table.Add(3310836248u, new RpcReceiveHandler(__rpc_handler_3310836248));
		}

		private static void __rpc_handler_2496892786(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				int chirpling = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref chirpling);
				int scale = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref scale);
				int extra = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref extra);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChirplingBase)(object)target).SyncChirplingServerRPC(num, chirpling, scale, extra);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1375749639(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				int chirpling = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref chirpling);
				int scale = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref scale);
				int extra = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref extra);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChirplingBase)(object)target).SyncChirplingClientRPC(num, chirpling, scale, extra);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1389204015(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChirplingBase)(object)target).SyncAnimationIndexServerRPC(num);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3310836248(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChirplingBase)(object)target).SyncAnimationIndexClientRPC(num);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ChirplingBase";
		}
	}
	internal class GroanTubeChirpling : ChirplingBase
	{
		private bool isFlipping = false;

		private float flipDuration = 0.6f;

		private Quaternion originalRotation;

		private Quaternion flippedRotation = Quaternion.Euler(180f, 0f, 0f);

		[SerializeField]
		private AudioClip[] groanSounds;

		[SerializeField]
		private Transform transformParent;

		public override void Awake()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			originalRotation = transformParent.localRotation;
		}

		protected override void SyncChirpling(int animationIndex, int chirpling, int scale, int extraData)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			base.SyncChirpling(animationIndex, chirpling, scale, extraData);
			chirplingExtra = extraData;
			transformParent.localRotation = ((chirplingExtra == 1) ? flippedRotation : originalRotation);
		}

		protected override void GetNewChirpling()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			base.GetNewChirpling();
			chirplingExtra = Random.Range(0, 2);
			transformParent.localRotation = ((chirplingExtra == 1) ? flippedRotation : originalRotation);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !isFlipping)
			{
				chirplingExtra ^= 1;
				WalkieTalkie.TransmitOneShotAudio(aso, (chirplingExtra == 1) ? groanSounds[0] : groanSounds[1], 1f);
				FlipChirplingServerRPC(chirplingExtra == 1);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void FlipChirplingServerRPC(bool isFlipped)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2188980248u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isFlipped, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2188980248u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					FlipChirplingClientRPC(isFlipped);
				}
			}
		}

		[ClientRpc]
		private void FlipChirplingClientRPC(bool isFlipped)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(335709907u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isFlipped, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 335709907u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					chirplingExtra = (isFlipped ? 1 : 0);
					isFlipping = true;
					aso.PlayOneShot((chirplingExtra == 1) ? groanSounds[0] : groanSounds[1]);
					((MonoBehaviour)this).StartCoroutine(FlipChirpling(isFlipped));
				}
			}
		}

		private IEnumerator FlipChirpling(bool isFlipped)
		{
			float elapsedTime = 0f;
			while (elapsedTime < flipDuration)
			{
				transformParent.localRotation = Quaternion.Lerp(isFlipped ? originalRotation : flippedRotation, isFlipped ? flippedRotation : originalRotation, elapsedTime / flipDuration);
				elapsedTime += Time.deltaTime;
				yield return null;
			}
			transformParent.localRotation = (isFlipped ? flippedRotation : originalRotation);
			isFlipping = false;
			yield return null;
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_GroanTubeChirpling()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2188980248u, new RpcReceiveHandler(__rpc_handler_2188980248));
			NetworkManager.__rpc_func_table.Add(335709907u, new RpcReceiveHandler(__rpc_handler_335709907));
		}

		private static void __rpc_handler_2188980248(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool isFlipped = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isFlipped, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GroanTubeChirpling)(object)target).FlipChirplingServerRPC(isFlipped);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_335709907(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool isFlipped = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isFlipped, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((GroanTubeChirpling)(object)target).FlipChirplingClientRPC(isFlipped);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "GroanTubeChirpling";
		}
	}
	internal class ThrowableChirpling : ChirplingBase
	{
		protected Ray ray;

		protected RaycastHit hit;

		private AnimationCurve fallCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
		{
			new Keyframe(0f, 0f, 2f, 2f),
			new Keyframe(1f, 1f, 0f, 0f)
		});

		private AnimationCurve fallCurveVertical = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
		{
			new Keyframe(0f, 0f, 0.11f, 0.11f, 0f, 0.27f),
			new Keyframe(0.49f, 1f, 4.11f, -1.81f, 0.07f, 0.28f),
			new Keyframe(0.76f, 1f, 1.41f, -1.37f, 0.32f, 0.57f),
			new Keyframe(0.94f, 1f, 0.83f, -0.03f, 0.54f, 1f),
			new Keyframe(1f, 1f)
		});

		private AnimationCurve fallCurveVerticalNB = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 0f, 0.11f, 0.11f, 0f, 0.27f),
			new Keyframe(0.49f, 1f, 4.11f, 0.06f, 0.07f, 0.21f),
			new Keyframe(0.94f, 1f, 0.06f, -0.03f, 0.2f, 1f)
		});

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetDestination(), true);
			}
		}

		public override void FallWithCurve()
		{
			//IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_006e: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((GrabbableObject)this).startFallingPosition - ((GrabbableObject)this).targetFloorPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(((GrabbableObject)this).itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, ((GrabbableObject)this).itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)this).transform.localPosition = Vector3.Lerp(((GrabbableObject)this).startFallingPosition, ((GrabbableObject)this).targetFloorPosition, fallCurve.Evaluate(((GrabbableObject)this).fallTime));
			if (magnitude > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), fallCurveVerticalNB.Evaluate(((GrabbableObject)this).fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), fallCurveVertical.Evaluate(((GrabbableObject)this).fallTime));
			}
			((GrabbableObject)this).fallTime = ((GrabbableObject)this).fallTime + Mathf.Abs(Time.deltaTime * 12f / magnitude);
		}

		private Vector3 GetDestination()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0037: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			ray = new Ray(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward);
			Vector3 val = ((!Physics.Raycast(ray, ref hit, 12f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) ? ((Ray)(ref ray)).GetPoint(10f) : ((Ray)(ref ray)).GetPoint(((RaycastHit)(ref hit)).distance - 0.05f));
			ray = new Ray(val, Vector3.down);
			if (Physics.Raycast(ray, ref hit, 30f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				return ((RaycastHit)(ref hit)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref ray)).GetPoint(30f);
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ThrowableChirpling";
		}
	}
}
namespace Chirpling.MonoEnemy
{
	internal class ChirplingAI : EnemyAI
	{
		private enum ChirplingState
		{
			Roaming,
			FollowSearch,
			Following,
			PreAttack,
			AttackSearch,
			Attacking
		}

		[Serializable]
		internal class ChirplingStateData
		{
			public float agentSpeed;

			public float agentStoppingDistance;

			public int animationIndex;

			public float animationSpeed;

			public ChirplingStateData(float agentSpeed, float agentStoppingDistance, int animationIndex)
			{
				this.agentSpeed = agentSpeed;
				this.agentStoppingDistance = agentStoppingDistance;
				this.animationIndex = animationIndex;
			}
		}

		private int[] timeBetweenStateSwitches = new int[2] { 70, 110 };

		private float aggroTreshFollow = 60f;

		private float aggroTresh = 75f;

		private float chirplingAge = 0f;

		private float aggro = 0f;

		private float timeSinceLastAttack = 0f;

		private float nextStateSwitch = 0f;

		private bool hasSeenPlayer;

		private float timeSinceSeeingTarget;

		private float outOfRange;

		private ScanNodeProperties scanNode;

		private Random random;

		[SerializeField]
		private WeaponBase[] weapons;

		private List<ChirplingStateData> chirplingStateData = new List<ChirplingStateData>
		{
			new ChirplingStateData(2f, 0f, 0),
			new ChirplingStateData(2f, 2f, 0),
			new ChirplingStateData(2f, 2f, 0),
			new ChirplingStateData(2f, 0f, 0),
			new ChirplingStateData(6f, 0f, 1),
			new ChirplingStateData(6f, 0f, 1)
		};

		private Vector3 previousPosition;

		public float speed;

		private int lookingForAuteru = 0;

		private void Awake()
		{
			random = new Random();
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			WeaponBase[] array = weapons;
			foreach (WeaponBase weaponBase in array)
			{
				weaponBase.Init(this);
			}
		}

		public override void Start()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			timeSinceLastAttack = 0f;
		}

		public override void DoAIInterval()
		{
			//IL_004e: 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_0110: 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)
			((EnemyAI)this).DoAIInterval();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (!base.currentSearch.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			case 1:
				if (!base.currentSearch.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				else if (ChirplingFollowClosest(1.5f, requireLineOfSight: true))
				{
					if (base.currentSearch.inProgress)
					{
						((EnemyAI)this).StopSearch(base.currentSearch, true);
					}
					FollowTargetServerRPC((int)base.targetPlayer.actualClientId);
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
				}
				break;
			case 2:
				break;
			case 4:
				if (!base.currentSearch.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				else if (ChirplingFollowClosest(1.5f, requireLineOfSight: true))
				{
					if (base.currentSearch.inProgress)
					{
						((EnemyAI)this).StopSearch(base.currentSearch, true);
					}
					((EnemyAI)this).SwitchToBehaviourState(5);
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
				}
				break;
			case 5:
				if (base.currentSearch.inProgress)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				else if (!((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 360f, 60, 5.5f, (Transform)null))
				{
					timeSinceSeeingTarget += Time.deltaTime;
					if (timeSinceSeeingTarget > 5f)
					{
						((EnemyAI)this).SwitchToBehaviourState(4);
						nextStateSwitch = 30f;
						timeSinceSeeingTarget = 0f;
					}
				}
				else
				{
					timeSinceSeeingTarget = 0f;
				}
				break;
			case 3:
				break;
			}
		}

		public bool AttackConditionsMet()
		{
			if (aggro < aggroTresh)
			{
				return false;
			}
			if (chirplingAge < 75f)
			{
				return false;
			}
			if (!hasSeenPlayer)
			{
				return false;
			}
			return true;
		}

		public override void Update()
		{
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			if (base.enemyBehaviourStates.Length == 0)
			{
				PluginLogger.LogError("No states???");
				return;
			}
			((EnemyAI)this).Update();
			if (((NetworkBehaviour)this).IsOwner)
			{
				PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(120f, 60, (Transform)null, 8f, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
				if (allPlayersInLineOfSight != null && allPlayersInLineOfSight.Length != 0)
				{
					hasSeenPlayer = true;
					aggro += Time.deltaTime * ((float)allPlayersInLineOfSight.Length / 2f);
				}
				if (hasSeenPlayer)
				{
					chirplingAge += Time.deltaTime;
				}
				timeSinceLastAttack += Time.deltaTime;
				if (nextStateSwitch <= 0f)
				{
					nextStateSwitch = random.Next(timeBetweenStateSwitches[0], timeBetweenStateSwitches[1]);
					if (base.currentBehaviourStateIndex == 5)
					{
						aggro = 0f;
					}
					if (AttackConditionsMet())
					{
						if (base.currentBehaviourStateIndex == 3)
						{
							((EnemyAI)this).SwitchToBehaviourState(4);
							nextStateSwitch = 30f;
						}
						else if (base.currentBehaviourStateIndex != 3)
						{
							((EnemyAI)this).SwitchToBehaviourState(3);
							EnterAttackPhaseServerRPC();
							nextStateSwitch = 2f;
						}
					}
					else
					{
						int num = ((!(aggro >= aggroTreshFollow)) ? random.Next(0, 2) : 0);
						if (base.currentBehaviourStateIndex != num)
						{
							((EnemyAI)this).SwitchToBehaviourState(num);
							switch (base.currentBehaviourStateIndex)
							{
							case 1:
								GetNewFollowTargetServerRPC();
								break;
							}
						}
					}
					base.agent.speed = chirplingStateData[base.currentBehaviourStateIndex].agentSpeed;
					base.agent.stoppingDistance = chirplingStateData[base.currentBehaviourStateIndex].agentStoppingDistance;
				}
				else
				{
					nextStateSwitch -= Time.deltaTime;
				}
			}
			Animator creatureAnimator = base.creatureAnimator;
			Vector3 velocity = base.agent.velocity;
			creatureAnimator.SetInteger("state", (((Vector3)(ref velocity)).sqrMagnitude < 0.01f) ? (-1) : chirplingStateData[base.currentBehaviourStateIndex].animationIndex);
			if (base.currentBehaviourStateIndex != 1 && base.currentBehaviourStateIndex != 2)
			{
				scanNode.subText = "";
			}
			if (base.currentBehaviourStateIndex < 3)
			{
				weapons[0].DisableWeapon();
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			int num = 30;
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val == (Object)null)
			{
				PluginLogger.LogWarning("Chirpling collided with a player, but player was null.");
			}
			else if (!(timeSinceLastAttack < 1f) && base.currentBehaviourStateIndex == 5)
			{
				base.creatureAnimator.ResetTrigger("stab");
				base.creatureAnimator.SetTrigger("stab");
				val.DamagePlayer(num, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (val.isPlayerDead)
				{
					aggro = 0f;
					nextStateSwitch = 0f;
				}
				timeSinceLastAttack = 0f;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void GetNewFollowTargetServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3699446059u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3699446059u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				lookingForAuteru = 0;
				if (Util.IsAuteruAlive() && random.Next(0, 3) == 0)
				{
					lookingForAuteru = 1;
				}
				GetNewFollowTargetClientRPC(lookingForAuteru);
			}
		}

		[ClientRpc]
		private void GetNewFollowTargetClientRPC(int lookingForAuteru)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1250205843u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, lookingForAuteru);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1250205843u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (lookingForAuteru == 1)
				{
					scanNode.subText = "Looking for Auteru";
				}
				else
				{
					scanNode.subText = "Looking for someone to follow";
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void FollowTargetServerRPC(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(135766074u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 135766074u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					FollowTargetClientRPC(playerId);
				}
			}
		}

		[ClientRpc]
		private void FollowTargetClientRPC(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3651541088u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3651541088u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					((Component)this).gameObject.GetComponentInChildren<ScanNodeProperties>().subText = "Following " + val3.playerUsername;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void EnterAttackPhaseServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(113220008u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 113220008u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					EnterAttackPhaseClientRPC();
				}
			}
		}

		private IEnumerator ExtendKnife()
		{
			yield return (object)new WaitForSeconds(2f);
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(5);
		}

		private IEnumerator DelayedAttack()
		{
			yield return (object)new WaitForSeconds(2f);
			((EnemyAI)this).SwitchToBehaviourState(5);
		}

		[ClientRpc]
		private void EnterAttackPhaseClientRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2584668701u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2584668701u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					weapons[0].EnableWeapon();
				}
			}
		}

		public PlayerControllerB FindValidTargets(float width = 45f, int range = 60, bool los = false, bool preferTeru = false)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0089: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				Vector3 position = ((Component)allPlayerScripts[i].gameplayCamera).transform.position;
				if (los)
				{
					if (!(Vector3.Distance(position, base.eye.position) < (float)range) || Physics.Linecast(base.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
					{
						continue;
					}
					Vector3 val = position - base.eye.position;
					if (!(Vector3.Angle(base.eye.forward, val) < width))
					{
						continue;
					}
					PlayerControllerB val2 = allPlayerScripts[i];
					list.Add(val2);
					foreach (PlayerControllerB val3 in allPlayerScripts)
					{
						if ((Object)(object)val2 != (Object)(object)val3 && Vector3.Distance(((Component)val2).transform.position, ((Component)val3).transform.position) < 8f)
						{
							list.Add(val3);
						}
					}
				}
				else if (!((Object)(object)StartOfRound.Instance.allPlayerScripts[i] == (Object)null) && !allPlayerScripts[i].isPlayerDead && allPlayerScripts[i].isPlayerControlled && allPlayerScripts[i].isInsideFactory && Vector3.Distance(((Component)this).transform.position, ((Component)allPlayerScripts[i]).transform.position) <= (float)range)
				{
					if (preferTeru && Util.PlayerIsAuteru(allPlayerScripts[i]))
					{
						return allPlayerScripts[i];
					}
					list.Add(allPlayerScripts[i]);
				}
			}
			if (list.Count != 0)
			{
				return list[random.Next(0, list.Count)];
			}
			return null;
		}

		public bool ChirplingFollowClosest(float bufferDistance = 1.5f, bool requireLineOfSight = false, float viewWidth = 70f, bool preferAuteru = true)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			PlayerControllerB targetPlayer = base.targetPlayer;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !((EnemyAI)this).PathIsIntersectedByLineOfSight(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position, false, false, false) && (!requireLineOfSight || ((EnemyAI)this).CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, viewWidth, 40, -1f, (Transform)null)))
				{
					base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
					if (base.tempDist < base.mostOptimalDistance)
					{
						base.mostOptimalDistance = base.tempDist;
						base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
					}
					if (Util.PlayerIsAuteru(StartOfRound.Instance.allPlayerScripts[i]) && preferAuteru)
					{
						base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
						break;
					}
				}
			}
			if ((Object)(object)base.targetPlayer != (Object)null && bufferDistance > 0f && (Object)(object)targetPlayer != (Object)null && Mathf.Abs(base.mostOptimalDistance - Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position)) < bufferDistance)
			{
				base.targetPlayer = targetPlayer;
			}
			if (lookingForAuteru == 1 && (Object)(object)base.targetPlayer != (Object)null && !Util.PlayerIsAuteru(base.targetPlayer))
			{
				return false;
			}
			return (Object)(object)base.targetPlayer != (Object)null;
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ChirplingAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3699446059u, new RpcReceiveHandler(__rpc_handler_3699446059));
			NetworkManager.__rpc_func_table.Add(1250205843u, new RpcReceiveHandler(__rpc_handler_1250205843));
			NetworkManager.__rpc_func_table.Add(135766074u, new RpcReceiveHandler(__rpc_handler_135766074));
			NetworkManager.__rpc_func_table.Add(3651541088u, new RpcReceiveHandler(__rpc_handler_3651541088));
			NetworkManager.__rpc_func_table.Add(113220008u, new RpcReceiveHandler(__rpc_handler_113220008));
			NetworkManager.__rpc_func_table.Add(2584668701u, new RpcReceiveHandler(__rpc_handler_2584668701));
		}

		private static void __rpc_handler_3699446059(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChirplingAI)(object)target).GetNewFollowTargetServerRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1250205843(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChirplingAI)(object)target).GetNewFollowTargetClientRPC(num);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_135766074(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChirplingAI)(object)target).FollowTargetServerRPC(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3651541088(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChirplingAI)(object)target).FollowTargetClientRPC(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_113220008(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChirplingAI)(object)target).EnterAttackPhaseServerRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2584668701(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChirplingAI)(object)target).EnterAttackPhaseClientRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ChirplingAI";
		}
	}
	internal class Knife : WeaponBase
	{
		private Vector3 initialPosition;

		private bool knifeBladeDeployed = false;

		[SerializeField]
		private GameObject knifeBlade;

		[SerializeField]
		private GameObject knifeHandle;

		[SerializeField]
		private AudioClip knifeSound;

		private bool knifeDeployed = false;

		public override void Init(ChirplingAI chirpling)
		{
			base.Init(chirpling);
			knifeBlade.SetActive(false);
			knifeHandle.SetActive(false);
		}

		public override void DisableWeapon()
		{
			//IL_001b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			if (knifeDeployed)
			{
				knifeBlade.transform.localPosition = Vector3.zero;
				knifeBlade.SetActive(false);
				knifeHandle.SetActive(false);
				initialPosition = knifeBlade.transform.localPosition;
				knifeDeployed = false;
			}
		}

		public override void EnableWeapon()
		{
			if (!knifeDeployed)
			{
				knifeDeployed = true;
				((MonoBehaviour)this).StartCoroutine(DeployKnife());
			}
		}

		private IEnumerator DeployKnife()
		{
			knifeHandle.SetActive(true);
			knifeBlade.SetActive(true);
			yield return (object)new WaitForSeconds(2f);
			float elapsedTime = 0f;
			if ((Object)(object)chirpling != (Object)null)
			{
				((EnemyAI)chirpling).creatureSFX.PlayOneShot(knifeSound);
			}
			while (elapsedTime < 0.4f)
			{
				knifeBlade.transform.localPosition = Vector3.Lerp(initialPosition, new Vector3(0f, 0f, 0.25f), elapsedTime / 0.4f);
				elapsedTime += Time.deltaTime;
				yield return null;
			}
			knifeBlade.transform.localPosition = new Vector3(0f, 0f, 0.25f);
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "Knife";
		}
	}
	internal class WeaponBase : NetworkBehaviour
	{
		protected ChirplingAI? chirpling;

		public virtual void Init(ChirplingAI chirpling)
		{
			this.chirpling = chirpling;
		}

		public virtual void DisableWeapon()
		{
			throw new NotImplementedException();
		}

		public virtual void EnableWeapon()
		{
			throw new NotImplementedException();
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "WeaponBase";
		}
	}
}
namespace Chirpling.Cosmetics
{
	internal class Teal : NetworkBehaviour
	{
		private Animator animator;

		private AudioSource aso;

		private Random random;

		[SerializeField]
		private AudioClip[] tealVoiceClips;

		private float tealLastDance;

		private float tealNextDance;

		private float tealLastTalk;

		private IEnumerator tealDanceCoroutine;

		private IEnumerator tealTalkCoroutine;

		private int[] tealAnimationDuration = new int[2] { 4, 7 };

		private int[] tealAnimationDelay = new int[2] { 50, 120 };

		private int tealTalkChance = 3;

		private float tealTalkDuration = 3f;

		private float tealTalkDelay = 360f;

		private void Awake()
		{
			animator = ((Component)this).GetComponent<Animator>();
			random = new Random();
			aso = ((Component)this).GetComponent<AudioSource>();
		}

		private void Start()
		{
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += OnClientConnectedCallback;
			FactoryResetBird();
		}

		private void Update()
		{
			if (tealLastDance > tealNextDance && (Object)(object)animator != (Object)null)
			{
				GetNextDance();
				animator.SetBool("idle", false);
				animator.SetBool("dancing", true);
				tealDanceCoroutine = TealStopDancing();
				((MonoBehaviour)this).StartCoroutine(tealDanceCoroutine);
				if (tealLastTalk >= tealTalkDelay && random.Next(0, tealTalkChance) == 0)
				{
					tealLastTalk = 0f;
					tealTalkCoroutine = TealTalk();
					((MonoBehaviour)this).StartCoroutine(tealTalkCoroutine);
				}
			}
			tealLastDance += Time.deltaTime;
			tealLastTalk += Time.deltaTime;
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).NetworkManager.OnClientDisconnectCallback -= OnClientConnectedCallback;
			((NetworkBehaviour)this).OnDestroy();
		}

		private void FactoryResetBird()
		{
			random = new Random(GameNetworkManager.Instance.gameHasStarted ? (StartOfRound.Instance.randomMapSeed + 7341) : 0);
			GetNextDance();
			animator.SetBool("idle", true);
			animator.SetBool("dancing", false);
			if (tealDanceCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(tealDanceCoroutine);
			}
			if (tealTalkCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(tealTalkCoroutine);
			}
			tealLastTalk = 0f;
		}

		private void GetNextDance()
		{
			tealNextDance = random.Next(tealAnimationDelay[0], tealAnimationDelay[1]);
			tealLastDance = 0f;
		}

		private IEnumerator TealStopDancing()
		{
			if (random != null)
			{
				yield return (object)new WaitForSeconds((float)random.Next(tealAnimationDuration[0], tealAnimationDuration[1]));
				if ((Object)(object)animator != (Object)null)
				{
					animator.SetBool("idle", true);
					animator.SetBool("dancing", false);
				}
			}
		}

		private IEnumerator TealTalk()
		{
			if ((Object)(object)aso == (Object)null)
			{
				yield break;
			}
			float elapsedTime = 0f;
			while (elapsedTime < tealTalkDuration)
			{
				elapsedTime += Time.deltaTime;
				if (!aso.isPlaying)
				{
					AudioClip tealVoiceClip = tealVoiceClips[random.Next(0, tealVoiceClips.Length)];
					aso.PlayOneShot(tealVoiceClip);
				}
				yield return null;
			}
		}

		private void OnClientConnectedCallback(ulong obj)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				SyncTealServerRPC();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SyncTealServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3624108027u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3624108027u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SyncTealClientRPC();
				}
			}
		}

		[ClientRpc]
		private void SyncTealClientRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be du