Decompiled source of DOOMLAB v1.0.2

DOOMLAB/Mods/DOOMLAB.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.Elements;
using BoneLib.Nullables;
using HarmonyLib;
using Il2CppSystem;
using MelonLoader;
using NEP.DOOMLAB;
using NEP.DOOMLAB.Data;
using NEP.DOOMLAB.Entities;
using NEP.DOOMLAB.Game;
using NEP.DOOMLAB.Rendering;
using NEP.DOOMLAB.Sound;
using NEP.DOOMLAB.WAD;
using NEP.DOOMLAB.WAD.DataTypes;
using SLZ.AI;
using SLZ.Combat;
using SLZ.Data;
using SLZ.Marrow.Data;
using SLZ.Marrow.Pool;
using SLZ.Marrow.Warehouse;
using SLZ.Props;
using SLZ.Props.Weapons;
using SLZ.Rig;
using SLZ.SFX;
using TMPro;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DOOMLAB")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Not Enough Photons")]
[assembly: AssemblyProduct("DOOMLAB")]
[assembly: AssemblyCopyright("Created by Not Enough Photons, adamdev")]
[assembly: AssemblyTrademark("Not Enough Photons")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("0.0.1")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: MelonInfo(typeof(Main), "DOOMLAB", "0.0.1", "Not Enough Photons, adamdev", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
namespace NEP.DOOMLAB
{
	[RegisterTypeInIl2Cpp]
	public class DoomPlayer : MonoBehaviour
	{
		private int itemCount;

		public static DoomPlayer Instance { get; private set; }

		public int ItemCount => itemCount;

		public Player_Health Health => Mobj.player.playerHealth;

		public DoomPlayer(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			Instance = this;
		}

		public void TouchSpecialThing(Mobj special)
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			SoundType soundType = SoundType.sfx_itemup;
			Player_Health playerHealth = Mobj.player.playerHealth;
			switch (special.sprite)
			{
			case SpriteNum.SPR_BON1:
				((Health)playerHealth).curr_Health = ((Health)playerHealth).curr_Health + 0.1f;
				if (((Health)playerHealth).curr_Health < 0f && playerHealth.deathIsImminent)
				{
					playerHealth.LifeSavingDamgeDealt();
				}
				break;
			case SpriteNum.SPR_SOUL:
				((Health)playerHealth).curr_Health = 10f;
				if (((Health)playerHealth).curr_Health < 0f && playerHealth.deathIsImminent)
				{
					playerHealth.LifeSavingDamgeDealt();
				}
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_MEGA:
				((Health)playerHealth).curr_Health = 10f;
				if (((Health)playerHealth).curr_Health < 0f && playerHealth.deathIsImminent)
				{
					playerHealth.LifeSavingDamgeDealt();
				}
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_STIM:
				((Health)playerHealth).curr_Health = ((Health)playerHealth).curr_Health + 1f;
				if (((Health)playerHealth).curr_Health < 0f && playerHealth.deathIsImminent)
				{
					playerHealth.LifeSavingDamgeDealt();
				}
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_MEDI:
				((Health)playerHealth).curr_Health = ((Health)playerHealth).curr_Health + 5f;
				if (((Health)playerHealth).curr_Health < 0f && playerHealth.deathIsImminent)
				{
					playerHealth.LifeSavingDamgeDealt();
				}
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_PINV:
				((Health)playerHealth).SetHealthMode(0);
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_PSTR:
				((Health)playerHealth)._rigManager.avatar._strengthLower = 1000f;
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_PINS:
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_SUIT:
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_PMAP:
				soundType = SoundType.sfx_getpow;
				break;
			case SpriteNum.SPR_PVIS:
				soundType = SoundType.sfx_getpow;
				break;
			}
			if (special.flags.HasFlag(MobjFlags.MF_COUNTITEM))
			{
				itemCount++;
			}
			MobjManager.Instance.RemoveMobj(special);
			SoundManager.Instance.PlaySound(soundType, Vector3.zero, fullVolume: true);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class MobjPlacer : MonoBehaviour
	{
		public MobjPlacer(IntPtr ptr)
			: base(ptr)
		{
		}
	}
	public static class Settings
	{
		public static bool DisableAI;

		public static bool NoTarget;

		public static bool FastMonsters;

		public static bool RespawnMonsters;

		public static float ProjectilePruneDistance = 64f;

		public static bool EnableMobjDebug = false;

		public static bool EnableMobjDebugLines = false;

		public static bool EnableMobjDebugColliders = false;
	}
	public static class BuildInfo
	{
		public const string Name = "DOOMLAB";

		public const string Description = "Hell has encroached into MythOS. Pick up Doomguy's skills and slay endless demons.";

		public const string Author = "Not Enough Photons, adamdev";

		public const string Company = "Not Enough Photons";

		public const string Version = "0.0.1";

		public const string DownloadLink = null;
	}
	public class Main : MelonMod
	{
		public AssetBundle bundle;

		public static GameObject mobjTemplate;

		public static Material unlitMaterial;

		public static Mobj player;

		public static SurfaceData mobjSurfaceData;

		public static readonly string UserDataDirectory = MelonUtils.UserDataDirectory;

		public static readonly string TeamDirectory = Path.Combine(UserDataDirectory, "Not Enough Photons");

		public static readonly string ModDirectory = Path.Combine(TeamDirectory, "DOOMLAB");

		public static readonly string IWADDirectory = Path.Combine(ModDirectory, "IWADS");

		public static readonly string PWADDirectory = Path.Combine(ModDirectory, "PWADS");

		public static Texture2D MissingSprite;

		private static AssetBundle GetEmbeddedBundle()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = (HelperMethods.IsAndroid() ? "doomlab_quest.pack" : "doomlab_pcvr.pack");
			using Stream stream = executingAssembly.GetManifestResourceStream("NEP.DOOMLAB.Resources." + text);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return AssetBundle.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(memoryStream.ToArray()));
		}

		public override void OnInitializeMelon()
		{
			Directory.CreateDirectory(ModDirectory);
			Directory.CreateDirectory(IWADDirectory);
			Directory.CreateDirectory(PWADDirectory);
			bundle = GetEmbeddedBundle();
			mobjTemplate = ((Il2CppObjectBase)bundle.LoadAsset("[MOBJ] - Null")).Cast<GameObject>();
			((Object)mobjTemplate).hideFlags = (HideFlags)32;
			MissingSprite = ((Il2CppObjectBase)bundle.LoadAsset("faila0")).Cast<Texture2D>();
			((Object)MissingSprite).hideFlags = (HideFlags)32;
			unlitMaterial = ((Il2CppObjectBase)bundle.LoadAsset("mat_unlit")).Cast<Material>();
			((Object)unlitMaterial).hideFlags = (HideFlags)32;
			new WADManager();
			WADManager.Instance.LoadWAD(WADManager.Instance.GetIWAD());
			FrameBuilder.GenerateTable();
			new DoomGame();
			Hooking.OnLevelInitialized += OnSceneLoaded;
			BoneMenuStuff();
		}

		public override void OnUpdate()
		{
			DoomGame.Instance.Update();
		}

		public void OnSceneLoaded(LevelInfo info)
		{
			DoomGame.Instance.gameTic = 0;
			new SoundManager();
			new MobjManager();
			if ((Object)(object)player != (Object)null)
			{
				Mobj.ComponentCache.RemoveInstance(((Object)((Component)player).gameObject).GetInstanceID());
			}
			player = ((Component)((Rig)Player.physicsRig).m_head).gameObject.AddComponent<Mobj>();
			((Component)player).gameObject.AddComponent<DoomPlayer>();
			player.flags ^= MobjFlags.MF_SOLID;
			player.flags ^= MobjFlags.MF_SHOOTABLE;
			player.playerHealth = ((Component)Player.rigManager).GetComponent<Player_Health>();
			Mobj.ComponentCache.AddInstance(((Object)((Component)player).gameObject).GetInstanceID(), player);
			if ((Object)(object)mobjSurfaceData == (Object)null)
			{
				mobjSurfaceData = ((ImpactPropertiesVariables)((Component)Player.physicsRig).GetComponent<ImpactPropertiesManager>()).surfaceData;
			}
		}

		internal void BoneMenuStuff()
		{
			//IL_0005: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			MenuCategory obj = MenuManager.CreateCategory("Not Enough Photons", Color.white).CreateCategory("DOOMLAB", Color.white);
			MenuCategory val = obj.CreateCategory("Game Settings", Color.white);
			MenuCategory obj2 = obj.CreateCategory("Debug", Color.white);
			val.CreateBoolElement("Disable Thinking", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.DisableAI = value;
			});
			val.CreateBoolElement("No Target", Color.white, false, (Action<bool>)null);
			val.CreateBoolElement("Fast Monsters", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.FastMonsters = value;
				DoomGame.Instance.UpdateFastMonsters(Settings.FastMonsters);
			});
			val.CreateBoolElement("Respawn Monsters", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.RespawnMonsters = value;
			});
			val.CreateFunctionElement("Clear Corpses", Color.red, (Action)delegate
			{
				DoomGame.DeleteCorpses();
			});
			obj2.CreateFloatElement("Projectile Pruning Distance", Color.white, 128f, 32f, 0f, 4096f, (Action<float>)delegate(float value)
			{
				Settings.ProjectilePruneDistance = value;
			});
			obj2.CreateBoolElement("MOBJ Debug Stats", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.EnableMobjDebug = value;
			});
			obj2.CreateBoolElement("MOBJ Debug Lines", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.EnableMobjDebugLines = value;
			});
			obj2.CreateBoolElement("MOBJ Debug Colliders", Color.white, false, (Action<bool>)delegate(bool value)
			{
				Settings.EnableMobjDebugColliders = value;
			});
			MenuCategory val2 = obj.CreateCategory("WADS", Color.white);
			string[] wADsInFolder = WADManager.Instance.GetWADsInFolder(WADFile.WADType.IWAD);
			string[] wADsInFolder2 = WADManager.Instance.GetWADsInFolder(WADFile.WADType.PWAD);
			for (int i = 0; i < wADsInFolder.Length; i++)
			{
				int index2 = i;
				val2.CreateFunctionElement(WADManager.Instance.GetWADFileName(wADsInFolder[index2], quest: true), Color.white, (Action)delegate
				{
					WADManager.Instance.LoadWAD(WADManager.Instance.IWADS[index2]);
					FrameBuilder.GenerateTable();
					MobjRenderer.LoadSpriteDefs();
					SoundManager.Instance.LoadWADAudio(WADManager.Instance.LoadedWAD.sounds);
				});
			}
			for (int j = 0; j < wADsInFolder2.Length; j++)
			{
				int index = j;
				val2.CreateFunctionElement(WADManager.Instance.GetWADFileName(wADsInFolder2[index], quest: true), Color.white, (Action)delegate
				{
					WADManager.Instance.LoadWAD(WADManager.Instance.PWADS[index]);
					FrameBuilder.GenerateTable();
					MobjRenderer.LoadSpriteDefs();
					SoundManager.Instance.LoadWADAudio(WADManager.Instance.LoadedWAD.sounds);
				});
			}
		}
	}
	public static class TestLoader
	{
		internal static readonly string companyCode = "NotEnoughPhotons.";

		internal static readonly string modCode = "DOOMLAB.";

		internal static readonly string typeCode = "Spawnable";

		internal static readonly string mobjBarcode = companyCode + modCode + typeCode + ".MOBJNull";

		internal static AssetPoolee loadedObject;

		internal static List<AssetPoolee> Warmup(string barcode, int size, bool startActive = false)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0037: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			List<AssetPoolee> cache = new List<AssetPoolee>();
			for (int i = 0; i < size; i++)
			{
				SpawnableCrateReference crateRef = new SpawnableCrateReference(barcode);
				Spawnable val = new Spawnable
				{
					crateRef = crateRef
				};
				AssetSpawner.Register(val);
				NullableMethodExtensions.PoolManager_Spawn(val, default(Vector3), default(Quaternion), (Vector3?)null, false, (int?)null, Action<GameObject>.op_Implicit((Action<GameObject>)delegate(GameObject obj)
				{
					CreateObject(ref cache, obj, startActive);
				}), (Action<GameObject>)null);
			}
			return cache;
		}

		private static void CreateObject(ref List<AssetPoolee> cache, GameObject obj, bool startActive = false)
		{
			obj.SetActive(startActive);
			cache.Add(obj.GetComponent<AssetPoolee>());
			loadedObject = obj.GetComponent<AssetPoolee>();
		}
	}
}
namespace NEP.DOOMLAB.ZDOOM
{
	public struct ZDSndInfoField
	{
		public string className;

