Decompiled source of Daleks v1.0.0

Daleks.dll

Decompiled a day 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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
using UnityEngine.Rendering.HighDefinition;

[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("Daleks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Daleks")]
[assembly: AssemblyTitle("Daleks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Daleks
{
	internal class AutoTestDriver : MonoBehaviour
	{
		internal static bool Active;

		private PlayerControllerB me;

		private DalekAI dalek;

		private Transform aimAt;

		private string scenario = "-";

		private readonly Dictionary<string, HashSet<string>> statesByScenario = new Dictionary<string, HashSet<string>>();

		private readonly List<string> errors = new List<string>();

		private readonly Dictionary<string, int> damageByScenario = new Dictionary<string, int>();

		private int shots;

		private int shotsHit;

		private string shotDir;

		private static readonly FieldInfo CameraUp = typeof(PlayerControllerB).GetField("cameraUp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static void Log(string s)
		{
			Plugin.Log.LogInfo((object)("[AutoTest] " + s));
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.logMessageReceived += new LogCallback(OnLog);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.logMessageReceived -= new LogCallback(OnLog);
		}

		private void OnLog(string message, string stack, LogType type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (((int)type == 4 || (int)type == 0) && ((stack ?? "").Contains("Daleks") || message.Contains("Dalek")))
			{
				errors.Add(message.Split('\n')[0]);
			}
		}

		private IEnumerator Start()
		{
			Active = true;
			shotDir = Path.Combine(Paths.ConfigPath, "Daleks", "autotest");
			Directory.CreateDirectory(shotDir);
			Log("Démarrage du test automatique.");
			yield return WaitFor(() => (Object)(object)Object.FindObjectOfType<PreInitSceneScript>() != (Object)null || (Object)(object)MainMenu() != (Object)null, 90f);
			PreInitSceneScript pre = Object.FindObjectOfType<PreInitSceneScript>();
			if ((Object)(object)pre != (Object)null)
			{
				yield return (object)new WaitForSeconds(2f);
				pre.ChooseLaunchOption(false);
				Log("Mode LAN choisi.");
			}
			MenuManager menu = null;
			yield return WaitFor(() => (Object)(object)(menu = MainMenu()) != (Object)null, 120f);
			if ((Object)(object)menu == (Object)null)
			{
				Fail("menu principal introuvable");
				yield break;
			}
			yield return (object)new WaitForSeconds(4f);
			GameNetworkManager.Instance.currentSaveFileName = "LCDalekAutoTest";
			menu.ClickHostButton();
			yield return (object)new WaitForSeconds(1f);
			menu.lobbyNameInputField.text = "DalekAutoTest";
			menu.ConfirmHostButton();
			Log("Partie LAN hébergée (sauvegarde LCDalekAutoTest).");
			yield return WaitFor(() => (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.inShipPhase && StartOfRound.Instance.fullyLoadedPlayers.Count > 0, 120f);
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				Fail("vaisseau non chargé");
				yield break;
			}
			yield return (object)new WaitForSeconds(6f);
			StartMatchLever obj = Object.FindObjectOfType<StartMatchLever>();
			obj.singlePlayerEnabled = true;
			obj.leverHasBeenPulled = true;
			obj.StartGame();
			Log("Levier tiré, lune : " + StartOfRound.Instance.currentLevel.PlanetName + ".");
			yield return WaitFor(() => StartOfRound.Instance.shipHasLanded && RoundManager.Instance.dungeonCompletedGenerating, 240f);
			if (!StartOfRound.Instance.shipHasLanded)
			{
				Fail("le vaisseau n'a pas atterri");
				yield break;
			}
			Log("Atterri.");
			me = StartOfRound.Instance.localPlayerController;
			yield return (object)new WaitForSeconds(4f);
			EntranceTeleport val = ((IEnumerable<EntranceTeleport>)Object.FindObjectsOfType<EntranceTeleport>()).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == 0 && e.isEntranceToBuilding));
			if ((Object)(object)val == (Object)null)
			{
				Fail("entrée principale introuvable");
				yield break;
			}
			val.TeleportPlayer();
			yield return (object)new WaitForSeconds(2f);
			Log($"Dans l'installation : {me.isInsideFactory}.");
			yield return WaitFor(() => (Object)(object)(dalek = FindDalek()) != (Object)null, 30f);
			if ((Object)(object)dalek == (Object)null)
			{
				Fail("aucun Dalek (SpawnAtStart activé ?)");
				yield break;
			}
			Log($"Dalek présent, PV {((EnemyAI)dalek).enemyHP}.");
			((MonoBehaviour)this).StartCoroutine(Monitor());
			DalekAI.Fired += OnFired;
			yield return Scenario("0-portrait", 6f, delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				TeleportTo(Spot(((Component)dalek).transform.position, 3.5f, 7f, needSight: true));
				aimAt = ((Component)dalek).transform;
			});
			yield return Capture("portrait");
			yield return Scenario("1-a-decouvert", 25f, delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				TeleportTo(Spot(((Component)dalek).transform.position, 9f, 16f, needSight: true));
				aimAt = ((Component)dalek).transform;
			});
			yield return Scenario("2-cache-loin", 25f, delegate
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				aimAt = null;
				TeleportTo(Spot(((Component)dalek).transform.position, 35f, 120f, needSight: false, needHidden: true));
			});
			yield return Scenario("3-coups-de-pelle", 15f, delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				TeleportTo(Spot(((Component)dalek).transform.position, 2f, 4f, needSight: true));
				aimAt = ((Component)dalek).transform;
				for (int i = 0; i < 3; i++)
				{
					((EnemyAI)dalek).HitEnemyOnLocalClient(1, ((Component)me).transform.forward, me, true, -1);
				}
			});
			yield return Scenario("4-destruction", 10f, delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: 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)
				TeleportTo(Spot(((Component)dalek).transform.position, 6f, 10f, needSight: true));
				aimAt = ((Component)dalek).transform;
				((EnemyAI)dalek).HitEnemyOnLocalClient(50, ((Component)me).transform.forward, me, true, -1);
			});
			yield return Capture("detruit");
			Summary();
			yield return (object)new WaitForSeconds(3f);
			Application.Quit();
		}

		private void OnFired(DalekAI d)
		{
			shots++;
			if (shots <= 2)
			{
				((MonoBehaviour)this).StartCoroutine(CaptureNextFrame("tir" + shots));
			}
		}

		private IEnumerator CaptureNextFrame(string name)
		{
			yield return null;
			ScreenCapture.CaptureScreenshot(Path.Combine(shotDir, name + ".png"));
			Log("Capture : " + name + ".png");
		}

		private IEnumerator Capture(string name)
		{
			yield return (object)new WaitForEndOfFrame();
			ScreenCapture.CaptureScreenshot(Path.Combine(shotDir, name + ".png"));
			Log("Capture : " + name + ".png");
			yield return (object)new WaitForSeconds(0.5f);
		}

		private IEnumerator Scenario(string name, float duration, Action setup)
		{
			scenario = name;
			statesByScenario[name] = new HashSet<string>();
			damageByScenario[name] = 0;
			Log($"===== Scénario {name} ({duration:0} s) =====");
			try
			{
				setup();
			}
			catch (Exception ex)
			{
				errors.Add("setup " + name + ": " + ex.Message);
				Log($"ERREUR setup : {ex}");
			}
			yield return (object)new WaitForSeconds(duration);
		}

		private IEnumerator Monitor()
		{
			while (true)
			{
				if ((Object)(object)me != (Object)null && (Object)(object)dalek != (Object)null)
				{
					string text = (((EnemyAI)dalek).isEnemyDead ? "Mort" : StateName((EnemyAI)(object)dalek));
					if (!statesByScenario.ContainsKey(scenario))
					{
						statesByScenario[scenario] = new HashSet<string>();
					}
					statesByScenario[scenario].Add(text);
					string[] obj = new string[7]
					{
						$"[{scenario}] Dalek {text} d={Vector3.Distance(((Component)dalek).transform.position, ((Component)me).transform.position):0.0} PV={((EnemyAI)dalek).enemyHP} ",
						"cible=",
						((Object)(object)((EnemyAI)dalek).targetPlayer != (Object)null) ? ((EnemyAI)dalek).targetPlayer.playerUsername : "-",
						" voix=",
						null,
						null,
						null
					};
					object obj2;
					if (!((EnemyAI)dalek).creatureVoice.isPlaying)
					{
						obj2 = "-";
					}
					else
					{
						AudioClip clip = ((EnemyAI)dalek).creatureVoice.clip;
						obj2 = ((clip != null) ? ((Object)clip).name : null);
					}
					obj[4] = (string)obj2;
					obj[5] = " ";
					obj[6] = $"bourdon={((EnemyAI)dalek).creatureSFX.volume:0.00}";
					Log(string.Concat(obj));
				}
				yield return (object)new WaitForSeconds(1f);
			}
		}

		private void LateUpdate()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)me == (Object)null || me.isPlayerDead)
			{
				return;
			}
			if (me.health < 100)
			{
				damageByScenario[scenario] = ((!damageByScenario.TryGetValue(scenario, out var value)) ? 1 : (value + 1));
				shotsHit++;
				Log($"[{scenario}] Joueur touché : PV {me.health} -> soigné à 100.");
				me.health = 100;
				me.criticallyInjured = false;
			}
			if (!((Object)(object)aimAt == (Object)null))
			{
				Vector3 val = aimAt.position + Vector3.up * 1.1f - ((Component)me.gameplayCamera).transform.position;
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(val.x, 0f, val.z);
				if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f))
				{
					me.thisPlayerBody.rotation = Quaternion.LookRotation(val2);
					float num = (0f - Mathf.Atan2(val.y, ((Vector3)(ref val2)).magnitude)) * 57.29578f;
					CameraUp?.SetValue(me, num);
					((Component)me.gameplayCamera).transform.localEulerAngles = new Vector3(num, 0f, 0f);
				}
			}
		}

		private Vector3 Spot(Vector3 from, float minD, float maxD, bool needSight, bool needHidden = false)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = (from n in RoundManager.Instance.insideAINodes
				where (Object)(object)n != (Object)null
				select n.transform.position).ToList();
			Vector3? val = null;
			float num = float.MaxValue;
			foreach (Vector3 item in list)
			{
				float num2 = Vector3.Distance(item, from);
				if (num2 < minD || num2 > maxD)
				{
					continue;
				}
				bool flag = Physics.Linecast(item + Vector3.up * 1.5f, from + Vector3.up * 1.5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
				if (!(needSight && flag) && (!needHidden || flag))
				{
					float num3 = Mathf.Abs(num2 - (minD + maxD) * 0.5f);
					if (num3 < num)
					{
						num = num3;
						val = item;
					}
				}
			}
			if (!val.HasValue)
			{
				Log($"Aucun point idéal ({minD}-{maxD} m, vue={needSight}) : placement devant le Dalek.");
				Vector3 val2 = from + ((Component)dalek).transform.forward * Mathf.Max(minD, 3f);
				return RoundManager.Instance.GetNavMeshPosition(val2, default(NavMeshHit), 5f, -1);
			}
			return val.Value;
		}

		private void TeleportTo(Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			me.TeleportPlayer(pos, false, 0f, false, true);
			me.isInsideFactory = true;
			Log($"Joueur téléporté en {pos} (à {Vector3.Distance(pos, ((Component)dalek).transform.position):0.0} m du Dalek).");
		}

		private static DalekAI FindDalek()
		{
			return (((Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.SpawnedEnemies : null)?.OfType<DalekAI>().FirstOrDefault((DalekAI d) => (Object)(object)d != (Object)null && !((EnemyAI)d).isEnemyDead);
		}

		private static string StateName(EnemyAI e)
		{
			int currentBehaviourStateIndex = e.currentBehaviourStateIndex;
			if (e.enemyBehaviourStates == null || currentBehaviourStateIndex < 0 || currentBehaviourStateIndex >= e.enemyBehaviourStates.Length)
			{
				return currentBehaviourStateIndex.ToString();
			}
			return e.enemyBehaviourStates[currentBehaviourStateIndex].name;
		}

		private static MenuManager MainMenu()
		{
			return ((IEnumerable<MenuManager>)Object.FindObjectsOfType<MenuManager>()).FirstOrDefault((Func<MenuManager, bool>)((MenuManager m) => !m.isInitScene && (Object)(object)m.lobbyNameInputField != (Object)null));
		}

		private static IEnumerator WaitFor(Func<bool> cond, float timeout)
		{
			float t = 0f;
			while (t < timeout)
			{
				bool flag = false;
				try
				{
					flag = cond();
				}
				catch
				{
				}
				if (flag)
				{
					break;
				}
				t += 0.5f;
				yield return (object)new WaitForSeconds(0.5f);
			}
		}

		private void Fail(string why)
		{
			Log("ÉCHEC : " + why);
			Summary();
			Application.Quit();
		}

		private void Summary()
		{
			Log("===== RÉSUMÉ =====");
			foreach (KeyValuePair<string, HashSet<string>> item in statesByScenario)
			{
				Log(string.Format("{0} : états {1} ; touché {2} fois", item.Key, string.Join(", ", item.Value.OrderBy((string s) => s)), damageByScenario.TryGetValue(item.Key, out var value) ? value : 0));
			}
			Log($"Tirs : {shots}, touchés : {shotsHit}. Sons : {DalekSounds.Short.Count} courts, {DalekSounds.Long.Count} longs.");
			Log((errors.Count == 0) ? "Aucune erreur du mod." : string.Format("{0} erreur(s) du mod : {1}", errors.Count, string.Join(" | ", errors.Distinct().Take(10))));
		}
	}
	public class DalekAI : EnemyAI
	{
		public const int Patrol = 0;

		public const int Hunt = 1;

		public const int Exterminate = 2;

		public const int Recover = 3;

		public static readonly string[] StateNames = new string[4] { "Patrol", "Hunt", "Exterminate", "Recover" };

		private DalekModel model;

		private readonly AISearchRoutine patrol = new AISearchRoutine();

		private Vector3 lastSeenPos;

		private float stateTimer;

		private float windup;

		private Vector3 lastPos;

		private float moveSpeed;

		private float flinch;

		private float speakLevel;

		private float scanPhase;

		private readonly float[] voiceBuffer = new float[256];

		private static int Mask => StartOfRound.Instance.collidersAndRoomMaskAndDefault;

		private static PlayerControllerB LocalPlayer
		{
			get
			{
				if (!((Object)(object)GameNetworkManager.Instance != (Object)null))
				{
					return null;
				}
				return GameNetworkManager.Instance.localPlayerController;
			}
		}

		internal static event Action<DalekAI> Fired;

		public override void Start()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			model = DalekModel.Build(((Component)this).transform, Plugin.ModelScale.Value);
			((EnemyAI)this).Start();
			DalekNet.EnsureRegistered();
			lastPos = ((Component)this).transform.position;
			scanPhase = Random.Range(0f, 10f);
			base.creatureSFX.clip = DalekSounds.Hum;
			base.creatureSFX.loop = true;
			base.creatureSFX.volume = 0f;
			base.creatureSFX.Play();
			base.creatureVoice.volume = Plugin.VoiceVolume.Value;
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.allPlayersDead || instance.shipIsLeaving || base.allAINodes == null || base.allAINodes.Length == 0)
			{
				base.agent.speed = 0f;
				return;
			}
			stateTimer += base.AIIntervalTime;
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
				if (base.currentBehaviourStateIndex == 2)
				{
					SwitchState(3);
				}
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				DoPatrol();
				break;
			case 1:
				DoHunt();
				break;
			case 2:
				DoExterminate();
				break;
			case 3:
				DoRecover();
				break;
			}
		}

		private void DoPatrol()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = Plugin.PatrolSpeed.Value;
			PlayerControllerB val = LookForPlayer();
			if ((Object)(object)val != (Object)null)
			{
				BeginExterminate(val, angry: false);
			}
			else if (!patrol.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, patrol);
			}
		}

		private void DoHunt()
		{
			//IL_0030: 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)
			base.agent.speed = Plugin.HuntSpeed.Value;
			PlayerControllerB val = LookForPlayer();
			if ((Object)(object)val != (Object)null)
			{
				BeginExterminate(val, angry: false);
			}
			else if (!((EnemyAI)this).SetDestinationToPosition(lastSeenPos, true) || stateTimer > 15f || (stateTimer > 1f && Vector3.Distance(((Component)this).transform.position, lastSeenPos) < 1.5f))
			{
				SwitchState(0);
			}
		}

		private void DoExterminate()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			PlayerControllerB targetPlayer = base.targetPlayer;
			if ((Object)(object)targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(targetPlayer, false, false, true))
			{
				SwitchState(3);
				return;
			}
			if (CanSee(targetPlayer))
			{
				lastSeenPos = ((Component)targetPlayer).transform.position;
			}
			if (!(stateTimer < windup))
			{
				Vector3 aim = (CanSee(targetPlayer) ? (((Component)targetPlayer).transform.position + Vector3.up * 1.1f) : (lastSeenPos + Vector3.up * 1.1f));
				if (Plugin.DebugLogs.Value)
				{
					Plugin.Log.LogInfo((object)$"[Dalek] tire sur {targetPlayer.playerUsername} (visible : {CanSee(targetPlayer)})");
				}
				DalekNet.SendFire(this, (int)targetPlayer.playerClientId, aim);
				SwitchState(3);
			}
		}

		private void DoRecover()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			if (stateTimer < Plugin.RecoverTime.Value)
			{
				return;
			}
			PlayerControllerB targetPlayer = base.targetPlayer;
			if ((Object)(object)targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(targetPlayer, false, false, true) && CanSee(targetPlayer) && Vector3.Distance(((Component)targetPlayer).transform.position, ((Component)this).transform.position) < Plugin.SightRange.Value)
			{
				BeginExterminate(targetPlayer, angry: false);
				return;
			}
			PlayerControllerB val = LookForPlayer();
			if ((Object)(object)val != (Object)null)
			{
				BeginExterminate(val, angry: false);
				return;
			}
			if ((Object)(object)targetPlayer != (Object)null && !targetPlayer.isPlayerDead)
			{
				SwitchState(1);
				return;
			}
			base.targetPlayer = null;
			SwitchState(0);
		}

		private void BeginExterminate(PlayerControllerB p, bool angry)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (patrol.inProgress)
			{
				((EnemyAI)this).StopSearch(patrol, true);
			}
			base.targetPlayer = p;
			lastSeenPos = ((Component)p).transform.position;
			base.moveTowardsDestination = false;
			if (base.agent.isOnNavMesh)
			{
				base.agent.ResetPath();
			}
			angry = angry && DalekSounds.Long.Count > 0;
			List<AudioClip> list = (angry ? DalekSounds.Long : DalekSounds.Short);
			int num = ((list.Count > 0) ? Random.Range(0, list.Count) : (-1));
			float num2 = ((num >= 0) ? list[num].length : 1.8f);
			windup = ((Plugin.AimTime.Value > 0f) ? Plugin.AimTime.Value : (angry ? (num2 - 0.3f) : num2));
			SwitchState(2);
			DalekNet.SendLock(this, (int)p.playerClientId, num, angry);
		}

		private void SwitchState(int state)
		{
			if (Plugin.DebugLogs.Value && state != base.currentBehaviourStateIndex)
			{
				Plugin.Log.LogInfo((object)("[Dalek] " + StateNames[base.currentBehaviourStateIndex] + " -> " + StateNames[state] + (((Object)(object)base.targetPlayer != (Object)null) ? (" (cible " + base.targetPlayer.playerUsername + ")") : "")));
			}
			stateTimer = 0f;
			if (state != 0 && patrol.inProgress)
			{
				((EnemyAI)this).StopSearch(patrol, true);
			}
			if (state == 1)
			{
				base.moveTowardsDestination = true;
			}
			((EnemyAI)this).SwitchToBehaviourState(state);
		}

		private PlayerControllerB LookForPlayer()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB result = null;
			float num = Plugin.SightRange.Value;
			Vector3 position = base.eye.position;
			Vector3 val = ((model != null) ? model.Head.forward : ((Component)this).transform.forward);
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (((EnemyAI)this).PlayerIsTargetable(val2, false, false, true))
				{
					Vector3 val3 = ((Component)val2.gameplayCamera).transform.position - position;
					float magnitude = ((Vector3)(ref val3)).magnitude;
					if (!(magnitude >= num) && (!(magnitude > 4f) || !(Vector3.Angle(val, val3) > Plugin.SightAngle.Value * 0.5f)) && CanSee(val2))
					{
						result = val2;
						num = magnitude;
					}
				}
			}
			return result;
		}

		private bool CanSee(PlayerControllerB p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			//IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = base.eye.position;
			if (Physics.Linecast(position, ((Component)p.gameplayCamera).transform.position, Mask, (QueryTriggerInteraction)1))
			{
				return !Physics.Linecast(position, ((Component)p).transform.position + Vector3.up * 1f, Mask, (QueryTriggerInteraction)1);
			}
			return true;
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || base.stunNormalizedTimer > 0f)
			{
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if ((currentBehaviourStateIndex == 0 || currentBehaviourStateIndex == 1) && !(noiseLoudness < 0.5f) && timesPlayedInOneSpot <= 5 && !(Vector3.Distance(noisePosition, ((Component)this).transform.position) > 30f * noiseLoudness + 5f))
			{
				lastSeenPos = noisePosition;
				if (currentBehaviourStateIndex == 0)
				{
					SwitchState(1);
				}
				else
				{
					stateTimer = 0f;
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (base.isEnemyDead)
			{
				return;
			}
			base.creatureVoice.PlayOneShot(DalekSounds.Clank, 0.9f);
			WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, DalekSounds.Clank, 0.6f);
			flinch = 0.3f;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (Plugin.Health.Value > 0)
			{
				base.enemyHP -= force;
				if (base.enemyHP <= 0)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
					return;
				}
			}
			if (Plugin.DebugLogs.Value)
			{
				Plugin.Log.LogInfo((object)$"[Dalek] touché ({force}), PV restants {base.enemyHP}");
			}
			if ((Object)(object)playerWhoHit != (Object)null && base.currentBehaviourStateIndex != 2 && ((EnemyAI)this).PlayerIsTargetable(playerWhoHit, false, false, true))
			{
				BeginExterminate(playerWhoHit, angry: true);
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			base.creatureVoice.Stop();
			base.creatureSFX.Stop();
			((EnemyAI)this).KillEnemy(destroy);
			if (!destroy && base.isEnemyDead)
			{
				if (patrol.inProgress)
				{
					((EnemyAI)this).StopSearch(patrol, true);
				}
				model?.SetDead();
				if (Plugin.ExplodeOnDeath.Value)
				{
					Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up * 0.9f * Plugin.ModelScale.Value, true, 0f, 3f, 25, 0f, (GameObject)null, false);
				}
			}
		}

		public void OnLockLocal(int player, int clip, bool angry)
		{
			//IL_00ee: 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)
			if (base.isEnemyDead)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			base.targetPlayer = ((player >= 0 && player < allPlayerScripts.Length) ? allPlayerScripts[player] : null);
			List<AudioClip> list = (angry ? DalekSounds.Long : DalekSounds.Short);
			AudioClip val = ((clip >= 0 && clip < list.Count) ? list[clip] : ((list.Count > 0) ? list[Random.Range(0, list.Count)] : null));
			if ((Object)(object)val != (Object)null)
			{
				base.creatureVoice.Stop();
				base.creatureVoice.clip = val;
				base.creatureVoice.Play();
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, 0.7f);
			}
			PlayerControllerB localPlayer = LocalPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !localPlayer.isPlayerDead)
			{
				if ((Object)(object)localPlayer == (Object)(object)base.targetPlayer)
				{
					localPlayer.JumpToFearLevel(angry ? 1f : 0.8f, true);
				}
				else if (Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) < 15f)
				{
					localPlayer.JumpToFearLevel(0.4f, true);
				}
			}
		}

		public void OnFireLocal(int player, Vector3 aim)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0062: 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_0077: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB val = ((player >= 0 && player < allPlayerScripts.Length) ? allPlayerScripts[player] : null);
			if ((Object)(object)val != (Object)null && (val.isPlayerDead || !val.isPlayerControlled))
			{
				val = null;
			}
			Vector3 val2 = ((model != null) ? model.Muzzle.position : (((Component)this).transform.position + Vector3.up * 1f + ((Component)this).transform.forward * 0.8f));
			Vector3 val3 = (((Object)(object)val != (Object)null) ? (((Component)val).transform.position + Vector3.up * 1.1f) : aim);
			Vector3 val4 = val3 - val2;
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			RaycastHit val6 = default(RaycastHit);
			Vector3 val5 = (Physics.Raycast(val2, normalized, ref val6, 80f, Mask, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val6)).point : (val2 + normalized * 80f));
			bool flag = Vector3.Distance(val2, val5) + 0.05f >= Vector3.Distance(val2, val3);
			DalekBeam.Spawn(val2, val5);
			DalekAI.Fired?.Invoke(this);
			base.creatureVoice.PlayOneShot(DalekSounds.Zap, 1f);
			WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, DalekSounds.Zap, 0.6f);
			PlayerControllerB localPlayer = LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)val != (Object)(object)localPlayer)
			{
				return;
			}
			bool flag2 = !Physics.Linecast(val2, ((Component)localPlayer.gameplayCamera).transform.position, Mask, (QueryTriggerInteraction)1);
			if (flag || flag2)
			{
				if (Plugin.DebugLogs.Value)
				{
					Plugin.Log.LogInfo((object)("[Dalek] " + localPlayer.playerUsername + " est touché"));
				}
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				int num = (AutoTestDriver.Active ? 20 : Plugin.Damage.Value);
				localPlayer.DamagePlayer(num, true, true, (CauseOfDeath)3, 0, false, normalized * 15f + Vector3.up * 4f);
			}
		}

		public override void Update()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (model == null)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			if (base.isEnemyDead)
			{
				model.EyeStalk.localRotation = Quaternion.Slerp(model.EyeStalk.localRotation, Quaternion.Euler(35f, 0f, 0f), deltaTime * 2f);
				model.Gun.localRotation = Quaternion.Slerp(model.Gun.localRotation, Quaternion.Euler(40f, 10f, 0f), deltaTime * 2f);
				model.Plunger.localRotation = Quaternion.Slerp(model.Plunger.localRotation, Quaternion.Euler(50f, -10f, 0f), deltaTime * 2f);
				model.Dome.localRotation = Quaternion.Slerp(model.Dome.localRotation, Quaternion.Euler(18f, 0f, 8f), deltaTime * 1.5f);
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			PlayerControllerB targetPlayer = base.targetPlayer;
			bool flag = (currentBehaviourStateIndex == 2 || currentBehaviourStateIndex == 3) && (Object)(object)targetPlayer != (Object)null && !targetPlayer.isPlayerDead;
			if (((NetworkBehaviour)this).IsOwner && flag)
			{
				Vector3 val = ((Component)targetPlayer).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), 160f * deltaTime);
				}
			}
			Vector3 val2 = ((Component)this).transform.position - lastPos;
			lastPos = ((Component)this).transform.position;
			val2.y = 0f;
			moveSpeed = Mathf.Lerp(moveSpeed, ((Vector3)(ref val2)).magnitude / Mathf.Max(deltaTime, 0.0001f), deltaTime * 6f);
			float num = Mathf.Clamp01(moveSpeed / 4f);
			base.creatureSFX.volume = Mathf.MoveTowards(base.creatureSFX.volume, 0.15f + num * 0.45f, deltaTime);
			base.creatureSFX.pitch = 0.9f + num * 0.25f;
			if (!base.creatureSFX.isPlaying && (Object)(object)base.creatureSFX.clip != (Object)null)
			{
				base.creatureSFX.Play();
			}
			float num2 = 0f;
			if (base.creatureVoice.isPlaying)
			{
				base.creatureVoice.GetOutputData(voiceBuffer, 0);
				float num3 = 0f;
				float[] array = voiceBuffer;
				foreach (float num4 in array)
				{
					num3 += num4 * num4;
				}
				num2 = Mathf.Sqrt(num3 / (float)voiceBuffer.Length) / Mathf.Max(0.05f, base.creatureVoice.volume);
			}
			speakLevel = Mathf.Max(num2, speakLevel - deltaTime * 4f);
			model.SetSpeaking(speakLevel);
			Animate(deltaTime, currentBehaviourStateIndex, targetPlayer, flag);
		}

		private void Animate(float dt, int s, PlayerControllerB t, bool tracking)
		{
			//IL_000f: 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)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val2;
			if (tracking)
			{
				Vector3 val = ((Component)t.gameplayCamera).transform.position - model.Head.position;
				val.y = 0f;
				val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(val) : ((Component)this).transform.rotation);
			}
			else
			{
				float num = ((s == 1) ? (Mathf.Sin(Time.time * 2.2f + scanPhase) * 40f) : (Mathf.Sin(Time.time * 0.7f + scanPhase) * 60f));
				val2 = ((Component)this).transform.rotation * Quaternion.Euler(0f, num, 0f);
			}
			model.Head.rotation = Quaternion.RotateTowards(model.Head.rotation, val2, (tracking ? 300f : 70f) * dt);
			float num2 = Mathf.Sin(Time.time * 0.9f + scanPhase) * 6f;
			Quaternion val3 = Quaternion.Euler(8f, 0f, 0f);
			if (tracking)
			{
				Vector3 val4 = ((Component)t.gameplayCamera).transform.position - model.EyeStalk.position;
				float y = val4.y;
				Vector2 val5 = new Vector2(val4.x, val4.z);
				num2 = Mathf.Clamp((0f - Mathf.Atan2(y, ((Vector2)(ref val5)).magnitude)) * 57.29578f, -35f, 35f);
				Vector3 val6 = model.Root.InverseTransformDirection(((Component)t).transform.position + Vector3.up * 1.1f - model.Gun.position);
				float num3 = Mathf.Clamp(Mathf.Atan2(val6.x, val6.z) * 57.29578f, -50f, 50f);
				float y2 = val6.y;
				val5 = new Vector2(val6.x, val6.z);
				val3 = Quaternion.Euler(Mathf.Clamp((0f - Mathf.Atan2(y2, ((Vector2)(ref val5)).magnitude)) * 57.29578f, -45f, 45f), num3, 0f);
			}
			model.EyeStalk.localRotation = Quaternion.Slerp(model.EyeStalk.localRotation, Quaternion.Euler(num2, 0f, 0f), dt * 8f);
			model.Gun.localRotation = Quaternion.Slerp(model.Gun.localRotation, val3, dt * (tracking ? 10f : 3f));
			float num4 = Mathf.Sin(Time.time * 1.3f + scanPhase) * 6f;
			model.Plunger.localRotation = Quaternion.Slerp(model.Plunger.localRotation, Quaternion.Euler(10f + num4, -6f + num4 * 0.5f, 0f), dt * 3f);
			if (flinch > 0f)
			{
				flinch -= dt;
				model.Root.localPosition = Random.insideUnitSphere * 0.03f;
			}
			else
			{
				model.Root.localPosition = Vector3.zero;
			}
		}
	}
	internal class DalekBeam : MonoBehaviour
	{
		private const float Life = 0.4f;

		private Transform core;

		private Light flashFrom;

		private Light flashTo;

		private float age;

		private float length;

		public static void Spawn(Vector3 from, Vector3 to)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0031: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_009e: 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_00c8: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("DalekBeam");
			val.transform.position = from;
			DalekBeam dalekBeam = val.AddComponent<DalekBeam>();
			dalekBeam.length = Vector3.Distance(from, to);
			Vector3 up = Vector3.up;
			Vector3 val2 = to - from;
			dalekBeam.core = Cylinder(rot: Quaternion.FromToRotation(up, ((Vector3)(ref val2)).normalized), mid: (from + to) * 0.5f, parent: val.transform, mat: DalekModel.BeamCore);
			GameObject val3 = new GameObject("FlashFrom");
			val3.transform.SetParent(val.transform, false);
			dalekBeam.flashFrom = DalekModel.AddLight(val3, (LightType)2, new Color(0.5f, 0.8f, 1f), 6000f, 7f);
			GameObject val4 = new GameObject("FlashTo");
			val4.transform.SetParent(val.transform, false);
			Transform transform = val4.transform;
			val2 = to - from;
			transform.position = to - ((Vector3)(ref val2)).normalized * 0.2f;
			dalekBeam.flashTo = DalekModel.AddLight(val4, (LightType)2, new Color(0.5f, 0.8f, 1f), 4000f, 5f);
			dalekBeam.Apply(0f);
		}

		private static Transform Cylinder(Transform parent, Vector3 mid, Quaternion rot, Material mat)
		{
			//IL_0024: 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)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.transform.SetParent(parent, true);
			obj.transform.position = mid;
			obj.transform.rotation = rot;
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = mat;
			return obj.transform;
		}

		private void Apply(float t)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - t;
			core.localScale = new Vector3(0.05f * num, length * 0.5f, 0.05f * num);
			HDAdditionalLightData component = ((Component)flashFrom).GetComponent<HDAdditionalLightData>();
			HDAdditionalLightData component2 = ((Component)flashTo).GetComponent<HDAdditionalLightData>();
			if ((Object)(object)component != (Object)null)
			{
				component.intensity = 6000f * num * num;
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.intensity = 4000f * num * num;
			}
		}

		private void Update()
		{
			age += Time.deltaTime;
			if (age >= 0.4f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Apply(age / 0.4f);
			}
		}
	}
	internal static class DalekFactory
	{
		public static (EnemyType, TerminalNode, TerminalKeyword) Create()
		{
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			float value = Plugin.ModelScale.Value;
			EnemyType val = ScriptableObject.CreateInstance<EnemyType>();
			((Object)val).name = "Dalek";
			val.enemyName = "Dalek";
			val.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
			val.numberSpawnedFalloff = AnimationCurve.Constant(0f, 1f, 1f);
			val.useNumberSpawnedFalloff = false;
			val.spawningDisabled = false;
			val.MaxCount = Mathf.Max(1, Plugin.MaxCount.Value);
			val.PowerLevel = 2f;
			val.isOutsideEnemy = false;
			val.isDaytimeEnemy = false;
			val.canDie = Plugin.Health.Value > 0;
			val.destroyOnDeath = false;
			val.canBeStunned = true;
			val.stunTimeMultiplier = 1f;
			val.doorSpeedMultiplier = 1.5f;
			val.canSeeThroughFog = false;
			val.loudnessMultiplier = 1f;
			int layer = LayerMask.NameToLayer("Enemies");
			int layer2 = LayerMask.NameToLayer("ScanNode");
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("Dalek");
			val2.layer = layer;
			NavMeshAgent obj = val2.AddComponent<NavMeshAgent>();
			obj.speed = Plugin.PatrolSpeed.Value;
			obj.angularSpeed = 220f;
			obj.acceleration = 12f;
			obj.stoppingDistance = 0f;
			obj.radius = 0.5f * value;
			obj.height = 1.7f * value;
			obj.autoBraking = true;
			DalekAI dalekAI = val2.AddComponent<DalekAI>();
			((EnemyAI)dalekAI).enemyType = val;
			((EnemyAI)dalekAI).enemyHP = ((Plugin.Health.Value > 0) ? Plugin.Health.Value : 999);
			((EnemyAI)dalekAI).AIIntervalTime = 0.15f;
			((EnemyAI)dalekAI).enemyBehaviourStates = Array.ConvertAll(DalekAI.StateNames, (Converter<string, EnemyBehaviourState>)((string n) => new EnemyBehaviourState
			{
				name = n
			}));
			Transform transform = new GameObject("Eye").transform;
			transform.SetParent(val2.transform, false);
			transform.localPosition = new Vector3(0f, 1.5f * value, 0.45f * value);
			((EnemyAI)dalekAI).eye = transform;
			((EnemyAI)dalekAI).creatureSFX = CreateAudio(val2.transform, "DalekHum", 18f, 1f * value);
			((EnemyAI)dalekAI).creatureVoice = CreateAudio(val2.transform, "DalekVoice", 55f, 1.4f * value);
			((EnemyAI)dalekAI).creatureVoice.minDistance = 6f;
			((Component)((EnemyAI)dalekAI).creatureVoice).gameObject.AddComponent<AudioReverbFilter>().reverbPreset = (AudioReverbPreset)13;
			((EnemyAI)dalekAI).dieSFX = DalekSounds.Death;
			GameObject val3 = new GameObject("DalekCollision");
			val3.transform.SetParent(val2.transform, false);
			val3.layer = layer;
			val3.tag = "Enemy";
			BoxCollider obj2 = val3.AddComponent<BoxCollider>();
			((Collider)obj2).isTrigger = true;
			obj2.center = new Vector3(0f, 0.85f * value, 0.05f * value);
			obj2.size = new Vector3(1.15f, 1.7f, 1.35f) * value;
			Rigidbody obj3 = val3.AddComponent<Rigidbody>();
			obj3.isKinematic = true;
			obj3.useGravity = false;
			val3.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)dalekAI;
			GameObject val4 = new GameObject("ScanNode");
			val4.transform.SetParent(val2.transform, false);
			val4.transform.localPosition = new Vector3(0f, 1.3f * value, 0f);
			val4.layer = layer2;
			BoxCollider obj4 = val4.AddComponent<BoxCollider>();
			((Collider)obj4).isTrigger = true;
			obj4.size = Vector3.one;
			ScanNodeProperties obj5 = val4.AddComponent<ScanNodeProperties>();
			obj5.headerText = "Dalek";
			obj5.subText = "EXTERMINATE!";
			obj5.nodeType = 1;
			obj5.minRange = 1;
			obj5.maxRange = 30;
			obj5.requiresLineOfSight = true;
			obj5.creatureScanID = -1;
			val.enemyPrefab = val2;
			TerminalNode val5 = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)val5).name = "DalekFile";
			val5.creatureName = "Daleks";
			val5.clearPreviousText = true;
			val5.maxCharactersToType = 35;
			val5.displayText = "DALEKS\n\nSigurd's danger level: 90%\n\nMutants kaleds enfermés dans des blindages en polycarbide. Ils ne connaissent ni la pitié ni la peur, seulement un ordre : EXTERMINER.\n\nUn Dalek patrouille en glissant lentement dans les couloirs, son œil bleu balayant tout devant lui. Quand il vous voit, il s'immobilise et hurle « EXTERMINATE! » avant de tirer. C'est votre seule chance : quittez sa ligne de mire avant la fin du mot.\n\nIl entend le bruit et poursuit ce qu'il a perdu de vue. Son blindage résiste longtemps à la pelle, et le frapper le met en rage. Une grenade aveuglante l'étourdit.\n\nIl ne monte pas les escaliers. Officiellement.\n\n";
			TerminalKeyword val6 = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)val6).name = "DalekKeyword";
			val6.word = "daleks";
			val6.isVerb = false;
			return (val, val5, val6);
		}

		private static AudioSource CreateAudio(Transform parent, string name, float maxDistance, float height)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, height, 0f);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = 2f;
			obj.maxDistance = maxDistance;
			obj.dopplerLevel = 0f;
			return obj;
		}
	}
	public class DalekModel
	{
		public Transform Root;

		public Transform Head;

		public Transform EyeStalk;

		public Transform Gun;

		public Transform Plunger;

		public Transform Muzzle;

		public Transform Dome;

		public readonly List<Renderer> DomeLights = new List<Renderer>();

		public Renderer EyeLens;

		public Light EyeLight;

		private static Material bronze;

		private static Material darkBronze;

		private static Material gold;

		private static Material black;

		private static Material silver;

		private static Material lightOff;

		private static Material lightOn;

		private static Material eyeOn;

		private static Material eyeOff;

		public static Material BeamCore;

		private static Mesh skirtMesh;

		private static Mesh fenderMesh;

		private static Mesh shoulderMesh;

		private static Material Lit(Color c, float smoothness, float metallic = 0f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("HDRP/Lit") ?? Shader.Find("Standard"));
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", c);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			val.color = c;
			return val;
		}

		private static Material Unlit(Color c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Color"));
			if (val.HasProperty("_UnlitColor"))
			{
				val.SetColor("_UnlitColor", c);
			}
			val.color = c;
			return val;
		}

		private static void EnsureAssets()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)bronze != (Object)null))
			{
				bronze = Lit(new Color(0.42f, 0.27f, 0.11f), 0.55f, 0.75f);
				darkBronze = Lit(new Color(0.2f, 0.13f, 0.06f), 0.45f, 0.6f);
				gold = Lit(new Color(0.78f, 0.56f, 0.2f), 0.7f, 0.9f);
				black = Lit(new Color(0.02f, 0.02f, 0.02f), 0.4f);
				silver = Lit(new Color(0.55f, 0.55f, 0.58f), 0.7f, 0.9f);
				lightOff = Lit(new Color(0.35f, 0.3f, 0.2f), 0.8f);
				lightOn = Unlit(new Color(1f, 0.92f, 0.65f));
				eyeOn = Unlit(new Color(0.35f, 0.75f, 1f));
				eyeOff = Lit(new Color(0.03f, 0.05f, 0.08f), 0.9f);
				BeamCore = Unlit(new Color(0.6f, 0.88f, 1f));
				fenderMesh = Frustum(8, 0.62f, 0.6f, 0f, 0.1f);
				skirtMesh = Frustum(8, 0.55f, 0.37f, 0.1f, 0.86f);
				shoulderMesh = Frustum(16, 0.41f, 0.37f, 0.88f, 1.13f);
			}
		}

		private static Mesh Frustum(int sides, float r0, float r1, float y0, float y1)
		{
			//IL_0044: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			float num = MathF.PI * 2f / (float)sides;
			for (int i = 0; i < sides; i++)
			{
				float a = ((float)i - 0.5f) * num;
				float a2 = ((float)i + 0.5f) * num;
				int count = list.Count;
				list.Add(P(a, r0, y0));
				list.Add(P(a2, r0, y0));
				list.Add(P(a2, r1, y1));
				list.Add(P(a, r1, y1));
				list2.AddRange(new int[6]
				{
					count + 1,
					count + 2,
					count + 3,
					count + 1,
					count + 3,
					count
				});
			}
			int count2 = list.Count;
			list.Add(new Vector3(0f, y1, 0f));
			for (int j = 0; j < sides; j++)
			{
				int count3 = list.Count;
				list.Add(P(((float)j - 0.5f) * num, r1, y1));
				list.Add(P(((float)j + 0.5f) * num, r1, y1));
				list2.AddRange(new int[3]
				{
					count2,
					count3,
					count3 + 1
				});
			}
			Mesh val = new Mesh
			{
				name = "DalekFrustum"
			};
			val.SetVertices(list);
			val.SetTriangles(list2, 0);
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
			static Vector3 P(float num2, float num3, float num4)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(Mathf.Sin(num2) * num3, num4, Mathf.Cos(num2) * num3);
			}
		}

		private static Transform Pivot(string name, Transform parent, Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject(name).transform;
			transform.SetParent(parent, false);
			transform.localPosition = pos;
			((Component)transform).gameObject.layer = ((Component)parent).gameObject.layer;
			return transform;
		}

		private static Renderer Part(PrimitiveType type, Transform parent, Vector3 pos, Vector3 scale, Material mat, Vector3 euler = default(Vector3))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(type);
			Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = pos;
			obj.transform.localEulerAngles = euler;
			obj.transform.localScale = scale;
			MeshRenderer component = obj.GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterial = mat;
			obj.layer = ((Component)parent).gameObject.layer;
			return (Renderer)(object)component;
		}

		private static void MeshPart(string name, Transform parent, Mesh mesh, Material mat)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.layer = ((Component)parent).gameObject.layer;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
		}

		private static Renderer Sphere(Transform p, Vector3 pos, Vector3 scale, Material m, Vector3 euler = default(Vector3))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Part((PrimitiveType)0, p, pos, scale, m, euler);
		}

		private static Renderer Cube(Transform p, Vector3 pos, Vector3 scale, Material m, Vector3 euler = default(Vector3))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Part((PrimitiveType)3, p, pos, scale, m, euler);
		}

		private static Renderer Disc(Transform p, Vector3 pos, float d, float h, Material m)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return Part((PrimitiveType)2, p, pos, new Vector3(d, h / 2f, d), m);
		}

		private static Renderer Rod(Transform p, float z0, float len, float d, Material m)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			return Part((PrimitiveType)2, p, new Vector3(0f, 0f, z0 + len / 2f), new Vector3(d, len / 2f, d), m, new Vector3(90f, 0f, 0f));
		}

		public static DalekModel Build(Transform owner, float scale)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_079d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Expected O, but got Unknown
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			EnsureAssets();
			DalekModel dalekModel = new DalekModel();
			dalekModel.Root = Pivot("DalekModel", owner, Vector3.zero);
			dalekModel.Root.localScale = Vector3.one * scale;
			Transform val = Pivot("Lower", dalekModel.Root, Vector3.zero);
			val.localScale = new Vector3(1f, 1f, 1.15f);
			MeshPart("Fender", val, fenderMesh, darkBronze);
			MeshPart("Skirt", val, skirtMesh, bronze);
			for (int i = 0; i < 8; i++)
			{
				float num = (float)i * MathF.PI / 4f;
				for (int j = 0; j < 4; j++)
				{
					float num2 = 0.13f + (float)j * 0.235f;
					float num3 = Mathf.Lerp(0.1f, 0.86f, num2);
					float num4 = Mathf.Lerp(0.55f, 0.37f, num2) * Mathf.Cos(MathF.PI / 8f);
					Sphere(val, new Vector3(Mathf.Sin(num) * num4, num3, Mathf.Cos(num) * num4), Vector3.one * 0.13f, gold);
				}
			}
			Disc(dalekModel.Root, new Vector3(0f, 0.87f, 0f), 0.86f, 0.04f, darkBronze);
			MeshPart("Shoulders", dalekModel.Root, shoulderMesh, gold);
			for (int k = 0; k < 20; k++)
			{
				float num5 = (float)k * MathF.PI * 2f / 20f;
				if (!(Mathf.Abs(Mathf.DeltaAngle(num5 * 57.29578f, 0f)) < 40f))
				{
					Cube(dalekModel.Root, new Vector3(Mathf.Sin(num5) * 0.395f, 1.005f, Mathf.Cos(num5) * 0.395f), new Vector3(0.025f, 0.22f, 0.03f), black, new Vector3(0f, num5 * 57.29578f, 0f));
				}
			}
			Cube(dalekModel.Root, new Vector3(0f, 1f, 0.37f), new Vector3(0.5f, 0.2f, 0.06f), darkBronze);
			Sphere(dalekModel.Root, new Vector3(0.15f, 1f, 0.4f), Vector3.one * 0.11f, black);
			Sphere(dalekModel.Root, new Vector3(-0.15f, 1f, 0.4f), Vector3.one * 0.11f, black);
			dalekModel.Gun = Pivot("Gun", dalekModel.Root, new Vector3(0.15f, 1f, 0.42f));
			Rod(dalekModel.Gun, 0f, 0.3f, 0.035f, silver);
			for (int l = 0; l < 4; l++)
			{
				Rod(dalekModel.Gun, 0.05f + (float)l * 0.055f, 0.012f, 0.07f, black);
			}
			Rod(dalekModel.Gun, 0.29f, 0.04f, 0.045f, black);
			dalekModel.Muzzle = Pivot("Muzzle", dalekModel.Gun, new Vector3(0f, 0f, 0.34f));
			dalekModel.Plunger = Pivot("Plunger", dalekModel.Root, new Vector3(-0.15f, 1f, 0.42f));
			Rod(dalekModel.Plunger, 0f, 0.44f, 0.04f, silver);
			Sphere(dalekModel.Plunger, new Vector3(0f, 0f, 0.47f), new Vector3(0.17f, 0.17f, 0.07f), black);
			Disc(dalekModel.Root, new Vector3(0f, 1.25f, 0f), 0.48f, 0.26f, black);
			for (int m = 0; m < 3; m++)
			{
				Disc(dalekModel.Root, new Vector3(0f, 1.155f + (float)m * 0.075f, 0f), 0.62f - (float)m * 0.04f, 0.035f, gold);
			}
			for (int n = 0; n < 12; n++)
			{
				float num6 = (float)n * MathF.PI * 2f / 12f;
				Cube(dalekModel.Root, new Vector3(Mathf.Sin(num6) * 0.255f, 1.25f, Mathf.Cos(num6) * 0.255f), new Vector3(0.02f, 0.25f, 0.02f), silver, new Vector3(0f, num6 * 57.29578f, 0f));
			}
			dalekModel.Head = Pivot("Head", dalekModel.Root, new Vector3(0f, 1.37f, 0f));
			Disc(dalekModel.Head, new Vector3(0f, 0.03f, 0f), 0.6f, 0.06f, gold);
			dalekModel.Dome = Pivot("Dome", dalekModel.Head, Vector3.zero);
			Sphere(dalekModel.Dome, new Vector3(0f, 0.06f, 0f), new Vector3(0.56f, 0.46f, 0.56f), silver);
			float[] array = new float[2] { -1f, 1f };
			foreach (float num8 in array)
			{
				Transform val2 = Pivot("Lamp", dalekModel.Dome, new Vector3(0.16f * num8, 0.24f, -0.02f));
				val2.localEulerAngles = new Vector3(0f, 0f, -28f * num8);
				dalekModel.DomeLights.Add(Disc(val2, new Vector3(0f, 0.045f, 0f), 0.065f, 0.1f, lightOff));
				Disc(val2, new Vector3(0f, 0.1f, 0f), 0.08f, 0.015f, black);
			}
			dalekModel.EyeStalk = Pivot("EyeStalk", dalekModel.Dome, new Vector3(0f, 0.13f, 0.2f));
			Rod(dalekModel.EyeStalk, 0f, 0.3f, 0.03f, silver);
			for (int num9 = 0; num9 < 3; num9++)
			{
				Rod(dalekModel.EyeStalk, 0.08f + (float)num9 * 0.06f, 0.012f, 0.085f - (float)num9 * 0.012f, black);
			}
			Sphere(dalekModel.EyeStalk, new Vector3(0f, 0f, 0.32f), new Vector3(0.09f, 0.09f, 0.07f), black);
			dalekModel.EyeLens = Rod(dalekModel.EyeStalk, 0.345f, 0.012f, 0.06f, eyeOn);
			if (Plugin.EyeLight.Value)
			{
				GameObject val3 = new GameObject("EyeLight");
				val3.transform.SetParent(dalekModel.EyeStalk, false);
				val3.transform.localPosition = new Vector3(0f, 0f, 0.37f);
				val3.layer = ((Component)dalekModel.EyeStalk).gameObject.layer;
				dalekModel.EyeLight = AddLight(val3, (LightType)0, new Color(0.45f, 0.75f, 1f), 900f, 14f * scale, 40f);
			}
			return dalekModel;
		}

		public static Light AddLight(GameObject go, LightType type, Color color, float lumens, float range, float spotAngle = 60f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Light obj = go.AddComponent<Light>();
			obj.type = type;
			obj.color = color;
			obj.range = range;
			obj.spotAngle = spotAngle;
			obj.shadows = (LightShadows)0;
			HDAdditionalLightData obj2 = go.AddComponent<HDAdditionalLightData>();
			obj2.lightUnit = (LightUnit)0;
			obj2.intensity = lumens;
			obj2.range = range;
			obj2.affectsVolumetric = false;
			return obj;
		}

		public void SetSpeaking(float level)
		{
			Material val = ((level > 0.12f) ? lightOn : lightOff);
			foreach (Renderer domeLight in DomeLights)
			{
				if ((Object)(object)domeLight.sharedMaterial != (Object)(object)val)
				{
					domeLight.sharedMaterial = val;
				}
			}
		}

		public void SetDead()
		{
			SetSpeaking(0f);
			if ((Object)(object)EyeLens != (Object)null)
			{
				EyeLens.sharedMaterial = eyeOff;
			}
			if ((Object)(object)EyeLight != (Object)null)
			{
				((Behaviour)EyeLight).enabled = false;
			}
		}
	}
	internal static class DalekNet
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnLock;

			public static HandleNamedMessageDelegate <1>__OnFire;
		}

		private const string MsgLock = "Daleks_Lock";

		private const string MsgFire = "Daleks_Fire";

		private static CustomMessagingManager registeredOn;

		private static NetworkManager NM => NetworkManager.Singleton;

		public static void EnsureRegistered()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			if (!((Object)(object)NM == (Object)null) && NM.CustomMessagingManager != null && registeredOn != NM.CustomMessagingManager)
			{
				registeredOn = NM.CustomMessagingManager;
				CustomMessagingManager obj = registeredOn;
				object obj2 = <>O.<0>__OnLock;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val = OnLock;
					<>O.<0>__OnLock = val;
					obj2 = (object)val;
				}
				obj.RegisterNamedMessageHandler("Daleks_Lock", (HandleNamedMessageDelegate)obj2);
				CustomMessagingManager obj3 = registeredOn;
				object obj4 = <>O.<1>__OnFire;
				if (obj4 == null)
				{
					HandleNamedMessageDelegate val2 = OnFire;
					<>O.<1>__OnFire = val2;
					obj4 = (object)val2;
				}
				obj3.RegisterNamedMessageHandler("Daleks_Fire", (HandleNamedMessageDelegate)obj4);
			}
		}

		public static void SendLock(DalekAI d, int player, int clip, bool angry)
		{
			d.OnLockLocal(player, clip, angry);
			Broadcast("Daleks_Lock", 32, delegate(FastBufferWriter w)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				ulong networkObjectId = ((NetworkBehaviour)d).NetworkObjectId;
				((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref player, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref clip, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref angry, default(ForPrimitives));
			}, 0uL);
		}

		public static void SendFire(DalekAI d, int player, Vector3 aim)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			d.OnFireLocal(player, aim);
			Broadcast("Daleks_Fire", 32, delegate(FastBufferWriter w)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				ulong networkObjectId = ((NetworkBehaviour)d).NetworkObjectId;
				((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref player, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe(ref aim);
			}, 0uL);
		}

		private static void OnLock(ulong sender, FastBufferReader r)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			ulong id = default(ulong);
			((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
			int player = default(int);
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref player, default(ForPrimitives));
			int clip = default(int);
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref clip, default(ForPrimitives));
			bool angry = default(bool);
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref angry, default(ForPrimitives));
			if (NM.IsServer)
			{
				Broadcast("Daleks_Lock", 32, delegate(FastBufferWriter w)
				{
					//IL_000a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_0036: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0052: Unknown result type (might be due to invalid IL or missing references)
					((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref player, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref clip, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref angry, default(ForPrimitives));
				}, sender);
			}
			Find(id)?.OnLockLocal(player, clip, angry);
		}

		private static void OnFire(ulong sender, FastBufferReader r)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			ulong id = default(ulong);
			((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
			int player = default(int);
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref player, default(ForPrimitives));
			Vector3 aim = default(Vector3);
			((FastBufferReader)(ref r)).ReadValueSafe(ref aim);
			if (NM.IsServer)
			{
				Broadcast("Daleks_Fire", 32, delegate(FastBufferWriter w)
				{
					//IL_000a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref player, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe(ref aim);
				}, sender);
			}
			Find(id)?.OnFireLocal(player, aim);
		}

		private static DalekAI Find(ulong id)
		{
			if ((Object)(object)NM == (Object)null || NM.SpawnManager == null)
			{
				return null;
			}
			if (!NM.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) || !((Object)(object)value != (Object)null))
			{
				return null;
			}
			return ((Component)value).GetComponent<DalekAI>();
		}

		private static void Broadcast(string name, int size, Action<FastBufferWriter> write, ulong except)
		{
			if ((Object)(object)NM == (Object)null || NM.CustomMessagingManager == null)
			{
				return;
			}
			if (!NM.IsServer)
			{
				SendTo(0uL, name, size, write);
				return;
			}
			foreach (ulong connectedClientsId in NM.ConnectedClientsIds)
			{
				if (connectedClientsId != 0L && connectedClientsId != except)
				{
					SendTo(connectedClientsId, name, size, write);
				}
			}
		}

		private unsafe static void SendTo(ulong clientId, string name, int size, Action<FastBufferWriter> write)
		{
			//IL_000b: 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)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(size, (Allocator)2, -1);
			try
			{
				write(val);
				NM.CustomMessagingManager.SendNamedMessage(name, clientId, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}
	}
	internal static class DalekSounds
	{
		private const int SampleRate = 44100;

		private static readonly Random Rng = new Random(1963);

		public static AudioClip Hum;

		public static AudioClip Zap;

		public static AudioClip Clank;

		public static AudioClip Death;

		public static readonly List<AudioClip> Short = new List<AudioClip>();

		public static readonly List<AudioClip> Long = new List<AudioClip>();

		private static readonly (string ext, AudioType type)[] Formats = new(string, AudioType)[3]
		{
			(".wav", (AudioType)20),
			(".ogg", (AudioType)14),
			(".mp3", (AudioType)13)
		};

		public static void Generate()
		{
			Hum = BuildHum();
			Zap = BuildZap();
			Clank = BuildClank();
			Death = BuildDeath();
		}

		private static float Noise()
		{
			return (float)(Rng.NextDouble() * 2.0 - 1.0);
		}

		private static float Saw(float phase)
		{
			return 2f * (phase - Mathf.Floor(phase)) - 1f;
		}

		private static AudioClip Make(string name, float seconds, Func<float, float> sample)
		{
			int num = (int)(seconds * 44100f);
			float[] array = new float[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = Mathf.Clamp(sample((float)i / 44100f), -1f, 1f);
			}
			AudioClip obj = AudioClip.Create(name, num, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}

		private static AudioClip BuildHum()
		{
			float lp = 0f;
			return Make("DalekHum", 2f, delegate(float t)
			{
				float num = MathF.PI * 2f * t;
				float num2 = Mathf.Sin(num * 50f) * 0.5f + Mathf.Sin(num * 100f) * 0.3f + Mathf.Sin(num * 150f) * 0.15f + Mathf.Sin(num * 101f) * 0.12f + Mathf.Sin(num * 300f) * 0.05f * (0.6f + 0.4f * Mathf.Sin(num * 3f));
				lp += (Noise() - lp) * 0.05f;
				return (num2 * (0.85f + 0.15f * Mathf.Sin(num * 2f)) + lp * 0.25f) * 0.45f;
			});
		}

		private static AudioClip BuildZap()
		{
			float phase = 0f;
			float ring = 0f;
			float lp = 0f;
			return Make("DalekZap", 0.9f, delegate(float t)
			{
				float num = 1800f * Mathf.Pow(7f / 90f, Mathf.Clamp01(t / 0.7f));
				phase += num * 2.2675737E-05f;
				ring += (num * 0.37f + 55f) * 2.2675737E-05f;
				float num2 = Noise();
				lp += (num2 - lp) * 0.35f;
				float num3 = Saw(phase) * 0.55f * Mathf.Sin(MathF.PI * 2f * ring) + lp * 0.6f + Mathf.Sin(MathF.PI * 120f * t) * 0.2f;
				float num4 = Mathf.Min(1f, t / 0.004f) * Mathf.Exp((0f - t) * 3.2f);
				return (float)Math.Tanh(num3 * 3f) * num4 * 0.9f;
			});
		}

		private static AudioClip BuildClank()
		{
			return Make("DalekClank", 0.8f, delegate(float t)
			{
				float num = MathF.PI * 2f * t;
				return (Mathf.Sin(num * 523f) * Mathf.Exp((0f - t) * 7f) + Mathf.Sin(num * 1307f) * 0.6f * Mathf.Exp((0f - t) * 11f) + Mathf.Sin(num * 2213f) * 0.4f * Mathf.Exp((0f - t) * 16f) + Mathf.Sin(num * 3571f) * 0.25f * Mathf.Exp((0f - t) * 25f) + Noise() * Mathf.Exp((0f - t) * 60f)) * 0.55f;
			});
		}

		private static AudioClip BuildDeath()
		{
			float phase = 0f;
			float ring = 0f;
			return Make("DalekDeath", 2.6f, delegate(float t)
			{
				float num = 260f * Mathf.Pow(0.15384616f, Mathf.Clamp01(t / 2.2f)) * (1f + 0.05f * Mathf.Sin(MathF.PI * 18f * t));
				phase += num * 2.2675737E-05f;
				ring += 0.0006802721f;
				float num2 = Saw(phase) * Mathf.Sin(MathF.PI * 2f * ring);
				float num3 = ((Rng.NextDouble() < 0.002 * (1.0 - (double)t / 2.6)) ? 1f : 0f);
				float num4 = num2 * 0.6f + Noise() * (0.25f + num3 * 2f) * Mathf.Exp((0f - t) * 0.8f);
				float num5 = Mathf.Min(1f, t / 0.01f) * Mathf.Clamp01((2.6f - t) / 0.6f);
				return (float)Math.Tanh(num4 * 2.5f) * num5 * 0.8f;
			});
		}

		public static IEnumerator LoadAudioFiles(params string[] folders)
		{
			SortedDictionary<string, (string, AudioType)> sortedDictionary = new SortedDictionary<string, (string, AudioType)>(StringComparer.OrdinalIgnoreCase);
			foreach (string path in folders)
			{
				if (!Directory.Exists(path))
				{
					continue;
				}
				string[] files = Directory.GetFiles(path, "dalek_extermina*.*");
				foreach (string text in files)
				{
					string key = Path.GetFileNameWithoutExtension(text).ToLowerInvariant();
					string ext = Path.GetExtension(text).ToLowerInvariant();
					int num = Array.FindIndex(Formats, ((string ext, AudioType type) x) => x.ext == ext);
					if (num >= 0 && !sortedDictionary.ContainsKey(key))
					{
						sortedDictionary[key] = (text, Formats[num].type);
					}
				}
			}
			Short.Clear();
			Long.Clear();
			foreach (KeyValuePair<string, (string, AudioType)> item in sortedDictionary)
			{
				bool isLong = item.Key.StartsWith("dalek_extermination");
				yield return Load(item.Value.Item1, item.Value.Item2, delegate(AudioClip c)
				{
					(isLong ? Long : Short).Add(c);
				});
			}
			Plugin.Log.LogInfo((object)$"Sons chargés : {Short.Count} « exterminate » courts, {Long.Count} longs.");
			if (Short.Count == 0)
			{
				Plugin.Log.LogWarning((object)"Aucun fichier dalek_exterminate*.wav trouvé : le Dalek tirera sans prévenir !");
			}
		}

		private static IEnumerator Load(string path, AudioType type, Action<AudioClip> onLoaded)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, type);
			try
			{
				yield return req.SendWebRequest();
				if ((int)req.result != 1)
				{
					Plugin.Log.LogError((object)("Impossible de charger " + Path.GetFileName(path) + " : " + req.error));
					yield break;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(req);
				((Object)content).name = Path.GetFileNameWithoutExtension(path);
				onLoaded(content);
			}
			finally
			{
				((IDisposable)req)?.Dispose();
			}
		}
	}
	internal class DebugSpawner : MonoBehaviour
	{
		internal static EnemyType Type;

		private bool spawnedThisRound;

		public static DebugSpawner Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			GameObject val = new GameObject("DaleksDebugSpawner")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			return val.AddComponent<DebugSpawner>();
		}

		private void Update()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.SpawnAtStart.Value || (Object)(object)Type == (Object)null)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			RoundManager instance2 = RoundManager.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null)
			{
				return;
			}
			if (!instance.shipHasLanded)
			{
				spawned