Decompiled source of NightmareFreddy v1.1.2

plugins/NightmareFreddy/NightmareFreddy.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.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 LethalBestiary.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: AssemblyCompany("NightmareFreddy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Nightmare Freddy from the FNAF franchise")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+d80cf10eaeda19f689e72876d2f6a35f2e1c0fd6")]
[assembly: AssemblyProduct("NightmareFreddy")]
[assembly: AssemblyTitle("NightmareFreddy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExampleEnemy
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NightmareFreddy";

		public const string PLUGIN_NAME = "NightmareFreddy";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace NightmareFreddy.Plugin
{
	[BepInPlugin("Xilef992.NightmareFreddy", "NightmareFreddy", "1.0.0")]
	[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);
			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, FreddyConfiguration.RARITY_SPAWN.Value, (LevelTypes)(-1), (SpawnType)2, 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, FreddyConfiguration.RARITY_SPAWN.Value, (LevelTypes)(-1), (SpawnType)2, 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.0.0";
	}
}
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(TransitionMaterial(manifest: false, 0f));
			SwitchToBehaviourStateClientRpc(0);
		}

		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_0010: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (Vector3.Distance(((Component)Object.FindObjectOfType<HangarShipDoor>()).transform.position, ((Component)this).transform.position) < 5f)
			{
				OpenShipDoorsClientRpc();
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				Debug.Log((object)GetNumberOfFreddles(onlyArrived: true));
				if (GetNumberOfFreddles(onlyArrived: true) >= global::NightmareFreddy.Plugin.Plugin.FreddyConfiguration.NUMBER_FREDDLES_PHASE_2.Value)
				{
					spawningMaterialChanges = ((MonoBehaviour)this).StartCoroutine(TransitionMaterial(manifest: true, 10f));
					SwitchToBehaviourStateServerRpc(1);
					PlayEuhEuhClientRpc();
				}
				else if (RandomNumberGenerator.GetInt32(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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1772070295u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, x);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1772070295u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(439919163u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, x);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 439919163u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1628094442u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1628094442u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			list.AddRange(RoundManager.Instance.currentLevel.Enemies);
			list.AddRange(RoundManager.Instance.currentLevel.OutsideEnemies);
			SpawnableEnemyWithRarity val = list.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("Freddles"));
			RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.GetRandomNavMeshPositionInRadius(StartOfRound.Instance.shipBounds.ClosestPointOnBounds(((Component)this).transform.position), 30f, default(NavMeshHit)), 0f, RoundManager.Instance.currentLevel.OutsideEnemies.IndexOf(val), val.enemyType);
			Debug.Log((object)"Finished spawning enemy!");
		}

		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_00e9: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(108499369u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 108499369u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2019128939u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref x, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2019128939u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(151065608u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 151065608u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3398053304u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3398053304u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3288863240u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref switchState, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3288863240u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					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_00e9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2160548281u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref switchState, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2160548281u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(933376120u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 933376120u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2633927549u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2633927549u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3363642111u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, x);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3363642111u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1229366648u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1229366648u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2967553296u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2967553296u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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_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 val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1904893732u, val, (RpcDelivery)0);
				bool flag = x != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(x, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1904893732u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				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_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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3804239045u, val, (RpcDelivery)0);
				bool flag = x != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(x, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3804239045u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3678980720u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3678980720u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NightmareFreddyAi()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1772070295u, new RpcReceiveHandler(__rpc_handler_1772070295));
			NetworkManager.__rpc_func_table.Add(439919163u, new RpcReceiveHandler(__rpc_handler_439919163));
			NetworkManager.__rpc_func_table.Add(1628094442u, new RpcReceiveHandler(__rpc_handler_1628094442));
			NetworkManager.__rpc_func_table.Add(108499369u, new RpcReceiveHandler(__rpc_handler_108499369));
			NetworkManager.__rpc_func_table.Add(2019128939u, new RpcReceiveHandler(__rpc_handler_2019128939));
			NetworkManager.__rpc_func_table.Add(151065608u, new RpcReceiveHandler(__rpc_handler_151065608));
			NetworkManager.__rpc_func_table.Add(3398053304u, new RpcReceiveHandler(__rpc_handler_3398053304));
			NetworkManager.__rpc_func_table.Add(3288863240u, new RpcReceiveHandler(__rpc_handler_3288863240));
			NetworkManager.__rpc_func_table.Add(2160548281u, new RpcReceiveHandler(__rpc_handler_2160548281));
			NetworkManager.__rpc_func_table.Add(933376120u, new RpcReceiveHandler(__rpc_handler_933376120));
			NetworkManager.__rpc_func_table.Add(2633927549u, new RpcReceiveHandler(__rpc_handler_2633927549));
			NetworkManager.__rpc_func_table.Add(3363642111u, new RpcReceiveHandler(__rpc_handler_3363642111));
			NetworkManager.__rpc_func_table.Add(1229366648u, new RpcReceiveHandler(__rpc_handler_1229366648));
			NetworkManager.__rpc_func_table.Add(2967553296u, new RpcReceiveHandler(__rpc_handler_2967553296));
			NetworkManager.__rpc_func_table.Add(1904893732u, new RpcReceiveHandler(__rpc_handler_1904893732));
			NetworkManager.__rpc_func_table.Add(3804239045u, new RpcReceiveHandler(__rpc_handler_3804239045));
			NetworkManager.__rpc_func_table.Add(3678980720u, new RpcReceiveHandler(__rpc_handler_3678980720));
		}

		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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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)2;
				((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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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;
					break;
				}
			}
			if (num == 10)
			{
				((MonoBehaviour)this).StartCoroutine(DestroySequence(0));
			}
			if (RandomNumberGenerator.GetInt32(2) == 0)
			{
				sittingOrLying = true;
			}
			else
			{
				sittingOrLying = false;
			}
			PlayAnimationClientRpc("Sit", sittingOrLying);
			SwitchCurrentBehaviourClientRpc(0);
			burnTick = RandomNumberGenerator.GetInt32(10, 20);
			currentBurnProgress = 0;
			((MonoBehaviour)this).StartCoroutine(DestroySequence(30));
		}

		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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			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:
				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);
				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))
				{
					return true;
				}
			}
			return false;
		}

		public bool CheckIfFlashedAt()
		{
			//IL_0022: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!val.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f))
				{
					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) < 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(487965023u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref x, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 487965023u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(949847044u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, x);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 949847044u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(513768869u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 513768869u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(520196285u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref x, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 520196285u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			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_00d0: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2306784073u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2306784073u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !canCollide)
			{
				return;
			}
			int num = 8;
			Transform transform = ((Component)this).transform;
			Collider[] array = Physics.OverlapBox(transform.position, transform.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null)
				{
					val4.DamagePlayer(global::NightmareFreddy.Plugin.Plugin.FreddyConfiguration.DAMAGE_FREDDLES.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					PlayAnimationClientRpc("Idle", value: true);
					SwitchCurrentBehaviourClientRpc(5);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (!base.isEnemyDead)
			{
				base.enemyHP -= force;
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					SwitchCurrentBehaviourClientRpc(5);
				}
			}
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_FreddlesAi()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(487965023u, new RpcReceiveHandler(__rpc_handler_487965023));
			NetworkManager.__rpc_func_table.Add(949847044u, new RpcReceiveHandler(__rpc_handler_949847044));
			NetworkManager.__rpc_func_table.Add(513768869u, new RpcReceiveHandler(__rpc_handler_513768869));
			NetworkManager.__rpc_func_table.Add(520196285u, new RpcReceiveHandler(__rpc_handler_520196285));
			NetworkManager.__rpc_func_table.Add(2306784073u, new RpcReceiveHandler(__rpc_handler_2306784073));
			NetworkManager.__rpc_func_table.Add(78470382u, new RpcReceiveHandler(__rpc_handler_78470382));
		}

		private static void __rpc_handler_487965023(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)2;
				((FreddlesAi)(object)target).ModifyMaterialClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_949847044(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)2;
				((FreddlesAi)(object)target).SwitchCurrentBehaviourClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_513768869(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((FreddlesAi)(object)target).PlayFootStepNoiseClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_520196285(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 x = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref x, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((FreddlesAi)(object)target).PlayGlitchClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2306784073(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((FreddlesAi)(object)target).SwingAttackHitClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_78470382(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_0067: 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_009a: 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 name = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref name, false);
				}
				bool value = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref value, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((FreddlesAi)(object)target).PlayAnimationClientRpc(name, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "FreddlesAi";
		}
	}
}
namespace NightmareFreddy.Configurations
{
	public class Config : SyncedInstance<Config>
	{
		public