		public string classSound;

		public string targetSound;
	}
	public class ZDSndInfo
	{
		private class Reader
		{
			public string[] ReadAllLines(string file)
			{
				return file.Split(new char[1] { '\n' });
			}
		}

		private class Tokenizer
		{
			public string[] Tokenize(string line, char splitChar = ' ')
			{
				if (!char.IsWhiteSpace(splitChar))
				{
					return line.Split(new char[1] { splitChar });
				}
				return line.Split();
			}

			public string[] Filter(string[] tokens)
			{
				List<string> list = new List<string>();
				foreach (string text in tokens)
				{
					if (text.StartsWith("//"))
					{
						break;
					}
					list.Add(text);
				}
				return list.ToArray();
			}
		}

		private class Parser
		{
			public ZDSndInfoField[] Parse(Tokenizer tokenizer, string[] lines)
			{
				List<ZDSndInfoField> list = new List<ZDSndInfoField>();
				foreach (string line in lines)
				{
					string[] tokens = tokenizer.Tokenize(line);
					string[] array = tokenizer.Filter(tokens);
					ZDSndInfoField item = default(ZDSndInfoField);
					foreach (string text in array)
					{
						if (text.Contains("/"))
						{
							tokenizer.Tokenize(text, '/');
						}
						list.Add(item);
					}
				}
				return list.ToArray();
			}
		}

		public List<ZDSndInfoField> fields;

		private Reader reader;

		private Tokenizer tokenizer;

		private Parser parser;

		public ZDSndInfo(string fileText)
		{
			fields = new List<ZDSndInfoField>();
			reader = new Reader();
			tokenizer = new Tokenizer();
			parser = new Parser();
			List<string> list = new List<string>();
			string[] array = reader.ReadAllLines(fileText);
			for (int i = 0; i < array.Length; i++)
			{
			}
			parser.Parse(tokenizer, list.ToArray());
		}
	}
	public class ZDActor
	{
		public static Dictionary<string, MobjType> ActorClassTable = new Dictionary<string, MobjType>
		{
			{
				"grunt",
				MobjType.MT_POSSESSED
			},
			{
				"shotguy",
				MobjType.MT_SHOTGUY
			},
			{
				"vile",
				MobjType.MT_VILE
			},
			{
				"skeleton",
				MobjType.MT_UNDEAD
			},
			{
				"fatso",
				MobjType.MT_FATSO
			},
			{
				"chainguy",
				MobjType.MT_CHAINGUY
			},
			{
				"imp",
				MobjType.MT_TROOP
			},
			{
				"demon",
				MobjType.MT_SERGEANT
			},
			{
				"spectre",
				MobjType.MT_SHADOWS
			},
			{
				"caco",
				MobjType.MT_HEAD
			},
			{
				"baron",
				MobjType.MT_BRUISER
			},
			{
				"knight",
				MobjType.MT_KNIGHT
			},
			{
				"skull",
				MobjType.MT_SKULL
			},
			{
				"spider",
				MobjType.MT_SPIDER
			},
			{
				"baby",
				MobjType.MT_BABY
			},
			{
				"cyber",
				MobjType.MT_CYBORG
			},
			{
				"pain",
				MobjType.MT_PAIN
			},
			{
				"wolfss",
				MobjType.MT_WOLFSS
			},
			{
				"keen",
				MobjType.MT_KEEN
			},
			{
				"brain",
				MobjType.MT_BOSSBRAIN
			}
		};
	}
}
namespace NEP.DOOMLAB.WAD
{
	[Serializable]
	public class WADFile
	{
		public enum WADType
		{
			IWAD,
			PWAD
		}

		public WADType wadType;

		public int indexEntries;

		public int indexOffset;

		public Dictionary<string, WADIndexEntry> entryTable;

		public HashSet<WADIndexEntry> entries;

		public List<Color32> colorPal;

		public List<Patch> patches;

		public List<NEP.DOOMLAB.WAD.DataTypes.Sound> sounds;

		private string filePath;

		private MemoryStream fileStream;

		private BinaryReader reader;

		public WADFile(string path)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			entries = new HashSet<WADIndexEntry>();
			entryTable = new Dictionary<string, WADIndexEntry>();
			filePath = path;
			sounds = new List<NEP.DOOMLAB.WAD.DataTypes.Sound>();
			patches = new List<Patch>();
			colorPal = new List<Color32>();
			for (int i = 0; i < 256; i++)
			{
				colorPal.Add(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
			}
		}

		public char[] ReadCharacters(int count)
		{
			char[] array = new char[count];
			for (int i = 0; i < count; i++)
			{
				array[i] = reader.ReadChar();
			}
			return array;
		}

		public short ReadShort()
		{
			return reader.ReadInt16();
		}

		public ushort ReadUnsignedShort()
		{
			return reader.ReadUInt16();
		}

		public int ReadInt()
		{
			return reader.ReadInt32();
		}

		public byte PeekByte()
		{
			byte result = reader.ReadByte();
			reader.BaseStream.Position--;
			return result;
		}

		public void Close()
		{
			reader.Close();
		}

		public void Dispose()
		{
			reader.Dispose();
		}

		public void CleanUp()
		{
			Close();
			Dispose();
		}

		public void Preload()
		{
			byte[] buffer = null;
			using (StreamReader streamReader = new StreamReader(filePath))
			{
				using MemoryStream memoryStream = new MemoryStream();
				streamReader.BaseStream.CopyTo(memoryStream);
				buffer = memoryStream.ToArray();
			}
			fileStream = new MemoryStream(buffer);
			reader = new BinaryReader(fileStream);
		}

		public void ReadHeader()
		{
			char[] array = ReadCharacters(4);
			wadType = ((array[0] != 'I') ? WADType.PWAD : WADType.IWAD);
			indexEntries = ReadInt();
			indexOffset = ReadInt();
		}

		public void ReadIndexEntries()
		{
			reader.BaseStream.Seek(indexOffset, SeekOrigin.Begin);
			for (int i = 0; i < indexEntries; i++)
			{
				WADIndexEntry wADIndexEntry = new WADIndexEntry();
				wADIndexEntry.offset = ReadInt();
				wADIndexEntry.size = ReadInt();
				char[] array = ReadCharacters(8);
				for (int j = 0; j < array.Length; j++)
				{
					char c = array[j];
					if (c == '\0')
					{
						break;
					}
					wADIndexEntry.name += c;
				}
				entries.Add(wADIndexEntry);
				if (!entryTable.ContainsKey(wADIndexEntry.name))
				{
					entryTable.Add(wADIndexEntry.name, wADIndexEntry);
				}
			}
		}

		public void ReadPalette()
		{
			//IL_00b0: 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)
			WADIndexEntry wADIndexEntry = null;
			if (wadType == WADType.PWAD)
			{
				colorPal = WADManager.Instance.IWAD.colorPal;
				return;
			}
			foreach (WADIndexEntry entry in entries)
			{
				if (entry.name == "PLAYPAL")
				{
					wADIndexEntry = entry;
					break;
				}
			}
			if (wADIndexEntry != null)
			{
				reader.BaseStream.Seek(wADIndexEntry.offset, SeekOrigin.Begin);
				for (int i = 0; i < 256; i++)
				{
					byte r = reader.ReadByte();
					byte g = reader.ReadByte();
					byte b = reader.ReadByte();
					Color32 value = default(Color32);
					value.r = r;
					value.g = g;
					value.b = b;
					value.a = byte.MaxValue;
					colorPal[i] = value;
				}
			}
		}

		public void ReadAllSounds()
		{
			foreach (WADIndexEntry entry in entries)
			{
				if (entry.name.StartsWith("DS"))
				{
					ReadSound(entry);
				}
			}
			if (wadType != WADType.PWAD)
			{
				return;
			}
			WADFile iWAD = WADManager.Instance.IWAD;
			for (int i = 0; i < iWAD.sounds.Count; i++)
			{
				NEP.DOOMLAB.WAD.DataTypes.Sound item = iWAD.sounds[i];
				if (!entryTable.ContainsKey(item.soundName))
				{
					sounds.Add(item);
				}
			}
		}

		public void ReadAllSprites()
		{
			bool flag = false;
			foreach (WADIndexEntry entry in entries)
			{
				if (!flag)
				{
					if (entry.name == "S_START" || entry.name == "SS_START")
					{
						flag = true;
					}
					continue;
				}
				if (entry.name == "S_END" || entry.name == "SS_END")
				{
					flag = false;
					break;
				}
				ReadPatch(entry);
			}
			if (wadType != WADType.PWAD)
			{
				return;
			}
			WADFile iWAD = WADManager.Instance.IWAD;
			for (int i = 0; i < iWAD.patches.Count; i++)
			{
				Patch item = iWAD.patches[i];
				if (!entryTable.ContainsKey(item.name))
				{
					patches.Add(item);
				}
			}
		}

