Decompiled source of CryOfFearMonsters v1.0.1

BepInEx/plugins/CryOfFearMonsters/CryOfFearMonsters.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CryOfFearMonsters.GoldSrc;
using CryOfFearMonsters.Monsters;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[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 CryOfFearMonsters
{
	[BepInPlugin("Joel_McCassidy.CryOfFearMonsters", "Cry of Fear Monsters", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal sealed class Settings
		{
			private const int CurrentConfigVersion = 4;

			private readonly ConfigEntry<int> _configVersion;

			private readonly bool _migrate;

			private readonly ConfigEntry<float> _volume;

			private readonly ConfigEntry<float> _sizeMultiplier;

			private readonly ConfigFile _file;

			private readonly Dictionary<string, ConfigEntry<bool>> _enabled = new Dictionary<string, ConfigEntry<bool>>();

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

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

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

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

			private readonly Dictionary<string, ConfigEntry<float>> _chase = new Dictionary<string, ConfigEntry<float>>();

			private readonly Dictionary<string, ConfigEntry<float>> _power = new Dictionary<string, ConfigEntry<float>>();

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

			private readonly Dictionary<string, ConfigEntry<float>> _scale = new Dictionary<string, ConfigEntry<float>>();

			public float Volume => Mathf.Clamp01(_volume.Value);

			public Settings(ConfigFile file)
			{
				_file = file;
				_configVersion = file.Bind<int>("General", "Config version", 0, "Used by the mod to update old settings. Don't edit.");
				_migrate = _configVersion.Value < 4;
				_volume = file.Bind<float>("General", "Monster volume", 0.6f, "Volume of monster voices and sounds (0-1).");
				if (_migrate)
				{
					_volume.Value = (float)((ConfigEntryBase)_volume).DefaultValue;
				}
				_sizeMultiplier = file.Bind<float>("General", "Size multiplier", 1f, "Extra size multiplier applied to every monster on top of its own Size setting.");
			}

			public bool Enabled(MonsterDefinition d)
			{
				return Get(_enabled, d, "Enabled", def: true, "Whether this monster can spawn.").Value;
			}

			public int Rarity(MonsterDefinition d)
			{
				return Get(_rarity, d, "Spawn weight", d.Rarity, "Spawn weight on every moon (vanilla enemies range ~1-100).").Value;
			}

			public int Health(MonsterDefinition d)
			{
				return Get(_health, d, "Health", d.Health, "Hit points (a shovel hit does 1).").Value;
			}

			public int Damage(MonsterDefinition d)
			{
				return Get(_damage, d, "Damage", d.Damage, "Damage per melee hit to players (players have 100).").Value;
			}

			public float ChaseSpeed(MonsterDefinition d)
			{
				return Get(_chase, d, "Chase speed", d.ChaseSpeed, "Movement speed while chasing, in m/s.").Value;
			}

			public float PowerLevel(MonsterDefinition d)
			{
				return Get(_power, d, "Power level", d.PowerLevel, "How much of a moon's enemy power budget one of these uses.").Value;
			}

			public int MaxCount(MonsterDefinition d)
			{
				return Get(_max, d, "Max count", d.MaxCount, "Maximum alive at once.").Value;
			}

			public int RangedDamage(MonsterDefinition d)
			{
				if (!string.IsNullOrEmpty(d.RangedClip))
				{
					return Get(_rangedDamage, d, "Ranged damage", d.RangedDamage, "Damage per ranged hit (spit, gunshot).").Value;
				}
				return d.RangedDamage;
			}

			public float Scale(MonsterDefinition d)
			{
				return Mathf.Clamp(Get(_scale, d, "Size", d.Scale, "Size relative to Cry of Fear (1.0 = original).").Value, 0.2f, 4f) * Mathf.Clamp(_sizeMultiplier.Value, 0.2f, 4f);
			}

			private ConfigEntry<T> Get<T>(Dictionary<string, ConfigEntry<T>> cache, MonsterDefinition d, string key, T def, string desc)
			{
				if (!cache.TryGetValue(d.Id, out var value))
				{
					value = (cache[d.Id] = _file.Bind<T>(d.DisplayName, key, def, desc));
					if (_migrate && key != "Enabled" && key != "Spawn weight")
					{
						value.Value = def;
					}
				}
				return value;
			}

			public void FinishMigration()
			{
				if (_migrate)
				{
					_configVersion.Value = 4;
					_file.Save();
					Log.LogInfo((object)string.Format("Updated {0}.cfg to settings version {1} (new sizes, speeds, health, volume).", "Joel_McCassidy.CryOfFearMonsters", 4));
				}
			}
		}

		public const string Guid = "Joel_McCassidy.CryOfFearMonsters";

		public const string Name = "Cry of Fear Monsters";

		public const string Version = "1.0.1";

		internal static ManualLogSource Log;

		internal static Settings Cfg;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Cfg = new Settings(((BaseUnityPlugin)this).Config);
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? "", "cryoffear");
			if (!Directory.Exists(Path.Combine(text, "models")))
			{
				Log.LogError((object)("Monster files missing: expected " + text + "\\models and \\sound. No Cry of Fear monsters will spawn."));
				return;
			}
			MonsterAssets.ContentRoot = text;
			Log.LogInfo((object)("Using Cry of Fear content from " + text));
			HashSet<int> hashSet = new HashSet<int>();
			int num = 0;
			Stopwatch stopwatch = Stopwatch.StartNew();
			foreach (MonsterDefinition item in MonsterCatalog.All())
			{
				if (!Cfg.Enabled(item))
				{
					continue;
				}
				Stopwatch stopwatch2 = Stopwatch.StartNew();
				try
				{
					MdlModel mdlModel = MonsterAssets.LoadModel(item.ModelFile, item.AnchorRoot);
					int i;
					for (i = ScanIdFor(item.Id); !hashSet.Add(i); i++)
					{
					}
					MonsterRuntime rt = new MonsterRuntime(item, mdlModel, i);
					MonsterRuntime.Register(rt);
					MonsterFactory.Build(rt);
					num++;
					Log.LogInfo((object)$"Registered {item.DisplayName} ({mdlModel.BoneCount} bones, {mdlModel.Clips.Length} animations) in {stopwatch2.ElapsedMilliseconds} ms");
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"Failed to load {item.DisplayName} from {item.ModelFile}: {arg}");
				}
			}
			Cfg.FinishMigration();
			Log.LogInfo((object)$"Loaded {num} Cry of Fear monsters in {stopwatch.ElapsedMilliseconds} ms");
		}

		private static int ScanIdFor(string id)
		{
			int num = 23;
			foreach (char c in id)
			{
				num = num * 31 + c;
			}
			return 7000000 + Math.Abs(num % 1000000);
		}
	}
	public static class MonsterAssets
	{
		private static readonly Dictionary<string, MdlModel> Models = new Dictionary<string, MdlModel>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, AudioClip> Sounds = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		public static string ContentRoot { get; internal set; }

		public static MdlModel LoadModel(string fileName, bool anchorRoot = false)
		{
			if (Models.TryGetValue(fileName, out var value))
			{
				return value;
			}
			string text = Path.Combine(ContentRoot, "models", fileName);
			if (!File.Exists(text))
			{
				throw new FileNotFoundException("Cry of Fear model not found: " + text);
			}
			value = new MdlModel(fileName, File.ReadAllBytes(text), anchorRoot);
			Models[fileName] = value;
			PreloadEventSounds(value);
			return value;
		}

		public static MdlModel GetModel(string key)
		{
			if (key != null && Models.TryGetValue(key, out var value))
			{
				return value;
			}
			Plugin.Log.LogError((object)("Model '" + key + "' was not loaded."));
			return null;
		}

		public static AudioClip Sound(string relative)
		{
			if (string.IsNullOrEmpty(relative))
			{
				return null;
			}
			relative = relative.Replace('\\', '/').TrimStart('*', '!', '/');
			if (!relative.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
			{
				relative += ".wav";
			}
			if (Sounds.TryGetValue(relative, out var value))
			{
				return value;
			}
			string path = Path.Combine(ContentRoot, "sound", relative.Replace('/', Path.DirectorySeparatorChar));
			value = (File.Exists(path) ? WavLoader.Load(path) : null);
			if ((Object)(object)value == (Object)null)
			{
				Plugin.Log.LogDebug((object)("Sound not available: " + relative));
			}
			Sounds[relative] = value;
			return value;
		}

		public static AudioClip[] SoundSet(params string[] relative)
		{
			List<AudioClip> list = new List<AudioClip>();
			for (int i = 0; i < relative.Length; i++)
			{
				AudioClip val = Sound(relative[i]);
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			return list.ToArray();
		}

		public static bool IsSoundEvent(int id)
		{
			if (id != 1004 && id != 1008)
			{
				return id == 5004;
			}
			return true;
		}

		private static void PreloadEventSounds(MdlModel m)
		{
			MdlModel.Clip[] clips = m.Clips;
			foreach (MdlModel.Clip clip in clips)
			{
				if (clip.Events == null)
				{
					continue;
				}
				MdlFile.Event[] events = clip.Events;
				for (int j = 0; j < events.Length; j++)
				{
					MdlFile.Event obj = events[j];
					if (IsSoundEvent(obj.Id) && obj.Options.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
					{
						Sound(obj.Options);
					}
				}
			}
		}
	}
	internal static class WavLoader
	{
		public static AudioClip Load(string path)
		{
			byte[] array;
			try
			{
				array = File.ReadAllBytes(path);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Couldn't read sound " + path + ": " + ex.Message));
				return null;
			}
			if (array.Length < 12 || Encoding.ASCII.GetString(array, 0, 4) != "RIFF" || Encoding.ASCII.GetString(array, 8, 4) != "WAVE")
			{
				Plugin.Log.LogWarning((object)("Not a RIFF/WAVE file: " + path));
				return null;
			}
			int num = 0;
			int num2 = 1;
			int num3 = 22050;
			int num4 = 16;
			int num5 = -1;
			int num6 = 0;
			int num7 = 12;
			while (num7 + 8 <= array.Length)
			{
				string text = Encoding.ASCII.GetString(array, num7, 4);
				int num8 = BitConverter.ToInt32(array, num7 + 4);
				int num9 = num7 + 8;
				if (text == "fmt ")
				{
					num = BitConverter.ToUInt16(array, num9);
					num2 = BitConverter.ToUInt16(array, num9 + 2);
					num3 = BitConverter.ToInt32(array, num9 + 4);
					num4 = BitConverter.ToUInt16(array, num9 + 14);
				}
				else if (text == "data")
				{
					num5 = num9;
					num6 = Math.Min(num8, array.Length - num9);
				}
				num7 = num9 + num8 + (num8 & 1);
			}
			if (num != 1 || num5 < 0 || num2 < 1 || (num4 != 8 && num4 != 16))
			{
				Plugin.Log.LogWarning((object)$"Unsupported wav ({path}): format {num}, {num4}-bit, {num2} ch");
				return null;
			}
			int num10 = num4 / 8;
			int num11 = num6 / num10 / num2;
			if (num11 <= 0)
			{
				return null;
			}
			float[] array2 = new float[num11 * num2];
			for (int i = 0; i < array2.Length; i++)
			{
				int num12 = num5 + i * num10;
				array2[i] = ((num4 == 8) ? ((float)(array[num12] - 128) / 128f) : ((float)BitConverter.ToInt16(array, num12) / 32768f));
			}
			AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num11, num2, num3, false);
			obj.SetData(array2, 0);
			return obj;
		}
	}
}
namespace CryOfFearMonsters.Monsters
{
	public class CoFMonsterAI : EnemyAI
	{
		public const int StateRoam = 0;

		public const int StateChase = 1;

		public const int StateMelee = 2;

		public const int StateRanged = 3;

		public const int StateEmerge = 4;

		public const int StateSubmerge = 5;

		public const int StateCount = 6;

		public string definitionId;

		public MdlAnimator mdl;

		public SkinnedMeshRenderer body;

		public Collider hitbox;

		public AudioSource loopSource;

		public Transform hover;

		private MonsterRuntime _rt;

		private MonsterDefinition _def;

		private Random _rng;

		private MdlModel.Clip _idle;

		private MdlModel.Clip _walk;

		private MdlModel.Clip _run;

		private MdlModel.Clip _melee;

		private MdlModel.Clip _ranged;

		private MdlModel.Clip _stun;

		private MdlModel.Clip _hidden;

		private MdlModel.Clip _appear;

		private MdlModel.Clip _disappear;

		private readonly List<MdlModel.Clip> _flinches = new List<MdlModel.Clip>();

		private readonly List<MdlModel.Clip> _deaths = new List<MdlModel.Clip>();

		private float _scale = 1f;

		private float _stateStarted;

		private float _lastSeenTarget;

		private float _nextMelee;

		private float _nextRanged;

		private float _investigateUntil;

		private float _outOfRangeSince = -1f;

		private int _lastState = -1;

		private float _flinchUntil;

		private Vector3 _lastPos;

		private float _speed;

		private float _nextVoice;

		private float _nextAura;

		private float _pendingStrike = -1f;

		private bool _pendingRanged;

		private bool _deathHandled;

		private float _hideBodyAt = -1f;

		private float _hoverY;

		private bool _cleanedUp;

		private bool Moves
		{
			get
			{
				if (_def.Stationary)
				{
					return _def.Lurker;
				}
				return true;
			}
		}

		private bool CanChase
		{
			get
			{
				if (!_def.Stationary)
				{
					if (_walk == null)
					{
						return _run != null;
					}
					return true;
				}
				return false;
			}
		}

		private bool HasMelee
		{
			get
			{
				if (_melee != null)
				{
					if (_def.AttackClips != null)
					{
						return _def.AttackClips.Length != 0;
					}
					return true;
				}
				return false;
			}
		}

		public override void Start()
		{
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			_rt = MonsterRuntime.Get(definitionId);
			_def = _rt?.Def;
			((EnemyAI)this).Start();
			if (_def == null)
			{
				Plugin.Log.LogError((object)("No monster definition '" + definitionId + "' on " + ((Object)this).name + "."));
				return;
			}
			base.AIIntervalTime = 0.2f;
			base.enemyHP = Plugin.Cfg.Health(_def);
			_scale = Plugin.Cfg.Scale(_def);
			mdl.Init();
			MdlModel model = mdl.Model;
			_rng = new Random((int)(((NetworkBehaviour)this).NetworkObjectId * 2654435761u % int.MaxValue));
			int[] choice = PickBody(model);
			body.sharedMesh = model.GetMesh(choice, out var materials);
			((Renderer)body).sharedMaterials = materials;
			_idle = model.FindClip(_def.IdleClip) ?? model.Clips[0];
			_walk = Pick(Prefixed(model, _def.WalkPrefix));
			_run = Pick(Prefixed(model, _def.RunPrefix));
			_melee = Pick(Named(model, _def.AttackClips) ?? Prefixed(model, _def.AttackPrefix));
			_ranged = model.FindClip(_def.RangedClip);
			_hidden = model.FindClip(_def.HiddenClip);
			_appear = model.FindClip(_def.AppearClip);
			_disappear = model.FindClip(_def.DisappearClip);
			string[] flinchClips = _def.FlinchClips;
			foreach (string name in flinchClips)
			{
				MdlModel.Clip clip = model.FindClip(name);
				if (clip != null && !_flinches.Contains(clip))
				{
					_flinches.Add(clip);
				}
			}
			_stun = model.FindClip(_def.StunClip) ?? ((_flinches.Count > 0) ? _flinches[_flinches.Count - 1] : _idle);
			_deaths.AddRange(Prefixed(model, _def.DeathPrefix) ?? new List<MdlModel.Clip>());
			_hoverY = _def.HoverHeight;
			mdl.OnAnimEvent += HandleAnimEvent;
			mdl.Play((_def.Lurker && _hidden != null) ? _hidden : _idle, loop: true, 0f);
			_lastPos = ((Component)this).transform.position;
			_nextVoice = Time.time + 4f + (float)_rng.NextDouble() * 8f;
			ApplyVisibility();
			if ((Object)(object)loopSource != (Object)null && (Object)(object)_rt.Loop != (Object)null)
			{
				loopSource.clip = _rt.Loop;
				loopSource.loop = true;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				base.agent.speed = (Moves ? _def.RoamSpeed : 0f);
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
		}

		private int[] PickBody(MdlModel model)
		{
			int[] array = new int[model.File.BodyParts.Length];
			for (int i = 0; i < array.Length; i++)
			{
				MdlFile.Model[] models = model.File.BodyParts[i].Models;
				string text = ((_def.BodyPrefer != null && i < _def.BodyPrefer.Length) ? _def.BodyPrefer[i] : null);
				int num = -1;
				if (!string.IsNullOrEmpty(text))
				{
					for (int j = 0; j < models.Length; j++)
					{
						if (string.Equals(models[j].Name, text, StringComparison.OrdinalIgnoreCase))
						{
							num = j;
							break;
						}
					}
				}
				if (num >= 0)
				{
					array[i] = num;
					continue;
				}
				List<int> list = model.ModelChoices(i, (string n) => string.IsNullOrEmpty(_def.ExcludeBodyToken) || n.IndexOf(_def.ExcludeBodyToken, StringComparison.OrdinalIgnoreCase) < 0);
				if (list.Count == 0)
				{
					list = model.ModelChoices(i);
				}
				array[i] = ((list.Count > 0) ? list[_rng.Next(list.Count)] : 0);
			}
			return array;
		}

		private static List<MdlModel.Clip> Prefixed(MdlModel m, string prefix)
		{
			if (string.IsNullOrEmpty(prefix))
			{
				return null;
			}
			List<MdlModel.Clip> list = m.ClipsStartingWith(prefix);
			if (list.Count <= 0)
			{
				return null;
			}
			return list;
		}

		private static List<MdlModel.Clip> Named(MdlModel m, string[] names)
		{
			if (names == null)
			{
				return null;
			}
			List<MdlModel.Clip> list = new List<MdlModel.Clip>();
			foreach (string name in names)
			{
				MdlModel.Clip clip = m.FindClip(name);
				if (clip != null)
				{
					list.Add(clip);
				}
			}
			return list;
		}

		private MdlModel.Clip Pick(List<MdlModel.Clip> list)
		{
			if (list != null && list.Count != 0)
			{
				return list[_rng.Next(list.Count)];
			}
			return null;
		}

		private static bool HoldsStill(int state)
		{
			if (state != 2 && state != 3 && state != 4)
			{
				return state == 5;
			}
			return true;
		}

		private void SetState(int state)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			_stateStarted = Time.time;
			if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh)
			{
				base.agent.isStopped = HoldsStill(state);
				if (base.agent.isStopped)
				{
					base.agent.velocity = Vector3.zero;
				}
			}
			if (base.currentBehaviourStateIndex != state)
			{
				((EnemyAI)this).SwitchToBehaviourState(state);
			}
		}

		private void TickMovement(int state)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh)
			{
				return;
			}
			if (HoldsStill(state) || base.stunNormalizedTimer > 0f)
			{
				base.agent.velocity = Vector3.zero;
				return;
			}
			if (base.agent.isStopped)
			{
				base.agent.isStopped = false;
			}
			if (!(_def.TurnSlowdown >= 1f))
			{
				Vector3 desiredVelocity = base.agent.desiredVelocity;
				desiredVelocity.y = 0f;
				if (!(((Vector3)(ref desiredVelocity)).sqrMagnitude < 0.01f))
				{
					float num = Vector3.Angle(((Component)this).transform.forward, desiredVelocity);
					float num2 = Mathf.Lerp(1f, _def.TurnSlowdown, Mathf.InverseLerp(15f, 90f, num));
					float num3 = ((state == 1) ? Plugin.Cfg.ChaseSpeed(_def) : _def.RoamSpeed);
					base.agent.speed = num3 * num2;
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (_def == null || base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
				return;
			}
			float num = Time.time - _stateStarted;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				base.agent.speed = (Moves ? _def.RoamSpeed : 0f);
				if (_def.Lurker)
				{
					PlayerControllerB val = ClosestTargetablePlayer(_def.LurkTriggerRange);
					if ((Object)(object)val != (Object)null)
					{
						BeginEmerge(val);
					}
					break;
				}
				PlayerControllerB val2 = ((EnemyAI)this).CheckLineOfSightForPlayer(70f, Mathf.RoundToInt(_def.SightRange), 3);
				if ((Object)(object)val2 != (Object)null && ((EnemyAI)this).PlayerIsTargetable(val2, false, false, true))
				{
					BeginChase(val2);
				}
				else if (_investigateUntil > 0f && Time.time > _investigateUntil)
				{
					_investigateUntil = 0f;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			}
			case 4:
				base.agent.speed = 0f;
				if (num >= Mathf.Max(0.3f, _appear?.Duration ?? 0.3f))
				{
					SetState(1);
				}
				break;
			case 1:
				ChaseTick();
				break;
			case 2:
				base.agent.speed = 0f;
				if (num >= Mathf.Max(0.4f, _melee?.Duration ?? 1f))
				{
					if (_def.DiesAfterAttack)
					{
						((EnemyAI)this).KillEnemyOnOwnerClient(false);
						break;
					}
					_nextMelee = Time.time + _def.AttackCooldown;
					SetState(1);
				}
				break;
			case 3:
				base.agent.speed = 0f;
				if (num >= Mathf.Max(0.5f, _ranged?.Duration ?? 1f))
				{
					_nextRanged = Time.time + _def.RangedCooldown;
					SetState(1);
				}
				break;
			case 5:
				base.agent.speed = 0f;
				if (num >= Mathf.Max(0.2f, _disappear?.Duration ?? 0.2f))
				{
					base.targetPlayer = null;
					base.movingTowardsTargetPlayer = false;
					SetState(0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			}
		}

		private void ChaseTick()
		{
			//IL_009c: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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)
			if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
			{
				PlayerControllerB val = (_def.Lurker ? ClosestTargetablePlayer(_def.LurkLoseRange) : ((EnemyAI)this).CheckLineOfSightForPlayer(70f, Mathf.RoundToInt(_def.SightRange), 3));
				if (!((Object)(object)val != (Object)null) || !((EnemyAI)this).PlayerIsTargetable(val, false, false, true))
				{
					LoseTarget();
					return;
				}
				base.targetPlayer = val;
				_lastSeenTarget = Time.time;
			}
			Vector3 position = ((Component)base.targetPlayer.gameplayCamera).transform.position;
			bool flag = ((EnemyAI)this).CheckLineOfSightForPosition(position, 100f, Mathf.RoundToInt(Mathf.Max(_def.SightRange, _def.RangedMax) * 1.5f), 3f, (Transform)null);
			if (flag)
			{
				_lastSeenTarget = Time.time;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
			if (_def.Lurker)
			{
				if (num > _def.LurkLoseRange)
				{
					if (_outOfRangeSince < 0f)
					{
						_outOfRangeSince = Time.time;
					}
				}
				else
				{
					_outOfRangeSince = -1f;
				}
				if (_outOfRangeSince > 0f && Time.time - _outOfRangeSince > 4f)
				{
					_outOfRangeSince = -1f;
					LoseTarget();
					return;
				}
			}
			else if (Time.time - _lastSeenTarget > _def.LoseTargetAfter)
			{
				LoseTarget();
				return;
			}
			if (HasMelee && num <= _def.AttackRange * Mathf.Max(1f, _scale) && Time.time >= _nextMelee)
			{
				base.agent.speed = 0f;
				SetState(2);
			}
			else if (_ranged != null && flag && num >= _def.RangedMin && num <= _def.RangedMax && Time.time >= _nextRanged)
			{
				base.agent.speed = 0f;
				SetState(3);
			}
			else if (CanChase)
			{
				base.agent.speed = Plugin.Cfg.ChaseSpeed(_def);
				((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			}
			else
			{
				base.agent.speed = 0f;
				base.movingTowardsTargetPlayer = false;
				base.moveTowardsDestination = false;
			}
		}

		private PlayerControllerB ClosestTargetablePlayer(float range)
		{
			//IL_0038: 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_005c: 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)
			PlayerControllerB result = null;
			float num = range;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(val, false, false, true))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num && Mathf.Abs(((Component)val).transform.position.y - ((Component)this).transform.position.y) < (_def.Outside ? 8f : 3f))
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private void BeginChase(PlayerControllerB player)
		{
			if (base.currentSearch != null && base.currentSearch.inProgress)
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
			}
			_investigateUntil = 0f;
			_lastSeenTarget = Time.time;
			base.targetPlayer = player;
			if (CanChase)
			{
				((EnemyAI)this).SetMovingTowardsTargetPlayer(player);
			}
			SetState(1);
		}

		private void BeginEmerge(PlayerControllerB player)
		{
			if (base.currentSearch != null && base.currentSearch.inProgress)
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
			}
			base.targetPlayer = player;
			_lastSeenTarget = Time.time;
			base.agent.speed = 0f;
			SetState(4);
		}

		private void LoseTarget()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (_def.Lurker)
			{
				SetState(5);
				return;
			}
			base.targetPlayer = null;
			base.movingTowardsTargetPlayer = false;
			SetState(0);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		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_0054: 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_008a: 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 && _def != null && !_def.Lurker && Moves && base.currentBehaviourStateIndex == 0 && !(noiseLoudness < 0.25f) && timesPlayedInOneSpot <= 5 && !(Vector3.Distance(((Component)this).transform.position, noisePosition) > 25f))
			{
				if (base.currentSearch != null && base.currentSearch.inProgress)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				((EnemyAI)this).SetDestinationToPosition(noisePosition, true);
				_investigateUntil = Time.time + 8f;
			}
		}

		public override void Update()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			NetworkManager singleton = NetworkManager.Singleton;
			bool flag = (Object)(object)instance == (Object)null || (Object)(object)RoundManager.Instance == (Object)null || (Object)(object)singleton == (Object)null || !singleton.IsListening;
			if (flag || instance.inShipPhase)
			{
				CleanUpLeftover(flag);
				return;
			}
			((EnemyAI)this).Update();
			if (_def == null || (Object)(object)mdl == (Object)null || mdl.Model == null)
			{
				return;
			}
			float num = Mathf.Max(Time.deltaTime, 0.0001f);
			Vector3 val = ((Component)this).transform.position - _lastPos;
			float num2 = ((Vector3)(ref val)).magnitude / num;
			_speed = Mathf.Lerp(_speed, num2, 1f - Mathf.Exp(-10f * num));
			_lastPos = ((Component)this).transform.position;
			if (_hideBodyAt > 0f && Time.time >= _hideBodyAt)
			{
				_hideBodyAt = -1f;
				if ((Object)(object)body != (Object)null)
				{
					((Renderer)body).enabled = false;
				}
			}
			if (base.isEnemyDead)
			{
				if (!_deathHandled)
				{
					HandleDeath();
				}
				TickHover(base.currentBehaviourStateIndex);
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if (currentBehaviourStateIndex != _lastState)
			{
				OnStateChanged(_lastState, currentBehaviourStateIndex);
				_lastState = currentBehaviourStateIndex;
			}
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 2 || currentBehaviourStateIndex == 3 || (currentBehaviourStateIndex == 1 && !CanChase)))
			{
				FaceTowards(((Component)base.targetPlayer).transform.position);
			}
			if (_pendingStrike > 0f && Time.time >= _pendingStrike)
			{
				_pendingStrike = -1f;
				if (_pendingRanged)
				{
					TryRangedOnLocalPlayer();
				}
				else
				{
					TryMeleeOnLocalPlayer();
				}
			}
			ChooseAnimation(currentBehaviourStateIndex);
			TickMovement(currentBehaviourStateIndex);
			TickHover(currentBehaviourStateIndex);
			FitHitbox();
			TickAura();
			TickVoice(currentBehaviourStateIndex);
		}

		private void ChooseAnimation(int state)
		{
			if (base.stunNormalizedTimer > 0f)
			{
				mdl.Speed = 1f;
				mdl.Play(_stun, loop: true);
			}
			else
			{
				if (Time.time < _flinchUntil)
				{
					return;
				}
				switch (state)
				{
				case 2:
				case 3:
				case 4:
				case 5:
					return;
				case 0:
					if (_def.Lurker)
					{
						mdl.Speed = 1f;
						mdl.Play(_hidden ?? _idle, loop: true, 0.2f);
						return;
					}
					break;
				}
				MdlModel.Clip clip = ((state == 1) ? (_run ?? _walk) : (_walk ?? _run));
				if (_speed > 0.2f && clip != null)
				{
					float num = clip.MoveSpeed * _scale;
					mdl.Speed = ((num > 0.01f) ? Mathf.Clamp(_speed / num, 0.6f, 2.5f) : 1f);
					mdl.Play(clip, loop: true, 0.25f);
				}
				else
				{
					mdl.Speed = 1f;
					mdl.Play(_idle, loop: true, 0.3f);
				}
			}
		}

		private void FitHitbox()
		{
			//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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_014d: 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_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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: 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_01fc: 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_01c5: 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_01de: 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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			Collider obj = hitbox;
			CapsuleCollider val = (CapsuleCollider)(object)((obj is CapsuleCollider) ? obj : null);
			if ((Object)(object)val == (Object)null || !((Collider)val).enabled || (Object)(object)mdl == (Object)null || mdl.bones == null)
			{
				return;
			}
			Transform transform = ((Component)val).transform;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(float.MaxValue, float.MaxValue, float.MaxValue);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(float.MinValue, float.MinValue, float.MinValue);
			int num = 0;
			float num2 = ((_def.HoverHeight > 0f) ? float.MinValue : (-0.1f));
			Transform[] bones = mdl.bones;
			foreach (Transform val4 in bones)
			{
				if (!((Object)(object)val4 == (Object)null))
				{
					Vector3 val5 = transform.InverseTransformPoint(val4.position);
					if (!(transform.TransformPoint(val5).y - ((Component)this).transform.position.y < num2))
					{
						val2 = Vector3.Min(val2, val5);
						val3 = Vector3.Max(val3, val5);
						num++;
					}
				}
			}
			if (num >= 2)
			{
				float num3 = 0.25f * Mathf.Max(0.5f, _scale);
				val2 -= new Vector3(num3, 0f, num3);
				val3 += new Vector3(num3, num3, num3);
				if (_def.HoverHeight <= 0f)
				{
					val2.y = Mathf.Max(0f, Mathf.Min(val2.y, 0.1f));
				}
				Vector3 val6 = val3 - val2;
				val.center = (val2 + val3) * 0.5f;
				if (val6.y >= Mathf.Max(val6.x, val6.z))
				{
					val.direction = 1;
					val.height = val6.y;
					val.radius = Mathf.Max(0.2f, Mathf.Max(val6.x, val6.z) * 0.5f);
				}
				else
				{
					val.direction = ((!(val6.x >= val6.z)) ? 2 : 0);
					val.height = Mathf.Max(val6.x, val6.z);
					val.radius = Mathf.Max(0.2f, Mathf.Max(val6.y, Mathf.Min(val6.x, val6.z)) * 0.5f);
				}
			}
		}

		private void TickHover(int state)
		{
			//IL_0121: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hover == (Object)null || _def.HoverHeight <= 0f)
			{
				return;
			}
			float num = _def.HoverHeight;
			if (base.isEnemyDead)
			{
				num = 0f;
			}
			else if (state == 2)
			{
				num = _def.HoverLow;
			}
			else
			{
				float num2 = float.MaxValue;
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead)
					{
						num2 = Mathf.Min(num2, Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position));
					}
				}
				if (num2 < _def.AttackRange * 3f)
				{
					num = _def.HoverLow;
				}
			}
			float num3 = (base.isEnemyDead ? 6f : 2.5f);
			_hoverY = Mathf.MoveTowards(_hoverY, num, num3 * Time.deltaTime);
			hover.localPosition = new Vector3(0f, _hoverY, 0f);
		}

		private void OnStateChanged(int from, int to)
		{
			ApplyVisibility();
			_pendingStrike = -1f;
			switch (to)
			{
			case 1:
				if (from == 0 || from == 4 || from == -1)
				{
					PlayVoice(_rt.Alert);
					_nextVoice = Time.time + 6f + (float)_rng.NextDouble() * 6f;
				}
				break;
			case 4:
				mdl.Speed = 1f;
				mdl.Play(_appear ?? _idle, loop: false, 0.05f, restart: true);
				PlaySfx(_rt.Appear);
				break;
			case 5:
				mdl.Speed = 1f;
				if (_disappear != null)
				{
					mdl.Play(_disappear, loop: false, 0.1f, restart: true);
				}
				break;
			case 2:
				mdl.Speed = 1f;
				mdl.Play(_melee, loop: false, 0.1f, restart: true);
				PlayVoice(_rt.Attack);
				ScheduleStrikeIfNoEvents(_melee, ranged: false);
				break;
			case 3:
				mdl.Speed = 1f;
				mdl.Play(_ranged, loop: false, 0.1f, restart: true);
				ScheduleStrikeIfNoEvents(_ranged, ranged: true);
				break;
			}
		}

		private void ScheduleStrikeIfNoEvents(MdlModel.Clip clip, bool ranged)
		{
			if (clip == null)
			{
				return;
			}
			if (clip.Events != null)
			{
				MdlFile.Event[] events = clip.Events;
				for (int i = 0; i < events.Length; i++)
				{
					if (events[i].Id < 1000)
					{
						return;
					}
				}
			}
			_pendingRanged = ranged;
			_pendingStrike = Time.time + clip.Duration * 0.5f;
		}

		private void ApplyVisibility()
		{
			bool flag = _def != null && _def.Lurker && base.currentBehaviourStateIndex == 0 && !base.isEnemyDead;
			if ((Object)(object)body != (Object)null && _hideBodyAt < 0f)
			{
				((Renderer)body).enabled = !flag;
			}
			if ((Object)(object)hitbox != (Object)null)
			{
				hitbox.enabled = !flag && !base.isEnemyDead;
			}
			if ((Object)(object)loopSource != (Object)null && (Object)(object)_rt?.Loop != (Object)null)
			{
				if (flag || base.isEnemyDead)
				{
					loopSource.Stop();
				}
				else if (!loopSource.isPlaying)
				{
					loopSource.Play();
				}
			}
		}

		private void FaceTowards(Vector3 target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0011: 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_003e: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - ((Component)this).transform.position;
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), 300f * Time.deltaTime);
			}
		}

		private void HandleAnimEvent(MdlModel.Clip clip, MdlFile.Event e)
		{
			if (base.isEnemyDead)
			{
				return;
			}
			if (MonsterAssets.IsSoundEvent(e.Id))
			{
				PlaySfx(MonsterAssets.Sound(e.Options), 0.7f);
			}
			else if (e.Id < 1000)
			{
				int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
				if (clip == _melee && currentBehaviourStateIndex == 2)
				{
					TryMeleeOnLocalPlayer();
				}
				else if (clip == _ranged && currentBehaviourStateIndex == 3)
				{
					TryRangedOnLocalPlayer();
				}
				else if ((clip == _walk || clip == _run) && (Object)(object)_rt.MoveEvent != (Object)null)
				{
					PlaySfx(_rt.MoveEvent, 0.6f);
				}
			}
		}

		private PlayerControllerB LocalTarget()
		{
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead || base.stunNormalizedTimer > 0f)
			{
				return null;
			}
			return val;
		}

		private bool ClearShot(PlayerControllerB p)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0028: 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)
			return !Physics.Linecast(((Object)(object)base.eye != (Object)null) ? base.eye.position : (((Component)this).transform.position + Vector3.up * 1.5f), ((Component)p.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
		}

		private void TryMeleeOnLocalPlayer()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_00b5: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			PlayerControllerB val = LocalTarget();
			if ((Object)(object)val != (Object)null)
			{
				Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				val2.y = 0f;
				bool flag2 = ((Vector3)(ref val2)).sqrMagnitude < 0.01f || Vector3.Angle(((Component)this).transform.forward, val2) < 75f;
				if (magnitude <= _def.AttackReach * Mathf.Max(1f, _scale) && flag2 && ClearShot(val))
				{
					val.DamagePlayer(Plugin.Cfg.Damage(_def), true, true, _rt.MeleeCause, 0, false, ((Component)this).transform.forward * 6f);
					flag = true;
				}
			}
			PlaySfx(flag ? _rt.Hit : _rt.Miss);
		}

		private void TryRangedOnLocalPlayer()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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)
			PlaySfx(_rt.Ranged);
			PlayerControllerB val = LocalTarget();
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				val2.y = 0f;
				if (!(magnitude > _def.RangedMax * 1.15f) && !(magnitude < _def.RangedMin * 0.8f) && (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f) || !(Vector3.Angle(((Component)this).transform.forward, val2) > 45f)) && ClearShot(val))
				{
					val.DamagePlayer(Plugin.Cfg.RangedDamage(_def), true, true, _rt.RangedCause, 0, false, ((Component)this).transform.forward * 3f);
				}
			}
		}

		private void TickAura()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!(_def.AuraDamagePerSecond <= 0f) && !(Time.time < _nextAura))
			{
				_nextAura = Time.time + 0.5f;
				PlayerControllerB val = LocalTarget();
				if (!((Object)(object)val == (Object)null) && !(Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) > _def.AuraRange * _scale) && ClearShot(val))
				{
					int num = Mathf.Max(1, Mathf.RoundToInt(_def.AuraDamagePerSecond * 0.5f));
					val.DamagePlayer(num, true, true, _rt.AuraCause, 0, false, Vector3.zero);
				}
			}
		}

		private void TickVoice(int state)
		{
			if (Time.time < _nextVoice)
			{
				return;
			}
			if (_def.Lurker && state == 0)
			{
				_nextVoice = Time.time + 5f;
				return;
			}
			AudioClip[] array = ((state != 0) ? _rt.Alert : ((_rt.Idle.Length != 0) ? _rt.Idle : null));
			if (array != null)
			{
				PlayVoice(array);
			}
			_nextVoice = Time.time + ((state == 0) ? 10f : 6f) + (float)_rng.NextDouble() * 8f;
		}

		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 || _def == null)
			{
				return;
			}
			base.enemyHP -= force;
			PlayVoice(_rt.Pain);
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if (_flinches.Count > 0 && currentBehaviourStateIndex != 2 && currentBehaviourStateIndex != 3 && currentBehaviourStateIndex != 4)
			{
				MdlModel.Clip clip = _flinches[Random.Range(0, _flinches.Count)];
				mdl.Speed = 1f;
				mdl.Play(clip, loop: false, 0.05f, restart: true);
				_flinchUntil = Time.time + Mathf.Min(clip.Duration, 0.8f);
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (base.enemyHP <= 0)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
			else if ((Object)(object)playerWhoHit != (Object)null && ((EnemyAI)this).PlayerIsTargetable(playerWhoHit, false, false, true))
			{
				if (currentBehaviourStateIndex == 0 && !_def.Lurker)
				{
					BeginChase(playerWhoHit);
				}
				else if (currentBehaviourStateIndex == 0 && _def.Lurker)
				{
					BeginEmerge(playerWhoHit);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			if (!destroy)
			{
				HandleDeath();
			}
		}

		private void HandleDeath()
		{
			if (_deathHandled || (Object)(object)mdl == (Object)null || _def == null)
			{
				return;
			}
			_deathHandled = true;
			_pendingStrike = -1f;
			if ((Object)(object)loopSource != (Object)null)
			{
				loopSource.Stop();
			}
			if ((Object)(object)hitbox != (Object)null)
			{
				hitbox.enabled = false;
			}
			if (_def.DiesAfterAttack && mdl.Current == _melee)
			{
				return;
			}
			if (_deaths.Count > 0)
			{
				MdlModel.Clip clip = _deaths[_rng.Next(_deaths.Count)];
				mdl.Speed = 1f;
				mdl.Play(clip, loop: false, 0.1f, restart: true);
				if (_def.Lurker)
				{
					_hideBodyAt = Time.time + clip.Duration + 0.1f;
				}
			}
			else
			{
				mdl.Paused = true;
				_hideBodyAt = Time.time + 0.4f;
			}
			AudioClip[] array = ((_rt.Death.Length != 0) ? _rt.Death : _rt.Pain);
			if (array.Length != 0 && (Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.PlayOneShot(array[Random.Range(0, array.Length)]);
			}
		}

		private void CleanUpLeftover(bool sessionGone)
		{
			if (_cleanedUp)
			{
				return;
			}
			_cleanedUp = true;
			((MonoBehaviour)this).StopAllCoroutines();
			if ((Object)(object)loopSource != (Object)null)
			{
				loopSource.Stop();
			}
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Stop();
			}
			if ((Object)(object)base.creatureSFX != (Object)null)
			{
				base.creatureSFX.Stop();
			}
			if ((Object)(object)body != (Object)null)
			{
				((Renderer)body).enabled = false;
			}
			if ((Object)(object)hitbox != (Object)null)
			{
				hitbox.enabled = false;
			}
			if ((Object)(object)base.agent != (Object)null)
			{
				((Behaviour)base.agent).enabled = false;
			}
			if (sessionGone)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Plugin.Log.LogWarning((object)(((Object)this).name + " was still around after the round ended; removing it."));
			NetworkObject networkObject = ((NetworkBehaviour)this).NetworkObject;
			if ((Object)(object)networkObject != (Object)null && networkObject.IsSpawned)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					networkObject.Despawn(true);
				}
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void PlayVoice(AudioClip[] set)
		{
			if (set != null && set.Length != 0 && !((Object)(object)base.creatureVoice == (Object)null))
			{
				AudioClip val = set[Random.Range(0, set.Length)];
				base.creatureVoice.PlayOneShot(val);
				WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, base.creatureVoice.volume);
			}
		}

		private void PlaySfx(AudioClip[] set, float volume = 1f)
		{
			if (set != null && set.Length != 0)
			{
				PlaySfx(set[Random.Range(0, set.Length)], volume);
			}
		}

		private void PlaySfx(AudioClip clip, float volume = 1f)
		{
			if (!((Object)(object)clip == (Object)null) && !((Object)(object)base.creatureSFX == (Object)null))
			{
				base.creatureSFX.PlayOneShot(clip, volume);
			}
		}
	}
	public static class MonsterCatalog
	{
		private static readonly string[] SlowerAlert = new string[3] { "slower/slower_alert10.wav", "slower/slower_alert20.wav", "slower/slower_alert30.wav" };

		private static readonly string[] SlowerAttack = new string[2] { "slower/slower_attack1.wav", "slower/slower_attack2.wav" };

		private static readonly string[] SlowerPain = new string[2] { "slower/slower_pain1.wav", "slower/slower_pain2.wav" };

		private static readonly string[] HammerHit = new string[3] { "slower/hammer_strike1.wav", "slower/hammer_strike2.wav", "slower/hammer_strike3.wav" };

		private static readonly string[] HammerMiss = new string[2] { "slower/hammer_miss1.wav", "slower/hammer_miss2.wav" };

		private static readonly string[] FistHit = new string[3] { "faceless/fist_strike1.wav", "faceless/fist_strike2.wav", "faceless/fist_strike3.wav" };

		private static readonly string[] FistMiss = new string[2] { "faceless/fist_miss1.wav", "faceless/fist_miss2.wav" };

		private static readonly string[] KnifeHit = new string[2] { "crazylady/knife_hitbody1.wav", "crazylady/knife_hitbody2.wav" };

		private static readonly string[] KnifeMiss = new string[1] { "crazylady/knife_swing.wav" };

		private static readonly string[] ChainsawHit = new string[1] { "sawrunner/chainsaw_attack_hit.wav" };

		private static readonly string[] ChainsawMiss = new string[1] { "sawrunner/chainsaw_attack_miss.wav" };

		public const float ChaseBoost = 1.3f;

		public const float RoamBoost = 1.25f;

		private static string[] Zombie(string folder, string kind)
		{
			return kind switch
			{
				"alert" => new string[3]
				{
					folder + "/zo_alert10.wav",
					folder + "/zo_alert20.wav",
					folder + "/zo_alert30.wav"
				}, 
				"attack" => new string[2]
				{
					folder + "/zo_attack1.wav",
					folder + "/zo_attack2.wav"
				}, 
				"pain" => new string[2]
				{
					folder + "/zo_pain1.wav",
					folder + "/zo_pain2.wav"
				}, 
				"hit" => new string[3]
				{
					folder + "/claw_strike1.wav",
					folder + "/claw_strike2.wav",
					folder + "/claw_strike3.wav"
				}, 
				_ => new string[2]
				{
					folder + "/claw_miss1.wav",
					folder + "/claw_miss2.wav"
				}, 
			};
		}

		public static IEnumerable<MonsterDefinition> All()
		{
			foreach (MonsterDefinition item in Raw())
			{
				if (item.Id != "Taller" && item.Id != "CrazyWoman")
				{
					item.ChaseSpeed *= 1.3f;
					item.RoamSpeed *= 1.25f;
				}
				yield return item;
			}
		}

		private static IEnumerable<MonsterDefinition> Raw()
		{
			yield return new MonsterDefinition
			{
				Id = "Slower",
				DisplayName = "Slower",
				ModelFile = "slower.mdl",
				TerminalWord = "slower",
				BestiaryText = "Hunched, shambling figure that wanders the halls swinging a blunt tool. Slow on its feet but it never gives up once it has seen you, and it follows noise.\n\nKeep corners between you and it. A few solid hits put it down.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.4f,
				Rarity = 35,
				MaxCount = 5,
				AlertSounds = SlowerAlert,
				AttackSounds = SlowerAttack,
				HitSounds = HammerHit,
				MissSounds = HammerMiss,
				PainSounds = SlowerPain
			};
			yield return new MonsterDefinition
			{
				Id = "SlowerB",
				DisplayName = "Slower (Ragged)",
				ModelFile = "slower3.mdl",
				TerminalWord = "raggedslower",
				BestiaryText = "A Slower in worse shape than most. Same slow, stubborn hunt and the same heavy swing.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.5f,
				ChaseSpeed = 3.3f,
				Rarity = 20,
				MaxCount = 4,
				AlertSounds = new string[3] { "slower3/slower_alert10.wav", "slower3/slower_alert20.wav", "slower3/slower_alert30.wav" },
				AttackSounds = new string[2] { "slower3/slower_attack1.wav", "slower3/slower_attack2.wav" },
				PainSounds = new string[2] { "slower3/slower_pain1.wav", "slower3/slower_pain2.wav" },
				HitSounds = HammerHit,
				MissSounds = HammerMiss
			};
			yield return new MonsterDefinition
			{
				Id = "SlowerC",
				DisplayName = "Slower (Pale)",
				ModelFile = "slowerno.mdl",
				TerminalWord = "paleslower",
				BestiaryText = "A pale Slower variant. Behaves like the others: wanders, listens, and swings hard at close range.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.4f,
				Rarity = 15,
				MaxCount = 3,
				AlertSounds = SlowerAlert,
				AttackSounds = SlowerAttack,
				HitSounds = HammerHit,
				MissSounds = HammerMiss,
				PainSounds = SlowerPain
			};
			yield return new MonsterDefinition
			{
				Id = "SlowerD",
				DisplayName = "Slower (Bound)",
				ModelFile = "tenslower.mdl",
				TerminalWord = "boundslower",
				BestiaryText = "A Slower variant that tends to turn up in groups. Its swings are slower but land hard.",
				Health = 5,
				Damage = 22,
				RoamSpeed = 1.4f,
				ChaseSpeed = 3.1f,
				Rarity = 15,
				MaxCount = 4,
				AlertSounds = SlowerAlert,
				AttackSounds = SlowerAttack,
				HitSounds = HammerHit,
				MissSounds = HammerMiss,
				PainSounds = SlowerPain
			};
			yield return new MonsterDefinition
			{
				Id = "CrawlingSlower",
				DisplayName = "Crawling Slower",
				ModelFile = "slower2.mdl",
				TerminalWord = "crawler",
				BestiaryText = "A Slower that drags itself along the floor. Low to the ground and easy to miss in the dark: watch your feet.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 1.2f,
				ChaseSpeed = 2.6f,
				AttackRange = 1.3f,
				AttackReach = 1.8f,
				Rarity = 15,
				MaxCount = 4,
				WalkPrefix = "walk2",
				AttackClips = new string[1] { "attack1" },
				AlertSounds = SlowerAlert,
				AttackSounds = SlowerAttack,
				HitSounds = FistHit,
				MissSounds = FistMiss,
				PainSounds = SlowerPain
			};
			yield return new MonsterDefinition
			{
				Id = "Cutter",
				DisplayName = "Cutter",
				ModelFile = "monster_cutter.mdl",
				TerminalWord = "cutter",
				BestiaryText = "Moves like a Slower but carries a blade. Quicker to close the gap, and its cuts hurt.",
				Health = 4,
				Damage = 25,
				RoamSpeed = 1.7f,
				ChaseSpeed = 3.6f,
				Rarity = 15,
				MaxCount = 3,
				MeleeCause = "Stabbing",
				AlertSounds = SlowerAlert,
				AttackSounds = SlowerAttack,
				HitSounds = KnifeHit,
				MissSounds = KnifeMiss,
				PainSounds = SlowerPain
			};
			string[] fasterAlert = new string[2] { "faster/faster_alert1.wav", "faster/faster_alert2.wav" };
			string[] fasterHit = new string[4] { "faster/faster_hit1.wav", "faster/faster_hit2.wav", "faster/faster_hit3.wav", "faster/faster_hit4.wav" };
			yield return new MonsterDefinition
			{
				Id = "Faster",
				DisplayName = "Faster",
				ModelFile = "faster.mdl",
				TerminalWord = "faster",
				BestiaryText = "Sprints on all fours and hits in quick bursts. You won't outrun it in a straight line. Fight it in a doorway.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 2.2f,
				ChaseSpeed = 6f,
				AttackCooldown = 0.3f,
				Rarity = 20,
				MaxCount = 3,
				MeleeCause = "Mauling",
				WalkPrefix = null,
				RunPrefix = "run",
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = fasterAlert,
				AttackSounds = new string[1] { "faster/faster_attack.wav" },
				HitSounds = fasterHit,
				MissSounds = new string[1] { "faster/faster_miss.wav" },
				PainSounds = new string[1] { "faster/faster_pain.wav" },
				DeathSounds = new string[1] { "faster/faster_death.wav" },
				MoveEventSound = "faster/faster_step.wav"
			};
			yield return new MonsterDefinition
			{
				Id = "FasterB",
				DisplayName = "Faster (Scarred)",
				ModelFile = "faster3.mdl",
				TerminalWord = "scarredfaster",
				BestiaryText = "A scarred Faster with an extra attack in its repertoire. Just as quick, just as aggressive.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 2.2f,
				ChaseSpeed = 6f,
				AttackCooldown = 0.3f,
				Rarity = 12,
				MaxCount = 3,
				MeleeCause = "Mauling",
				WalkPrefix = null,
				RunPrefix = "run",
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = fasterAlert,
				AttackSounds = new string[1] { "faster/faster_attack.wav" },
				HitSounds = fasterHit,
				MissSounds = new string[1] { "faster/faster_miss.wav" },
				PainSounds = new string[1] { "faster/faster_pain.wav" },
				DeathSounds = new string[1] { "faster/faster_death.wav" },
				MoveEventSound = "faster/faster_step.wav"
			};
			yield return new MonsterDefinition
			{
				Id = "FasterClown",
				DisplayName = "Faster (Clown)",
				ModelFile = "faster_clown.mdl",
				TerminalWord = "clown",
				BestiaryText = "A Faster in clown paint. Nothing about it is funny once it starts running.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 2.2f,
				ChaseSpeed = 6f,
				AttackCooldown = 0.3f,
				Rarity = 6,
				MaxCount = 2,
				MeleeCause = "Mauling",
				WalkPrefix = null,
				RunPrefix = "run",
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = fasterAlert,
				AttackSounds = new string[1] { "faster/faster_attack.wav" },
				HitSounds = fasterHit,
				MissSounds = new string[1] { "faster/faster_miss.wav" },
				PainSounds = new string[1] { "faster/faster_pain.wav" },
				DeathSounds = new string[1] { "faster/faster_death.wav" },
				MoveEventSound = "faster/faster_step.wav"
			};
			yield return new MonsterDefinition
			{
				Id = "Children",
				DisplayName = "Children",
				ModelFile = "children.mdl",
				TerminalWord = "children",
				BestiaryText = "Small, quick, and armed with something sharp. Weak on its own but easy to lose track of in a crowd.",
				Scale = 1.15f,
				Health = 2,
				Damage = 12,
				RoamSpeed = 1.8f,
				ChaseSpeed = 4.2f,
				AttackRange = 1.2f,
				AttackReach = 1.7f,
				Rarity = 20,
				MaxCount = 5,
				MeleeCause = "Stabbing",
				AlertSounds = new string[3] { "children/child_alert10.wav", "children/child_alert20.wav", "children/child_alert30.wav" },
				AttackSounds = new string[2] { "children/child_attack1.wav", "children/child_attack2.wav" },
				HitSounds = new string[1] { "children/child_slice.wav" },
				MissSounds = new string[1] { "children/child_slash.wav" },
				PainSounds = new string[2] { "children/child_pain1.wav", "children/child_pain2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Baby",
				DisplayName = "Baby",
				ModelFile = "baby.mdl",
				TerminalWord = "baby",
				BestiaryText = "A small, malformed thing that lunges once it is close. Kill it before it reaches you.",
				Health = 2,
				Damage = 15,
				RoamSpeed = 1.4f,
				ChaseSpeed = 3f,
				AttackRange = 1.3f,
				AttackReach = 1.9f,
				Rarity = 12,
				MaxCount = 3,
				MeleeCause = "Mauling",
				AttackClips = new string[1] { "attack" },
				StunClip = "flinch",
				AlertSounds = new string[3] { "baby/b_alert1.wav", "baby/b_alert2.wav", "baby/b_alert3.wav" },
				AttackSounds = new string[2] { "baby/b_attack1.wav", "baby/b_attack2.wav" },
				HitSounds = Zombie("zombie", "hit"),
				MissSounds = Zombie("zombie", "miss"),
				PainSounds = new string[2] { "baby/b_pain1.wav", "baby/b_pain2.wav" },
				DeathSounds = new string[2] { "baby/b_death1.wav", "baby/b_death2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "CrazyWoman",
				DisplayName = "Crazy Woman",
				ModelFile = "crazywoman.mdl",
				TerminalWord = "crazywoman",
				BestiaryText = "Wanders slowly, then stabs twice in quick succession. Back off after the first strike.",
				Health = 3,
				Damage = 18,
				RoamSpeed = 1f,
				ChaseSpeed = 2.2f,
				Rarity = 12,
				MaxCount = 2,
				MeleeCause = "Stabbing",
				AttackClips = new string[1] { "attack" },
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = new string[3] { "crazylady/lady_alert10.wav", "crazylady/lady_alert20.wav", "crazylady/lady_alert30.wav" },
				AttackSounds = new string[2] { "crazylady/lady_attack1.wav", "crazylady/lady_attack2.wav" },
				HitSounds = KnifeHit,
				MissSounds = KnifeMiss,
				PainSounds = new string[2] { "crazylady/lady_pain1.wav", "crazylady/lady_pain2.wav" }
			};
			string[] rcAlert = new string[3] { "rcrazy/rc_alert1.wav", "rcrazy/rc_alert2.wav", "rcrazy/rc_alert3.wav" };
			yield return new MonsterDefinition
			{
				Id = "RunningCrazy",
				DisplayName = "Running Crazy",
				ModelFile = "runningcrazy.mdl",
				TerminalWord = "runningcrazy",
				BestiaryText = "Screams, charges, and swings. It doesn't stop to think, and neither should you.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 2f,
				ChaseSpeed = 5.4f,
				Rarity = 14,
				MaxCount = 3,
				AttackClips = new string[1] { "attack" },
				StunClip = null,
				AlertSounds = rcAlert,
				AttackSounds = Zombie("zombie2", "attack"),
				HitSounds = FistHit,
				MissSounds = FistMiss,
				PainSounds = Zombie("zombie2", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "CrazyRumpel",
				DisplayName = "Running Crazy (Torn)",
				ModelFile = "crazyrumpel.mdl",
				TerminalWord = "torncrazy",
				BestiaryText = "Another Running Crazy, in torn clothes. Same reckless charge.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 2f,
				ChaseSpeed = 5.4f,
				Rarity = 8,
				MaxCount = 2,
				AttackClips = new string[1] { "attack" },
				StunClip = null,
				AlertSounds = rcAlert,
				AttackSounds = Zombie("zombie2", "attack"),
				HitSounds = FistHit,
				MissSounds = FistMiss,
				PainSounds = Zombie("zombie2", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "DavidMonster",
				DisplayName = "David Monster",
				ModelFile = "david_monster.mdl",
				TerminalWord = "david",
				BestiaryText = "A lurching brute carrying an axe. Slow, but one clean hit takes a big chunk out of you.",
				Health = 5,
				Damage = 30,
				RoamSpeed = 1.1f,
				ChaseSpeed = 2.4f,
				AttackRange = 1.6f,
				AttackReach = 2.2f,
				AttackCooldown = 1f,
				Rarity = 10,
				PowerLevel = 2f,
				MaxCount = 2,
				AttackClips = new string[2] { "attack_axe", "attack" },
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = new string[3] { "davidbad/db_alert10.wav", "davidbad/db_alert20.wav", "davidbad/db_alert30.wav" },
				AttackSounds = new string[1] { "davidbad/david_attack.wav" },
				HitSounds = new string[2] { "davidbad/Axe_hitbody.wav", "davidbad/axe_hit.wav" },
				MissSounds = new string[1] { "davidbad/Axe_swing.wav" },
				PainSounds = new string[4] { "davidbad/db_pain1.wav", "davidbad/db_pain2.wav", "davidbad/david_hurt.wav", "davidbad/david_hurt2.wav" }
			};
			string[] facelessAlert = new string[3] { "faceless/faceless_alert10.wav", "faceless/faceless_alert20.wav", "faceless/faceless_alert30.wav" };
			string[] facelessAttack = new string[2] { "faceless/faceless_attack1.wav", "faceless/faceless_attack2.wav" };
			string[] facelessPain = new string[2] { "faceless/faceless_pain1.wav", "faceless/faceless_pain2.wav" };
			yield return new MonsterDefinition
			{
				Id = "Faceless",
				DisplayName = "Faceless",
				ModelFile = "Faceless.mdl",
				TerminalWord = "faceless",
				BestiaryText = "No face, no hesitation. Walks straight at you and punches hard.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.5f,
				ChaseSpeed = 3.4f,
				Rarity = 14,
				MaxCount = 3,
				AlertSounds = facelessAlert,
				AttackSounds = facelessAttack,
				HitSounds = FistHit,
				MissSounds = FistMiss,
				PainSounds = facelessPain
			};
			yield return new MonsterDefinition
			{
				Id = "FacelessB",
				DisplayName = "Faceless (Bandaged)",
				ModelFile = "faceless3.mdl",
				TerminalWord = "bandaged",
				BestiaryText = "A Faceless variant wrapped in bandages. Behaves the same.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.5f,
				ChaseSpeed = 3.4f,
				Rarity = 8,
				MaxCount = 2,
				AlertSounds = facelessAlert,
				AttackSounds = facelessAttack,
				HitSounds = FistHit,
				MissSounds = FistMiss,
				PainSounds = facelessPain
			};
			yield return new MonsterDefinition
			{
				Id = "Twister",
				DisplayName = "Twister",
				ModelFile = "twister.mdl",
				TerminalWord = "twister",
				BestiaryText = "A contorted body that moves faster than it looks like it should. Claws at close range.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.7f,
				Rarity = 12,
				MaxCount = 3,
				MeleeCause = "Mauling",
				AlertSounds = Zombie("zombie3", "alert"),
				AttackSounds = Zombie("zombie3", "attack"),
				HitSounds = Zombie("zombie3", "hit"),
				MissSounds = Zombie("zombie3", "miss"),
				PainSounds = Zombie("zombie3", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "TwisterV",
				DisplayName = "Twister (Veiled)",
				ModelFile = "twisterv.mdl",
				TerminalWord = "veiled",
				BestiaryText = "A veiled Twister. Same twisted gait, same claws.",
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.7f,
				Rarity = 8,
				MaxCount = 2,
				MeleeCause = "Mauling",
				AlertSounds = Zombie("zombie3", "alert"),
				AttackSounds = Zombie("zombie3", "attack"),
				HitSounds = Zombie("zombie3", "hit"),
				MissSounds = Zombie("zombie3", "miss"),
				PainSounds = Zombie("zombie3", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "Psycho",
				DisplayName = "Psycho",
				ModelFile = "psycho.mdl",
				TerminalWord = "psycho",
				BestiaryText = "Tall and heavy. It charges fast in a straight line but turns like a truck, so sidestep and make it come around. Its swings hit harder than almost anything else down here.",
				Scale = 1.1f,
				Health = 6,
				Damage = 35,
				RoamSpeed = 1.5f,
				ChaseSpeed = 4.2f,
				TurnSlowdown = 0.3f,
				AngularSpeed = 150f,
				Acceleration = 8f,
				AttackRange = 1.7f,
				AttackReach = 2.3f,
				AttackCooldown = 1f,
				Rarity = 8,
				PowerLevel = 2f,
				MaxCount = 2,
				StunClip = "flinch",
				AlertSounds = facelessAlert,
				AttackSounds = facelessAttack,
				HitSounds = HammerHit,
				MissSounds = HammerMiss,
				PainSounds = facelessPain
			};
			yield return new MonsterDefinition
			{
				Id = "PsychoPumpkin",
				DisplayName = "Psycho (Pumpkin)",
				ModelFile = "psychopumpkin.mdl",
				TerminalWord = "pumpkin",
				BestiaryText = "A Psycho wearing a carved pumpkin. Just as heavy-handed.",
				Scale = 1.1f,
				Health = 6,
				Damage = 35,
				RoamSpeed = 1.5f,
				ChaseSpeed = 4.2f,
				TurnSlowdown = 0.3f,
				AngularSpeed = 150f,
				Acceleration = 8f,
				AttackRange = 1.7f,
				AttackReach = 2.3f,
				AttackCooldown = 1f,
				Rarity = 4,
				PowerLevel = 2f,
				MaxCount = 1,
				StunClip = "flinch",
				AlertSounds = facelessAlert,
				AttackSounds = facelessAttack,
				HitSounds = HammerHit,
				MissSounds = HammerMiss,
				PainSounds = facelessPain
			};
			yield return new MonsterDefinition
			{
				Id = "Sewmo",
				DisplayName = "Sewmo",
				ModelFile = "sewmo.mdl",
				TerminalWord = "sewmo",
				BestiaryText = "A stitched-together body that hunts in damp places. Claws and a long reach.",
				Health = 5,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.6f,
				AttackReach = 2.2f,
				Rarity = 10,
				MaxCount = 3,
				MeleeCause = "Mauling",
				AlertSounds = new string[3] { "sewmo/sewmo_alert10.wav", "sewmo/sewmo_alert20.wav", "sewmo/sewmo_alert30.wav" },
				AttackSounds = new string[2] { "sewmo/sewmo_attack1.wav", "sewmo/sewmo_attack2.wav" },
				HitSounds = new string[3] { "sewmo/claw_strike1.wav", "sewmo/claw_strike2.wav", "sewmo/claw_strike3.wav" },
				MissSounds = new string[3] { "sewmo/claw_miss1.wav", "sewmo/claw_miss2.wav", "sewmo/claw_miss3.wav" },
				PainSounds = new string[2] { "sewmo/sewmo_pain1.wav", "sewmo/sewmo_pain2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Upper",
				DisplayName = "Upper",
				ModelFile = "upper.mdl",
				TerminalWord = "upper",
				BestiaryText = "Mostly torso, hauling itself along on its arms. Faster than you'd expect from something with no legs.",
				Scale = 1f,
				Health = 4,
				Damage = 20,
				RoamSpeed = 1.6f,
				ChaseSpeed = 3.6f,
				Rarity = 10,
				MaxCount = 3,
				MeleeCause = "Mauling",
				StunClip = null,
				AlertSounds = Zombie("zombie", "alert"),
				AttackSounds = Zombie("zombie", "attack"),
				HitSounds = Zombie("zombie", "hit"),
				MissSounds = Zombie("zombie", "miss"),
				PainSounds = Zombie("zombie", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "Krypande",
				DisplayName = "Krypande",
				ModelFile = "krypande.mdl",
				TerminalWord = "krypande",
				BestiaryText = "Skitters on all fours like an insect. Low, quick, and hard to hit. Listen for it before you see it.",
				Health = 3,
				Damage = 15,
				RoamSpeed = 1.7f,
				ChaseSpeed = 3.6f,
				AttackRange = 1.3f,
				AttackReach = 1.8f,
				Rarity = 12,
				MaxCount = 3,
				MeleeCause = "Mauling",
				DeathPrefix = "death",
				StunClip = "flinch",
				AlertSounds = new string[3] { "slower/k_crawl1.wav", "slower/k_crawl2.wav", "slower/k_crawl3.wav" },
				IdleSounds = new string[4] { "slower/k_crawl4.wav", "slower/k_crawl5.wav", "slower/k_crawl6.wav", "slower/k_crawl7.wav" },
				AttackSounds = Zombie("zombie2", "attack"),
				HitSounds = Zombie("zombie2", "hit"),
				MissSounds = Zombie("zombie2", "miss"),
				PainSounds = Zombie("zombie2", "pain")
			};
			string[] sawrunnerAlert = new string[3] { "sawrunner/sawrunner_alert10.wav", "sawrunner/sawrunner_alert20.wav", "sawrunner/sawrunner_alert30.wav" };
			yield return new MonsterDefinition
			{
				Id = "Sawrunner",
				DisplayName = "Sawrunner",
				ModelFile = "sawrunner.mdl",
				TerminalWord = "sawrunner",
				BestiaryText = "Walks toward you with a running chainsaw and takes a lot of punishment. If you hear the saw, leave.\n\nIts swing is close to lethal.",
				Health = 12,
				Damage = 60,
				RoamSpeed = 1.5f,
				ChaseSpeed = 3.3f,
				AttackRange = 1.6f,
				AttackReach = 2.2f,
				AttackCooldown = 1.2f,
				Rarity = 6,
				PowerLevel = 3f,
				MaxCount = 1,
				MeleeCause = "Snipping",
				LoopSound = "boss/sawer/chainsaw_loop.wav",
				AlertSounds = sawrunnerAlert,
				AttackSounds = new string[2] { "sawrunner/sawrunner_attack1.wav", "sawrunner/sawrunner_attack2.wav" },
				HitSounds = ChainsawHit,
				MissSounds = ChainsawMiss,
				PainSounds = new string[2] { "sawrunner/sawrunner_pain1.wav", "sawrunner/sawrunner_pain2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Duorunner",
				DisplayName = "Sawrunner (Twin Saw)",
				ModelFile = "duorunner.mdl",
				TerminalWord = "twinsaw",
				BestiaryText = "A Sawrunner with a second blade. Everything said about the Sawrunner applies, twice.",
				Health = 12,
				Damage = 60,
				RoamSpeed = 1.5f,
				ChaseSpeed = 3.3f,
				AttackRange = 1.6f,
				AttackReach = 2.2f,
				AttackCooldown = 1.2f,
				Rarity = 4,
				PowerLevel = 3f,
				MaxCount = 1,
				MeleeCause = "Snipping",
				LoopSound = "sawcrazy/dblsawloop.wav",
				AlertSounds = sawrunnerAlert,
				AttackSounds = new string[2] { "sawrunner/sawrunner_attack1.wav", "sawrunner/sawrunner_attack2.wav" },
				HitSounds = ChainsawHit,
				MissSounds = ChainsawMiss,
				PainSounds = new string[2] { "sawrunner/sawrunner_pain1.wav", "sawrunner/sawrunner_pain2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Sawcrazy",
				DisplayName = "Sawcrazy",
				ModelFile = "sawcrazy.mdl",
				TerminalWord = "sawcrazy",
				BestiaryText = "Runs at full speed with two saws held out. Its attack is short-ranged but brutal. Sidestep, don't backpedal.",
				Scale = 1.1f,
				Health = 8,
				Damage = 50,
				RoamSpeed = 2f,
				ChaseSpeed = 5f,
				AttackCooldown = 0.8f,
				Rarity = 5,
				PowerLevel = 2f,
				MaxCount = 1,
				MeleeCause = "Snipping",
				WalkPrefix = null,
				RunPrefix = "run",
				StunClip = null,
				LoopSound = "sawcrazy/dblsawloop.wav",
				AlertSounds = new string[2] { "sawcrazy/random1.wav", "sawcrazy/random2.wav" },
				HitSounds = ChainsawHit,
				MissSounds = ChainsawMiss,
				PainSounds = new string[1] { "sawcrazy/random1.wav" },
				DeathSounds = new string[1] { "sawcrazy/death.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Sawer",
				DisplayName = "Sawer",
				ModelFile = "chainsawguy.mdl",
				TerminalWord = "sawer",
				BestiaryText = "A huge figure with a chainsaw, built to soak up damage. Treat it like weather: get out of its way.",
				Scale = 1f,
				Health = 20,
				Damage = 70,
				RoamSpeed = 1.4f,
				ChaseSpeed = 2.9f,
				AttackRange = 1.8f,
				AttackReach = 2.5f,
				AttackCooldown = 1.4f,
				Rarity = 3,
				PowerLevel = 3f,
				MaxCount = 1,
				Boss = true,
				MeleeCause = "Snipping",
				RunPrefix = "run",
				StunClip = "flinch",
				DeathPrefix = "hurt",
				LoopSound = "boss/sawer/chainsaw_loop.wav",
				AlertSounds = new string[3] { "boss/sawer/sawer_alert10.wav", "boss/sawer/sawer_alert20.wav", "boss/sawer/sawer_alert30.wav" },
				AttackSounds = new string[2] { "boss/sawer/sawer_attack1.wav", "boss/sawer/sawer_attack2.wav" },
				HitSounds = ChainsawHit,
				MissSounds = new string[1] { "boss/sawer/chainsaw_attack.wav" },
				PainSounds = new string[2] { "boss/sawer/sawer_pain1.wav", "boss/sawer/sawer_pain2.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Taller",
				DisplayName = "Taller",
				ModelFile = "taller.mdl",
				TerminalWord = "taller",
				BestiaryText = "A giant that walks the grounds outside at night, about as tall as a two-storey house. It smashes or stamps whatever is in front of it, its reach is enormous, and it takes a huge amount of punishment.\n\nDon't fight it in the open. Get inside.",
				Outside = true,
				Scale = 1.45f,
				Health = 30,
				Damage = 60,
				RoamSpeed = 1.4f,
				ChaseSpeed = 2.8f,
				AttackRange = 2.6f,
				AttackReach = 3.4f,
				AttackCooldown = 1.4f,
				SightRange = 45f,
				LoseTargetAfter = 12f,
				Rarity = 10,
				PowerLevel = 3f,
				MaxCount = 1,
				Boss = true,
				AttackClips = new string[2] { "attack", "stamp" },
				DeathPrefix = "death",
				StunClip = "flinch",
				AlertSounds = new string[1] { "taller/taller_alert.wav" },
				AttackSounds = new string[1] { "taller/taller_swing.wav" },
				HitSounds = new string[2] { "taller/taller_player_punch.wav", "taller/taller_player_impact.wav" },
				MissSounds = new string[1] { "taller/taller_wall_punch.wav" },
				PainSounds = new string[1] { "taller/taller_pain.wav" },
				DeathSounds = new string[1] { "taller/taller_die.wav" },
				MoveEventSound = "taller/taller_step.wav"
			};
			yield return new MonsterDefinition
			{
				Id = "Stranger",
				DisplayName = "Stranger",
				ModelFile = "stranger.mdl",
				TerminalWord = "stranger",
				BestiaryText = "Drifts slowly toward you. It doesn't attack: being near it is what hurts. Don't let it corner you.",
				Scale = 1.1f,
				Health = 6,
				Damage = 0,
				RoamSpeed = 1f,
				ChaseSpeed = 1.7f,
				Rarity = 6,
				PowerLevel = 2f,
				MaxCount = 1,
				AttackClips = new string[0],
				StunClip = null,
				AuraDamagePerSecond = 8f,
				AuraRange = 3.5f,
				LoopSound = "stranger/st_voiceloop.wav",
				AlertSounds = new string[1] { "stranger/st_hearbeat.wav" },
				DeathSounds = new string[1] { "stranger/st_death.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Suicider",
				DisplayName = "Suicider",
				ModelFile = "suicider.mdl",
				TerminalWord = "suicider",
				BestiaryText = "Runs at you with a pistol. When it gets close it pulls the trigger and the shot goes through whoever is in front of it. Keep your distance.",
				Health = 2,
				Damage = 40,
				RoamSpeed = 2f,
				ChaseSpeed = 5f,
				AttackRange = 2f,
				AttackReach = 3f,
				Rarity = 8,
				MaxCount = 2,
				MeleeCause = "Gunshots",
				BodyPrefer = new string[2] { "", "ref_gun" },
				WalkPrefix = null,
				RunPrefix = "run",
				AttackClips = new string[1] { "suicide" },
				DiesAfterAttack = true,
				DeathPrefix = "death",
				StunClip = null,
				AlertSounds = new string[1] { "crazylady/suicide_attempt.wav" },
				AttackSounds = new string[1] { "weapons/glock/suicide_prime.wav" },
				HitSounds = new string[1] { "weapons/glock/glock_fire.wav" },
				MissSounds = new string[1] { "weapons/glock/glock_fire.wav" },
				PainSounds = Zombie("zombie2", "pain")
			};
			yield return new MonsterDefinition
			{
				Id = "Watro",
				DisplayName = "Watro",
				ModelFile = "watro.mdl",
				TerminalWord = "watro",
				BestiaryText = "Lurks under the ground outside and erupts when you walk past. It's huge and its strike reaches a long way. Once it surfaces, back away. It won't follow.",
				Outside = true,
				Scale = 1.8f,
				Health = 15,
				Damage = 45,
				Rarity = 10,
				PowerLevel = 2f,
				MaxCount = 2,
				Stationary = true,
				Lurker = true,
				RoamSpeed = 1.2f,
				WalkPrefix = null,
				AttackClips = new string[1] { "attack" },
				AttackRange = 2.6f,
				AttackReach = 3.2f,
				AttackCooldown = 0.9f,
				HiddenClip = "under",
				AppearClip = "appear",
				DisappearClip = "disappear",
				DeathPrefix = "disappear",
				StunClip = null,
				LurkTriggerRange = 9f,
				LurkLoseRange = 16f,
				MeleeCause = "Mauling",
				AppearSounds = new string[1] { "sewmo/out_water.wav" },
				AttackSounds = new string[1] { "watro/watro_swing.wav" },
				HitSounds = new string[1] { "watro/watro_hit.wav" },
				MissSounds = new string[1] { "watro/watro_swing.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "Flygare",
				DisplayName = "Flygare",
				ModelFile = "flygare.mdl",
				TerminalWord = "flygare",
				BestiaryText = "A winged thing that circles high over the grounds at night. It spits acid from above and dives down to slash when you're close. Look up.",
				Outside = true,
				HoverHeight = 4f,
				HoverLow = 0.8f,
				Health = 5,
				Damage = 20,
				RoamSpeed = 2f,
				ChaseSpeed = 4f,
				AttackRange = 1.8f,
				AttackReach = 2.6f,
				SightRange = 35f,
				Rarity = 12,
				PowerLevel = 2f,
				MaxCount = 2,
				MeleeCause = "Scratching",
				IdleClip = "idle1",
				WalkPrefix = "forward",
				AttackClips = new string[1] { "punch" },
				DeathPrefix = "die1",
				StunClip = "hit",
				RangedClip = "shoot",
				RangedMin = 4f,
				RangedMax = 22f,
				RangedDamage = 15,
				RangedCooldown = 3f,
				RangedCause = "Burning",
				AlertSounds = new string[2] { "flygare/flygare_alert1.wav", "flygare/flygare_alert2.wav" },
				IdleSounds = new string[2] { "flygare/flygare_idle2.wav", "flygare/flygare_idle3.wav" },
				AttackSounds = new string[2] { "flygare/flygare_attack1.wav", "flygare/flygare_attack2.wav" },
				HitSounds = new string[1] { "flygare/flygare_slice.wav" },
				MissSounds = new string[1] { "flygare/flygare_slash.wav" },
				RangedSounds = new string[1] { "flygare/flygare_acid_hit.wav" },
				PainSounds = new string[1] { "flygare/flygare_pain.wav" },
				DeathSounds = new string[1] { "flygare/flygare_death.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "BookSimon",
				DisplayName = "Book Simon",
				ModelFile = "booksimon.mdl",
				TerminalWord = "booksimon",
				BestiaryText = "A tall figure with a sledgehammer that sprints straight at you. Rare, tough, and it hits like a truck.",
				Scale = 1.1f,
				Health = 15,
				Damage = 40,
				RoamSpeed = 2f,
				ChaseSpeed = 5f,
				AttackRange = 1.6f,
				AttackReach = 2.3f,
				AttackCooldown = 0.7f,
				Rarity = 3,
				PowerLevel = 3f,
				MaxCount = 1,
				Boss = true,
				IdleClip = "idle_sledgehammer",
				WalkPrefix = null,
				RunPrefix = "run_sledgehammer",
				AttackClips = new string[1] { "attack_sledgehammer" },
				DeathPrefix = "sledgeflare_death",
				StunClip = null,
				BodyPrefer = new string[4] { "ref_sledgehammer", "blank", "blank", "simon_body" },
				AttackSounds = new string[1] { "weapons/sledgehammer/sledgehammer_swing.wav" },
				HitSounds = new string[1] { "weapons/sledgehammer/sledgehammer_hitbody.wav" },
				MissSounds = new string[1] { "weapons/sledgehammer/sledgehammer_hit.wav" }
			};
			yield return new MonsterDefinition
			{
				Id = "SewerBoss",
				DisplayName = "Sewer Mace",
				ModelFile = "sewer_boss.mdl",
				TerminalWord = "mace",
				BestiaryText = "A hulking brute dragging a spiked mace. Slow to swing, slow to walk, and very slow to die.",
				Scale = 1.05f,
				Health = 15,
				Damage = 40,
				RoamSpeed = 1.2f,
				ChaseSpeed = 2.6f,
				AttackRange = 1.9f,
				AttackReach = 2.6f,
				AttackCooldown = 1.2f,
				Rarity = 3,
				PowerLevel = 3f,
				MaxCount = 1,
				Boss = true,
				AttackClips = new string[1] { "attack1" },
				DeathPrefix = "death2",
				StunClip = "electrocute",
				BodyPrefer = new string[2] { "blank", "sewer_boss" },
				AlertSounds = new string[1] { "boss/sewer/mace_scream.wav" },
				AttackSounds = new string[1] { "boss/sewer/mace_swing.wav" },
				HitSounds = new string[1] { "boss/sewer/mace_hitflesh.wav" },
				MissSounds = new string[1] { "boss/sewer/mace_hitwall.wav" }
			};
		}
	}
	public sealed class MonsterDefinition
	{
		public string Id;

		public string DisplayName;

		public string ModelFile;

		public string TerminalWord;

		public string BestiaryText;

		public float Scale = 1.15f;

		public float HoverHeight;

		public float HoverLow;

		public bool AnchorRoot;

		public bool Outside;

		public int Health = 4;

		public int Damage = 20;

		public float RoamSpeed = 1.6f;

		public float ChaseSpeed = 3.4f;

		public float AttackRange = 1.5f;

		public float AttackReach = 2f;

		public float AttackCooldown = 0.6f;

		public float TurnSlowdown = 1f;

		public float AngularSpeed = 420f;

		public float Acceleration = 18f;

		public float SightRange = 20f;

		public float LoseTargetAfter = 7f;

		public int Rarity = 25;

		public float PowerLevel = 1f;

		public int MaxCount = 4;

		public bool Boss;

		public string MeleeCause = "Bludgeoning";

		public string IdleClip = "idle";

		public string WalkPrefix = "walk";

		public string RunPrefix;

		public string AttackPrefix = "attack";

		public string[] AttackClips;

		public string[] FlinchClips = new string[7] { "flinchsmall", "flinchsmall_1", "flinchsmall_2", "flinch", "flinch3", "bigflinch", "smlflinch" };

		public string StunClip = "flinch3";

		public string DeathPrefix = "die";

		public string ExcludeBodyToken = "headless";

		public string[] BodyPrefer;

		public string RangedClip;

		public float RangedMin = 3f;

		public float RangedMax = 16f;

		public int RangedDamage = 15;

		public float RangedCooldown = 2.5f;

		public string RangedCause = "Gunshots";

		public bool Stationary;

		public bool Lurker;

		public string HiddenClip;

		public string AppearClip;

		public string DisappearClip;

		public float LurkTriggerRange = 7f;

		public float LurkLoseRange = 14f;

		public bool DiesAfterAttack;

		public float AuraDamagePerSecond;

		public float AuraRange = 3.5f;

		public string AuraCause = "Electrocution";

		public string[] AlertSounds = Array.Empty<string>();

		public string[] IdleSounds = Array.Empty<string>();

		public string[] AttackSounds = Array.Empty<string>();

		public string[] HitSounds = Array.Empty<string>();

		public string[] MissSounds = Array.Empty<string>();

		public string[] PainSounds = Array.Empty<string>();

		public string[] DeathSounds = Array.Empty<string>();

		public string[] RangedSounds = Array.Empty<string>();

		public string[] AppearSounds = Array.Empty<string>();

		public string MoveEventSound;

		public string LoopSound;
	}
	internal static class MonsterFactory
	{
		private const int LayerEnemies = 19;

		private const int LayerScanNode = 22;

		public static void Build(MonsterRuntime rt)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_0138: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_0214: 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_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: 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_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0878: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Expected O, but got Unknown
			MonsterDefinition def = rt.Def;
			MdlModel model = rt.Model;
			float num = Plugin.Cfg.Scale(def);
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("CoF_" + def.Id);
			val.layer = 19;
			Transform transform = new GameObject("Hover").transform;
			transform.SetParent(val.transform, false);
			GameObject val2 = new GameObject("Model");
			val2.transform.SetParent(transform, false);
			val2.transform.localScale = Vector3.one * num;
			Transform[] array = (Transform[])(object)new Transform[model.BoneCount];
			for (int i = 0; i < model.BoneCount; i++)
			{
				GameObject val3 = new GameObject(model.BoneNames[i]);
				int num2 = model.BoneParents[i];
				val3.transform.SetParent((num2 >= 0) ? array[num2] : val2.transform, false);
				val3.transform.localPosition = model.BindPos[i];
				val3.transform.localRotation = model.BindRot[i];
				val3.layer = 19;
				array[i] = val3.transform;
			}
			GameObject val4 = new GameObject("Body");
			val4.transform.SetParent(val2.transform, false);
			val4.layer = 19;
			SkinnedMeshRenderer val5 = val4.AddComponent<SkinnedMeshRenderer>();
			int[] array2 = new int[model.File.BodyParts.Length];
			for (int j = 0; j < array2.Length; j++)
			{
				List<int> list = model.ModelChoices(j);
				array2[j] = ((list.Count > 0) ? list[0] : 0);
			}
			Material[] materials;
			Mesh val6 = (val5.sharedMesh = model.GetMesh(array2, out materials));
			((Renderer)val5).sharedMaterials = materials;
			val5.bones = array;
			val5.quality = (SkinQuality)1;
			val5.updateWhenOffscreen = false;
			Bounds bounds = val6.bounds;
			((Renderer)val5).localBounds = new Bounds(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).size * 1.6f + Vector3.one * 0.5f);
			float num3 = 0f;
			if (!def.Lurker && def.HoverHeight <= 0f && Mathf.Abs(((Bounds)(ref bounds)).min.y) > 0.05f)
			{
				num3 = (0f - ((Bounds)(ref bounds)).min.y) * num;
			}
			val2.transform.localPosition = new Vector3(0f, num3, 0f);
			float num4 = Mathf.Clamp(((Bounds)(ref bounds)).max.y * num + num3, 0.6f, 12f);
			float num5 = Mathf.Clamp(Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) * num, 0.5f, 6f);
			MdlAnimator mdlAnimator = val.AddComponent<MdlAnimator>();
			mdlAnimator.bones = array;
			mdlAnimator.modelKey = model.Key;
			NavMeshAgent obj = val.AddComponent<NavMeshAgent>();
			obj.speed = def.RoamSpeed;
			obj.angularSpeed = def.AngularSpeed;
			obj.acceleration = def.Acceleration;
			obj.radius = Mathf.Clamp(num5 * 0.35f, 0.3f, def.Outside ? 1.5f : 0.9f);
			obj.height = Mathf.Clamp(num4, 0.8f, def.Outside ? 8f : 4f);
			obj.stoppingDistance = 0.4f;
			obj.autoBraking = true;
			obj.obstacleAvoidanceType = (ObstacleAvoidanceType)1;
			int num6 = Array.FindIndex(model.BoneNames, (string n) => n.EndsWith("Head", StringComparison.OrdinalIgnoreCase));
			float num7 = ((num6 >= 0) ? (array[num6].position.y - transform.position.y) : (num4 * 0.9f));
			num7 = Mathf.Clamp(num7, 0.3f, num4);
			Transform transform2 = new GameObject("Eye").transform;
			transform2.SetParent(transform, false);
			transform2.localPosition = new Vector3(0f, num7, 0.1f);
			transform.localPosition = new Vector3(0f, def.HoverHeight, 0f);
			AudioSource creatureVoice = MakeAudio(val.transform, "CreatureVoice", num7 + def.HoverHeight);
			AudioSource creatureSFX = MakeAudio(val.transform, "CreatureSFX", num4 * 0.5f);
			AudioSource val7 = MakeAudio(val.transform, "Loop", num4 * 0.5f);
			val7.volume = Plugin.Cfg.Volume * 0.5f;
			GameObject val8 = new GameObject("Collision");
			val8.transform.SetParent(transform, false);
			val8.layer = 19;
			CapsuleCollider val9 = val8.AddComponent<CapsuleCollider>();
			((Collider)val9).isTrigger = true;
			float num8 = Mathf.Max(0.6f, num4);
			val9.center = new Vector3(0f, num8 * 0.5f, 0f);
			val9.height = num8;
			val9.radius = Mathf.Clamp(num5 * 0.4f, 0.3f, 1.2f);
			val9.direction = ((num8 >= num5) ? 1 : 2);
			if (val9.direction == 2)
			{
				val9.height = Mathf.Max(num5, val9.radius * 2f);
			}
			Rigidbody obj2 = val8.AddComponent<Rigidbody>();
			obj2.isKinematic = true;
			obj2.useGravity = false;
			EnemyAICollisionDetect val10 = val8.AddComponent<EnemyAICollisionDetect>();
			GameObject val11 = new GameObject("ScanNode");
			val11.transform.SetParent(transform, false);
			val11.transform.localPosition = new Vector3(0f, Mathf.Max(0.3f, num4 * 0.6f), 0f);
			val11.layer = 22;
			BoxCollider obj3 = val11.AddComponent<BoxCollider>();
			obj3.size = Vector3.one * 0.6f;
			((Collider)obj3).isTrigger = false;
			ScanNodeProperties obj4 = val11.AddComponent<ScanNodeProperties>();
			obj4.headerText = def.DisplayName;
			obj4.subText = (def.Boss ? "Boss" : "");
			obj4.maxRange = 14;
			obj4.minRange = 1;
			obj4.requiresLineOfSight = true;
			obj4.nodeType = 1;
			obj4.creatureScanID = rt.ScanId;
			EnemyType val12 = ScriptableObject.CreateInstance<EnemyType>();
			((Object)val12).name = def.Id;
			val12.enemyName = def.DisplayName;
			val12.enemyPrefab = val;
			val12.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
			val12.numberSpawnedFalloff = AnimationCurve.Constant(0f, 10f, 1f);
			val12.useNumberSpawnedFalloff = false;
			val12.PowerLevel = Plugin.Cfg.PowerLevel(def);
			val12.MaxCount = Plugin.Cfg.MaxCount(def);
			val12.spawnInGroupsOf = 1;
			val12.isOutsideEnemy = def.Outside;
			val12.isDaytimeEnemy = false;
			val12.canDie = true;
			val12.canBeStunned = true;
			val12.canBeDestroyed = true;
			val12.destroyOnDeath = false;
			val12.stunTimeMultiplier = (def.Boss ? 0.5f : 1f);
			val12.doorSpeedMultiplier = 0.6f;
			val12.canSeeThroughFog = false;
			val12.disableAnimatorWhenFar = false;
			val12.pushPlayerForce = 0f;
			val12.pushPlayerDistance = 0f;
			val12.timeToPlayAudio = 0.5f;
			val12.loudnessMultiplier = 1f;
			val12.miscAnimations = Array.Empty<MiscAnimation>();
			val12.audioClips = Array.Empty<AudioClip>();
			val12.hitEnemyVoiceSFX = null;
			val12.hitBodySFX = null;
			val12.stunSFX = ((rt.Pain.Length != 0) ? rt.Pain[0] : null);
			rt.EnemyType = val12;
			CoFMonsterAI coFMonsterAI = val.AddComponent<CoFMonsterAI>();
			coFMonsterAI.definitionId = def.Id;
			((EnemyAI)coFMonsterAI).enemyType = val12;
			coFMonsterAI.mdl = mdlAnimator;
			coFMonsterAI.body = val5;
			coFMonsterAI.hitbox = (Collider)(object)val9;
			coFMonsterAI.loopSource = val7;
			coFMonsterAI.hover = transform;
			((EnemyAI)coFMonsterAI).eye = transform2;
			((EnemyAI)coFMonsterAI).creatureVoice = creatureVoice;
			((EnemyAI)coFMonsterAI).creatureSFX = creatureSFX;
			((EnemyAI)coFMonsterAI).enemyHP = def.Health;
			((EnemyAI)coFMonsterAI).creatureAnimator = null;
			EnemyBehaviourState[] array3 = (EnemyBehaviourState[])(object)new EnemyBehaviourState[6];
			string[] array4 = new string[6] { "Roam", "Chase", "Melee", "Ranged", "Emerge", "Submerge" };
			for (int num9 = 0; num9 < array3.Length; num9++)
			{
				array3[num9] = new EnemyBehaviourState
				{
					name = array4[num9]
				};
			}
			((EnemyAI)coFMonsterAI).enemyBehaviourStates = array3;
			val10.mainScript = (EnemyAI)(object)coFMonsterAI;
			val10.canCollideWithEnemies = false;
			TerminalNode val13 = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)val13).name = def.Id + "File";
			val13.creatureName = def.DisplayName;
			val13.creatureFileID = rt.ScanId;
			val13.displayText = def.DisplayName.ToUpperInvariant() + "\n\n" + def.BestiaryText + "\n\n";
			val13.clearPreviousText = true;
			val13.maxCharactersToType = 35;
			TerminalKeyword val14 = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)val14).name = def.Id + "Keyword";
			val14.word = def.TerminalWord;
			val14.isVerb = false;
			Enemies.RegisterEnemy(val12, Plugin.Cfg.Rarity(def), (LevelTypes)(-1), (SpawnType)(def.Outside ? 2 : 0), val13, val14);
		}

		private static AudioSource MakeAudio(Transform parent, string name, 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 = 30f;
			obj.dopplerLevel = 0f;
			obj.volume = Plugin.Cfg.Volume;
			return obj;
		}
	}
	public sealed class MonsterRuntime
	{
		public MonsterDefinition Def;

		public MdlModel Model;

		public EnemyType EnemyType;

		public int ScanId;

		public AudioClip[] Alert;

		public AudioClip[] Idle;

		public AudioClip[] Attack;

		public AudioClip[] Hit;

		public AudioClip[] Miss;

		public AudioClip[] Pain;

		public AudioClip[] Death;

		public AudioClip[] Ranged;

		public AudioClip[] Appear;

		public AudioClip MoveEvent;

		public AudioClip Loop;

		public CauseOfDeath MeleeCause;

		public CauseOfDeath RangedCause;

		public CauseOfDeath AuraCause;

		private static readonly Dictionary<string, MonsterRuntime> ById = new Dictionary<string, MonsterRuntime>();

		public MonsterRuntime(MonsterDefinition def, MdlModel model, int scanId)
		{
			//IL_00de: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			Def = def;
			Model = model;
			ScanId = scanId;
			Alert = MonsterAssets.SoundSet(def.AlertSounds);
			Idle = MonsterAssets.SoundSet(def.IdleSounds);
			Attack = MonsterAssets.SoundSet(def.AttackSounds);
			Hit = MonsterAssets.SoundSet(def.HitSounds);
			Miss = MonsterAssets.SoundSet(def.MissSounds);
			Pain = MonsterAssets.SoundSet(def.PainSounds);