Decompiled source of SCP1507 v1.1.1

plugins/SCP1507/ProjectSCP.SCP1507.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalBestiary.Modules;
using Microsoft.CodeAnalysis;
using ProjectSCP.SCP1507.NetcodePatcher;
using SCP1507.Configurations;
using SCP1507.DataClass;
using SCP1507.FlamingoManager;
using SCP1507.Patches;
using SCP1507.SCP1507;
using SCP1507.SCP1507Alpha;
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("ProjectSCP.SCP1507")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+fc6b89a5c85206e060744060f941978f7e739113")]
[assembly: AssemblyProduct("SCP1507")]
[assembly: AssemblyTitle("ProjectSCP.SCP1507")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<NetworkBehaviourReference>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<NetworkBehaviourReference>();
	}
}
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 SCP1507
{
	[BepInPlugin("ProjectSCP.SCP1507", "SCP1507", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		private readonly Harmony harmony = new Harmony("ProjectSCP.SCP1507");

		public static Config FlamingoConfig { get; internal set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			FlamingoConfig = new Config(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			Logger.LogInfo((object)"Plugin ProjectSCP.SCP1507 loading asset bundles");
			string path = "scp1507modassets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			Logger.LogInfo((object)"Extracting Enemies");
			EnemyType val = ModAssets.LoadAsset<EnemyType>("scp1507");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("SCP1507TN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("SCP1507TK");
			EnemyType val4 = ModAssets.LoadAsset<EnemyType>("SCP1507Alpha");
			TerminalNode val5 = ModAssets.LoadAsset<TerminalNode>("SCP1507ATN");
			TerminalKeyword val6 = ModAssets.LoadAsset<TerminalKeyword>("SCP1507ATK");
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>
			{
				{
					(LevelTypes)16,
					20
				},
				{
					(LevelTypes)64,
					20
				},
				{
					(LevelTypes)(-1),
					FlamingoConfig.RARITY_ALPHA.Value
				},
				{
					(LevelTypes)1024,
					40
				}
			};
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Logger.LogInfo((object)"Registered Prfabs");
			Enemies.RegisterEnemy(val, 0, (LevelTypes)(-1), val2, val3);
			Enemies.RegisterEnemy(val4, dictionary, dictionary2, val5, val6);
			Logger.LogInfo((object)"Registered enemies");
			harmony.PatchAll(typeof(ConfigurationsPatch));
			harmony.PatchAll(typeof(NoiseItemPatch));
			harmony.PatchAll(typeof(PhysicsProp));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			Logger.LogInfo((object)"Executed patches");
			Logger.LogInfo((object)"Plugin ProjectSCP.SCP1507 is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ProjectSCP.SCP1507";

		public const string PLUGIN_NAME = "SCP1507";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace SCP1507.SCP1507
{
	public class AnimationRelaySCP1507Alpha : MonoBehaviour
	{
		public Scp1507Alpha mainScript;

		public void AttackDoorAnimationHandle()
		{
			MonsterLogger("Started attack sequence against door! FROM ALPHA. This is not supposed to happen and may cause issue!", reportable: true);
		}

		public void AttackPlayerAnimationHandle()
		{
			mainScript.SwingAttackHitClientRpc();
		}

		public void FootStepAnimationHandle()
		{
			mainScript.walkingSource.Play();
		}

		private void MonsterLogger(string message, bool reportable = false)
		{
			if (!reportable)
			{
				Debug.Log((object)("[ProjectSCP.SCP1507][SCP1507Alpha.Animations][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
			else
			{
				Debug.LogError((object)("[ProjectSCP.SCP1507][SCP1507Alpha.Animations][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
		}
	}
	public class AnimationRelaySCP1507 : MonoBehaviour
	{
		public Scp1507 mainScript;

		public void AttackDoorAnimationHandle()
		{
			((EnemyAI)mainScript).creatureSFX.PlayOneShot(mainScript.destroyDoor);
			mainScript.SwingAttackHitDoor();
		}

		public void AttackPlayerAnimationHandle()
		{
			mainScript.SwingAttackHitClientRpc();
		}

		public void FootStepAnimationHandle()
		{
			mainScript.walkingSource.Play();
		}
	}
	public class Scp1507 : EnemyAI
	{
		[NonSerialized]
		[Header("Alpha")]
		public Scp1507Alpha alpha;

		[NonSerialized]
		public int alphaId;

		private bool isAlphaAlive;

		[Header("Attack")]
		public float attackCooldown;

		private float attackCooldownBeheader;

		public int damage;

		public Transform AttackArea;

		private Coroutine KillCoroutine;

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

		public AudioClip[] honks;

		public AudioClip[] attacks;

		public AudioClip attackDoor;

		public AudioSource walkingSource;

		private global::SCP1507.FlamingoManager.FlamingoManager flamingoManager;

		[Header("LookAt")]
		public Transform lookAt;

		public Transform defaultLookAt;

		private Coroutine startCo;

		[NonSerialized]
		private NetworkVariable<NetworkBehaviourReference> _playerNetVar = new NetworkVariable<NetworkBehaviourReference>(default(NetworkBehaviourReference), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public PlayerControllerB Scp1507TargetPlayer
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				return (PlayerControllerB)NetworkBehaviourReference.op_Implicit(_playerNetVar.Value);
			}
			set
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)value == (Object)null)
				{
					_playerNetVar.Value = default(NetworkBehaviourReference);
				}
				else
				{
					_playerNetVar.Value = new NetworkBehaviourReference((NetworkBehaviour)(object)value);
				}
			}
		}

		private void DoAttackSound()
		{
			base.creatureSFX.PlayOneShot(attacks[RandomNumberGenerator.GetInt32(attacks.Length)]);
		}

		public void DoQuackSound()
		{
			base.creatureVoice.PlayOneShot(honks[RandomNumberGenerator.GetInt32(honks.Length)]);
		}

		private void OnTriggerEnter(Collider other)
		{
			MonsterLogger("We collided with something!");
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<DoorLock>()))
			{
				PlayAnimationClientRpc("AttackDoor", value: true);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<DoorLock>()))
			{
				PlayAnimationClientRpc("AttackDoor", value: false);
			}
		}

		private void CheckIfCanBreakDoor(DoorLock Door)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0081: 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_008b: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			if (alpha.HitDoor(Door))
			{
				return;
			}
			try
			{
				GameObject gameObject = ((Component)((Component)((Component)((Component)Door).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 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
					BashDoorClientRpc(netObjRef, ((Vector3)(ref val)).normalized * 20f);
				}
			}
			catch (NullReferenceException)
			{
				try
				{
					Door.OpenDoorAsEnemyClientRpc();
				}
				catch (Exception ex)
				{
					Debug.Log((object)("The doors are not formatted the right way and as such Flamingo's may seems really stupid hitting doors " + ex));
				}
			}
		}

		[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_0140: 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(4184319842u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref Position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4184319842u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					GameObject gameObject = ((Component)val3).gameObject;
					Rigidbody val4 = gameObject.AddComponent<Rigidbody>();
					AudioSource val5 = gameObject.AddComponent<AudioSource>();
					val5.spatialBlend = 1f;
					val5.maxDistance = 60f;
					val5.rolloffMode = (AudioRolloffMode)1;
					val5.volume = 1f;
					((MonoBehaviour)this).StartCoroutine(TurnOffC(val4, 0.12f));
					val4.AddForce(Position, (ForceMode)1);
					val5.PlayOneShot(destroyDoor);
				}
			}
		}

		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);
		}

		public void SwingAttackHitDoor()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			int num = 512;
			if (((NetworkBehaviour)this).IsHost)
			{
				Collider[] array = Physics.OverlapBox(AttackArea.position, AttackArea.localScale, Quaternion.identity, num);
				if (array.Length != 0)
				{
					Collider[] array2 = array;
					foreach (Collider val in array2)
					{
						DoorLock component = ((Component)val).gameObject.GetComponent<DoorLock>();
						if ((Object)(object)component != (Object)null)
						{
							CheckIfCanBreakDoor(component);
						}
					}
				}
			}
			attackCooldown = attackCooldownBeheader;
		}

		private void Awake()
		{
			attackCooldownBeheader = attackCooldown;
			attackCooldown = 0f;
			startCo = ((MonoBehaviour)this).StartCoroutine(StartCoroutineFLAMINGO());
			damage = Plugin.FlamingoConfig.DAMAGE_NORMAL.Value;
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				flamingoManager = global::SCP1507.FlamingoManager.FlamingoManager.Instance;
				flamingoManager.RegisterScp1507Instance(this);
			}
			Random random = new Random();
			bool value = random.Next(2) == 0;
			PlayAnimationClientRpc("DanceDirection", value);
		}

		private IEnumerator StartCoroutineFLAMINGO()
		{
			yield return (object)new WaitForSeconds(3f);
			TriggerRampage(2000);
		}

		[ClientRpc]
		public void StartCallAlphaClientRpc(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(3896637521u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, x);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3896637521u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((MonoBehaviour)this).StopCoroutine(startCo);
			Scp1507Alpha[] array = Object.FindObjectsOfType<Scp1507Alpha>();
			foreach (Scp1507Alpha scp1507Alpha in array)
			{
				if (scp1507Alpha.alphaId == x)
				{
					alpha = scp1507Alpha;
					alphaId = x;
					isAlphaAlive = true;
					break;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (isAlphaAlive)
			{
				if (alpha.LocalAnger >= 7)
				{
					if ((Object)(object)Scp1507TargetPlayer != (Object)null)
					{
						lookAt.position = Scp1507TargetPlayer.playerEye.position;
					}
					else
					{
						lookAt.position = defaultLookAt.position;
					}
				}
				else
				{
					lookAt.position = defaultLookAt.position;
				}
			}
			else if ((Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null)
			{
				lookAt.position = ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position;
			}
			attackCooldown += Time.deltaTime;
		}

		public override void DoAIInterval()
		{
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.isStopped = true;
				base.agent.speed = 5f;
				base.agent.ResetPath();
				break;
			case 1:
				base.agent.isStopped = false;
				Scp1507TargetPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
				base.agent.speed = 5f;
				if (base.creatureAnimator.GetBool("Dancing"))
				{
					PlayAnimationClientRpc("Dancing", value: false);
				}
				if (!((Object)(object)Scp1507TargetPlayer != (Object)null))
				{
					break;
				}
				if (Vector3.Distance(((Component)this).transform.position, ((Component)Scp1507TargetPlayer).transform.position) > 10f)
				{
					base.agent.SetDestination(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)alpha).transform.position, 10f, default(NavMeshHit)));
					base.agent.speed = 10f;
				}
				else if ((Object)(object)Scp1507TargetPlayer != (Object)null)
				{
					base.agent.SetDestination(((Component)Scp1507TargetPlayer).transform.position);
					if (Vector3.Distance(((Component)this).transform.position, ((Component)Scp1507TargetPlayer).transform.position) < 1.2f && attackCooldown >= 1f)
					{
						PlayAnimationClientRpc("Attack");
					}
				}
				break;
			case 2:
				base.agent.speed = 5f;
				Scp1507TargetPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
				if ((Object)(object)Scp1507TargetPlayer != (Object)null)
				{
					base.agent.SetDestination(((Component)Scp1507TargetPlayer).transform.position);
					if (Vector3.Distance(((Component)this).transform.position, ((Component)Scp1507TargetPlayer).transform.position) < 1.2f && attackCooldown >= 1f)
					{
						PlayAnimationClientRpc("Attack");
					}
				}
				else
				{
					base.agent.ResetPath();
				}
				break;
			default:
				MonsterLogger("WRONG BEHAVIOUR STATE INDEX!", reportable: true);
				break;
			case 3:
				break;
			}
		}

		public void StopMoving(int flamingoId)
		{
			if (flamingoId == alphaId)
			{
				PlayAnimationClientRpc("Walking", value: false);
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
		}

		public void TriggerAlphaCharge(int flamingoId)
		{
			if (flamingoId == alphaId)
			{
				PlayAnimationClientRpc("Walking", value: true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}

		public void TriggerRampage(int flamingoId)
		{
			if (flamingoId == alphaId || flamingoId == 2000)
			{
				PlayAnimationClientRpc("Walking", value: true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
		}

		private bool CheckIfPlayerDances()
		{
			//IL_001e: 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)
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			int num = 0;
			if (num < allPlayerScripts.Length)
			{
				PlayerControllerB val = allPlayerScripts[num];
				if (!(Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 10f) && val.performingEmote)
				{
					return true;
				}
			}
			return false;
		}

		[ClientRpc]
		public void PlayAnimationClientRpc(string animationName)
		{
			//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(783826533u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 783826533u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void PlayAnimationClientRpc(string animationName, 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(3605508353u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3605508353u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetBool(animationName, value);
			}
		}

		public void StartDance()
		{
			PlayAnimationClientRpc("Dancing", value: true);
		}

		public void StopDance()
		{
			PlayAnimationClientRpc("Dancing", value: false);
		}

		private void MonsterLogger(string message, bool reportable = false)
		{
			if (!reportable)
			{
				Plugin.Logger.LogInfo((object)("[ProjectSCP.SCP1507][SCP1507Instance][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
			else
			{
				Plugin.Logger.LogError((object)("[ProjectSCP.SCP1507][SCP1507Instance][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if ((Object)(object)playerWhoHit != (Object)null && isAlphaAlive)
			{
				alpha.LocalAnger += 5;
				try
				{
					alpha.GiveServerAngerServerRpc(playerWhoHit.actualClientId, alpha.LocalAnger);
				}
				catch (InvalidOperationException)
				{
					MonsterLogger("Small error on calling!");
					throw;
				}
			}
			if (base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
				if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
				{
					global::SCP1507.FlamingoManager.FlamingoManager.Instance.UnregisterScp1507Instance(this);
				}
			}
		}

		[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_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(2851027910u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2851027910u, 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)
			{
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
					if ((Object)(object)val4 != (Object)null)
					{
						base.creatureSFX.PlayOneShot(attacks[RandomNumberGenerator.GetInt32(attacks.Length)]);
						MonsterLogger(val4.health.ToString());
						KillCoroutine = ((MonoBehaviour)this).StartCoroutine(DamagePlayerCoroutine(val4));
					}
				}
			}
			attackCooldown = attackCooldownBeheader;
		}

		private IEnumerator DamagePlayerCoroutine(PlayerControllerB playerControllerB)
		{
			yield return (object)new WaitForSeconds(0.3f);
			((MonoBehaviour)this).StopCoroutine(KillCoroutine);
			playerControllerB.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}

		protected override void __initializeVariables()
		{
			if (_playerNetVar == null)
			{
				throw new Exception("Scp1507._playerNetVar cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_playerNetVar).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_playerNetVar, "_playerNetVar");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_playerNetVar);
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Scp1507()
		{
			//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
			NetworkManager.__rpc_func_table.Add(4184319842u, new RpcReceiveHandler(__rpc_handler_4184319842));
			NetworkManager.__rpc_func_table.Add(3896637521u, new RpcReceiveHandler(__rpc_handler_3896637521));
			NetworkManager.__rpc_func_table.Add(783826533u, new RpcReceiveHandler(__rpc_handler_783826533));
			NetworkManager.__rpc_func_table.Add(3605508353u, new RpcReceiveHandler(__rpc_handler_3605508353));
			NetworkManager.__rpc_func_table.Add(2851027910u, new RpcReceiveHandler(__rpc_handler_2851027910));
		}

		private static void __rpc_handler_4184319842(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)2;
				((Scp1507)(object)target).BashDoorClientRpc(netObjRef, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3896637521(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;
				((Scp1507)(object)target).StartCallAlphaClientRpc(x);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_783826533(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 animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Scp1507)(object)target).PlayAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "Scp1507";
		}
	}
	public class HatHandler : MonoBehaviour
	{
		public List<GameObject> allHats;

		private void Awake()
		{
			if (Plugin.FlamingoConfig.CUSTOM_HAT.Value)
			{
				int @int = RandomNumberGenerator.GetInt32(allHats.Count);
				allHats[@int].SetActive(true);
				allHats.RemoveAt(@int);
			}
			foreach (GameObject allHat in allHats)
			{
				Object.Destroy((Object)(object)allHat);
			}
		}
	}
	public enum State
	{
		Unmoving,
		AlphaCharge,
		Rampage,
		None
	}
}
namespace SCP1507.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch("GrabServerRpc")]
		[HarmonyPostfix]
		private static void PostFix(GrabbableObject __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"WE DID GRAB ITEM!");
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				global::SCP1507.FlamingoManager.FlamingoManager.Instance.PickupItemTrigger(__instance.playerHeldBy, ((Component)__instance).transform.position);
			}
		}
	}
	[HarmonyPatch(typeof(NoisemakerProp))]
	internal class NoiseItemPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		private static bool PreFix(NoisemakerProp __instance, bool used, bool buttonDown = true)
		{
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				Debug.Log((object)"Activated!");
				if (((Object)__instance).name == "Airhorn(Clone)")
				{
					Debug.Log((object)"It's an Airhorn!");
					global::SCP1507.FlamingoManager.FlamingoManager.Instance.AirHornCheck(((GrabbableObject)__instance).playerHeldBy);
				}
				if (((Object)__instance).name == "Clownhorn(Clone)")
				{
					Debug.Log((object)"It's a clown Horn");
					global::SCP1507.FlamingoManager.FlamingoManager.Instance.ClownHornCheck(((GrabbableObject)__instance).playerHeldBy);
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("StartPerformingEmoteServerRpc")]
		[HarmonyPostfix]
		private static void PostFixStart(PlayerControllerB __instance)
		{
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				global::SCP1507.FlamingoManager.FlamingoManager.Instance.StartEmoting(__instance);
			}
		}

		[HarmonyPatch("StopPerformingEmoteServerRpc")]
		[HarmonyPostfix]
		private static void PostFixStop(PlayerControllerB __instance)
		{
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				global::SCP1507.FlamingoManager.FlamingoManager.Instance.StopEmoting(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("UnloadSceneObjectsEarly")]
		[HarmonyPostfix]
		private static void PostFixStart(RoundManager __instance)
		{
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance != (Object)null)
			{
				global::SCP1507.FlamingoManager.FlamingoManager.Instance.DestroyManagerClientRpc();
			}
		}
	}
}
namespace SCP1507.FlamingoManager
{
	public class FlamingoManager : MonoBehaviour
	{
		private static FlamingoManager _instance;

		private List<Scp1507> allFlamingo;

		private List<EmoteTime> playersDoingEmotes;

		private int honksDone;

		public static FlamingoManager Instance => _instance;

		private void Awake()
		{
			allFlamingo = new List<Scp1507>();
			playersDoingEmotes = new List<EmoteTime>();
			if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_instance = this;
			((MonoBehaviour)this).InvokeRepeating("CheckIfSeen", 2f, 7f);
			((MonoBehaviour)this).InvokeRepeating("Emotehandles", 5f, 1f);
			((MonoBehaviour)this).InvokeRepeating("HonkManager", 5f, 6f);
		}

		public void RegisterScp1507Instance(Scp1507 instance)
		{
			allFlamingo.Add(instance);
		}

		public void UnregisterScp1507Instance(Scp1507 instance)
		{
			foreach (Scp1507 item in allFlamingo)
			{
				if ((Object)(object)item == (Object)(object)instance)
				{
					allFlamingo.Remove(instance);
					break;
				}
			}
		}

		public void AirHornCheck(PlayerControllerB playerHeldBy)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			foreach (Scp1507 item in allFlamingo)
			{
				float num = Vector3.Distance(((Component)playerHeldBy).transform.position, ((Component)item).transform.position);
				if (num <= 5f)
				{
					item.alpha.LocalAnger++;
					item.alpha.GiveServerAngerServerRpc(playerHeldBy.actualClientId, item.alpha.LocalAnger);
					break;
				}
			}
		}

		public void ClownHornCheck(PlayerControllerB playerHeldBy)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			foreach (Scp1507 item in allFlamingo)
			{
				float num = Vector3.Distance(((Component)playerHeldBy).transform.position, ((Component)item).transform.position);
				if (num <= 5f)
				{
					item.alpha.LocalAnger--;
					item.alpha.GiveServerAngerServerRpc(playerHeldBy.actualClientId, item.alpha.LocalAnger);
					break;
				}
			}
		}

		public void PickupItemTrigger(PlayerControllerB playerHeldBy, Vector3 positionOfPickup)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Scp1507 item in allFlamingo)
			{
				float num = Vector3.Distance(positionOfPickup, ((Component)item).transform.position);
				if (num <= 5f)
				{
					item.alpha.LocalAnger += 2;
					item.alpha.GiveServerAngerServerRpc(playerHeldBy.actualClientId, item.alpha.LocalAnger);
					break;
				}
			}
		}

		public void CheckIfSeen()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] array = RoundManager.Instance.playersManager.allPlayerScripts.Where((PlayerControllerB player) => !player.isPlayerDead && player.isPlayerControlled && player.isInsideFactory).ToArray();
			if (array.Length == 0)
			{
				return;
			}
			PlayerControllerB val = array[RandomNumberGenerator.GetInt32(array.Length)];
			foreach (Scp1507 item in allFlamingo)
			{
				if (!val.HasLineOfSightToPosition(((Component)item).transform.position, 45f, 60, -1f) || !((Object)(object)item.alpha != (Object)null))
				{
					continue;
				}
				item.alpha.LocalAnger += 2;
				GrabbableObject[] itemSlots = val.ItemSlots;
				foreach (GrabbableObject val2 in itemSlots)
				{
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					MonsterLogger("1 DONE");
					if (val2.isHeld)
					{
						MonsterLogger("2 DONE");
						if ((Object)(object)((Component)val2).gameObject.GetComponent<Shovel>() != (Object)null)
						{
							MonsterLogger("Holding shovel!");
							item.alpha.LocalAnger += 3;
							break;
						}
						if ((Object)(object)((Component)val2).gameObject.GetComponent<KnifeItem>() != (Object)null)
						{
							item.alpha.LocalAnger += 3;
							break;
						}
						if ((Object)(object)((Component)val2).gameObject.GetComponent<ShotgunItem>() != (Object)null)
						{
							item.alpha.LocalAnger += 7;
							break;
						}
					}
				}
				item.alpha.GiveServerAngerServerRpc(val.actualClientId, item.alpha.LocalAnger);
				break;
			}
		}

		public void Emotehandles()
		{
			foreach (EmoteTime playersDoingEmote in playersDoingEmotes)
			{
				playersDoingEmote.TimeEmoting++;
				if (allFlamingo != null)
				{
					switch (playersDoingEmote.TimeEmoting)
					{
					case 10:
						allFlamingo[0].alpha.LocalAnger--;
						allFlamingo[0].alpha.GiveServerAngerServerRpc(playersDoingEmote.ClientId, allFlamingo[0].alpha.LocalAnger);
						break;
					case 20:
						allFlamingo[0].alpha.LocalAnger -= 2;
						allFlamingo[0].alpha.GiveServerAngerServerRpc(playersDoingEmote.ClientId, allFlamingo[0].alpha.LocalAnger);
						break;
					case 30:
						allFlamingo[0].alpha.LocalAnger -= 3;
						allFlamingo[0].alpha.GiveServerAngerServerRpc(playersDoingEmote.ClientId, allFlamingo[0].alpha.LocalAnger);
						break;
					case 40:
						allFlamingo[0].alpha.LocalAnger -= 4;
						allFlamingo[0].alpha.GiveServerAngerServerRpc(playersDoingEmote.ClientId, allFlamingo[0].alpha.LocalAnger);
						break;
					}
				}
			}
		}

		public void StartEmoting(PlayerControllerB actualPlayer)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB actualPlayer2 = actualPlayer;
			bool flag = false;
			foreach (Scp1507 item in allFlamingo)
			{
				try
				{
					if (Vector3.Distance(((Component)item).transform.position, ((Component)actualPlayer2).transform.position) < 6f)
					{
						item.StartDance();
						flag = true;
					}
				}
				catch (NullReferenceException)
				{
					UnregisterScp1507Instance(item);
					throw;
				}
			}
			if (flag && playersDoingEmotes.FirstOrDefault((EmoteTime e) => e.ClientId == actualPlayer2.actualClientId) == null)
			{
				playersDoingEmotes.Add(new EmoteTime(actualPlayer2.actualClientId));
			}
		}

		public void HonkManager()
		{
			if (allFlamingo.Count != 0)
			{
				int num = allFlamingo.Count / 3;
				num++;
				((MonoBehaviour)this).StartCoroutine(HonkForTimes(num));
			}
		}

		private IEnumerator HonkForTimes(int numberOfHonks)
		{
			for (honksDone = 0; honksDone < numberOfHonks; honksDone++)
			{
				allFlamingo[RandomNumberGenerator.GetInt32(allFlamingo.Count)].DoQuackSound();
				yield return (object)new WaitForSeconds(RandomFloatBetween(0.1f, 1f));
			}
		}

		public void StopEmoting(PlayerControllerB actualPlayer)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB actualPlayer2 = actualPlayer;
			bool flag = false;
			foreach (Scp1507 item in allFlamingo)
			{
				if (Vector3.Distance(((Component)item).transform.position, ((Component)actualPlayer2).transform.position) < 6f)
				{
					item.StopDance();
					flag = true;
				}
			}
			if (flag)
			{
				playersDoingEmotes.Remove(playersDoingEmotes.FirstOrDefault((EmoteTime e) => e.ClientId == actualPlayer2.actualClientId));
			}
		}

		public static float RandomFloatBetween(float min, float max)
		{
			Random random = new Random();
			double num = max - min;
			double num2 = random.NextDouble();
			double num3 = num2 * num + (double)min;
			return (float)num3;
		}

		[ClientRpc]
		public void DestroyManagerClientRpc()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)this).CancelInvoke("CheckIfSeen");
			((MonoBehaviour)this).CancelInvoke("Emotehandles");
			((MonoBehaviour)this).CancelInvoke("HonkManager");
		}

		private void MonsterLogger(string message, bool reportable = false)
		{
			if (!reportable)
			{
				Plugin.Logger.Log((LogLevel)16, (object)("[ProjectSCP.SCP1507][SCP1507Manager][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
			else
			{
				Plugin.Logger.Log((LogLevel)2, (object)("[ProjectSCP.SCP1507][SCP1507Manager][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
		}
	}
}
namespace SCP1507.DataClass
{
	public class PlayerRecord
	{
		private PlayerControllerB playerControllerB;

		private ulong clientId;

		private int angerMeter;

		private bool angered;

		public PlayerControllerB PlayerControllerB => playerControllerB;

		public ulong ClientId => clientId;

		public bool Angered
		{
			get
			{
				if (!playerControllerB.isPlayerDead && playerControllerB.isInsideFactory)
				{
					return angered;
				}
				return false;
			}
		}

		public int AngerMeter
		{
			get
			{
				return angerMeter;
			}
			set
			{
				if (value <= 0)
				{
					angerMeter = 0;
					return;
				}
				if (value >= Plugin.FlamingoConfig.ANGER_FOR_ANGRY_FLAMINGO.Value)
				{
					angered = true;
				}
				angerMeter = value;
			}
		}

		public PlayerRecord(ulong clientId, int angerMeter)
		{
			this.clientId = clientId;
			this.angerMeter = angerMeter;
			if (this.angerMeter >= Plugin.FlamingoConfig.ANGER_FOR_ANGRY_FLAMINGO.Value)
			{
				angered = true;
			}
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.playerClientId == clientId)
				{
					playerControllerB = val;
				}
			}
		}
	}
}
namespace SCP1507.SCP1507Alpha
{
	public class EmoteTime
	{
		private ulong clientId;

		private int timeEmoting;

		public int TimeEmoting
		{
			get
			{
				return timeEmoting;
			}
			set
			{
				timeEmoting = value;
			}
		}

		public ulong ClientId => clientId;

		public EmoteTime(ulong clientId)
		{
			this.clientId = clientId;
			timeEmoting = 0;
		}
	}
	public class Scp1507Alpha : EnemyAI
	{
		private List<DoorHold> currentBreakingDoors;

		[Header("Make anger")]
		public int alphaId;

		private int localAnger;

		public List<PlayerRecord> listOfAnger;

		[Header("NetStats")]
		private ulong localPlayerId;

		private PlayerControllerB localPlayer;

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

		public AudioClip[] attacks;

		public AudioSource walkingSource;

		[Header("FlamingoBasics")]
		private bool isSeen;

		[Header("Attack")]
		public int damage;

		public Transform AttackArea;

		public float attackCooldown;

		private float attackCooldownBeheader;

		[Header("Look")]
		public Transform lookAt;

		public Transform defaultLookAt;

		private Coroutine beingLookedAtCoroutine;

		private Coroutine KillCoroutine;

		private int numberOfFlamingos;

		[NonSerialized]
		private NetworkVariable<NetworkBehaviourReference> _playerNetVar = new NetworkVariable<NetworkBehaviourReference>(default(NetworkBehaviourReference), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public int LocalAnger
		{
			get
			{
				return localAnger;
			}
			set
			{
				localAnger = value;
			}
		}

		public PlayerControllerB Scp1507AlphaTargetPlayer
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				return (PlayerControllerB)NetworkBehaviourReference.op_Implicit(_playerNetVar.Value);
			}
			set
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)value == (Object)null)
				{
					_playerNetVar.Value = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)null);
				}
				else
				{
					_playerNetVar.Value = new NetworkBehaviourReference((NetworkBehaviour)(object)value);
				}
			}
		}

		private void DoAttackSound()
		{
			base.creatureSFX.PlayOneShot(attacks[RandomNumberGenerator.GetInt32(attacks.Length)]);
		}

		private void DoQuackSound()
		{
			base.creatureVoice.PlayOneShot(honks[RandomNumberGenerator.GetInt32(honks.Length)]);
		}

		private IEnumerator QuackAlpha()
		{
			while (!base.isEnemyDead)
			{
				yield return (object)new WaitForSeconds(global::SCP1507.FlamingoManager.FlamingoManager.RandomFloatBetween(5f, 10f));
				DoQuackSound();
			}
		}

		public bool HitDoor(DoorLock door)
		{
			foreach (DoorHold currentBreakingDoor in currentBreakingDoors)
			{
				if ((Object)(object)door == (Object)(object)currentBreakingDoor.Door)
				{
					currentBreakingDoor.NumberOfHits++;
					if (currentBreakingDoor.CanBreak)
					{
						return true;
					}
					return false;
				}
			}
			currentBreakingDoors.Add(new DoorHold(door));
			return false;
		}

		public void DeleteDoor(DoorLock door)
		{
			foreach (DoorHold currentBreakingDoor in currentBreakingDoors)
			{
				if ((Object)(object)door == (Object)(object)currentBreakingDoor.Door)
				{
					currentBreakingDoors.Remove(currentBreakingDoor);
				}
			}
		}

		public void SpawnNewFlamingo()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			list.AddRange(RoundManager.Instance.currentLevel.Enemies);
			SpawnableEnemyWithRarity val = list.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("scp1507"));
			GameObject val2 = NetworkObjectReference.op_Implicit(RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 10f, default(NavMeshHit)), (float)Random.RandomRangeInt(0, 360), RoundManager.Instance.currentLevel.Enemies.IndexOf(val), val.enemyType));
			val2.GetComponent<Scp1507>().StartCallAlphaClientRpc(alphaId);
			numberOfFlamingos++;
			if (RandomNumberGenerator.GetInt32(100) <= Plugin.FlamingoConfig.CHANCE_SPAWN_NEW_ALPHA.Value && Plugin.FlamingoConfig.CAN_SPAWN_ALPHA.Value)
			{
				SpawnNewAlphaFlamingo();
			}
		}

		public void SpawnNewAlphaFlamingo()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			list.AddRange(RoundManager.Instance.currentLevel.Enemies);
			SpawnableEnemyWithRarity val = list.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("scp1507Alpha"));
			GameObject val2 = NetworkObjectReference.op_Implicit(RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 10f, default(NavMeshHit)), (float)Random.RandomRangeInt(0, 360), RoundManager.Instance.currentLevel.Enemies.IndexOf(val), val.enemyType));
			val2.GetComponent<Scp1507>().StartCallAlphaClientRpc(alphaId);
		}

		public void ActivateRampage()
		{
			((MonoBehaviour)this).StartCoroutine(OrderRampage());
		}

		private IEnumerator OrderRampage()
		{
			Scp1507[] array = Object.FindObjectsOfType<Scp1507>();
			foreach (Scp1507 flamingo in array)
			{
				yield return (object)new WaitForSeconds(0.1f);
				flamingo.TriggerRampage(alphaId);
			}
		}

		public void StartCrusade()
		{
			MonsterLogger("Calling Crusade! ", reportable: true);
			Scp1507[] array = Object.FindObjectsOfType<Scp1507>();
			foreach (Scp1507 scp in array)
			{
				((MonoBehaviour)this).StartCoroutine(OrderCrusade());
			}
		}

		private IEnumerator OrderCrusade()
		{
			Scp1507[] array = Object.FindObjectsOfType<Scp1507>();
			foreach (Scp1507 flamingo in array)
			{
				yield return (object)new WaitForSeconds(0.1f);
				flamingo.TriggerAlphaCharge(alphaId);
			}
		}

		public void StopMoving()
		{
			Scp1507[] array = Object.FindObjectsOfType<Scp1507>();
			foreach (Scp1507 scp in array)
			{
				((MonoBehaviour)this).StartCoroutine(OrderStop());
			}
		}

		private IEnumerator OrderStop()
		{
			Scp1507[] array = Object.FindObjectsOfType<Scp1507>();
			foreach (Scp1507 flamingo in array)
			{
				yield return (object)new WaitForSeconds(0.1f);
				flamingo.StopMoving(alphaId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GiveServerAngerServerRpc(ulong clientId, int anger)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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(1748763037u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				BytePacker.WriteValueBitPacked(val2, anger);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1748763037u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			try
			{
				PlayerRecord playerByClientId = GetPlayerByClientId(clientId);
				playerByClientId.AngerMeter = anger;
				MonsterLogger("Player is " + playerByClientId.AngerMeter);
			}
			catch (KeyNotFoundException value)
			{
				Console.WriteLine(value);
				listOfAnger.Add(new PlayerRecord(clientId, anger));
			}
		}

		[ClientRpc]
		public void StartLookAtCoroutineClientRpc()
		{
			//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(100667040u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 100667040u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && beingLookedAtCoroutine == null)
				{
					beingLookedAtCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckIfLookedCoroutine());
				}
			}
		}

		[ClientRpc]
		public void PlayAnimationClientRpc(string animationName)
		{
			//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(81093682u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 81093682u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void PlayAnimationClientRpc(string animationName, 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(3413923772u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3413923772u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetBool(animationName, value);
			}
		}

		private void Awake()
		{
			numberOfFlamingos = 0;
			damage = Plugin.FlamingoConfig.DAMAGE_NORMAL.Value;
			alphaId = RandomNumberGenerator.GetInt32(1000);
			localAnger = 0;
			listOfAnger = new List<PlayerRecord>();
		}

		public override void Start()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			((EnemyAI)this).Start();
			localPlayer = RoundManager.Instance.playersManager.localPlayerController;
			localPlayerId = localPlayer.playerClientId;
			StartAlphaSearch();
			attackCooldownBeheader = attackCooldown;
			attackCooldown = 0f;
			PlayAnimationClientRpc("IsAlpha", value: true);
			if ((Object)(object)global::SCP1507.FlamingoManager.FlamingoManager.Instance == (Object)null)
			{
				GameObject val = new GameObject("Scp1507Manager");
				val.AddComponent<global::SCP1507.FlamingoManager.FlamingoManager>();
			}
		}

		private void LateUpdate()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead)
			{
				if ((Object)(object)Scp1507AlphaTargetPlayer != (Object)null)
				{
					lookAt.position = Scp1507AlphaTargetPlayer.playerEye.position;
				}
				else
				{
					lookAt.position = defaultLookAt.position;
				}
			}
			attackCooldown += Time.deltaTime;
		}

		public override void DoAIInterval()
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.isStopped = true;
				PlayAnimationClientRpc("Walking", value: false);
				if (!CheckIfAPlayerHasVisionToCurrentPosition())
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				if (FindAlphaTarget())
				{
					StartCrusade();
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
				break;
			case 1:
				base.agent.isStopped = false;
				PlayAnimationClientRpc("Walking", value: true);
				if (CheckIfAPlayerHasVisionToCurrentPosition())
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				if (FindAlphaTarget())
				{
					StartCrusade();
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
				if (RandomNumberGenerator.GetInt32(100) <= Plugin.FlamingoConfig.CHANCE_SPAWN_NEW_FLAMINGO.Value && numberOfFlamingos <= Plugin.FlamingoConfig.MAXIMUM_NUMBER_OF_FLAMINGO.Value)
				{
					SpawnNewFlamingo();
				}
				break;
			case 2:
				base.agent.isStopped = false;
				((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
				PlayAnimationClientRpc("Walking", value: true);
				base.agent.SetDestination(((Component)Scp1507AlphaTargetPlayer).transform.position);
				if (Vector3.Distance(((Component)this).transform.position, ((Component)Scp1507AlphaTargetPlayer).transform.position) < 1.2f && attackCooldown >= attackCooldownBeheader)
				{
					PlayAnimationClientRpc("Attack");
				}
				if (!Scp1507AlphaTargetPlayer.isInsideFactory || Scp1507AlphaTargetPlayer.isPlayerDead)
				{
					base.agent.ResetPath();
					StartAlphaSearch();
					StopMoving();
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			default:
				MonsterLogger("WRONG BEHAVIOUR STATE INDEX!", reportable: true);
				break;
			}
		}

		private bool CheckIfPlayerDances()
		{
			//IL_001e: 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)
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			int num = 0;
			if (num < allPlayerScripts.Length)
			{
				PlayerControllerB val = allPlayerScripts[num];
				if (Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 6f && val.performingEmote)
				{
					return true;
				}
			}
			return false;
		}

		private void StartAlphaSearch()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (base.searchCoroutine == null)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
		}

		private bool FindAlphaTarget()
		{
			if (listOfAnger == null)
			{
				MonsterLogger("List of Anger is null", reportable: true);
				return false;
			}
			int num = 0;
			PlayerRecord playerRecord = null;
			foreach (PlayerRecord item in listOfAnger)
			{
				if (item == null)
				{
					MonsterLogger("Encounteed a null value Entry", reportable: true);
				}
				else if (item.Angered && num < item.AngerMeter)
				{
					num = item.AngerMeter;
					playerRecord = item;
				}
			}
			if (playerRecord == null)
			{
				return false;
			}
			Scp1507AlphaTargetPlayer = playerRecord.PlayerControllerB;
			return true;
		}

		private bool CheckIfAPlayerHasVisionToCurrentPosition()
		{
			//IL_001f: 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))
				{
					isSeen = true;
					return true;
				}
			}
			return false;
		}

		private bool CheckIfLocalPlayerHasVisionToCurrentPosition_ONEPLAYER()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (localPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f))
			{
				isSeen = true;
				return true;
			}
			return false;
		}

		private IEnumerator CheckIfLookedCoroutine()
		{
			int numberOfSecondsSeen = 0;
			while (true)
			{
				if (CheckIfLocalPlayerHasVisionToCurrentPosition_ONEPLAYER())
				{
					numberOfSecondsSeen++;
					switch (numberOfSecondsSeen)
					{
					case 10:
						AddToAnger(1);
						break;
					case 20:
						AddToAnger(2);
						break;
					case 30:
						AddToAnger(3);
						break;
					case 40:
						AddToAnger(4);
						break;
					}
					yield return (object)new WaitForSeconds(1f);
				}
				else
				{
					numberOfSecondsSeen = 0;
				}
			}
		}

		public void AddToAnger(int x)
		{
			localAnger += x;
			GiveServerAngerServerRpc(localPlayerId, localAnger);
		}

		public void SetToAnger(int x)
		{
			localAnger = x;
			GiveServerAngerServerRpc(localPlayerId, localAnger);
		}

		public void RemoveToAnger(int x)
		{
			localAnger -= x;
			GiveServerAngerServerRpc(localPlayerId, localAnger);
		}

		private PlayerRecord? GetPlayerByClientId(ulong clientId)
		{
			for (int i = 0; i < listOfAnger.Count; i++)
			{
				if (listOfAnger[i].ClientId == clientId)
				{
					return listOfAnger[i];
				}
			}
			throw new KeyNotFoundException("Player with the given ClientId was not found. CREATING NEW PROFILE");
		}

		private void MonsterLogger(string message, bool reportable = false)
		{
			if (!reportable)
			{
				Plugin.Logger.Log((LogLevel)16, (object)("[ProjectSCP.SCP1507][SCP1507Alpha][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
			else
			{
				Plugin.Logger.Log((LogLevel)2, (object)("[ProjectSCP.SCP1507][SCP1507Alpha][" + (reportable ? "PLEASE REPORT TO US IN THE DISCORD CHANNEL" : "Don't Report") + "] ~ " + message));
			}
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if ((Object)(object)playerWhoHit != (Object)null)
			{
				GiveServerAngerServerRpc(playerWhoHit.actualClientId, 20);
			}
			if (base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
			{
				if (base.searchCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
				}
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
				ActivateRampage();
			}
		}

		[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_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(4249217996u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4249217996u, 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)
			{
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
					if ((Object)(object)val4 != (Object)null)
					{
						DoAttackSound();
						KillCoroutine = ((MonoBehaviour)this).StartCoroutine(DamagePlayerCoroutine(val4));
					}
				}
			}
			attackCooldown = 0f;
		}

		private IEnumerator DamagePlayerCoroutine(PlayerControllerB playerControllerB)
		{
			yield return (object)new WaitForSeconds(0.1f);
			playerControllerB.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			((MonoBehaviour)this).StopCoroutine(KillCoroutine);
		}

		protected override void __initializeVariables()
		{
			if (_playerNetVar == null)
			{
				throw new Exception("Scp1507Alpha._playerNetVar cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_playerNetVar).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_playerNetVar, "_playerNetVar");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_playerNetVar);
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Scp1507Alpha()
		{
			//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
			NetworkManager.__rpc_func_table.Add(1748763037u, new RpcReceiveHandler(__rpc_handler_1748763037));
			NetworkManager.__rpc_func_table.Add(100667040u, new RpcReceiveHandler(__rpc_handler_100667040));
			NetworkManager.__rpc_func_table.Add(81093682u, new RpcReceiveHandler(__rpc_handler_81093682));
			NetworkManager.__rpc_func_table.Add(3413923772u, new RpcReceiveHandler(__rpc_handler_3413923772));
			NetworkManager.__rpc_func_table.Add(4249217996u, new RpcReceiveHandler(__rpc_handler_4249217996));
		}

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

		private static void __rpc_handler_100667040(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;
				((Scp1507Alpha)(object)target).StartLookAtCoroutineClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_81093682(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 animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Scp1507Alpha)(object)target).PlayAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "Scp1507Alpha";
		}
	}
	public class DoorHold
	{
		private DoorLock door;

		private int numberOfHits;

		private bool canBreak;

		public DoorLock Door => door;

		public bool CanBreak => canBreak;

		public int NumberOfHits
		{
			get
			{
				return numberOfHits;
			}
			set
			{
				numberOfHits = value;
				if (numberOfHits >= 10)
				{
					canBreak = true;
				}
			}
		}

		public DoorHold(DoorLock door)
		{
			this.door = door;
			numberOfHits = 1;
		}
	}
	public enum StateA
	{
		Seen,
		Walking,
		Targeting
	}
}
namespace SCP1507.Configurations
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		public ConfigEntry<int> MAXIMUM_NUMBER_OF_FLAMINGO { get; private set; }

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

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

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

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

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

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

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

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

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			MAXIMUM_NUMBER_OF_FLAMINGO = cfg.Bind<int>("Flamingo Spawn", "Maximum number of flamingo!", 30, "This value defines the number of flamingo there can be on the map. It does not take alpha's into account");
			CAN_SPAWN_ALPHA = cfg.Bind<bool>("Flamingo Spawn", "Can alpha spawn alpha?", false, "Enabling this option will make alpha able to spawn other alpha's. This can go out of hand quickly");
			CHANCE_SPAWN_NEW_FLAMINGO = cfg.Bind<int>("Flamingo Spawn", "Spawn speed flamingo", 4, "Every 0.2 seconds, the alpha will generate a number between 0 and 100. If the number generated is lower than the value specified, he will spawn a new flamingo. The higher this value the more likely a flamingo will spawn. Do not");
			RARITY_ALPHA = cfg.Bind<int>("Flamingo Spawn", "Rarity alpha flamingo", 40, "This is the rarity for an alpha flamingo to spawn direcly registered into the game");
			CHANCE_SPAWN_NEW_ALPHA = cfg.Bind<int>("Flamingo Spawn", "Chances to spawn a new alpha by alpha", 10, "Whenever a flamingo is summoned this is the chance for it to summon an additional alpha flamingo. See Spawn speed flamingo for how this value works.");
			DAMAGE_ALPHA = cfg.Bind<int>("Stats", "Chances to spawn alpha", 20, "This is the amount of raw damage dealt by flamingo alpha");
			DAMAGE_NORMAL = cfg.Bind<int>("Stats", "Chances to spawn alpha", 5, "This is the amount of raw damage dealt by flamingo");
			ANGER_FOR_ANGRY_FLAMINGO = cfg.Bind<int>("Anger", "Anger before flamingos are angry", 10, "This is the amount of anger before the flamingo's are angry");
			CUSTOM_HAT = cfg.Bind<bool>("Cosmetics", "Can flamingos have custom hat?", true, "True = yes, false = no");
		}

		public 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("Xilef992SCP1507_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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);
			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("Xilef992SCP1507_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).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("SCP1507_OnRequestConfigSync", (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("SCP1507_OnReceiveConfigSync", (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 ProjectSCP.SCP1507.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}