		public void ReadSound(WADIndexEntry entry)
		{
			if (entry.size > 4)
			{
				reader.BaseStream.Seek(entry.offset, SeekOrigin.Begin);
				NEP.DOOMLAB.WAD.DataTypes.Sound item = default(NEP.DOOMLAB.WAD.DataTypes.Sound);
				item.soundName = entry.name;
				item.id = reader.ReadInt16();
				item.sampleRate = reader.ReadUInt16();
				item.sampleCount = reader.ReadUInt16();
				item.soundData = reader.ReadBytes(item.sampleCount - 32);
				float[] array = new float[item.soundData.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = ((float)(int)item.soundData[i] - 127f) / 127f;
				}
				AudioClip val = AudioClip.Create(entry.name, item.sampleCount, 1, item.sampleRate, false);
				val.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
				item.output = val;
				((Object)item.output).hideFlags = (HideFlags)32;
				sounds.Add(item);
			}
		}

		public void ReadPatch(WADIndexEntry entry)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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)
			reader.BaseStream.Seek(entry.offset, SeekOrigin.Begin);
			short num = reader.ReadInt16();
			short num2 = reader.ReadInt16();
			short leftOffset = reader.ReadInt16();
			short topOffset = reader.ReadInt16();
			Patch item = new Patch(entry.name, num, num2, leftOffset, topOffset);
			int[] array = new int[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = reader.ReadInt32();
			}
			Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)0;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			Color32[] array2 = (Color32[])(object)new Color32[num * num2];
			for (int j = 0; j < num; j++)
			{
				reader.BaseStream.Seek(entry.offset + array[j], SeekOrigin.Begin);
				int num3 = 0;
				while (num3 != 255)
				{
					num3 = reader.ReadByte();
					if (num3 == 255)
					{
						break;
					}
					int num4 = reader.ReadByte();
					reader.ReadByte();
					for (int k = 0; k < num4; k++)
					{
						Color32 val2 = colorPal[reader.ReadByte()];
						array2[(num2 - num3 - k - 1) * num + j] = val2;
					}
					reader.ReadByte();
				}
			}
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array2), 0);
			val.Apply();
			item.output = val;
			((Object)item.output).hideFlags = (HideFlags)32;
			patches.Add(item);
		}

		public Patch GetPatch(string name)
		{
			return patches.FirstOrDefault((Patch patch) => patch.name == name);
		}

		public NEP.DOOMLAB.WAD.DataTypes.Sound GetSound(string name)
		{
			return sounds.FirstOrDefault((NEP.DOOMLAB.WAD.DataTypes.Sound sound) => sound.soundName == name);
		}
	}
	public class WADIndexEntry
	{
		public int offset;

		public int size;

		public string name;
	}
	public class WADManager
	{
		public WADFile IWAD;

		private readonly string[] iwads = new string[15]
		{
			"D", "DOOM", "DOOMU", "BFGDOOM", "DOOMBFG", "DOOM2", "BFGDOOM2", "DOOM2BFG", "TNT", "PLUTONIA",
			"FREEDOOM1", "FREEDOOM2", "CHEX", "HERETIC", "HEXEN"
		};

		public static WADManager Instance { get; private set; }

		public Dictionary<string, WADFile> LoadedWADs { get; private set; } = new Dictionary<string, WADFile>();


		public Dictionary<string, WADIndexEntry> LumpMap { get; private set; } = new Dictionary<string, WADIndexEntry>();


		public WADFile LoadedWAD { get; private set; }

		public string[] IWADS => GetWADsInFolder(WADFile.WADType.IWAD, fullPath: true);

		public string[] PWADS => GetWADsInFolder(WADFile.WADType.PWAD, fullPath: true);

		public WADManager()
		{
			Instance = this;
		}

		public void LoadIWAD(string file)
		{
			GetWADFileName(file);
			WADFile wADFile = new WADFile(file);
			wADFile.Preload();
			wADFile.ReadHeader();
			wADFile.ReadIndexEntries();
			wADFile.ReadPalette();
			wADFile.ReadAllSounds();
			wADFile.ReadAllSprites();
			IWAD = wADFile;
		}

		public void LoadPWAD(string file)
		{
			GetWADFileName(file);
			WADFile wADFile = new WADFile(file);
			wADFile.Preload();
			wADFile.ReadHeader();
			wADFile.ReadIndexEntries();
			LumpMap = IWAD.entryTable;
			foreach (WADIndexEntry entry in wADFile.entries)
			{
				if (LumpMap.ContainsKey(entry.name))
				{
					LumpMap[entry.name] = entry;
				}
			}
			wADFile.colorPal = IWAD.colorPal;
			wADFile.ReadIndexEntries();
			wADFile.ReadAllSounds();
			wADFile.ReadAllSprites();
		}

		public void LoadWAD(string file)
		{
			string wADFileName = GetWADFileName(file);
			if (LoadedWADs.ContainsKey(wADFileName))
			{
				LoadedWAD = LoadedWADs[wADFileName];
				return;
			}
			WADFile wADFile = new WADFile(file);
			wADFile.Preload();
			wADFile.ReadHeader();
			wADFile.ReadIndexEntries();
			wADFile.ReadPalette();
			wADFile.ReadAllSounds();
			wADFile.ReadAllSprites();
			LoadedWAD = wADFile;
			LoadedWADs.Add(wADFileName, wADFile);
			if (file == GetIWAD())
			{
				IWAD = wADFile;
			}
		}

		public string GetIWAD()
		{
			string[] files = Directory.GetFiles(Main.IWADDirectory);
			string result = "";
			for (int i = 0; i < iwads.Length; i++)
			{
				for (int j = 0; j < files.Length; j++)
				{
					string text = iwads[i] + ".WAD";
					string text2 = files[j];
					if (Path.GetFileName(text2).ToLower() == text.ToLower())
					{
						result = text2;
						break;
					}
				}
			}
			return result;
		}

		public string[] GetWADsInFolder(WADFile.WADType wadType, bool fullPath = false)
		{
			string[] files = Directory.GetFiles((wadType == WADFile.WADType.IWAD) ? Main.IWADDirectory : Main.PWADDirectory);
			if (fullPath)
			{
				return files;
			}
			string[] array = new string[files.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = GetWADFileName(files[i]);
			}
			return array;
		}

		public string GetWADFileName(string pathToWad, bool quest = false)
		{
			return ((!quest) ? pathToWad.Split(new char[1] { '\\' }) : pathToWad.Split(new char[1] { '/' }))[^1];
		}
	}
}
namespace NEP.DOOMLAB.WAD.DataTypes
{
	public struct Patch
	{
		public string name;

		public short width;

		public short height;

		public short leftOffset;

		public short topOffset;

		public Texture2D output;

		public Patch(string name, short width, short height, short leftOffset, short topOffset)
		{
			this.name = name;
			this.width = width;
			this.height = height;
			this.leftOffset = leftOffset;
			this.topOffset = topOffset;
			output = null;
		}
	}
	public struct Sound
	{
		public string soundName;

		public int id;

		public int sampleRate;

		public int sampleCount;

		public byte[] soundData;

		public AudioClip output;

		public Sound(string soundName, byte id, short sampleRate, ushort sampleCount, byte[] soundData)
		{
			this.soundName = soundName;
			this.id = id;
			this.sampleRate = sampleRate;
			this.sampleCount = sampleCount;
			this.soundData = soundData;
			output = null;
		}
	}
}
namespace NEP.DOOMLAB.Sound
{
	[RegisterTypeInIl2Cpp]
	public class PooledAudio : MonoBehaviour
	{
		private AudioSource source;

		private float time;

		public PooledAudio(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Start()
		{
			source = ((Component)this).GetComponent<AudioSource>();
		}

		private void Update()
		{
			time += Time.deltaTime;
			if (time >= source.clip.length)
			{
				((Component)this).gameObject.SetActive(false);
				time = 0f;
			}
		}
	}
	public class SoundManager
	{
		private static NEP.DOOMLAB.WAD.DataTypes.Sound[] soundLumps;

		private List<GameObject> pooledAudioObjects;

		public static SoundManager Instance { get; private set; }

		public SoundManager()
		{
			Awake();
		}

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			Instance = this;
			LoadWADAudio(WADManager.Instance.LoadedWAD.sounds);
			pooledAudioObjects = new List<GameObject>();
			GameObject val = new GameObject("Pooled Audio");
			GameObject val2 = new GameObject("Sound Manager");
			val.transform.parent = val2.transform;
			for (int i = 0; i < 256; i++)
			{
				GameObject val3 = new GameObject("Poolee Audio");
				val3.transform.parent = val.transform;
				AudioSource obj = val3.AddComponent<AudioSource>();
				obj.playOnAwake = true;
				obj.volume = 0.75f;
				obj.dopplerLevel = 0f;
				val3.AddComponent<PooledAudio>();
				val3.SetActive(false);
				pooledAudioObjects.Add(val3);
			}
		}

		public void LoadWADAudio(List<NEP.DOOMLAB.WAD.DataTypes.Sound> sounds)
		{
			LoadWADAudio(sounds.ToArray());
		}

		public void LoadWADAudio(NEP.DOOMLAB.WAD.DataTypes.Sound[] sounds)
		{
			soundLumps = sounds;
		}

		public AudioClip GetSound(SoundType soundType)
		{
			string text = soundType.ToString();
			string text2 = "DS" + text.Split(new char[1] { '_' })[1].ToUpper();
			NEP.DOOMLAB.WAD.DataTypes.Sound[] array = soundLumps;
			for (int i = 0; i < array.Length; i++)
			{
				NEP.DOOMLAB.WAD.DataTypes.Sound sound = array[i];
				if (((Object)sound.output).name == text2)
				{
					return sound.output;
				}
			}
			return null;
		}

		public void PlaySound(SoundType soundType, AudioSource source, bool fullVolume)
		{
			if (!((Object)(object)source == (Object)null) && soundType >= SoundType.sfx_pistol && soundType != 0)
			{
				AudioClip sound = GetSound(soundType);
				if (!((Object)(object)sound == (Object)null))
				{
					source.clip = sound;
					source.spatialBlend = (fullVolume ? 0f : 0.75f);
					source.Play();
				}
			}
		}

