Decompiled source of NightmareFreddyFix v1.0.0

NightmareFreddy/NightmareFreddy.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NightmareFreddy.Configurations;
using NightmareFreddy.Freddles;
using NightmareFreddy.NetcodePatcher;
using NightmareFreddy.Plugin;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 NightmareFreddy.Plugin
{
	internal sealed class MoonSpawnRules
	{
		internal readonly Dictionary<LevelTypes, int> GroupWeights = new Dictionary<LevelTypes, int>();

		internal readonly Dictionary<string, int> NamedMoonWeights = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

		internal unsafe static MoonSpawnRules Parse(string rawRules, int defaultWeight, ManualLogSource logger)
		{
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Invalid comparison between Unknown and I4
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			MoonSpawnRules moonSpawnRules = new MoonSpawnRules();
			int num = Math.Max(0, Math.Min(10000, defaultWeight));
			string[] array = (string.IsNullOrWhiteSpace(rawRules) ? "all" : rawRules).Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
			bool flag = false;
			if (array.Length == 1 && array[0].Trim().Equals("none", StringComparison.OrdinalIgnoreCase))
			{
				logger.LogInfo((object)"[NoFloor Spawn] Moon Rules=none: spawn natural desativado em todas as luas.");
				return moonSpawnRules;
			}
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text = array2[i].Trim();
				if (text.Length == 0)
				{
					continue;
				}
				int num2 = text.LastIndexOf(':');
				string text2 = ((num2 >= 0) ? text.Substring(0, num2) : text).Trim().Trim('"', '\'');
				string s = ((num2 >= 0) ? text.Substring(num2 + 1).Trim() : string.Empty);
				int result = num;
				if (text2.Length == 0)
				{
					logger.LogWarning((object)("[NoFloor Spawn] Regra ignorada (lua vazia): " + text));
					continue;
				}
				if (num2 >= 0 && !int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
				{
					logger.LogWarning((object)("[NoFloor Spawn] Peso invalido, esperado numero inteiro: " + text));
					continue;
				}
				if (result < 0 || result > 10000)
				{
					logger.LogWarning((object)("[NoFloor Spawn] Peso fora de 0..10000; ajustado: " + text));
					result = Math.Max(0, Math.Min(10000, result));
				}
				string text3 = new string(text2.SkipWhile((char c) => !char.IsLetter(c)).ToArray()).Trim();
				string text4 = text3.Replace(" ", string.Empty);
				if (text4.Equals("none", StringComparison.OrdinalIgnoreCase))
				{
					logger.LogWarning((object)("[NoFloor Spawn] 'none' so pode ser usado sozinho; ignorando: " + text));
					continue;
				}
				if (!text4.EndsWith("Level", StringComparison.OrdinalIgnoreCase) && !text4.Equals("all", StringComparison.OrdinalIgnoreCase) && !text4.Equals("vanilla", StringComparison.OrdinalIgnoreCase) && !text4.Equals("modded", StringComparison.OrdinalIgnoreCase))
				{
					text4 += "Level";
				}
				if (Enum.TryParse<LevelTypes>(text4, ignoreCase: true, out LevelTypes result2) && Enum.IsDefined(typeof(LevelTypes), result2) && (int)result2 != 1)
				{
					moonSpawnRules.GroupWeights[result2] = result;
					logger.LogInfo((object)("[NoFloor Spawn] Grupo/lua vanilla: " + ((object)(*(LevelTypes*)(&result2))/*cast due to .constrained prefix*/).ToString() + " = " + result));
				}
				else
				{
					string text5 = NormalizeCustomMoon(text3);
					if (text5.Length == 0)
					{
						logger.LogWarning((object)("[NoFloor Spawn] Nome de lua invalido: " + text));
						continue;
					}
					moonSpawnRules.NamedMoonWeights[text5] = result;
					logger.LogInfo((object)("[NoFloor Spawn] Lua por nome: " + text5 + " = " + result));
				}
				flag = true;
			}
			if (!flag)
			{
				moonSpawnRules.GroupWeights[(LevelTypes)(-1)] = num;
				logger.LogWarning((object)("[NoFloor Spawn] Nenhuma regra valida. Usando all:" + num));
			}
			logger.LogInfo((object)("[NoFloor Spawn] Configuracao pronta: " + moonSpawnRules.GroupWeights.Count + " grupos/luas vanilla, " + moonSpawnRules.NamedMoonWeights.Count + " luas por nome. Pesos NAO sao porcentagens."));
			return moonSpawnRules;
		}

		private static string NormalizeCustomMoon(string name)
		{
			string text = new string(name.Where((char c) => char.IsLetterOrDigit(c) || c == ' ').ToArray()).Trim();
			if (!text.EndsWith("Level", StringComparison.OrdinalIgnoreCase))
			{
				text += "Level";
			}
			return text.ToLowerInvariant();
		}
	}
	[BepInPlugin("Xilef992.NightmareFreddy", "NightmareFreddy", "1.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "Xilef992.NightmareFreddy";

		internal static ManualLogSource Logger;

		public static AssetBundle ModAssetsFreddles;

		public static AssetBundle ModAssetsFreddy;

		private readonly Harmony harmony = new Harmony("NightmareFreddy");

		public static Config FreddyConfiguration { get; internal set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			FreddyConfiguration = new Config(((BaseUnityPlugin)this).Config);
			MoonSpawnRules moonSpawnRules = MoonSpawnRules.Parse(FreddyConfiguration.MOON_RULES.Value, FreddyConfiguration.RARITY_SPAWN.Value, Logger);
			InitializeNetworkBehaviours();
			string path = "freddlesmodassets";
			string path2 = "freddymodassets";
			ModAssetsFreddles = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			ModAssetsFreddy = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path2));
			if ((Object)(object)ModAssetsFreddles == (Object)null)
			{
				Debug.Log((object)"Error Loading Asset [ Freddles ]");
				return;
			}
			if ((Object)(object)ModAssetsFreddy == (Object)null)
			{
				Debug.Log((object)"Error Loading Asset [ Freddy Nightmare ]");
				return;
			}
			EnemyType obj = ModAssetsFreddles.LoadAsset<EnemyType>("FreddlesEnemy");
			TerminalNode val = ModAssetsFreddles.LoadAsset<TerminalNode>("FreddlesTN");
			TerminalKeyword val2 = ModAssetsFreddles.LoadAsset<TerminalKeyword>("FreddlesTK");
			NetworkPrefabs.RegisterNetworkPrefab(obj.enemyPrefab);
			Enemies.RegisterEnemy(obj, (SpawnType)2, moonSpawnRules.GroupWeights, moonSpawnRules.NamedMoonWeights, val, val2);
			EnemyType obj2 = ModAssetsFreddy.LoadAsset<EnemyType>("NightmareFreddy");
			TerminalNode val3 = ModAssetsFreddy.LoadAsset<TerminalNode>("FreddyTN");
			TerminalKeyword val4 = ModAssetsFreddy.LoadAsset<TerminalKeyword>("FreddyTK");
			NetworkPrefabs.RegisterNetworkPrefab(obj2.enemyPrefab);
			Enemies.RegisterEnemy(obj2, (SpawnType)2, moonSpawnRules.GroupWeights, moonSpawnRules.NamedMoonWeights, val3, val4);
			harmony.PatchAll(typeof(ConfigurationsPatch));
			Debug.Log((object)"Nightmare Freddy Loaded Successfully!");
			Debug.Log((object)"                                                                                       \n                                  %%######%%%%                                         \n                                ###%%%%#{}{#%%%                                        \n                                ###%%%%%###%%%%                                        \n                                %##%%%%%####%%%             %##%                       \n                                 ##%%%%%####%%%          %%########%                   \n                                 #{#%%%%##{#%%%         ##%%%%%%%%#{#                  \n                                  ##%%%%##{#%%%%      %##%#{{{{{#%%##%                 \n                 %#######%        ##%%%%####%%%%%%%  %##%{{{{{{{{#%##%                 \n               %###%%%%%%#{#%   %%%%%%%%##{}{{#%%%%%%###}}}{{{{{{#%##%                 \n              %##%#{{{{#%%%#{#%%%%%%%%%%%%%%%%##%%%%%%%%{}}}}{{{#%%##                  \n              %%#{}{{{{{##%%%##%%###################%%%%%%#{{{{#%%##%                  \n              %%##}}}{{{{{{%%%######################%%##%%%%%%#%###%                   \n               %%#{}{{{{{#%%%########################%%%%##%%%###%                     \n               %%###{{#%%%%###%%%####################%%###%%%%%%%                      \n                 %####%%%%##%%%%%#####{#{{{{{{{{{{{#%########%%%%%                     \n                  %%#%%###%%###%%%#######{{##{{{#%%%%%%######%%%%%                     \n                    %%%##%%%#%%#%%%%%%%%#{{{{{%%%####%%%%###%%%%%%                     \n                     #%#%%%%%%##%%#{##%%%%{{{%%%%%#}{{#%%###%#%%%%                     \n                     #%%%%%%%#{%%%%%#{}{#%%{{%%%%#+:={#%%%%%%#%%%%                     \n                     ####%%%%##%%%%[::}{#%%#{%%%%%%%%%%%%%%###%%%%                     \n                      ####%%%#{%%%%%#%%%%%%#{{%%%%%%%%%%%%###%%%%%%%                   \n                      #####%%%%{%%%%%%%%%%##{{{%%%%%%%%#%%%%%%%%%%%%%%                 \n                      ######%#####%%%%%%#%####{{#%%#####%%%%%%%%%%%%%%%%               \n                      %%######%%%%#######%%%##{#%#{}}}{}}{###%%%%%%%%%%%               \n                    %%%%###%%%###{{{{{}{{{{#%%%{[}}}}}}}{{{##%%%%%%%%%%                \n                   ########{{{###########{{{{{{{{{{{}}}}{{###%%%%%%%%%%                \n                   ########{{##%%%%%%######{{{{{{{{{{}}{{##%%%%%%^-{%%                 \n                   %%%%%%##{{{#%%%%%%%%#####{{{{#{}}[}{{{{{()<^-^=~##%                 \n                    %%%%%%#####%%%%%%%%##{########{{}][[=~)~-~~-)(>##%                 \n                      %%%][]{{}({{#{{##{{#}]#}))#^-[]-(%>*#<*>>^(%###%%                \n                       ##{[[(]]]^*{(-]#*+#(~}%><%}^{#>[%{]%#[##%%{-{#%%                \n                        #%{{#(][]={#*[%](%#]#%##%%%%%%%%%%%%%%%>(}>##%%                \n                        #%%#%{#}%{%%%%%%%%%%%%%%%%%%%%%%%%%%%({^-]}%%%%                \n                        ##%[}##%%%%%%%%%%%%%%%%%%%%%%%%%%%%]{>:*:)%%%%                 \n                         ##]]]+[%%%%%%%%%%%%%%%%%%%%%[%%)(%>=^:~{%%%%%                 \n                         ###]<-=+(##{%%}{%#}%%(%%[<%#~(%>-[>:^#%##%%%                  \n                         ####(~*:-[}~[%<+#[=}#=)%(:]{~-#[<[#{{##%%%%                   \n                          ######(=)]~-%)-[[-+#*~{}<}%###{{###%%%%%                     \n                           %###%%%%###%%%%%%%############%%%%%%                        \n                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{%                          \n                               %%%%%%%%%%%%%%%%%%%%%%%%%%###%                          \n                              #%%%%%%%%%%%%%%%%%%%%####{{{}{%                          \n                              %%%%%%%%%%%%%%%  %%%%%%%#####%%                          \n                               %%%%%%%%%%%       %%%%%%%%%%%                           \n                                  %%%%%              %%%%                              \n                                                                                       ");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInformation
	{
		public const string PLUGIN_GUID = "NightmareFreddy";

		public const string PLUGIN_NAME = "NightmareFreddy";

		public const string PLUGIN_VERSION = "1.1.3";
	}
}
namespace NightmareFreddy.NightmareFreddy
{
	public class NightmareFreddyAi : EnemyAI
	{
		private enum State
		{
			Hidden,
			Spawning,
			Attacking,
			Walking,
			Running,
			Screaming,
			WaitingOnCoroutine
		}

		[Header("Roar Global Info [ Modifiable ]")]
		public float radiusRoar = 10f;

		public float forceRoar = 50f;

		[Header("Material")]
		public Material endoSkeleton;

		public Material exoSkeleton;

		public Material DistortionMaterial;

		[Header("Audio")]
		public AudioSource scream;

		public AudioSource footstep;

		public AudioSource spawning;

		public AudioSource hitting;

		public AudioClip[] gigles;

		public BoxCollider EnemyCollider;

		[Header("Attack")]
		public Transform attackArea;

		[Header("Rendering!")]
		public SkinnedMeshRenderer FreddyRenderer;

		public MeshRenderer Sphere;

		public BoxCollider ScanNode;

		private float timeSinceHittingLocalPlayer;

		private Coroutine spawningMaterialChanges;

		private float animationSpeedAttack;

		private bool wasRunning;

		private int lastBeforeAttack;

		[Header("Head rotation stuff")]
		public Transform freddyStare;

		public override void Start()
		{
			//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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			((Collider)EnemyCollider).enabled = false;
			endoSkeleton.SetFloat("_Strenght", 0f);
			endoSkeleton.SetFloat("_Dissolve", 1f);
			exoSkeleton.SetFloat("_Dissolve", 1f);
			((Renderer)Sphere).enabled = false;
			((EnemyAI)this).SetDestinationToPosition(((Component)StartOfRound.Instance.shipInnerRoomBounds).transform.position, false);
			int num = 0;
			base.destination = Vector3.zero;
			while (base.destination == Vector3.zero && num < 10)
			{
				num++;
				base.destination = GetRandomPointInCollider(StartOfRound.Instance.shipInnerRoomBounds);
				_ = base.destination;
				NavMeshPath val = new NavMeshPath();
				NavMesh.CalculatePath(((Component)this).transform.position, base.destination, -1, val);
				if ((int)val.status == 0)
				{
					((EnemyAI)this).SetDestinationToPosition(base.destination, false);
					continue;
				}
				base.destination = Vector3.zero;
				break;
			}
			((Collider)ScanNode).enabled = false;
			((MonoBehaviour)this).StartCoroutine(InitializeFreddyWhenNetworkReady());
		}

		private IEnumerator InitializeFreddyWhenNetworkReady()
		{
			while (!((NetworkBehaviour)this).IsSpawned)
			{
				yield return null;
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(TransitionMaterial(manifest: false, 0f));
				SwitchToBehaviourStateClientRpc(0);
				Debug.Log((object)"[NightmareFreddy-v81] Freddy inicializado na rede, estado Hidden.");
			}
		}

		private void LateUpdate()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				freddyStare.position = ((Component)base.targetPlayer).transform.position;
			}
		}

		public static Vector3 GetRandomPointInCollider(Collider collider)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(new Vector3(Random.Range(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.x), Random.Range(((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.y), Random.Range(((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.z)), ref val, 5f, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			return ((Bounds)(ref bounds)).center;
		}

		public override void DoAIInterval()
		{
			//IL_0021: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			if (Vector3.Distance(((Component)Object.FindObjectOfType<HangarShipDoor>()).transform.position, ((Component)this).transform.position) < 5f)
			{
				OpenShipDoorsClientRpc();
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (GetNumberOfFreddles(onlyArrived: true) >= global::NightmareFreddy.Plugin.Plugin.FreddyConfiguration.NUMBER_FREDDLES_PHASE_2.Value)
				{
					Debug.Log((object)"[NightmareFreddy-v81] Freddles suficientes: iniciando manifestacao do Freddy.");
					spawningMaterialChanges = ((MonoBehaviour)this).StartCoroutine(TransitionMaterial(manifest: true, 10f));
					SwitchToBehaviourStateServerRpc(1);
					PlayEuhEuhClientRpc();
				}
				else if (RandomNumberGenerator.GetInt32(Math.Max(3, global::NightmareFreddy.Plugin.Plugin.FreddyConfiguration.POURCENTAGE_SPAWN.Value)) <= 2)
				{
					SpawnNewFreddle();
				}
				break;
			case 1:
				if (GetNumberOfFreddles(onlyArrived: true) <= 3 && spawningMaterialChanges == null)
				{
					spawningMaterialChanges = ((MonoBehaviour)this).StartCoroutine(TransitionMaterial(manifest: false, 15f));
				}
				if (endoSkeleton.GetFloat("_Strenght") == 5f)
				{
					SwitchToBehaviourStateServerRpc(5);
				}
				break;
			case 3:
				SetTargetPlayerClientRpc(FindPlayerToTarget().actualClientId);
				CheckIfPlayerHittableServerRpc();
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				if (RandomNumberGenerator.GetInt32(100) <= 2)
				{
					SpawnNewFreddle();
				}
				if (RandomNumberGenerator.GetInt32(125) == 1)
				{
					SwitchToBehaviourStateServerRpc(4);
					PlayEuhEuhClientRpc();
				}
				break;
			case 4:
				SetTargetPlayerClientRpc(FindPlayerToTarget().actualClientId);
				if (RandomNumberGenerator.GetInt32(100) <= 1)
				{
					SpawnNewFreddle();
				}
				if (RandomNumberGenerator.GetInt32(100) == 1)
				{
					SwitchToBehaviourStateServerRpc(3);
					PlayEuhEuhClientRpc();
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				CheckIfPlayerHittableServerRpc();
				break;
			case 2:
			case 5:
			case 6:
				break;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwitchToBehaviourStateServerRpc(int x)
		{
			//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)
			//IL_00ce: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1772070295u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, x);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1772070295u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SwitchToBehaviourStateClientRpc(x);
				}
			}
		}

		[ClientRpc]
		public void SwitchToBehaviourStateClientRpc(int x)
		{
			//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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(439919163u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, x);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 439919163u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(x);
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 0f;
				wasRunning = false;
				break;
			case 1:
				base.agent.speed = 0f;
				((Collider)ScanNode).enabled = true;
				((Collider)EnemyCollider).enabled = true;
				wasRunning = false;
				PlayLullabyClientRpc();
				break;
			case 2:
				ActivateAllFreddlesClientRpc();
				if (wasRunning)
				{
					base.agent.speed = 5f;
				}
				else
				{
					base.agent.speed = 0f;
				}
				PlayAnimationServerRpc("Attack");
				break;
			case 3:
				base.agent.speed = 4f;
				PlayAnimationServerRpc("Walking");
				ActivateAllFreddlesClientRpc();
				wasRunning = false;
				lastBeforeAttack = 3;
				break;
			case 4:
				ActivateAllFreddlesClientRpc();
				base.agent.speed = 7f;
				PlayAnimationServerRpc("Running");
				wasRunning = true;
				lastBeforeAttack = 4;
				break;
			case 5:
				ActivateAllFreddlesClientRpc();
				base.agent.speed = 0f;
				PlayAnimationServerRpc("Roar");
				PerformRoarClientRpc();
				wasRunning = false;
				break;
			case 6:
				break;
			}
		}

		[ClientRpc]
		private void PlayLullabyClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1628094442u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1628094442u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					spawning.Play();
				}
			}
		}

		public int GetNumberOfFreddles(bool onlyArrived)
		{
			FreddlesAi[] array = Object.FindObjectsOfType<FreddlesAi>();
			if (!onlyArrived)
			{
				return array.Length;
			}
			int num = 0;
			FreddlesAi[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				if (array2[i].arrived)
				{
					num++;
				}
			}
			return num;
		}

		public FreddlesAi[] GetAllFreddles(bool onlyArrived)
		{
			FreddlesAi[] array = Object.FindObjectsOfType<FreddlesAi>();
			if (!onlyArrived)
			{
				return array;
			}
			List<FreddlesAi> list = new List<FreddlesAi>();
			FreddlesAi[] array2 = array;
			foreach (FreddlesAi freddlesAi in array2)
			{
				if (freddlesAi.arrived)
				{
					list.Add(freddlesAi);
				}
			}
			return list.ToArray();
		}

		public void SpawnNewFreddle()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned || (Object)(object)RoundManager.Instance == (Object)null || (Object)(object)RoundManager.Instance.currentLevel == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.shipBounds == (Object)null)
			{
				return;
			}
			List<SpawnableEnemyWithRarity> outsideEnemies = RoundManager.Instance.currentLevel.OutsideEnemies;
			if (outsideEnemies != null)
			{
				int num = outsideEnemies.FindIndex((SpawnableEnemyWithRarity x) => x != null && (Object)(object)x.enemyType != (Object)null && x.enemyType.enemyName == "Freddles");
				if (num < 0)
				{
					Debug.LogWarning((object)"[NightmareFreddy-v81] Freddles nao esta na OutsideEnemies desta lua; spawn cancelado.");
					return;
				}
				EnemyType enemyType = outsideEnemies[num].enemyType;
				Vector3 val = StartOfRound.Instance.shipBounds.ClosestPointOnBounds(((Component)this).transform.position);
				Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(val, 30f, default(NavMeshHit));
				RoundManager.Instance.SpawnEnemyGameObject(randomNavMeshPositionInRadius, 0f, num, enemyType);
				Debug.Log((object)("[NightmareFreddy-v81] Spawn de Freddle requisitado pelo servidor (id externo " + num + ")."));
			}
		}

		private PlayerControllerB FindPlayerToTarget()
		{
			//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)
			//IL_0033: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)StartOfRound.Instance.shipBounds).transform.position;
			PlayerControllerB result = RoundManager.Instance.playersManager.allPlayerScripts[0];
			float num = 0f;
			Vector3 position2 = ((Component)this).transform.position;
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.isPlayerControlled && !val.isPlayerDead && Vector3.Distance(((Component)val).transform.position, position2) + Vector3.Distance(position2, position) > num)
				{
					result = ((Component)val).GetComponent<PlayerControllerB>();
				}
			}
			return result;
		}

		[ClientRpc]
		private void PerformRoarClientRpc()
		{
			//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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(108499369u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 108499369u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (val3.isPlayerControlled && !val3.isPlayerDead && Vector3.Distance(((Component)this).transform.position, ((Component)val3).transform.position) < radiusRoar)
				{
					PushingPlayer(val3);
				}
			}
		}

		public void PushingPlayer(PlayerControllerB player)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0069: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			player.DamagePlayer(5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position;
			val.y = Mathf.Max(0f, val.y);
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = -val * forceRoar;
			player.externalForces += val2;
			player.externalForces += Vector3.up * forceRoar / 2f;
		}

		private IEnumerator EnableKninematicPlayer(int i, Rigidbody rb)
		{
			yield return (object)new WaitForSeconds(3f);
			rb.isKinematic = true;
		}

		private IEnumerator TransitionMaterial(bool manifest, float time)
		{
			float elapsedTime = 0f;
			float startValue = endoSkeleton.GetFloat("_Dissolve");
			float targetValue = (manifest ? 2f : 0f);
			yield return null;
			while (elapsedTime < time)
			{
				float x = Mathf.Lerp(startValue, targetValue, elapsedTime / time);
				ModifyMaterialClientRpc(x);
				elapsedTime += Time.unscaledDeltaTime;
				yield return null;
			}
			ModifyMaterialClientRpc(targetValue);
		}

		[ClientRpc]
		public void ModifyMaterialClientRpc(float x)
		{
			//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)
			//IL_00dc: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2019128939u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref x, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2019128939u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (x < 1.01f && x >= 0f)
			{
				endoSkeleton.SetFloat("_Dissolve", 1f - x);
				endoSkeleton.SetFloat("_Strenght", 0f);
				((Renderer)FreddyRenderer).enabled = true;
				if (x == 0f)
				{
					((Renderer)FreddyRenderer).enabled = false;
				}
				else
				{
					((Renderer)FreddyRenderer).enabled = true;
				}
			}
			if (x > 1f && x <= 2f)
			{
				float num = x - 1f;
				exoSkeleton.SetFloat("_Dissolve", 1f - num);
				if (x == 2f)
				{
					endoSkeleton.SetFloat("_Strenght", 5f);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CheckIfPlayerHittableServerRpc()
		{
			//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)
			//IL_00c1: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(151065608u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 151065608u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					CheckIfPlayerHittableClientRpc();
				}
			}
		}

		[ClientRpc]
		public void CheckIfPlayerHittableClientRpc()
		{
			//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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3398053304u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3398053304u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if ((Object)(object)((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false) != (Object)null)
				{
					SwitchToBehaviourStateServerRpc(2);
				}
			}
		}

		public void SwingAttack()
		{
			SwingAttackHitServerRpc(switchState: true);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwingAttackHitServerRpc(bool switchState)
		{
			//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)
			//IL_00dc: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3288863240u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref switchState, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3288863240u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SwingAttackHitClientRpc(switchState);
				}
			}
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc(bool switchState)
		{
			//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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2160548281u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref switchState, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2160548281u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			hitting.Play();
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length != 0)
			{
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
					if ((Object)(object)val4 != (Object)null && (Object)(object)val4 == (Object)(object)RoundManager.Instance.playersManager.localPlayerController)
					{
						val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
						PushingPlayer(val4);
						PlayEuhEuhClientRpc();
						break;
					}
				}
			}
			SwitchToBehaviourStateServerRpc(lastBeforeAttack);
		}

		[ClientRpc]
		public void ActivateAllFreddlesClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(933376120u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 933376120u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				FreddlesAi[] allFreddles = GetAllFreddles(onlyArrived: false);
				for (int i = 0; i < allFreddles.Length; i++)
				{
					allFreddles[i].ActivateDangerousMod();
				}
			}
		}

		[ClientRpc]
		public void OpenShipDoorsClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2633927549u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2633927549u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Object.FindObjectOfType<HangarShipDoor>().doorPower = 0f;
				}
			}
		}

		public void PlayFootStepSounds()
		{
			footstep.Play();
		}

		[ClientRpc]
		public void PlayRandomGigglesClientRpc(int x)
		{
			//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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3363642111u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, x);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3363642111u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					scream.PlayOneShot(gigles[x]);
				}
			}
		}

		public void AnimationScreamEnd()
		{
			((Renderer)Sphere).enabled = false;
			SwitchToBehaviourStateServerRpc(3);
			ActivateAllFreddlesClientRpc();
		}

		public void Logger(string log)
		{
			Debug.Log((object)("[NightmareFreddy][Freddy] ~ " + log));
		}

		[ClientRpc]
		public void PlayEuhEuhClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1229366648u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1229366648u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.creatureVoice.PlayOneShot(gigles[RandomNumberGenerator.GetInt32(3)]);
				}
			}
		}

		[ClientRpc]
		public void ScreamClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2967553296u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2967553296u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					scream.Play();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayAnimationServerRpc(string x)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1904893732u, val2, (RpcDelivery)0);
				bool flag = x != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(x, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1904893732u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayAnimationClientRpc(x);
			}
		}

		[ClientRpc]
		public void PlayAnimationClientRpc(string x)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3804239045u, val2, (RpcDelivery)0);
				bool flag = x != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(x, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3804239045u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetTrigger(x);
			}
		}

		public void StartRoar()
		{
			((Renderer)Sphere).enabled = true;
			ScreamClientRpc();
		}

		[ClientRpc]
		public void SetTargetPlayerClientRpc(ulong clientId)
		{
			//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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3678980720u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clientId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3678980720u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (val3.actualClientId == clientId)
				{
					base.targetPlayer = val3;
					break;
				}
			}
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			endoSkeleton.SetFloat("_Dissolve", 1f);
			endoSkeleton.SetFloat("_Strenght", 0f);
			exoSkeleton.SetFloat("_Dissolve", 1f);
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1772070295u, new RpcReceiveHandler(__rpc_handler_1772070295), "SwitchToBehaviourStateServerRpc");
			((NetworkBehaviour)this).__registerRpc(439919163u, new RpcReceiveHandler(__rpc_handler_439919163), "SwitchToBehaviourStateClientRpc");
			((NetworkBehaviour)this).__registerRpc(1628094442u, new RpcReceiveHandler(__rpc_handler_1628094442), "PlayLullabyClientRpc");
			((NetworkBehaviour)this).__registerRpc(108499369u, new RpcReceiveHandler(__rpc_handler_108499369), "PerformRoarClientRpc");
			((NetworkBehaviour)this).__registerRpc(2019128939u, new RpcReceiveHandler(__rpc_handler_2019128939), "ModifyMaterialClientRpc");
			((NetworkBehaviour)this).__registerRpc(151065608u, new RpcReceiveHandler(__rpc_handler_151065608), "CheckIfPlayerHittableServerRpc");
			((NetworkBehaviour)this).__registerRpc(3398053304u, new RpcReceiveHandler(__rpc_handler_3398053304), "CheckIfPlayerHittableClientRpc");
			((NetworkBehaviour)this).__registerRpc(3288863240u, new RpcReceiveHandler(__rpc_handler_3288863240), "SwingAttackHitServerRpc");
			((NetworkBehaviour)this).__registerRpc(2160548281u, new RpcReceiveHandler(__rpc_handler_2160548281), "SwingAttackHitClientRpc");
			((NetworkBehaviour)this).__registerRpc(933376120u, new RpcReceiveHandler(__rpc_handler_933376120), "ActivateAllFreddlesClientRpc");
			((NetworkBehaviour)this).__registerRpc(2633927549u, new RpcReceiveHandler(__rpc_handler_2633927549), "OpenShipDoorsClientRpc");
			((NetworkBehaviour)this).__registerRpc(3363642111u, new RpcReceiveHandler(__rpc_handler_3363642111), "PlayRandomGigglesClientRpc");
			((NetworkBehaviour)this).__registerRpc(1229366648u, new RpcReceiveHandler(__rpc_handler_1229366648), "PlayEuhEuhClientRpc");
			((NetworkBehaviour)this).__registerRpc(2967553296u, new RpcReceiveHandler(__rpc_handler_2967553296), "ScreamClientRpc");
			((NetworkBehaviour)this).__registerRpc(1904893732u, new RpcReceiveHandler(__rpc_handler_1904893732), "PlayAnimationServerRpc");
			((NetworkBehaviour)this).__registerRpc(3804239045u, new RpcReceiveHandler(__rpc_handler_3804239045), "PlayAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(3678980720u, new RpcReceiveHandler(__rpc_handler_3678980720), "SetTargetPlayerClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_1772070295(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 x = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref x);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).SwitchToBehaviourStateServerRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_439919163(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 x = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref x);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).SwitchToBehaviourStateClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1628094442(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;
				((NightmareFreddyAi)(object)target).PlayLullabyClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_108499369(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;
				((NightmareFreddyAi)(object)target).PerformRoarClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2019128939(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)
			{
				float x = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref x, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).ModifyMaterialClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_151065608(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;
				((NightmareFreddyAi)(object)target).CheckIfPlayerHittableServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3398053304(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;
				((NightmareFreddyAi)(object)target).CheckIfPlayerHittableClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3288863240(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 switchState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref switchState, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).SwingAttackHitServerRpc(switchState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2160548281(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 switchState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref switchState, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).SwingAttackHitClientRpc(switchState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_933376120(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;
				((NightmareFreddyAi)(object)target).ActivateAllFreddlesClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2633927549(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;
				((NightmareFreddyAi)(object)target).OpenShipDoorsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3363642111(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 x = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref x);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).PlayRandomGigglesClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1229366648(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;
				((NightmareFreddyAi)(object)target).PlayEuhEuhClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2967553296(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;
				((NightmareFreddyAi)(object)target).ScreamClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1904893732(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string x = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref x, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).PlayAnimationServerRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3804239045(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string x = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref x, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).PlayAnimationClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3678980720(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)
			{
				ulong targetPlayerClientRpc = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetPlayerClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NightmareFreddyAi)(object)target).SetTargetPlayerClientRpc(targetPlayerClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NightmareFreddyAi";
		}
	}
}
namespace NightmareFreddy.Freddles
{
	public class FreddlesAi : EnemyAI
	{
		private enum State
		{
			Running,
			LookedAt,
			Idle,
			Burning,
			Aggressive,
			TrueBurn,
			None
		}

		[Header("Material Handler!")]
		public Material endoMaterial;

		private Material copiedEndoMaterial;

		public Material coverMaterial;

		private Material copiedCoverMaterial;

		public SkinnedMeshRenderer FreddlesRenderer;

		[Header("Audio")]
		public AudioClip glitchProj;

		public AudioClip paranoidStep;

		[NonSerialized]
		public Vector3 destination;

		[NonSerialized]
		public bool arrived;

		private bool sittingOrLying;

		private int burnTick;

		private int currentBurnProgress;

		private bool canCollide;

		public void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			if ((Object)(object)endoMaterial != (Object)null)
			{
				copiedEndoMaterial = new Material(endoMaterial);
			}
			if ((Object)(object)coverMaterial != (Object)null)
			{
				copiedCoverMaterial = new Material(coverMaterial);
			}
			((Renderer)FreddlesRenderer).materials = (Material[])(object)new Material[2] { copiedCoverMaterial, copiedEndoMaterial };
		}

		public override void Start()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			int num = 0;
			arrived = false;
			destination = Vector3.zero;
			while (destination == Vector3.zero && num < 10)
			{
				num++;
				destination = GetRandomPointInCollider(StartOfRound.Instance.shipInnerRoomBounds);
				_ = destination;
				NavMeshPath val = new NavMeshPath();
				NavMesh.CalculatePath(((Component)this).transform.position, destination, -1, val);
				if ((int)val.status != 0)
				{
					destination = Vector3.zero;
				}
			}
			if (num == 10 && ((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(DestroySequence(0));
			}
			if (RandomNumberGenerator.GetInt32(2) == 0)
			{
				sittingOrLying = true;
			}
			else
			{
				sittingOrLying = false;
			}
			((MonoBehaviour)this).StartCoroutine(InitializeFreddleWhenNetworkReady());
			burnTick = RandomNumberGenerator.GetInt32(10, 20);
			currentBurnProgress = 0;
			if (((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(DestroySequence(30));
			}
		}

		private IEnumerator InitializeFreddleWhenNetworkReady()
		{
			while (!((NetworkBehaviour)this).IsSpawned)
			{
				yield return null;
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				PlayAnimationClientRpc("Sit", sittingOrLying);
				SwitchCurrentBehaviourClientRpc(0);
				Debug.Log((object)"[NightmareFreddy-v81] Freddle: RPCs de inicializacao enviados apos NetworkSpawn.");
			}
		}

		public static Vector3 GetRandomPointInCollider(Collider collider)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(new Vector3(Random.Range(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.x), Random.Range(((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.y), Random.Range(((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.z)), ref val, 5f, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			return ((Bounds)(ref bounds)).center;
		}

		public override void DoAIInterval()
		{
			//IL_006d: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.isStopped = false;
				if (base.creatureAnimator.GetBool("Idle"))
				{
					PlayAnimationClientRpc("Idle", value: false);
				}
				((EnemyAI)this).SetDestinationToPosition(destination, false);
				if (Vector3.Distance(((Component)this).transform.position, destination) < 1f)
				{
					ModifyMaterialClientRpc(0f);
					SwitchCurrentBehaviourClientRpc(2);
				}
				if (CheckIfLookedAt())
				{
					SwitchCurrentBehaviourClientRpc(1);
				}
				break;
			case 1:
				base.agent.ResetPath();
				base.agent.isStopped = true;
				if (!base.creatureAnimator.GetBool("Idle"))
				{
					PlayAnimationClientRpc("Idle", value: true);
				}
				if (copiedEndoMaterial.GetFloat("_Dissolve") == 0f)
				{
					ModifyMaterialClientRpc(0f);
					if (((NetworkBehaviour)this).IsHost)
					{
						PlayGlitchClientRpc(x: false);
					}
				}
				if (currentBurnProgress > 0)
				{
					currentBurnProgress--;
					ModifyMaterialBasedOnBurnProgress();
				}
				if (CheckIfFlashedAt())
				{
					if (((NetworkBehaviour)this).IsHost)
					{
						PlayGlitchClientRpc(x: true);
					}
					SwitchCurrentBehaviourClientRpc(5);
					base.agent.ResetPath();
				}
				if (!CheckIfLookedAt())
				{
					SwitchCurrentBehaviourClientRpc(0);
				}
				break;
			case 2:
				if (!arrived)
				{
					Debug.Log((object)"[NightmareFreddy-v81] Freddle chegou a nave.");
				}
				arrived = true;
				base.agent.isStopped = true;
				if (((NetworkBehaviour)this).IsHost && RandomNumberGenerator.GetInt32(100) <= 2)
				{
					PlayFootStepNoiseClientRpc();
				}
				if (!base.creatureAnimator.GetBool("Idle"))
				{
					PlayAnimationClientRpc("Idle", value: true);
				}
				if (((NetworkBehaviour)this).IsHost && RandomNumberGenerator.GetInt32(100) == 0 && !CheckIfLookedAt())
				{
					PlayFootStepNoiseClientRpc();
				}
				if (copiedEndoMaterial.GetFloat("_Dissolve") == 0f)
				{
					ModifyMaterialClientRpc(0f);
					if (((NetworkBehaviour)this).IsHost)
					{
						PlayGlitchClientRpc(x: false);
					}
				}
				if (currentBurnProgress > 0)
				{
					currentBurnProgress--;
					ModifyMaterialBasedOnBurnProgress();
				}
				if (CheckIfFlashedAt())
				{
					if (((NetworkBehaviour)this).IsHost)
					{
						PlayGlitchClientRpc(x: true);
					}
					SwitchCurrentBehaviourClientRpc(3);
				}
				break;
			case 3:
				base.agent.isStopped = true;
				if (CheckIfFlashedAt())
				{
					if (!base.creatureAnimator.GetBool("Burning"))
					{
						PlayAnimationClientRpc("Burning", value: true);
					}
					if (currentBurnProgress < burnTick)
					{
						currentBurnProgress++;
						ModifyMaterialBasedOnBurnProgress();
					}
					else
					{
						SwitchCurrentBehaviourClientRpc(6);
						((MonoBehaviour)this).StartCoroutine(DestroySequence(3));
					}
				}
				else if (arrived)
				{
					SwitchCurrentBehaviourClientRpc(2);
				}
				else
				{
					SwitchCurrentBehaviourClientRpc(1);
				}
				break;
			case 4:
				base.agent.isStopped = false;
				if (CheckIfFlashedAt())
				{
					if (((NetworkBehaviour)this).IsHost)
					{
						PlayGlitchClientRpc(x: true);
					}
					PlayAnimationClientRpc("Idle", value: true);
					SwitchCurrentBehaviourClientRpc(5);
					base.agent.ResetPath();
					break;
				}
				if (base.creatureAnimator.GetBool("Idle"))
				{
					PlayAnimationClientRpc("Idle", value: false);
				}
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f, false, false, true);
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
					SwingAttackHitClientRpc();
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(destination, false);
				}
				ModifyMaterialBasedOnBurnProgress();
				break;
			case 5:
				base.agent.isStopped = true;
				if (!base.creatureAnimator.GetBool("Burning"))
				{
					PlayAnimationClientRpc("Burning", value: true);
				}
				if (currentBurnProgress < burnTick)
				{
					currentBurnProgress++;
					ModifyMaterialBasedOnBurnProgress();
				}
				else
				{
					SwitchCurrentBehaviourClientRpc(6);
					((MonoBehaviour)this).StartCoroutine(DestroySequence(3));
				}
				break;
			case 6:
				break;
			}
		}

		public bool CheckIfLookedAt()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				if (allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f, -1))
				{
					return true;
				}
			}
			return false;
		}

		public bool CheckIfFlashedAt()
		{
			//IL_0022: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!val.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f, -1))
				{
					continue;
				}
				GrabbableObject[] itemSlots = val.ItemSlots;
				foreach (GrabbableObject val2 in itemSlots)
				{
					if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject.GetComponent<FlashlightItem>() == (Object)null) && ((GrabbableObject)((Component)val2).gameObject.GetComponent<FlashlightItem>()).isBeingUsed && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 6f && val.LineOfSightToPositionAngle(((Component)this).transform.position, 60, -1f, -1) < 20f)
					{
						return true;
					}
				}
			}
			return false;
		}

		public void ModifyMaterialBasedOnBurnProgress()
		{
			float x = Mathf.Clamp01((float)currentBurnProgress / (float)burnTick);
			ModifyMaterialClientRpc(x);
			if (currentBurnProgress == 0)
			{
				PlayAnimationClientRpc("Burning", value: false);
			}
		}

		[ClientRpc]
		public void ModifyMaterialClientRpc(float x)
		{
			//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)
			//IL_00dc: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(487965023u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref x, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 487965023u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (x < 1.01f && x >= 0f)
				{
					copiedEndoMaterial.SetFloat("_Dissolve", x);
					copiedCoverMaterial.SetFloat("Vector1_FEFF47F1", x);
				}
			}
		}

		[ClientRpc]
		public void SwitchCurrentBehaviourClientRpc(int x)
		{
			//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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(949847044u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, x);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 949847044u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.currentBehaviourStateIndex = x;
				}
			}
		}

		public void PlayFootStep()
		{
			base.creatureSFX.Play();
		}

		[ClientRpc]
		public void PlayFootStepNoiseClientRpc()
		{
			//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)
			//IL_00c1: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(513768869u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 513768869u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.creatureSFX.PlayOneShot(paranoidStep);
				}
			}
		}

		[ClientRpc]
		public void PlayGlitchClientRpc(bool x)
		{
			//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)
			//IL_00dc: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(520196285u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref x, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 520196285u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (x)
			{
				if (!base.creatureVoice.isPlaying)
				{
					base.creatureVoice.Play();
				}
			}
			else
			{
				base.creatureVoice.Stop();
			}
		}

		private IEnumerator DestroySequence(int x)
		{
			yield return (object)new WaitForSeconds((float)x);
			if (base.currentBehaviourStateIndex != 2)
			{
				((EnemyAI)this).KillEnemyClientRpc(true);
			}
		}

		public void ActivateDangerousMod()
		{
			SwitchCurrentBehaviourClientRpc(4);
			canCollide = true;
			((MonoBehaviour)this).StopCoroutine(DestroySequence(30));
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc()
		{
			//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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2306784073u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2306784073u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!canCollide)
			{
				return;
			}
			int num = 8;