Decompiled source of NightmareFoxyV81 v1.2.0

plugins/NightmareFoxy/NightmareFoxy.dll

Decompiled 12 hours 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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NightmareFoxy.NetcodePatcher;
using NightmareFoxyLC.Configurations;
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("NightmareFoxy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Nightmare Foxy from FNAF 4 for Lethal Company")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("NightmareFoxy")]
[assembly: AssemblyTitle("NightmareFoxy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NightmareFoxyLC
{
	public class FoxyAi : EnemyAI
	{
		private enum State
		{
			Down,
			Standing,
			ChargePose,
			Running,
			Seen,
			Jumping
		}

		public AudioSource howlingAudioSRC;

		public ParticleSystem footSpeed;

		public Light eyesLight;

		public AudioClip portalSFX;

		public AudioClip deactivate;

		public AudioClip activate;

		public BoxCollider foxyCollider;

		[Header("Engine Stuff")]
		public AudioSource engine;

		public AudioClip idle1;

		public AudioClip idle2;

		[Header("Whenseen")]
		public AudioClip fallOnKnee;

		public AudioClip fallOnBody;

		public AudioClip fallOnKneeVariant;

		public AudioClip destroyDoor;

		public AudioClip train;

		[Header("Footstep")]
		public AudioSource footStepAudio;

		public AudioClip footStep1;

		public AudioClip footStep2;

		public AudioClip footStep3;

		public AudioClip footStep4;

		[Header("Kill Animation")]
		public AudioClip[] killAnimationSound;

		public AudioClip[] howlAudioSounds;

		public Transform killZone;

		public Material foxEyes;

		private int generatedNumber;

		private bool justSwitchedBehaviour;

		private float timer;

		private bool startedHowling;

		private float duration = 3f;

		private float currentDuration;

		private float oldspeed;

		private PlayerControllerB localPlayer;

		public List<DoorLock> doorLocked;

		private bool stopLooking;

		public override void Start()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			duration = SyncedInstance<Config>.Instance.TIME_TO_SLOW_DOWN.Value;
			foxEyes.SetFloat("_Strenght", 0f);
			base.agent.angularSpeed = 10000f;
			justSwitchedBehaviour = false;
			timer = 0f;
			foxyCollider.size = new Vector3(4.531483f, 21.24057f, 5.783448f);
			base.agent.updateRotation = true;
			localPlayer = RoundManager.Instance.playersManager.localPlayerController;
			howlingAudioSRC.volume = SyncedInstance<Config>.Instance.HOWLING_STRENGHT.Value;
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (justSwitchedBehaviour)
			{
				timer += Time.deltaTime;
				if (timer >= 5f)
				{
					timer = 0f;
					justSwitchedBehaviour = false;
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				if (!justSwitchedBehaviour)
				{
					generatedNumber = RandomNumberGenerator.GetInt32(1, SyncedInstance<Config>.Instance.CHANCE_NEXT_PHASE.Value);
				}
				else
				{
					generatedNumber = 100;
				}
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				footSpeed.Stop();
				engine.Stop();
				base.movingTowardsTargetPlayer = false;
				base.agent.isStopped = true;
				base.agent.ResetPath();
				base.targetPlayer = null;
				base.creatureAnimator.speed = 1f;
				footSpeed.Stop();
				if (((NetworkBehaviour)this).IsServer && generatedNumber <= 1)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					engine.PlayOneShot(portalSFX);
				}
				break;
			case 1:
				footSpeed.Stop();
				foxyCollider.size = new Vector3(foxyCollider.size.x, foxyCollider.size.y, 6.619311f);
				foxyCollider.center = new Vector3(foxyCollider.center.x, foxyCollider.center.y, 0.8878318f);
				base.creatureAnimator.speed = 1f;
				base.agent.isStopped = true;
				base.agent.ResetPath();
				if (generatedNumber <= 1)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					((MonoBehaviour)this).StartCoroutine(EyesManager(opening: true));
				}
				break;
			case 2:
				if (!engine.isPlaying)
				{
					engine.clip = idle1;
					engine.Play(3uL);
					engine.loop = true;
				}
				base.creatureAnimator.speed = 1f;
				base.agent.isStopped = true;
				base.agent.ResetPath();
				if (generatedNumber <= 2 && !startedHowling)
				{
					engine.clip = idle2;
					base.creatureAnimator.speed = 0f;
					base.agent.speed = 0f;
					engine.Play();
					startedHowling = true;
					if (((NetworkBehaviour)this).IsServer)
					{
						((MonoBehaviour)this).StartCoroutine(CloseHunt(RandomNumberGenerator.GetInt32(SyncedInstance<Config>.Instance.MIN_AMOUNT_HOWL.Value, SyncedInstance<Config>.Instance.MAX_AMOUNT_HOWL.Value)));
					}
				}
				break;
			case 3:
				foxyCollider.size = new Vector3(foxyCollider.size.x, foxyCollider.size.y, 30f);
				foxyCollider.center = new Vector3(foxyCollider.center.x, foxyCollider.center.y, 12.56404f);
				if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isInsideFactory)
				{
					if (((NetworkBehaviour)this).IsServer)
					{
						FetchTarget();
					}
					if ((Object)(object)base.targetPlayer == (Object)null)
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(4);
						((MonoBehaviour)this).StartCoroutine(EyesManager(opening: false));
						break;
					}
				}
				if (!base.targetPlayer.isInsideFactory)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				if (base.targetPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f, -1) || !base.targetPlayer.isInsideFactory || !base.targetPlayer.isPlayerControlled || base.targetPlayer.isPlayerDead)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(4);
					((MonoBehaviour)this).StartCoroutine(EyesManager(opening: false));
					break;
				}
				base.movingTowardsTargetPlayer = true;
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				if (base.agent.speed <= SyncedInstance<Config>.Instance.MAX_SPEED.Value)
				{
					NavMeshAgent agent = base.agent;
					agent.speed += 0.1f * SyncedInstance<Config>.Instance.SPEED_MULTIPLIER.Value;
					Animator creatureAnimator = base.creatureAnimator;
					creatureAnimator.speed += 0.02f * SyncedInstance<Config>.Instance.SPEED_MULTIPLIER.Value;
				}
				else
				{
					base.creatureVoice.PlayOneShot(train);
				}
				BreakDoorServerRpc();
				if (!footSpeed.isPlaying)
				{
					footSpeed.Play();
				}
				currentDuration = 0f;
				break;
			case 4:
			{
				Vector3 velocity;
				if (currentDuration < duration)
				{
					float num = currentDuration / duration;
					float speed = Mathf.Lerp(base.agent.speed, 0f, num);
					float speed2 = Mathf.Lerp(base.creatureAnimator.speed, 0f, num);
					base.agent.speed = speed;
					base.creatureAnimator.speed = speed2;
					Transform transform = ((Component)this).transform;
					velocity = base.agent.velocity;
					transform.rotation = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized);
					if (CheckIfFlashedAt())
					{
						currentDuration += Time.deltaTime * SyncedInstance<Config>.Instance.FLASHLIGHT_SLOW_DOWN_MODIFIER.Value;
						if ((double)base.agent.speed >= 0.3)
						{
							NavMeshAgent agent2 = base.agent;
							agent2.speed -= 0.1f * SyncedInstance<Config>.Instance.FLASHLIGHT_SLOW_DOWN_MODIFIER.Value;
						}
					}
					else if ((Object)(object)base.targetPlayer != (Object)null)
					{
						((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
						if (SyncedInstance<Config>.Instance.ACTIVATE_CONSTANT_LOOK.Value)
						{
							if (!base.targetPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f, -1) && base.targetPlayer.isInsideFactory && base.targetPlayer.isPlayerControlled && !base.targetPlayer.isPlayerDead)
							{
								SwitchToBehaviourWithoutEnterStateClientRpc(3);
								((MonoBehaviour)this).StartCoroutine(EyesManager(opening: true));
								break;
							}
							currentDuration += Time.deltaTime;
						}
						else
						{
							currentDuration += Time.deltaTime;
						}
					}
					else
					{
						currentDuration += Time.deltaTime;
					}
				}
				else
				{
					base.agent.speed = 0f;
					base.creatureAnimator.speed = 0f;
				}
				if (base.agent.speed <= 0.1f)
				{
					Transform transform2 = ((Component)this).transform;
					velocity = base.agent.velocity;
					transform2.rotation = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized);
					base.agent.ResetPath();
					base.agent.speed = 0f;
					base.creatureAnimator.speed = 0.8f;
					DoAnimationClientRpc("GotSeen");
					((MonoBehaviour)this).StartCoroutine(EyesManager(opening: false));
					((EnemyAI)this).SwitchToBehaviourClientRpc(5);
					footSpeed.Stop();
					if (((NetworkBehaviour)this).IsServer)
					{
						((MonoBehaviour)this).StartCoroutine(WaitAndGoBackUp(RandomNumberGenerator.GetInt32(10, 30)));
					}
				}
				break;
			}
			default:
				if (((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 5:
				break;
			}
		}

		private IEnumerator CloseHunt(int howling)
		{
			int howlingStore = howling;
			yield return (object)new WaitForSeconds(4f);
			while (howlingStore > 0)
			{
				HowlClientRpc();
				yield return (object)new WaitForSeconds(3f);
				howlingStore--;
			}
			startedHowling = false;
			base.creatureAnimator.speed = 0f;
			base.agent.speed = 0f;
			((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			UnlockAllDoorClientRpc();
		}

		private IEnumerator WaitAndGoBackUp(int x)
		{
			base.movingTowardsTargetPlayer = false;
			base.agent.isStopped = true;
			base.agent.ResetPath();
			base.agent.speed = 0f;
			yield return (object)new WaitForSeconds((float)x);
			DoAnimationClientRpc("FallDown");
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}

		private IEnumerator EyesManager(bool opening)
		{
			float num = (opening ? 2f : 0f);
			float num2 = (opening ? 0f : 2f);
			if (opening)
			{
				engine.PlayOneShot(activate);
			}
			else
			{
				engine.PlayOneShot(deactivate);
			}
			bool flag = true;
			float num3 = 0f;
			while (flag)
			{
				foxEyes.SetFloat("_Strenght", Mathf.Lerp(num2, num, num3 / 10f));
				num3 += Time.deltaTime;
				if (foxEyes.GetFloat("_Strenght") == num)
				{
					break;
				}
			}
			yield break;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val == (Object)null || !val.isPlayerControlled)
			{
				return;
			}
			if ((Object)(object)val == (Object)(object)base.targetPlayer)
			{
				if (3 == base.currentBehaviourStateIndex)
				{
					Debug.Log((object)"Agent has reached the destination!");
					((EnemyAI)this).SwitchToBehaviourClientRpc(5);
					base.agent.speed = 0f;
					((MonoBehaviour)this).StartCoroutine(FoxyKills(base.targetPlayer));
				}
				if (4 == base.currentBehaviourStateIndex)
				{
					if (base.agent.speed >= SyncedInstance<Config>.Instance.MAX_SPEED.Value / (100f / SyncedInstance<Config>.Instance.SPEED_FOXY_KILLS.Value))
					{
						Debug.Log((object)("Agent has reached the destination. Current Speed = " + base.agent.speed));
						((EnemyAI)this).SwitchToBehaviourClientRpc(5);
						base.agent.speed = 0f;
						((MonoBehaviour)this).StartCoroutine(FoxyKills(base.targetPlayer));
					}
					else if (base.agent.speed >= SyncedInstance<Config>.Instance.MAX_SPEED.Value / (100f / SyncedInstance<Config>.Instance.SPEED_FOXY_DAMAGES.Value))
					{
						Debug.Log((object)("Agent has reached the destination. Current speed to low = " + base.agent.speed));
						base.targetPlayer.DamagePlayer(SyncedInstance<Config>.Instance.FOXY_DAMAGES.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
						base.agent.speed = 0f;
					}
				}
			}
			else if (3 == base.currentBehaviourStateIndex)
			{
				if (base.agent.speed > 5f)
				{
					val.DamagePlayer(2, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
			else if (4 == base.currentBehaviourStateIndex && base.agent.speed > 2f)
			{
				val.DamagePlayer(1, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			}
		}

		public void FetchTarget()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0038: 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)
			List<string> list = new List<string>();
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.isInsideFactory)
				{
					NavMeshPath val2 = new NavMeshPath();
					if (NavMesh.CalculatePath(((Component)base.agent).transform.position, ((Component)val).transform.position, -1, val2))
					{
						list.Add(((Object)val).name);
					}
				}
			}
			if (list.Count > 0)
			{
				SetTargetPlayerClientRpc(list[RandomNumberGenerator.GetInt32(0, list.Count)]);
				base.agent.speed = 0f;
				base.creatureAnimator.speed = 0f;
			}
			else
			{
				base.targetPlayer = null;
				SetTargetPlayerClientRpc("NoneCode1234567890");
			}
		}

		public void FootStepHandler()
		{
			if (localPlayer.isInsideFactory)
			{
				switch (RandomNumberGenerator.GetInt32(0, 4))
				{
				case 0:
					footStepAudio.PlayOneShot(footStep1);
					break;
				case 1:
					footStepAudio.PlayOneShot(footStep2);
					break;
				case 2:
					footStepAudio.PlayOneShot(footStep3);
					break;
				case 3:
					footStepAudio.PlayOneShot(footStep4);
					break;
				}
			}
		}

		public void FallOnKnee()
		{
			if (RandomNumberGenerator.GetInt32(0, 101) != 0)
			{
				base.creatureVoice.PlayOneShot(fallOnKnee);
			}
			else
			{
				base.creatureVoice.PlayOneShot(fallOnKneeVariant);
			}
		}

		public void FallOnBody()
		{
			base.creatureVoice.PlayOneShot(fallOnBody);
		}

		private IEnumerator FoxyKills(PlayerControllerB player)
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(5);
			base.agent.speed = 0f;
			base.creatureAnimator.speed = 1f;
			base.movingTowardsTargetPlayer = false;
			base.agent.isStopped = true;
			base.agent.ResetPath();
			oldspeed = player.movementSpeed;
			player.movementSpeed = 0f;
			((MonoBehaviour)this).StartCoroutine(RotatePlayerToMe(player));
			((Component)this).transform.LookAt(((Component)player).transform.position, Vector3.up);
			DoAnimationClientRpc("Kill");
			yield return (object)new WaitForSeconds(5f);
			player.movementSpeed = oldspeed;
			engine.Stop();
			footSpeed.Stop();
		}

		private IEnumerator RotatePlayerToMe(PlayerControllerB PCB)
		{
			stopLooking = false;
			((MonoBehaviour)this).StartCoroutine(StopAfterThreeSeconds(PCB));
			if (Object.op_Implicit((Object)(object)PCB))
			{
				Vector3 Position = ((Component)this).transform.position - ((Component)PCB).gameObject.transform.position;
				while (PCB.health != 0 && !PCB.isPlayerDead && !stopLooking)
				{
					PlayerSmoothLookAt(Position, PCB);
					yield return null;
				}
			}
		}

		private IEnumerator StopAfterThreeSeconds(PlayerControllerB PCB)
		{
			yield return (object)new WaitForSeconds(3f);
			stopLooking = true;
			yield return (object)new WaitForSeconds(1f);
			stopLooking = false;
		}

		private void PlayerSmoothLookAt(Vector3 newDirection, PlayerControllerB PCB)
		{
			//IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			((Component)PCB).gameObject.transform.rotation = Quaternion.Lerp(((Component)PCB).gameObject.transform.rotation, Quaternion.LookRotation(newDirection), Time.deltaTime * 5f);
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3119595832u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3119595832u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (base.currentBehaviourStateIndex != 3)
			{
				return;
			}
			int num = 8;
			Collider[] array = Physics.OverlapBox(killZone.position, killZone.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				Debug.Log((object)"Player In punishable zone!");
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null && (Object)(object)val4 == (Object)(object)base.targetPlayer)
				{
					base.agent.speed = 0f;
					base.agent.ResetPath();
					base.creatureAnimator.speed = 1.5f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(5);
					((MonoBehaviour)this).StartCoroutine(FoxyKills(base.targetPlayer));
				}
			}
		}

		[ClientRpc]
		public void KillTargetPlayerClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2316803305u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2316803305u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					base.targetPlayer.KillPlayer(Vector3.back, true, (CauseOfDeath)1, 2, default(Vector3), false);
					base.targetPlayer = null;
				}
			}
		}

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

		public void PlayKillSound(int x)
		{
			base.creatureVoice.PlayOneShot(killAnimationSound[x]);
		}

		[ClientRpc]
		public void SetTargetPlayerClientRpc(string name)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(544624150u, val2, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(name, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 544624150u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (name == "NoneCode1234567890")
			{
				base.targetPlayer = null;
			}
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (((Object)val3).name == name)
				{
					base.targetPlayer = val3;
				}
			}
		}

		[ClientRpc]
		public void HowlClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4231414868u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 4231414868u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					howlingAudioSRC.Play();
				}
			}
		}

		[ClientRpc]
		public void UnlockAllDoorClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(462155729u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 462155729u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			DoorLock[] array = Object.FindObjectsOfType(typeof(DoorLock)) as DoorLock[];
			foreach (DoorLock val3 in array)
			{
				if (val3.isLocked)
				{
					doorLocked.Add(val3);
					val3.UnlockDoorClientRpc();
					val3.isLocked = false;
				}
			}
		}

		[ServerRpc]
		public void BreakDoorServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3660176003u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3660176003u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			DoorLock[] array = Object.FindObjectsOfType(typeof(DoorLock)) as DoorLock[];
			foreach (DoorLock val3 in array)
			{
				try
				{
					GameObject gameObject = ((Component)((Component)((Component)((Component)val3).transform.parent).transform.parent).transform.parent).gameObject;
					if (!Object.op_Implicit((Object)(object)gameObject.GetComponent<Rigidbody>()) && Vector3.Distance(((Component)this).transform.position, gameObject.transform.position) <= 4f)
					{
						NetworkObjectReference netObjRef = NetworkObjectReference.op_Implicit(gameObject);
						Vector3 val4 = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
						BashDoorClientRpc(netObjRef, ((Vector3)(ref val4)).normalized * 20f);
					}
				}
				catch (NullReferenceException)
				{
					try
					{
						val3.OpenDoorAsEnemyClientRpc();
					}
					catch (Exception ex2)
					{
						Debug.Log((object)("The doors are not formatted the right way and as such foxy may seems really stupid hitting doors " + ex2));
					}
				}
			}
		}

		[ClientRpc]
		public void BashDoorClientRpc(NetworkObjectReference netObjRef, Vector3 Position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2378787064u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val)).WriteValueSafe(ref Position);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2378787064u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					GameObject gameObject = ((Component)val3).gameObject;
					Rigidbody val4 = gameObject.AddComponent<Rigidbody>();
					AudioSource obj = gameObject.AddComponent<AudioSource>();
					obj.spatialBlend = 1f;
					obj.maxDistance = 60f;
					obj.rolloffMode = (AudioRolloffMode)1;
					obj.volume = 1f;
					((MonoBehaviour)this).StartCoroutine(TurnOffC(val4, 0.12f));
					val4.AddForce(Position, (ForceMode)1);
					obj.PlayOneShot(destroyDoor);
				}
			}
		}

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

		private IEnumerator TurnOffC(Rigidbody rigidbody, float time)
		{
			rigidbody.detectCollisions = false;
			yield return (object)new WaitForSeconds(time);
			rigidbody.detectCollisions = true;
			Object.Destroy((Object)(object)((Component)rigidbody).gameObject, 5f);
		}

		[ClientRpc]
		public void SwitchToBehaviourWithoutEnterStateClientRpc(int x)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1775796155u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, x);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1775796155u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.previousBehaviourStateIndex = base.currentBehaviourStateIndex;
					base.currentBehaviourStateIndex = x;
					base.currentBehaviourState = base.enemyBehaviourStates[x];
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3119595832u, new RpcReceiveHandler(__rpc_handler_3119595832), "SwingAttackHitClientRpc");
			((NetworkBehaviour)this).__registerRpc(2316803305u, new RpcReceiveHandler(__rpc_handler_2316803305), "KillTargetPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(3118782829u, new RpcReceiveHandler(__rpc_handler_3118782829), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(544624150u, new RpcReceiveHandler(__rpc_handler_544624150), "SetTargetPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(4231414868u, new RpcReceiveHandler(__rpc_handler_4231414868), "HowlClientRpc");
			((NetworkBehaviour)this).__registerRpc(462155729u, new RpcReceiveHandler(__rpc_handler_462155729), "UnlockAllDoorClientRpc");
			((NetworkBehaviour)this).__registerRpc(3660176003u, new RpcReceiveHandler(__rpc_handler_3660176003), "BreakDoorServerRpc");
			((NetworkBehaviour)this).__registerRpc(2378787064u, new RpcReceiveHandler(__rpc_handler_2378787064), "BashDoorClientRpc");
			((NetworkBehaviour)this).__registerRpc(1775796155u, new RpcReceiveHandler(__rpc_handler_1775796155), "SwitchToBehaviourWithoutEnterStateClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_3119595832(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;
				((FoxyAi)(object)target).SwingAttackHitClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2316803305(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;
				((FoxyAi)(object)target).KillTargetPlayerClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3118782829(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;
				((FoxyAi)(object)target).DoAnimationClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_544624150(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 targetPlayerClientRpc = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref targetPlayerClientRpc, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FoxyAi)(object)target).SetTargetPlayerClientRpc(targetPlayerClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4231414868(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;
				((FoxyAi)(object)target).HowlClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_462155729(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;
				((FoxyAi)(object)target).UnlockAllDoorClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3660176003(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FoxyAi)(object)target).BreakDoorServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2378787064(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_0051: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FoxyAi)(object)target).BashDoorClientRpc(netObjRef, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1775796155(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;
				((FoxyAi)(object)target).SwitchToBehaviourWithoutEnterStateClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "FoxyAi";
		}
	}
	[BepInPlugin("Xilef992.NightmareFoxy", "NightmareFoxy", "1.2.0")]
	[BepInDependency("evaisa.lethallib", "1.2.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "Xilef992.NightmareFoxy";

		public const string LethalLibGuid = "evaisa.lethallib";

		internal static ManualLogSource Logger;

		public static AssetBundle ModAssets;

		private readonly Harmony harmony = new Harmony("Xilef992.NightmareFoxy");

		public static Config FoxyConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Loading NightmareFoxy 1.2.0");
			FoxyConfig = new Config(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			if (string.IsNullOrEmpty(directoryName))
			{
				Logger.LogError((object)"Could not determine the plugin directory");
				return;
			}
			string text = Path.Combine(directoryName, "foxymodasset");
			ModAssets = AssetBundle.LoadFromFile(text);
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)("Failed to load asset bundle: " + text));
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("Foxy");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("FoxyTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("FoxyTK");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"The asset bundle does not contain EnemyType 'Foxy'");
				return;
			}
			if ((Object)(object)val.enemyPrefab == (Object)null)
			{
				Logger.LogError((object)"EnemyType 'Foxy' has no enemyPrefab assigned");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, FoxyConfig.RARITY.Value, (LevelTypes)(-1), (SpawnType)0, val2, val3);
			harmony.PatchAll(typeof(ConfigurationsPatch));
			Logger.LogInfo((object)"Plugin Xilef992.NightmareFoxy loaded successfully");
		}

		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.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Xilef992.NightmareFoxy";

		public const string PLUGIN_NAME = "NightmareFoxy";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace NightmareFoxyLC.Configurations
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		internal const string RequestSyncMessage = "Xilef992.NightmareFoxy.RequestConfigSync";

		internal const string ReceiveSyncMessage = "Xilef992.NightmareFoxy.ReceiveConfigSync";

		public ConfigEntry<float> MAX_SPEED { get; private set; }

		public ConfigEntry<int> CHANCE_NEXT_PHASE { get; private set; }

		public ConfigEntry<float> SPEED_MULTIPLIER { get; private set; }

		public ConfigEntry<float> TIME_TO_SLOW_DOWN { get; private set; }

		public ConfigEntry<int> RARITY { get; private set; }

		public ConfigEntry<int> MIN_AMOUNT_HOWL { get; private set; }

		public ConfigEntry<int> MAX_AMOUNT_HOWL { get; private set; }

		public ConfigEntry<float> SPEED_FOXY_KILLS { get; private set; }

		public ConfigEntry<float> SPEED_FOXY_DAMAGES { get; private set; }

		public ConfigEntry<int> FOXY_DAMAGES { get; private set; }

		public ConfigEntry<float> HOWLING_STRENGHT { get; private set; }

		public ConfigEntry<float> FLASHLIGHT_SLOW_DOWN_MODIFIER { get; private set; }

		public ConfigEntry<bool> ACTIVATE_CONSTANT_LOOK { get; private set; }

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			MAX_SPEED = cfg.Bind<float>("Difficulty", "Maximum speed", 10f, "This is the maximum speed foxy can go at! Please note that to high might actually slow him down in the end for the game won't handle his speed properly, 20 is REALLY fast");
			RARITY = cfg.Bind<int>("Spawn", "His chance rarity", 20, "Refer to other guids for better idea on how that works, I am sadly not qualified enough to explain it well");
			CHANCE_NEXT_PHASE = cfg.Bind<int>("Difficulty", "His chance of going to the next phase", 125, "Every 0.2 seconds, foxy will generate a random number from 0-this number. If this number is 1, he will go to the next phase. There are four inactive state and 1 state where he chases you");
			SPEED_MULTIPLIER = cfg.Bind<float>("Difficulty", "Speed multiplier", 1.5f, "Every 0.2 seconds, FOxy will add 0.01 to his speed which leads to him being faster and faster. This number multiplies this 0.01 directly to whatever number you want!");
			TIME_TO_SLOW_DOWN = cfg.Bind<float>("Difficulty", "Slow down speed", 3f, "Time it takes in seconds for foxy to loose all his speed in seconds");
			MIN_AMOUNT_HOWL = cfg.Bind<int>("Audio", "Minimum amount of Howl", 4, "This is for the howls before he starts chasing you");
			MAX_AMOUNT_HOWL = cfg.Bind<int>("Audio", "Maximum amount of Howl", 7, "This is for the howls before he starts chasing you");
			SPEED_FOXY_KILLS = cfg.Bind<float>("Kill Behaviour", "Seen Amount of speed needed to kill", 50f, "This is for the howls before he starts chasing you. DON'T ENTER 0, ENTER 1 INSTEAD. This is a percentage relative to Foxy's Max speed");
			SPEED_FOXY_DAMAGES = cfg.Bind<float>("Kill Behaviour", "Seen Amount of speed needed to deal damage", 25f, "This is for the howls before he starts chasing you. DON'T ENTER 0, ENTER 1 instead. This is a percentage relative to Foxy's Max speed");
			FOXY_DAMAGES = cfg.Bind<int>("Kill Behaviour", "Foxy Damage", 40, "Amount of damage Foxy does to you when he doesn't have the speed to kill you");
			HOWLING_STRENGHT = cfg.Bind<float>("Audio", "How loud are the screaming before he runs!", 7f, "A value usually betweeen 0 and 1 where 0 is no volume and 1 is max volume. It is possible to go over 1, but it will be really loud");
			FLASHLIGHT_SLOW_DOWN_MODIFIER = cfg.Bind<float>("Difficulty", "Sleep deceleration when Foxy is flshed At", 3f, "Affects how fast Foxy slows down when a flashlight is pointed at him. The chosen value is direcly multiplied with his deceleration");
			ACTIVATE_CONSTANT_LOOK = cfg.Bind<bool>("Difficulty", "Do you have to constantly look at foxy for him to slow down?", false, "If this value is true, foxy will re-accelerate when not looked at even if you took a glimpse of him earlier. Putting it to false, the second foxy is looked at, he will start decelerating even if you stop looking at him");
		}

		public unsafe static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("Xilef992.NightmareFoxy.RequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public unsafe static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			Plugin.Logger.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			if (array == null)
			{
				Plugin.Logger.LogError((object)"Could not serialize the host configuration");
				return;
			}
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("Xilef992.NightmareFoxy.ReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			Plugin.Logger.LogInfo((object)"Successfully synced config with host.");
		}
	}
	public static class ConfigurationsPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//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_0031: Expected O, but got Unknown
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = Config.OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("Xilef992.NightmareFoxy.RequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = Config.OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("Xilef992.NightmareFoxy.ReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			Config.RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Debug.Log((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Debug.Log((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace NightmareFoxy.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}