		public void PlaySound(SoundType soundType, Vector3 position, bool fullVolume)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (soundType < SoundType.sfx_pistol || soundType == SoundType.sfx_None)
			{
				return;
			}
			AudioClip sound = GetSound(soundType);
			if (!((Object)(object)sound == (Object)null))
			{
				GameObject val = ((IEnumerable<GameObject>)pooledAudioObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject inactive) => !inactive.activeInHierarchy));
				if ((Object)(object)val != (Object)null)
				{
					AudioSource component = val.GetComponent<AudioSource>();
					component.clip = sound;
					component.spatialBlend = (fullVolume ? 0f : 0.75f);
					val.transform.position = position;
					val.SetActive(true);
				}
			}
		}
	}
	public enum SoundType
	{
		sfx_None,
		sfx_pistol,
		sfx_shotgn,
		sfx_sgcock,
		sfx_dshtgn,
		sfx_dbopn,
		sfx_dbcls,
		sfx_dbload,
		sfx_plasma,
		sfx_bfg,
		sfx_sawup,
		sfx_sawidl,
		sfx_sawful,
		sfx_sawhit,
		sfx_rlaunc,
		sfx_rxplod,
		sfx_firsht,
		sfx_firxpl,
		sfx_pstart,
		sfx_pstop,
		sfx_doropn,
		sfx_dorcls,
		sfx_stnmov,
		sfx_swtchn,
		sfx_swtchx,
		sfx_plpain,
		sfx_dmpain,
		sfx_popain,
		sfx_vipain,
		sfx_mnpain,
		sfx_pepain,
		sfx_slop,
		sfx_itemup,
		sfx_wpnup,
		sfx_oof,
		sfx_telept,
		sfx_posit1,
		sfx_posit2,
		sfx_posit3,
		sfx_bgsit1,
		sfx_bgsit2,
		sfx_sgtsit,
		sfx_cacsit,
		sfx_brssit,
		sfx_cybsit,
		sfx_spisit,
		sfx_bspsit,
		sfx_kntsit,
		sfx_vilsit,
		sfx_mansit,
		sfx_pesit,
		sfx_sklatk,
		sfx_sgtatk,
		sfx_skepch,
		sfx_vilatk,
		sfx_claw,
		sfx_skeswg,
		sfx_pldeth,
		sfx_pdiehi,
		sfx_podth1,
		sfx_podth2,
		sfx_podth3,
		sfx_bgdth1,
		sfx_bgdth2,
		sfx_sgtdth,
		sfx_cacdth,
		sfx_skldth,
		sfx_brsdth,
		sfx_cybdth,
		sfx_spidth,
		sfx_bspdth,
		sfx_vildth,
		sfx_kntdth,
		sfx_pedth,
		sfx_skedth,
		sfx_posact,
		sfx_bgact,
		sfx_dmact,
		sfx_bspact,
		sfx_bspwlk,
		sfx_vilact,
		sfx_noway,
		sfx_barexp,
		sfx_punch,
		sfx_hoof,
		sfx_metal,
		sfx_chgun,
		sfx_tink,
		sfx_bdopn,
		sfx_bdcls,
		sfx_itmbk,
		sfx_flame,
		sfx_flamst,
		sfx_getpow,
		sfx_bospit,
		sfx_boscub,
		sfx_bossit,
		sfx_bospn,
		sfx_bosdth,
		sfx_manatk,
		sfx_mandth,
		sfx_sssit,
		sfx_ssdth,
		sfx_keenpn,
		sfx_keendt,
		sfx_skeact,
		sfx_skesit,
		sfx_skeatk,
		sfx_radio,
		NUMSFX
	}
}
namespace NEP.DOOMLAB.Rendering
{
	[RegisterTypeInIl2Cpp]
	public class MobjRenderer : MonoBehaviour
	{
		public MobjType mobjType;

		public DoomGame game;

		public Mobj mobj;

		private MeshRenderer meshRenderer;

		private Transform drawQuad;

		private static SpriteDef[] spriteDefs;

		private Camera camera;

		private static Patch missingPatch;

		private static SpriteFrame missingFrame;

		private Material original;

		private Material unlit;

		public MobjRenderer(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			meshRenderer = ((Component)this).GetComponentInChildren<MeshRenderer>();
			mobj = ((Component)this).GetComponentInParent<Mobj>();
			game = DoomGame.Instance;
			camera = Camera.main;
			drawQuad = ((Component)this).transform.GetChild(0);
			original = ((Renderer)meshRenderer).material;
			unlit = Main.unlitMaterial;
			missingPatch = new Patch("FAILA0", 32, 32, 16, 38);
			missingPatch.output = Main.MissingSprite;
			SpriteFrame spriteFrame = new SpriteFrame();
			spriteFrame.canRotate = false;
			spriteFrame.flipBits = new bool[8];
			spriteFrame.mirrorSprite = new bool[8];
			spriteFrame.numRotations = 0;
			spriteFrame.patches = new Patch[8] { missingPatch, missingPatch, missingPatch, missingPatch, missingPatch, missingPatch, missingPatch, missingPatch };
			missingFrame = spriteFrame;
		}

		private void Start()
		{
			DoomGame instance = DoomGame.Instance;
			instance.OnTick = (Action)Delegate.Combine(instance.OnTick, new Action(UpdateSprite));
			LoadSpriteDefs();
			UpdateSprite();
		}

		private void OnDestroy()
		{
			DoomGame instance = DoomGame.Instance;
			instance.OnTick = (Action)Delegate.Remove(instance.OnTick, new Action(UpdateSprite));
		}

		private void Update()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.LookRotation(((Component)camera).transform.position - ((Component)this).transform.position, Vector3.up);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Component)this).transform.eulerAngles.x, ((Quaternion)(ref val)).eulerAngles.y, ((Component)this).transform.eulerAngles.z);
			((Component)this).transform.rotation = Quaternion.Euler(val2);
		}

		public static void LoadSpriteDefs()
		{
			spriteDefs = FrameBuilder.spriteDefs;
		}

		public void UpdateSprite()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			int rotation = (int)((Mathf.Repeat(Vector3.SignedAngle(((Component)mobj).transform.forward, ((Component)camera).transform.forward, Vector3.up) + 180f, 360f) - 180f - 198f) / 45f) & 7;
			int num = mobj.frame;
			if (mobj.frame >= 32768)
			{
				num = mobj.frame - 32768;
				((Renderer)meshRenderer).material = unlit;
			}
			else
			{
				((Renderer)meshRenderer).material = original;
			}
			SpriteDef spriteDef = spriteDefs[(int)mobj.sprite];
			if (spriteDef.spriteFrames == null || num > spriteDef.spriteFrames.Length)
			{
				SetSprite(missingFrame, 0);
				return;
			}
			SpriteFrame spriteFrame = spriteDef.spriteFrames[num];
			if (spriteFrame.patches != null)
			{
				SetSprite(spriteFrame, rotation);
			}
		}

		private void SetSprite(SpriteFrame spriteFrame, int rotation)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			Patch patch = spriteFrame.patches[rotation];
			int num = (spriteFrame.flipBits[rotation] ? 1 : (-1));
			float num2 = (float)patch.width / 32f;
			float num3 = (float)patch.height / 32f;
			float num4 = (float)patch.leftOffset / 32f;
			float num5 = (float)patch.topOffset / 32f;
			((Renderer)meshRenderer).material.mainTexture = (Texture)(object)patch.output;
			((Component)this).transform.localScale = new Vector3(num2 * (float)num, num3, 1f);
			drawQuad.localPosition = new Vector3(num4 / 100f, num5 / 100f + 0.5f);
			if (mobj.frame >= 32768)
			{
				((Renderer)meshRenderer).material.SetTexture("_EmissionMap", (Texture)(object)patch.output);
				((Renderer)meshRenderer).material.SetColor("_EmissionColor", Color.white);
				((Renderer)meshRenderer).material.EnableKeyword("_EMISSION");
			}
			else
			{
				((Renderer)meshRenderer).material.DisableKeyword("_EMISSION");
			}
		}
	}
	public class SpriteDef
	{
		public int numFrames;

		public SpriteFrame[] spriteFrames;

		public void ResetFrames()
		{
			numFrames = 0;
		}
	}
	public class SpriteFrame
	{
		public int numRotations;

		public bool canRotate;

		public bool[] mirrorSprite;

		public Patch[] patches;

		public bool[] flipBits;

		public SpriteFrame()
		{
			patches = new Patch[8];
			flipBits = new bool[8];
		}
	}
	public static class FrameBuilder
	{
		public static SpriteDef[] spriteDefs;

		private static string[] spriteNames;

		private static Dictionary<string, List<SpriteFrame>> temp;

		private static Patch[] spritePatches;

		public static void GenerateTable()
		{
			spriteNames = Info.SpriteNames;
			spritePatches = WADManager.Instance.LoadedWAD.patches.ToArray();
			temp = new Dictionary<string, List<SpriteFrame>>();
			for (int i = 0; i < spriteNames.Length; i++)
			{
				temp.Add(spriteNames[i], new List<SpriteFrame>());
			}
			Patch[] array = spritePatches;
			for (int j = 0; j < array.Length; j++)
			{
				Patch patch = array[j];
				string name = patch.name;
				string key = name.Substring(0, 4);
				if (!temp.ContainsKey(key))
				{
					continue;
				}
				List<SpriteFrame> list = temp[key];
				int num = name[4] - 65;
				int num2 = name[5] - 48;
				while (list.Count < num + 1)
				{
					list.Add(new SpriteFrame());
				}
				if (num2 == 0)
				{
					for (int k = 0; k < 8; k++)
					{
						list[num].patches[k] = patch;
						list[num].flipBits[k] = false;
					}
				}
				else
				{
					list[num].patches[num2 - 1] = patch;
					list[num].flipBits[num2 - 1] = false;
				}
				if (name.Length != 8)
				{
					continue;
				}
				int num3 = name[6] - 65;
				int num4 = name[7] - 48;
				while (list.Count < num3 + 1)
				{
					list.Add(new SpriteFrame());
				}
				if (num4 == 0)
				{
					for (int l = 0; l < 8; l++)
					{
						list[num3].patches[l] = patch;
						list[num3].flipBits[l] = true;
					}
				}
				else
				{
					list[num3].patches[num4 - 1] = patch;
					list[num3].flipBits[num4 - 1] = true;
				}
			}
			spriteDefs = new SpriteDef[spriteNames.Length];
			for (int m = 0; m < spriteDefs.Length; m++)
			{
				List<SpriteFrame> list2 = temp[spriteNames[m]];
				SpriteFrame[] array2 = new SpriteFrame[list2.Count];
				for (int n = 0; n < array2.Length; n++)
				{
					SpriteFrame spriteFrame = new SpriteFrame();
					spriteFrame.patches = list2[n].patches;
					spriteFrame.flipBits = list2[n].flipBits;
					array2[n] = spriteFrame;
				}
				spriteDefs[m] = new SpriteDef();
				spriteDefs[m].spriteFrames = array2;
			}
		}
	}
}
namespace NEP.DOOMLAB.Patches
{
	internal static class AttackPatch
	{
		private delegate void AttackPatchDelegate(IntPtr instance, IntPtr attack, IntPtr method);

		public struct Attack_
		{
			public float damage;

			public Vector3 normal;

			public Vector3 origin;

			public byte backFacing;

			public int OrderInPool;

			public IntPtr collider;

			public AttackType attackType;

			public IntPtr proxy;

			public Collider Collider
			{
				get
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Expected O, but got Unknown
					return new Collider(collider);
				}
				set
				{
					collider = ((Il2CppObjectBase)value).Pointer;
				}
			}

			public TriggerRefProxy Proxy
			{
				get
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Expected O, but got Unknown
					return new TriggerRefProxy(proxy);
				}
				set
				{
					proxy = ((Il2CppObjectBase)value).Pointer;
				}
			}
		}

		public static Action<Attack> OnAttackReceived;

		private static AttackPatchDelegate _original;

		public unsafe static void Patch()
		{
			AttackPatchDelegate attackPatchDelegate = Patch;
			string name = "NativeMethodInfoPtr_ReceiveAttack_Public_Virtual_Final_New_Void_Attack_0";
			IntPtr ptr = *(IntPtr*)(void*)(IntPtr)typeof(ImpactProperties).GetField(name, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
			IntPtr functionPointer = attackPatchDelegate.Method.MethodHandle.GetFunctionPointer();
			MelonUtils.NativeHookAttach((IntPtr)(&ptr), functionPointer);
			_original = Marshal.GetDelegateForFunctionPointer<AttackPatchDelegate>(ptr);
		}

		public unsafe static void Patch(IntPtr instance, IntPtr attack, IntPtr method)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			_original(instance, attack, method);
			try
			{
				Attack_ attack_ = System.Runtime.CompilerServices.Unsafe.Read<Attack_>((void*)attack);
				Attack obj = new Attack
				{
					damage = attack_.damage,
					normal = attack_.normal,
					origin = attack_.origin,
					backFacing = (attack_.backFacing == 1),
					OrderInPool = attack_.OrderInPool,
					collider = attack_.Collider,
					attackType = attack_.attackType,
					proxy = attack_.Proxy
				};
				OnAttackReceived?.Invoke(obj);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	[HarmonyPatch("Awake")]
	public static class ProjectilePatch
	{
		public static void Postfix(Projectile __instance)
		{
			((UnityEvent<Collider, Vector3, Vector3>)(object)__instance.onCollision).AddListener(UnityAction<Collider, Vector3, Vector3>.op_Implicit((Action<Collider, Vector3, Vector3>)delegate(Collider hitCol, Vector3 world, Vector3 normal)
			{
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<int, Mobj> cacheLookup = Mobj.ComponentCache.CacheLookup;
				if (cacheLookup.ContainsKey(((Object)((Component)hitCol).gameObject).GetInstanceID()))
				{
					Mobj mobj = cacheLookup[((Object)((Component)hitCol).gameObject).GetInstanceID()];
					if (!((Object)(object)mobj == (Object)null) && !((Object)(object)mobj == (Object)(object)Mobj.player) && mobj.flags.HasFlag(MobjFlags.MF_SOLID | MobjFlags.MF_SHOOTABLE) && !mobj.flags.HasFlag(MobjFlags.MF_CORPSE))
					{
						MobjInteraction.DamageMobj(mobj, Mobj.player, Mobj.player, __instance._data.damageMultiplier * (float)(DoomGame.RNG.P_Random() & 3) * 6f);
						if (!mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD))
						{
							MobjManager.Instance.SpawnMobj(world, MobjType.MT_BLOOD);
						}
						else if (mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD))
						{
							MobjManager.Instance.SpawnMobj(world, MobjType.MT_PUFF);
						}
					}
				}
			}));
		}
	}
	[HarmonyPatch(typeof(HandSFX))]
	[HarmonyPatch("PunchAttack")]
	public static class PunchPatch
	{
		public static void Postfix(Collision c, float impulse, float relVelSqr)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_0093: 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_00d7: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Mobj> cacheLookup = Mobj.ComponentCache.CacheLookup;
			if (!cacheLookup.ContainsKey(((Object)c.gameObject).GetInstanceID()))
			{
				return;
			}
			Mobj mobj = cacheLookup[((Object)c.gameObject).GetInstanceID()];
			if ((Object)(object)mobj != (Object)null && (Object)(object)mobj != (Object)(object)Mobj.player && mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE))
			{
				ContactPoint val;
				if (!mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD))
				{
					MobjManager instance = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_BLOOD);
				}
				else
				{
					MobjManager instance2 = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance2.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_PUFF);
				}
				mobj.rigidbody.AddForce(c.impactForceSum, (ForceMode)1);
				MobjInteraction.DamageMobj(mobj, Mobj.player, Mobj.player, impulse);
				SoundManager instance3 = SoundManager.Instance;
				val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
				instance3.PlaySound(SoundType.sfx_punch, ((ContactPoint)(ref val)).point, fullVolume: false);
			}
		}
	}
	[HarmonyPatch(typeof(ImpactSFX))]
	[HarmonyPatch("BluntAttack")]
	public static class BluntPatch
	{
		public static void Postfix(float impulse, Collision c)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_0093: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Mobj> cacheLookup = Mobj.ComponentCache.CacheLookup;
			if (!cacheLookup.ContainsKey(((Object)c.gameObject).GetInstanceID()))
			{
				return;
			}
			Mobj mobj = cacheLookup[((Object)c.gameObject).GetInstanceID()];
			if ((Object)(object)mobj != (Object)null && (Object)(object)mobj != (Object)(object)Mobj.player && mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE))
			{
				ContactPoint val;
				if (!mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD))
				{
					MobjManager instance = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_BLOOD);
				}
				else
				{
					MobjManager instance2 = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance2.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_PUFF);
				}
				mobj.rigidbody.AddForce(c.impactForceSum, (ForceMode)1);
				MobjInteraction.DamageMobj(mobj, Mobj.player, Mobj.player, impulse);
			}
		}
	}
	[HarmonyPatch(typeof(StabSlash))]
	[HarmonyPatch("OnCollisionEnter")]
	public static class StabPatch
	{
		public static void Postfix(Collision c)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Mobj> cacheLookup = Mobj.ComponentCache.CacheLookup;
			if (!cacheLookup.ContainsKey(((Object)c.gameObject).GetInstanceID()))
			{
				return;
			}
			Mobj mobj = cacheLookup[((Object)c.gameObject).GetInstanceID()];
			if (!((Object)(object)mobj != (Object)null) || !((Object)(object)mobj != (Object)(object)Mobj.player))
			{
				return;
			}
			Vector3 impulse = c.impulse;
			if (((Vector3)(ref impulse)).magnitude > 0.125f && mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE))
			{
				ContactPoint val;
				if (!mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD))
				{
					MobjManager instance = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_BLOOD);
				}
				else
				{
					MobjManager instance2 = MobjManager.Instance;
					val = ((Il2CppArrayBase<ContactPoint>)(object)c.contacts)[0];
					instance2.SpawnMobj(((ContactPoint)(ref val)).point, MobjType.MT_PUFF);
				}
				mobj.rigidbody.AddForce(c.impactForceSum, (ForceMode)1);
				Mobj player = Mobj.player;
				Mobj player2 = Mobj.player;
				impulse = c.impulse;
				MobjInteraction.DamageMobj(mobj, player, player2, ((Vector3)(ref impulse)).magnitude * 2f);
			}
		}
	}
	[HarmonyPatch(typeof(Gun), "OnFire")]
	public static class GunPatches
	{
		public static void Postfix(Gun __instance)
		{
			PropagateSound(__instance);
		}

		public static void PropagateSound(Gun gun)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			LayerMask val = LayerMask.op_Implicit(~LayerMask.NameToLayer("EnemyColliders"));
			Il2CppReferenceArray<Collider> val2 = Physics.OverlapBox(gun.firePointTransform.position, Vector3.one * 16f, Quaternion.identity, LayerMask.op_Implicit(val), (QueryTriggerInteraction)1);
			for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val2).Length; i++)
			{
				int instanceID = ((Object)((Component)((Il2CppArrayBase<Collider>)(object)val2)[i]).gameObject).GetInstanceID();
				Dictionary<int, Mobj> cacheLookup = Mobj.ComponentCache.CacheLookup;
				if (cacheLookup.ContainsKey(instanceID))
				{
					Mobj mobj = cacheLookup[instanceID];
					if (!((Object)(object)mobj == (Object)(object)Mobj.player) && !((Object)(object)mobj.target != (Object)null))
					{
						mobj.target = Mobj.player;
						mobj.brain.A_SeeYou();
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(SpawnGun), "OnFire")]
	public static class SpawnGunPatch
	{
		public static bool Prefix(SpawnGun __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance._selectedMode == 1)
			{
				RaycastHit hitInfo = __instance._hitInfo;
				Mobj component = ((Component)((RaycastHit)(ref hitInfo)).collider).GetComponent<Mobj>();
				if ((Object)(object)component != (Object)null)
				{
					if ((Object)(object)component == (Object)(object)Mobj.player)
					{
						return false;
					}
					MobjManager.Instance.RemoveMobj(component);
					return false;
				}
				return true;
			}
			Crate selectedCrate = (Crate)(object)__instance._selectedCrate;
			if ((Object)(object)selectedCrate == (Object)null)
			{
				return false;
			}
			if (MobjLookup.npcLookup.ContainsKey(((Scannable)selectedCrate).Title))
			{
				MobjType type = MobjLookup.npcLookup[((Scannable)selectedCrate).Title];
				Vector3 truePlacePosition = __instance.truePlacePosition;
				Quaternion truePlaceRotation = __instance.truePlaceRotation;
				Vector3 position = default(Vector3);
				((Vector3)(ref position))..ctor(truePlacePosition.x, truePlacePosition.y, truePlacePosition.z);
				Mobj mobj = MobjManager.Instance.SpawnMobj(position, type, ((Quaternion)(ref truePlaceRotation)).eulerAngles.y);
				MobjManager.Instance.SpawnMobj(position, MobjType.MT_TFOG);
				SoundManager.Instance.PlaySound(SoundType.sfx_telept, ((Component)mobj).transform.position, fullVolume: false);
				return false;
			}
			if (MobjLookup.itemLookup.ContainsKey(((Scannable)selectedCrate).Title))
			{
				MobjType type2 = MobjLookup.itemLookup[((Scannable)selectedCrate).Title];
				Vector3 truePlacePosition2 = __instance.truePlacePosition;
				Quaternion truePlaceRotation2 = __instance.truePlaceRotation;
				Vector3 position2 = default(Vector3);
				((Vector3)(ref position2))..ctor(truePlacePosition2.x, truePlacePosition2.y, truePlacePosition2.z);
				Quaternion val = Quaternion.Euler(new Vector3(0f, truePlaceRotation2.y, 0f));
				Mobj mobj2 = MobjManager.Instance.SpawnMobj(position2, type2, ((Quaternion)(ref val)).eulerAngles.y);
				MobjManager.Instance.SpawnMobj(position2, MobjType.MT_TFOG);
				SoundManager.Instance.PlaySound(SoundType.sfx_telept, ((Component)mobj2).transform.position, fullVolume: false);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(SpawnableCratePlacer), "PlaceSpawnable")]
	public static class CrateSpawnerPatch
	{
		public static bool Prefix(SpawnableCratePlacer __instance)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			MelonLogger.Msg("Spawnable Crate Placer Run");
			Crate crate = (Crate)(object)((CrateReferenceT<SpawnableCrate>)(object)__instance.spawnableCrateReference).Crate;
			if ((Object)(object)crate == (Object)null)
			{
				return false;
			}
			if (MobjLookup.npcLookup.ContainsKey(((Scannable)crate).Title))
			{
				MobjType type = MobjLookup.npcLookup[((Scannable)crate).Title];
				Vector3 position = ((Component)__instance).transform.position;
				Quaternion rotation = ((Component)__instance).transform.rotation;
				Vector3 position2 = default(Vector3);
				((Vector3)(ref position2))..ctor(position.x, position.y, position.z);
				MobjManager.Instance.SpawnMobj(position2, type, ((Quaternion)(ref rotation)).eulerAngles.y);
				return false;
			}
			if (MobjLookup.itemLookup.ContainsKey(((Scannable)crate).Title))
			{
				MobjType type2 = MobjLookup.itemLookup[((Scannable)crate).Title];
				Vector3 position3 = ((Component)__instance).transform.position;
				Quaternion rotation2 = ((Component)__instance).transform.rotation;
				Vector3 position4 = default(Vector3);
				((Vector3)(ref position4))..ctor(position3.x, position3.y, position3.z);
				Quaternion val = Quaternion.Euler(new Vector3(0f, rotation2.y, 0f));
				MobjManager.Instance.SpawnMobj(position4, type2, ((Quaternion)(ref val)).eulerAngles.y);
				return false;
			}
			return true;
		}
	}
}
namespace NEP.DOOMLAB.Entities
{
	[RegisterTypeInIl2Cpp]
	public class Mobj : MonoBehaviour
	{
		public enum MoveDirection
		{
			EAST,
			NORTHEAST,
			NORTH,
			NORTHWEST,
			WEST,
			SOUTHWEST,
			SOUTH,
			SOUTHEAST,
			NODIR
		}

		public static Action<Mobj> OnDeath;

		public MobjInfo info;

		public State state;

		public StateNum currentState;

		public MobjType type;

		public MobjFlags flags;

		public Vector3 position;

		public Quaternion rotation;

		public SpriteNum sprite;

		public int frame;

		public float radius;

		public float height;

		public MobjBrain brain;

		public MobjProxy proxy;

		public Mobj target;

		public Mobj tracer;

		public bool sightedPlayer;

		public Vector3 momentum;

		public int validCount;

		public float health;

		public int tics;

		public MoveDirection moveDirection;

		public int moveCount;

		public int reactionTime;

		public int threshold;

		public int lastLook;

		public Rigidbody rigidbody;

		public BoxCollider collider;

		public Player_Health playerHealth;

		public TriggerRefProxy triggerRefProxy;

		public AudioSource audioSource;

		public static Instances<Mobj> ComponentCache { get; private set; }

		public static Mobj player => Main.player;

		public Action<Mobj> CurrentAction { get; private set; }

		public Stopwatch ActionStopwatch { get; private set; } = new Stopwatch();


		public Mobj(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			if (ComponentCache == null)
			{
				ComponentCache = new Instances<Mobj>();
			}
			else
			{
				ComponentCache.AddInstance(((Object)((Component)this).gameObject).GetInstanceID(), this);
			}
		}

		private void Start()
		{
			info = Info.MobjInfos[(int)type];
			playerHealth = ((Component)Player.rigManager).GetComponent<Player_Health>();
			player.health = ((Health)player.playerHealth).curr_Health;
			DoomGame instance = DoomGame.Instance;
			instance.OnTick = (Action)Delegate.Combine(instance.OnTick, new Action(WorldTick));
		}

		private void OnDestroy()
		{
			DoomGame instance = DoomGame.Instance;
			instance.OnTick = (Action)Delegate.Remove(instance.OnTick, new Action(WorldTick));
			ComponentCache.RemoveInstance(((Object)((Component)this).gameObject).GetInstanceID());
		}

		private void WorldTick()
		{
			//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)
			position = ((Component)this).transform.position;
			UpdateThinker();
		}

		public void UpdateThinker()
		{
			//IL_001c: 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)
			if (Settings.DisableAI)
			{
				return;
			}
			if (Settings.NoTarget)
			{
				target = null;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) > Settings.ProjectilePruneDistance && flags.HasFlag(MobjFlags.MF_MISSILE))
			{
				MobjManager.Instance.RemoveMobj(this);
			}
			else if (tics != -1)
			{
				tics--;
				if (tics <= 0)
				{
					SetState(state.nextstate);
				}
			}
			else if (flags.HasFlag(MobjFlags.MF_COUNTKILL) && Settings.RespawnMonsters)
			{
				moveCount++;
				if (moveCount >= 420 && DoomGame.RNG.P_Random() <= 4)
				{
					NightmareRespawn();
				}
			}
		}

		public bool SetState(StateNum state)
		{
			currentState = state;
			if (state == StateNum.S_NULL)
			{
				this.state = Info.states[0];
				MobjManager.Instance.RemoveMobj(this);
				return false;
			}
			State state2 = (this.state = Info.states[(int)state]);
			tics = state2.tics;
			sprite = state2.sprite;
			frame = state2.frame;
			ActionStopwatch = new Stopwatch();
			ActionStopwatch.Start();
			state2.action?.Invoke(this);
			CurrentAction = state2.action;
			ActionStopwatch.Stop();
			return true;
		}

		public void OnSpawn(Vector3 position, MobjType type)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			info = Info.MobjInfos[(int)type];
			this.type = type;
			radius = info.radius;
			height = info.height;
			flags = info.flags;
			health = info.spawnHealth;
			reactionTime = info.reactionTime;
			State state = (this.state = Info.states[(int)info.spawnState]);
			tics = state.tics;
			sprite = state.sprite;
			frame = state.frame;
			((Component)this).transform.position = position;
		}

		public void OnRemove()
		{
			Object.Destroy((Object)(object)((Component)this).GetComponentInChildren<MobjRenderer>());
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void SetFlag(MobjFlags flags)
		{
			this.flags ^= flags;
			((Collider)collider).enabled = flags.HasFlag(MobjFlags.MF_SOLID);
			rigidbody.useGravity = !flags.HasFlag(MobjFlags.MF_NOGRAVITY);
		}

		public void Kill()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)this == (Object)(object)player))
			{
				flags &= ~(MobjFlags.MF_SHOOTABLE | MobjFlags.MF_FLOAT | MobjFlags.MF_SKULLFLY);
				if (type != MobjType.MT_SKULL)
				{
					flags &= ~MobjFlags.MF_NOGRAVITY;
				}
				if (!flags.HasFlag(MobjFlags.MF_NOGRAVITY) && (Object)(object)rigidbody != (Object)null)
				{
					rigidbody.useGravity = true;
					rigidbody.drag = 1f;
				}
				flags |= MobjFlags.MF_DROPOFF | MobjFlags.MF_CORPSE;
				if ((Object)(object)collider != (Object)null)
				{
					collider.center = Vector3.zero;
					collider.size = new Vector3(radius / 32f, 0.01f, radius / 32f);
				}
				if (health < 0f - info.spawnHealth && info.xDeathState != 0)
				{
					SetState(info.xDeathState);
				}
				else
				{
					SetState(info.deathState);
				}
				tics -= DoomGame.RNG.P_Random() & 3;
				if (tics < 1)
				{
					tics = 1;
				}
				if (flags.HasFlag(MobjFlags.MF_COUNTKILL) && player.playerHealth.deathIsImminent)
				{
					player.playerHealth.LifeSavingDamgeDealt();
				}
				SpawnMobjAmmo(type);
				sightedPlayer = false;
				OnDeath?.Invoke(this);
			}
		}

		public void NightmareRespawn()
		{
			//IL_000b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			MobjManager.Instance.SpawnMobj(((Component)this).transform.position, MobjType.MT_TFOG);
			Mobj mobj = MobjManager.Instance.SpawnMobj(((Component)this).transform.position, type);
			SoundManager.Instance.PlaySound(SoundType.sfx_telept, ((Component)this).transform.position, fullVolume: false);
			mobj.reactionTime = 18;
			MobjManager.Instance.RemoveMobj(this);
		}

		public void SpawnMobjAmmo(MobjType type)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			string text = "c1534c5a-683b-4c01-b378-6795416d6d6f";
			string text2 = "c1534c5a-57d4-4468-b5f0-c795416d6d6f";
			string text3 = "c1534c5a-97a9-43f7-be30-6095416d6d6f";
			string text4;
			switch (type)
			{
			default:
				return;
			case MobjType.MT_POSSESSED:
			case MobjType.MT_WOLFSS:
				text4 = text;
				break;
			case MobjType.MT_SHOTGUY:
				text4 = text3;
				break;
			case MobjType.MT_CHAINGUY:
				text4 = text2;
				break;
			}
			SpawnableCrateReference crateRef = new SpawnableCrateReference(text4);
			Spawnable val = new Spawnable
			{
				crateRef = crateRef
			};
			AssetSpawner.Register(val);
			NullableMethodExtensions.PoolManager_Spawn(val, ((Component)this).transform.position, default(Quaternion), (Vector3?)null, false, (int?)null, (Action<GameObject>)null, (Action<GameObject>)null);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class MobjBrain : MonoBehaviour
	{
		public bool SeesTarget;

		public Mobj mobj;

		private List<Mobj> listBrainTargets;

		private float[] directions = new float[8] { 90f, 45f, 0f, 315f, 270f, 225f, 180f, 135f };

		private int moveIndex;

		private Mobj.MoveDirection[] opposite = new Mobj.MoveDirection[9]
		{
			Mobj.MoveDirection.WEST,
			Mobj.MoveDirection.SOUTHWEST,
			Mobj.MoveDirection.SOUTH,
			Mobj.MoveDirection.SOUTHEAST,
			Mobj.MoveDirection.EAST,
			Mobj.MoveDirection.NORTHEAST,
			Mobj.MoveDirection.NORTH,
			Mobj.MoveDirection.NORTHWEST,
			Mobj.MoveDirection.NODIR
		};

		private Mobj.MoveDirection[] diags = new Mobj.MoveDirection[4]
		{
			Mobj.MoveDirection.NORTHWEST,
			Mobj.MoveDirection.NORTHEAST,
			Mobj.MoveDirection.SOUTHWEST,
			Mobj.MoveDirection.SOUTHEAST
		};

		public MobjBrain(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			mobj = ((Component)this).GetComponent<Mobj>();
		}

		public void SetMoveDirection(Mobj.MoveDirection direction)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			if (!((Object)(object)mobj == (Object)null) && direction != Mobj.MoveDirection.NODIR)
			{
				mobj.moveDirection = direction;
				Quaternion rotation = Quaternion.AngleAxis(directions[(int)direction], Vector3.up);
				((Component)mobj).transform.rotation = rotation;
			}
		}

		public bool Move()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: 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)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			if (mobj.moveDirection == Mobj.MoveDirection.NODIR)
			{
				return false;
			}
			if (mobj.moveDirection >= Mobj.MoveDirection.NODIR)
			{
				return false;
			}
			Transform transform = ((Component)mobj).transform;
			Transform transform2 = ((Component)mobj.target).transform;
			RaycastHit val = default(RaycastHit);
			if (Physics.BoxCast(transform.position + Vector3.up * 0.5f, new Vector3(0.25f, 0.25f, 0.075f), transform.forward, ref val, transform.rotation, 1f))
			{
				Mobj component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<Mobj>();
				if ((Object)(object)component != (Object)null)
				{
					if (!component.flags.HasFlag(MobjFlags.MF_CORPSE))
					{
						return false;
					}
					Physics.IgnoreCollision((Collider)(object)mobj.collider, (Collider)(object)component.collider);
				}
				if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && !((RaycastHit)(ref val)).collider.isTrigger)
				{
					return false;
				}
			}
			if (mobj.flags.HasFlag(MobjFlags.MF_FLOAT) && (Object)(object)mobj.target != (Object)null && !mobj.flags.HasFlag(MobjFlags.MF_SKULLFLY) && !mobj.flags.HasFlag(MobjFlags.MF_INFLOAT))
			{
				float num = transform2.position.y - 1f + mobj.info.height / 32f / 2f - transform.position.y;
				float num2 = Vector3.Distance(transform.position, transform2.position);
				if ((double)num < -0.075 && num2 < 5f)
				{
					Rigidbody rigidbody = mobj.rigidbody;
					rigidbody.position -= transform.up * mobj.info.speed * Time.fixedDeltaTime;
				}
				else if ((double)num > 0.075 && num2 < 5f)
				{
					Rigidbody rigidbody2 = mobj.rigidbody;
					rigidbody2.position += transform.up * mobj.info.speed * Time.fixedDeltaTime;
				}
			}
			Rigidbody rigidbody3 = mobj.rigidbody;
			rigidbody3.position += transform.forward * mobj.info.speed * Time.fixedDeltaTime;
			return true;
		}

		public bool TryWalk()
		{
			if (!Move())
			{
				return false;
			}
			mobj.moveCount = DoomGame.RNG.P_Random() & 0xF;
			return true;
		}

		public void NewChaseDir()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			if ((Object)(object)mobj.target == (Object)null)
			{
				return;
			}
			Mobj.MoveDirection moveDirection = mobj.moveDirection;
			Mobj.MoveDirection moveDirection2 = opposite[(int)moveDirection];
			float num = ((Component)mobj.target).transform.position.x - ((Component)mobj).transform.position.x;
			float num2 = ((Component)mobj.target).transform.position.z - ((Component)mobj).transform.position.z;
			Mobj.MoveDirection[] array = new Mobj.MoveDirection[2];
			if (num > 1.5f)
			{
				array[0] = Mobj.MoveDirection.EAST;
			}
			else if (num < -1.5f)
			{
				array[0] = Mobj.MoveDirection.WEST;
			}
			else
			{
				array[0] = Mobj.MoveDirection.NODIR;
			}
			if (num2 > 1.5f)
			{
				array[1] = Mobj.MoveDirection.NORTH;
			}
			else if (num2 < -1.5f)
			{
				array[1] = Mobj.MoveDirection.SOUTH;
			}
			else
			{
				array[1] = Mobj.MoveDirection.NODIR;
			}
			if (array[0] != Mobj.MoveDirection.NODIR && array[1] != Mobj.MoveDirection.NODIR)
			{
				SetMoveDirection(diags[((num2 < 0f) ? 1 : 0) * 2 + ((num > 0f) ? 1 : 0)]);
				if (mobj.moveDirection != moveDirection2 && TryWalk())
				{
					return;
				}
			}
			if (DoomGame.RNG.P_Random() < 200 || Mathf.Abs(num2) > Mathf.Abs(num))
			{
				Mobj.MoveDirection moveDirection3 = array[0];
				array[0] = array[1];
				array[1] = moveDirection3;
			}
			if (array[0] == moveDirection2)
			{
				array[0] = Mobj.MoveDirection.NODIR;
			}
			if (array[1] == moveDirection2)
			{
				array[1] = Mobj.MoveDirection.NODIR;
			}
			if (array[0] != Mobj.MoveDirection.NODIR)
			{
				SetMoveDirection(array[0]);
				if (TryWalk())
				{
					return;
				}
			}
			if (array[1] != Mobj.MoveDirection.NODIR)
			{
				SetMoveDirection(array[1]);
				if (TryWalk())
				{
					return;
				}
			}
			if (moveDirection != Mobj.MoveDirection.NODIR)
			{
				SetMoveDirection(moveDirection);
				if (TryWalk())
				{
					return;
				}
			}
			if (((uint)DoomGame.RNG.P_Random() & (true ? 1u : 0u)) != 0)
			{
				for (Mobj.MoveDirection moveDirection3 = Mobj.MoveDirection.EAST; moveDirection3 <= Mobj.MoveDirection.SOUTHEAST; moveDirection3++)
				{
					if (moveDirection3 != moveDirection2)
					{
						SetMoveDirection(moveDirection3);
						if (TryWalk())
						{
							return;
						}
					}
				}
			}
			else
			{
				for (Mobj.MoveDirection moveDirection3 = Mobj.MoveDirection.SOUTHEAST; moveDirection3 != (Mobj.MoveDirection)(-1); moveDirection3--)
				{
					if (moveDirection3 != moveDirection2)
					{
						SetMoveDirection(moveDirection3);
						if (TryWalk())
						{
							return;
						}
					}
				}
			}
			if (moveDirection2 != Mobj.MoveDirection.NODIR)
			{
				SetMoveDirection(moveDirection2);
				if (TryWalk())
				{
					return;
				}
			}
			mobj.moveDirection = Mobj.MoveDirection.NODIR;
		}

		public bool CheckObstructedByBreakable()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)mobj).transform.position + Vector3.up * 0.5f;
			Vector3 forward = ((Component)mobj).transform.forward;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(new Ray(val, forward), ref val2, 2f))
			{
				Prop_Health componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Prop_Health>();
				ObjectDestructable componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ObjectDestructable>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					return true;
				}
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		public bool CheckObstructedByBreakable(out Prop_Health destructibleProp)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)mobj).transform.position + Vector3.up * 0.5f;
			Vector3 forward = ((Component)mobj).transform.forward;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(new Ray(val, forward), ref val2, 2f) && (Object)(object)(destructibleProp = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Prop_Health>()) != (Object)null)
			{
				return true;
			}
			destructibleProp = null;
			return false;
		}

		public bool CheckObstructedByBreakable(out ObjectDestructable destructibleProp)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)mobj).transform.position + Vector3.up * 0.5f;
			Vector3 forward = ((Component)mobj).transform.forward;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(new Ray(val, forward), ref val2, 2f) && (Object)(object)(destructibleProp = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ObjectDestructable>()) != (Object)null)
			{
				return true;
			}
			destructibleProp = null;
			return false;
		}

		public bool CheckMeleeRange()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mobj.target == (Object)null)
			{
				return false;
			}
			if (Vector3.Distance(((Component)mobj).transform.position, ((Component)mobj.target).transform.position) > 2f)
			{
				return false;
			}
			if (!MobjInteraction.CheckSight(mobj, mobj.target))
			{
				return false;
			}
			return true;
		}

		public bool CheckMissileRange()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (!MobjInteraction.CheckSight(mobj, mobj.target))
			{
				return false;
			}
			if (mobj.flags.HasFlag(MobjFlags.MF_JUSTHIT))
			{
				mobj.flags &= ~MobjFlags.MF_JUSTHIT;
				return true;
			}
			if (mobj.reactionTime != 0)
			{
				return false;
			}
			float num = Vector3.Distance(((Component)mobj).transform.position, ((Component)mobj.target).transform.position);
			if (mobj.info.meleeState == StateNum.S_NULL)
			{
				num -= 4f;
			}
			num *= 8f;
			if (mobj.type == MobjType.MT_VILE && num > 28f)
			{
				return false;
			}
			if (mobj.type == MobjType.MT_UNDEAD)
			{
				if ((double)num < 6.125)
				{
					return false;
				}
				num *= 2f;
			}
			if (mobj.type == MobjType.MT_CYBORG || mobj.type == MobjType.MT_SPIDER || mobj.type == MobjType.MT_SKULL)
			{
				num *= 2f;
			}
			if (num > 6.25f)
			{
				num = 6.25f;
			}
			if (mobj.type == MobjType.MT_CYBORG && num > 5f)
			{
				num = 5f;
			}
			if ((float)DoomGame.RNG.P_Random() < num)
			{
				return false;
			}
			return true;
		}

		public bool FindPlayer()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)Mobj.player).transform;
			Transform transform2 = ((Component)mobj).transform;
			float num = Vector3.Angle(transform.position - transform2.position, transform2.forward);
			if (!MobjInteraction.CheckSight(mobj, Mobj.player))
			{
				return false;
			}
			if (num < 45f)
			{
				mobj.target = Mobj.player;
				mobj.sightedPlayer = true;
				return true;
			}
			if (Vector3.Distance(transform.position, transform2.position) < mobj.radius / 32f + 2f)
			{
				mobj.target = Mobj.player;
				mobj.sightedPlayer = true;
				return true;
			}
			return true;
		}

		public void A_Look()
		{
			if (FindPlayer() && (Object)(object)mobj.target != (Object)null && mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE))
			{
				A_SeeYou();
			}
		}

		public void A_SeeYou()
		{
			//IL_0070: 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)
			SoundType soundType;
			switch (mobj.info.seeSound)
			{
			case SoundType.sfx_posit1:
			case SoundType.sfx_posit2:
			case SoundType.sfx_posit3:
				soundType = (SoundType)(36 + DoomGame.RNG.P_Random() % 3);
				break;
			case SoundType.sfx_bgsit1:
			case SoundType.sfx_bgsit2:
				soundType = (SoundType)(39 + DoomGame.RNG.P_Random() % 2);
				break;
			default:
				soundType = mobj.info.seeSound;
				break;
			}
			if (mobj.type == MobjType.MT_SPIDER || mobj.type == MobjType.MT_CYBORG)
			{
				SoundManager.Instance.PlaySound(soundType, Vector3.zero, fullVolume: true);
			}
			else
			{
				SoundManager.Instance.PlaySound(soundType, ((Component)mobj).transform.position, fullVolume: false);
			}
			mobj.SetState(mobj.info.seeState);
		}

		public void A_Chase()
		{
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			if (mobj.reactionTime != 0)
			{
				mobj.reactionTime--;
			}
			if (mobj.threshold != 0)
			{
				if ((Object)(object)mobj.target != (Object)null && mobj.health <= 0f)
				{
					mobj.threshold = 0;
				}
				else
				{
					mobj.threshold--;
				}
			}
			if ((Object)(object)mobj.target == (Object)null || !mobj.target.flags.HasFlag(MobjFlags.MF_SHOOTABLE))
			{
				if (mobj.sightedPlayer)
				{
					mobj.target = Mobj.player;
				}
				mobj.SetState(mobj.info.spawnState);
			}
			else if (mobj.flags.HasFlag(MobjFlags.MF_JUSTATTACKED))
			{
				mobj.flags &= ~MobjFlags.MF_JUSTATTACKED;
				if (!Settings.FastMonsters)
				{
					NewChaseDir();
				}
			}
			else if ((mobj.info.meleeState != 0 && CheckMeleeRange()) || CheckObstructedByBreakable())
			{
				if (mobj.info.attackSound != 0)
				{
					SoundManager.Instance.PlaySound(mobj.info.attackSound, ((Component)mobj).transform.position, fullVolume: false);
				}
				mobj.SetState(mobj.info.meleeState);
			}
			else if (mobj.info.missileState != 0)
			{
				if (!Settings.FastMonsters && mobj.moveCount != 0)
				{
					A_NoMissile();
					return;
				}
				if (!CheckMissileRange())
				{
					A_NoMissile();
					return;
				}
				mobj.SetState(mobj.info.missileState);
				mobj.flags |= MobjFlags.MF_JUSTATTACKED;
			}
			else
			{
				A_NoMissile();
			}
		}

		public void A_NoMissile()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (mobj.threshold != 0 || MobjInteraction.CheckSight(mobj, mobj.target) || !FindPlayer())
			{
				if (mobj.moveCount-- <= 0 || !Move())
				{
					NewChaseDir();
				}
				if (mobj.info.activeSound != 0 && DoomGame.RNG.P_Random() < 3)
				{
					SoundManager.Instance.PlaySound(mobj.info.activeSound, ((Component)mobj).transform.position, fullVolume: false);
				}
			}
		}

		public void A_FaceTarget()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				Quaternion val = Quaternion.LookRotation(((Component)mobj.target).transform.position - ((Component)mobj).transform.position, Vector3.up);
				((Component)mobj).transform.rotation = Quaternion.Euler(Vector3.up * ((Quaternion)(ref val)).eulerAngles.y);
			}
		}

		public void A_Explode()
		{
			MobjInteraction.RadiusAttack(mobj, mobj.target, 128f);
		}

		public void A_TroopAttack()
		{
			//IL_0041: 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)
			if ((Object)(object)mobj.target == (Object)null)
			{
				return;
			}
			A_FaceTarget();
			float num = (DoomGame.RNG.P_Random() % 8 + 1) * 3;
			if (CheckMeleeRange())
			{
				SoundManager.Instance.PlaySound(SoundType.sfx_claw, ((Component)mobj).transform.position, fullVolume: false);
				MobjInteraction.DamageMobj(mobj.target, mobj, mobj, num);
				return;
			}
			if (CheckObstructedByBreakable())
			{
				if (CheckObstructedByBreakable(out Prop_Health destructibleProp))
				{
					if (destructibleProp != null)
					{
						destructibleProp.TAKEDAMAGE(num, false, (AttackType)32);
					}
					return;
				}
				if (CheckObstructedByBreakable(out ObjectDestructable destructibleProp2))
				{
					if (destructibleProp2 != null)
					{
						destructibleProp2.TakeDamage(((Component)mobj).transform.forward, num, false, (AttackType)32);
					}
					return;
				}
			}
			MobjManager.Instance.SpawnMissile(mobj, mobj.target, MobjType.MT_TROOPSHOT);
		}

		public void A_PosAttack()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				A_FaceTarget();
				_ = (float)((DoomGame.RNG.P_Random() - DoomGame.RNG.P_Random()) & 0x14) / 10f;
				float num = (DoomGame.RNG.P_Random() % 5 + 1) * 3;
				SoundManager.Instance.PlaySound(SoundType.sfx_pistol, ((Component)mobj).transform.position, fullVolume: false);
				MobjInteraction.LineAttack(mobj, ((Component)mobj).transform.position + Vector3.up, ((Component)mobj.target).transform.position, num / 10f, 128f);
			}
		}

		public void A_SPosAttack()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0071: 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)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				A_FaceTarget();
				for (int i = 0; i < 3; i++)
				{
					_ = (float)((DoomGame.RNG.P_Random() - DoomGame.RNG.P_Random()) & 0x14) / 10f;
					float num = (DoomGame.RNG.P_Random() % 5 + 1) * 3;
					MobjInteraction.LineAttack(mobj, ((Component)mobj).transform.position + Vector3.up, ((Component)mobj.target).transform.position, num / 10f, 128f);
				}
				SoundManager.Instance.PlaySound(SoundType.sfx_shotgn, ((Component)mobj).transform.position, fullVolume: false);
			}
		}

		public void A_CPosAttack()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				SoundManager.Instance.PlaySound(SoundType.sfx_shotgn, ((Component)mobj).transform.position, fullVolume: false);
				A_FaceTarget();
				_ = (float)((DoomGame.RNG.P_Random() - DoomGame.RNG.P_Random()) & 0x14) / 10f;
				float num = (DoomGame.RNG.P_Random() % 5 + 1) * 3;
				MobjInteraction.LineAttack(mobj, ((Component)mobj).transform.position + Vector3.up, ((Component)mobj.target).transform.position, num / 10f, 128f);
			}
		}

		public void A_CPosRefire()
		{
			A_FaceTarget();
			if (DoomGame.RNG.P_Random() >= 40 && ((Object)(object)mobj.target == (Object)null || mobj.target.health <= 0f || !MobjInteraction.CheckSight(mobj, mobj.target)))
			{
				mobj.SetState(mobj.info.seeState);
			}
		}

		public void A_SpidRefire()
		{
			A_FaceTarget();
			if (DoomGame.RNG.P_Random() >= 10 && ((Object)(object)mobj.target == (Object)null || mobj.target.health == 0f || !MobjInteraction.CheckSight(mobj, mobj.target)))
			{
				mobj.SetState(mobj.info.seeState);
			}
		}

		public void A_BspiAttack()
		{
			if (!((Object)(object)mobj.target == (Object)null))
			{
				A_FaceTarget();
				MobjManager.Instance.SpawnMissile(mobj, mobj.target, MobjType.MT_ARACHPLAZ);
			}
		}

		public void A_SargAttack()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mobj.target == (Object)null)
			{
				return;
			}
			A_FaceTarget();
			float num = (DoomGame.RNG.P_Random() % 10 + 1) * 4;
			Prop_Health destructibleProp;
			ObjectDestructable destructibleProp2;
			if (CheckMeleeRange())
			{
				MobjInteraction.DamageMobj(mobj.target, mobj, mobj, num);
			}
			else if (CheckObstructedByBreakable(out destructibleProp))
			{
				if (destructibleProp != null)
				{
					destructibleProp.TAKEDAMAGE(num, false, (AttackType)32);
				}
			}
			else if (CheckObstructedByBreakable(out destructibleProp2) && destructibleProp2 != null)
			{
				destructibleProp2.TakeDamage(((Component)mobj).transform.forward, num, false, (AttackType)32);
			}
		}

		public void A_Tracer()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (DoomGame.Instance.gameTic % 2 == 0)
			{
				Quaternion val = Quaternion.LookRotation(mobj.tracer.position - ((Component)mobj).transform.position, Vector3.up);
				((Component)mobj).transform.rotation = Quaternion.Slerp(((Component)mobj).transform.rotation, val, 4f * Time.deltaTime);
				mobj.rigidbody.velocity = ((Component)mobj).transform.forward * mobj.info.speed;
			}
		}

		public void A_SkelMissile()
		{
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				A_FaceTarget();
				Transform transform = ((Component)mobj).transform;
				transform.position += Vector3.up * 0.5f;
				Mobj obj = MobjManager.Instance.SpawnMissile(mobj, mobj.target, MobjType.MT_TRACER);
				Transform transform2 = ((Component)mobj).transform;
				transform2.position -= Vector3.up * 0.5f;
				Transform transform3 = ((Component)obj).transform;
				transform3.position += ((Component)mobj).transform.forward;
				obj.tracer = mobj.target;
			}
		}

		public void A_SkelWhoosh()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mobj.target == (Object)null))
			{
				A_FaceTarget();
				SoundManager.Instance.PlaySound(SoundType.sfx_skeswg, ((Component)mobj).transform.position, fullVolume: false);
			}
		}

		public void A_SkelFist()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mobj.targ