Decompiled source of RuntimeIcons v0.1.5

plugins/LethalLib.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using LethalLib.Extras;
using LethalLib.Modules;
using LethalLib.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Evaisa")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Content-addition API for Lethal Company")]
[assembly: AssemblyFileVersion("0.16.1.0")]
[assembly: AssemblyInformationalVersion("0.16.1+1544246572e61ff167c447c6c4ceee7f9c8c05d5")]
[assembly: AssemblyProduct("LethalLib")]
[assembly: AssemblyTitle("LethalLib")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EvaisaDev/LethalLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalLib
{
	[BepInPlugin("evaisa.lethallib", "LethalLib", "0.16.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "evaisa.lethallib";

		public const string ModName = "LethalLib";

		public const string ModVersion = "0.16.1";

		public static AssetBundle MainAssets;

		public static ManualLogSource logger;

		public static ConfigFile config;

		public static Plugin Instance;

		public static ConfigEntry<bool> extendedLogging;

		private void Awake()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			config = ((BaseUnityPlugin)this).Config;
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalLib loaded!!");
			extendedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExtendedLogging", false, "Enable extended logging");
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "lethallib"));
			new ILHook((MethodBase)typeof(StackTrace).GetMethod("AddFrames", BindingFlags.Instance | BindingFlags.NonPublic), new Manipulator(IlHook));
			Enemies.Init();
			Items.Init();
			Unlockables.Init();
			MapObjects.Init();
			Dungeon.Init();
			Weathers.Init();
			Player.Init();
			Utilities.Init();
			NetworkPrefabs.Init();
		}

		private void IlHook(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			MethodInfo getFileLineNumberMethod = typeof(StackFrame).GetMethod("GetFileLineNumber", BindingFlags.Instance | BindingFlags.Public);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)getFileLineNumberMethod)
			}))
			{
				val.RemoveRange(2);
				val.EmitDelegate<Func<StackFrame, string>>((Func<StackFrame, string>)GetLineOrIL);
			}
		}

		private static string GetLineOrIL(StackFrame instance)
		{
			int fileLineNumber = instance.GetFileLineNumber();
			if (fileLineNumber == -1 || fileLineNumber == 0)
			{
				return "IL_" + instance.GetILOffset().ToString("X4");
			}
			return fileLineNumber.ToString();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalLib";

		public const string PLUGIN_NAME = "LethalLib";

		public const string PLUGIN_VERSION = "0.16.1";
	}
}
namespace LethalLib.Modules
{
	public class ContentLoader
	{
		public class CustomContent
		{
			private string id = "";

			public string ID => id;

			public CustomContent(string id)
			{
				this.id = id;
			}
		}

		public class CustomItem : CustomContent
		{
			public Action<Item> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal Item item;

			public Item Item => item;

			public CustomItem(string id, string contentPath, Action<Item> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
			}
		}

		public class ShopItem : CustomItem
		{
			public int initPrice;

			public string buyNode1Path;

			public string buyNode2Path;

			public string itemInfoPath;

			public void RemoveFromShop()
			{
				Items.RemoveShopItem(base.Item);
			}

			public void SetPrice(int price)
			{
				Items.UpdateShopItemPrice(base.Item, price);
			}

			public ShopItem(string id, string contentPath, int price = 0, string buyNode1Path = null, string buyNode2Path = null, string itemInfoPath = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				initPrice = price;
				this.buyNode1Path = buyNode1Path;
				this.buyNode2Path = buyNode2Path;
				this.itemInfoPath = itemInfoPath;
			}
		}

		public class ScrapItem : CustomItem
		{
			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public int Rarity => 0;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags)
			{
				Items.RemoveScrapFromLevels(base.Item, levelFlags);
			}

			public ScrapItem(string id, string contentPath, int rarity, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					levelRarities.Add(levelFlags, rarity);
				}
				else if (levelOverrides != null)
				{
					foreach (string key in levelOverrides)
					{
						customLevelRarities.Add(key, rarity);
					}
				}
			}

			public ScrapItem(string id, string contentPath, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, Action<Item> registryCallback = null)
				: base(id, contentPath, registryCallback)
			{
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
				if (customLevelRarities != null)
				{
					this.customLevelRarities = customLevelRarities;
				}
			}
		}

		public class Unlockable : CustomContent
		{
			public Action<UnlockableItem> registryCallback = delegate
			{
			};

			internal UnlockableItem unlockable;

			public string contentPath = "";

			public int initPrice;

			public string buyNode1Path;

			public string buyNode2Path;

			public string itemInfoPath;

			public StoreType storeType;

			public UnlockableItem UnlockableItem => unlockable;

			public void RemoveFromShop()
			{
				Unlockables.DisableUnlockable(UnlockableItem);
			}

			public void SetPrice(int price)
			{
				Unlockables.UpdateUnlockablePrice(UnlockableItem, price);
			}

			public Unlockable(string id, string contentPath, int price = 0, string buyNode1Path = null, string buyNode2Path = null, string itemInfoPath = null, StoreType storeType = StoreType.None, Action<UnlockableItem> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				initPrice = price;
				this.buyNode1Path = buyNode1Path;
				this.buyNode2Path = buyNode2Path;
				this.itemInfoPath = itemInfoPath;
				this.storeType = storeType;
			}
		}

		public class CustomEnemy : CustomContent
		{
			public Action<EnemyType> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal EnemyType enemy;

			public string infoNodePath;

			public string infoKeywordPath;

			public int rarity;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public Enemies.SpawnType spawnType = (Enemies.SpawnType)(-1);

			public EnemyType Enemy => enemy;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags)
			{
				Enemies.RemoveEnemyFromLevels(Enemy, levelFlags);
			}

			public CustomEnemy(string id, string contentPath, int rarity = 0, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, Enemies.SpawnType spawnType = (Enemies.SpawnType)(-1), string[] levelOverrides = null, string infoNodePath = null, string infoKeywordPath = null, Action<EnemyType> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				this.infoNodePath = infoNodePath;
				this.infoKeywordPath = infoKeywordPath;
				this.rarity = rarity;
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnType = spawnType;
			}
		}

		public class MapHazard : CustomContent
		{
			public Action<SpawnableMapObjectDef> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal SpawnableMapObjectDef hazard;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public SpawnableMapObjectDef Hazard => hazard;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
			{
				MapObjects.RemoveMapObject(Hazard, levelFlags, levelOverrides);
			}

			public MapHazard(string id, string contentPath, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, Action<SpawnableMapObjectDef> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnRateFunction = spawnRateFunction;
			}
		}

		public class OutsideObject : CustomContent
		{
			public Action<SpawnableOutsideObjectDef> registryCallback = delegate
			{
			};

			public string contentPath = "";

			internal SpawnableOutsideObjectDef mapObject;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;

			public Levels.LevelTypes LevelTypes = Levels.LevelTypes.None;

			public string[] levelOverrides;

			public SpawnableOutsideObjectDef MapObject => mapObject;

			public void RemoveFromLevels(Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
			{
				MapObjects.RemoveOutsideObject(MapObject, levelFlags, levelOverrides);
			}

			public OutsideObject(string id, string contentPath, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, Action<SpawnableOutsideObjectDef> registryCallback = null)
				: base(id)
			{
				this.contentPath = contentPath;
				if (registryCallback != null)
				{
					this.registryCallback = registryCallback;
				}
				LevelTypes = levelFlags;
				this.levelOverrides = levelOverrides;
				this.spawnRateFunction = spawnRateFunction;
			}
		}

		public PluginInfo modInfo;

		private AssetBundle modBundle;

		public Action<CustomContent, GameObject> prefabCallback = delegate
		{
		};

		public Dictionary<string, CustomContent> LoadedContent { get; } = new Dictionary<string, CustomContent>();


		public string modName => modInfo.Metadata.Name;

		public string modVersion => modInfo.Metadata.Version.ToString();

		public string modGUID => modInfo.Metadata.GUID;

		public ContentLoader(PluginInfo modInfo, AssetBundle modBundle, Action<CustomContent, GameObject> prefabCallback = null)
		{
			this.modInfo = modInfo;
			this.modBundle = modBundle;
			if (prefabCallback != null)
			{
				this.prefabCallback = prefabCallback;
			}
		}

		public ContentLoader Create(PluginInfo modInfo, AssetBundle modBundle, Action<CustomContent, GameObject> prefabCallback = null)
		{
			return new ContentLoader(modInfo, modBundle, prefabCallback);
		}

		public void Register(CustomContent content)
		{
			if (LoadedContent.ContainsKey(content.ID))
			{
				Debug.LogError((object)("[LethalLib] " + modName + " tried to register content with ID " + content.ID + " but it already exists!"));
				return;
			}
			if (content is CustomItem customItem)
			{
				Item val = (customItem.item = modBundle.LoadAsset<Item>(customItem.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Utilities.FixMixerGroups(val.spawnPrefab);
				prefabCallback(customItem, val.spawnPrefab);
				customItem.registryCallback(val);
				if (content is ShopItem shopItem)
				{
					TerminalNode buyNode = null;
					TerminalNode buyNode2 = null;
					TerminalNode itemInfo = null;
					if (shopItem.buyNode1Path != null)
					{
						buyNode = modBundle.LoadAsset<TerminalNode>(shopItem.buyNode1Path);
					}
					if (shopItem.buyNode2Path != null)
					{
						buyNode2 = modBundle.LoadAsset<TerminalNode>(shopItem.buyNode2Path);
					}
					if (shopItem.itemInfoPath != null)
					{
						itemInfo = modBundle.LoadAsset<TerminalNode>(shopItem.itemInfoPath);
					}
					Items.RegisterShopItem(val, buyNode, buyNode2, itemInfo, shopItem.initPrice);
				}
				else if (content is ScrapItem scrapItem)
				{
					Items.RegisterScrap(val, scrapItem.levelRarities, scrapItem.customLevelRarities);
				}
				else
				{
					Items.RegisterItem(val);
				}
			}
			else if (content is Unlockable unlockable)
			{
				UnlockableItemDef unlockableItemDef = modBundle.LoadAsset<UnlockableItemDef>(unlockable.contentPath);
				if ((Object)(object)unlockableItemDef.unlockable.prefabObject != (Object)null)
				{
					NetworkPrefabs.RegisterNetworkPrefab(unlockableItemDef.unlockable.prefabObject);
					prefabCallback(content, unlockableItemDef.unlockable.prefabObject);
					Utilities.FixMixerGroups(unlockableItemDef.unlockable.prefabObject);
				}
				unlockable.unlockable = unlockableItemDef.unlockable;
				unlockable.registryCallback(unlockableItemDef.unlockable);
				TerminalNode buyNode3 = null;
				TerminalNode buyNode4 = null;
				TerminalNode itemInfo2 = null;
				if (unlockable.buyNode1Path != null)
				{
					buyNode3 = modBundle.LoadAsset<TerminalNode>(unlockable.buyNode1Path);
				}
				if (unlockable.buyNode2Path != null)
				{
					buyNode4 = modBundle.LoadAsset<TerminalNode>(unlockable.buyNode2Path);
				}
				if (unlockable.itemInfoPath != null)
				{
					itemInfo2 = modBundle.LoadAsset<TerminalNode>(unlockable.itemInfoPath);
				}
				Unlockables.RegisterUnlockable(unlockableItemDef, unlockable.storeType, buyNode3, buyNode4, itemInfo2, unlockable.initPrice);
			}
			else if (content is CustomEnemy customEnemy)
			{
				EnemyType val2 = modBundle.LoadAsset<EnemyType>(customEnemy.contentPath);
				NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab);
				Utilities.FixMixerGroups(val2.enemyPrefab);
				customEnemy.enemy = val2;
				prefabCallback(content, val2.enemyPrefab);
				customEnemy.registryCallback(val2);
				TerminalNode infoNode = null;
				TerminalKeyword infoKeyword = null;
				if (customEnemy.infoNodePath != null)
				{
					infoNode = modBundle.LoadAsset<TerminalNode>(customEnemy.infoNodePath);
				}
				if (customEnemy.infoKeywordPath != null)
				{
					infoKeyword = modBundle.LoadAsset<TerminalKeyword>(customEnemy.infoKeywordPath);
				}
				if (customEnemy.spawnType == (Enemies.SpawnType)(-1))
				{
					Enemies.RegisterEnemy(val2, customEnemy.rarity, customEnemy.LevelTypes, customEnemy.levelOverrides, infoNode, infoKeyword);
				}
				else
				{
					Enemies.RegisterEnemy(val2, customEnemy.rarity, customEnemy.LevelTypes, customEnemy.spawnType, customEnemy.levelOverrides, infoNode, infoKeyword);
				}
			}
			else if (content is MapHazard mapHazard)
			{
				SpawnableMapObjectDef spawnableMapObjectDef = (mapHazard.hazard = modBundle.LoadAsset<SpawnableMapObjectDef>(mapHazard.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				Utilities.FixMixerGroups(spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				prefabCallback(content, spawnableMapObjectDef.spawnableMapObject.prefabToSpawn);
				mapHazard.registryCallback(spawnableMapObjectDef);
				MapObjects.RegisterMapObject(spawnableMapObjectDef, mapHazard.LevelTypes, mapHazard.levelOverrides, mapHazard.spawnRateFunction);
			}
			else if (content is OutsideObject outsideObject)
			{
				SpawnableOutsideObjectDef spawnableOutsideObjectDef = (outsideObject.mapObject = modBundle.LoadAsset<SpawnableOutsideObjectDef>(outsideObject.contentPath));
				NetworkPrefabs.RegisterNetworkPrefab(spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				Utilities.FixMixerGroups(spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				prefabCallback(content, spawnableOutsideObjectDef.spawnableMapObject.spawnableObject.prefabToSpawn);
				outsideObject.registryCallback(spawnableOutsideObjectDef);
				MapObjects.RegisterOutsideObject(spawnableOutsideObjectDef, outsideObject.LevelTypes, outsideObject.levelOverrides, outsideObject.spawnRateFunction);
			}
			LoadedContent.Add(content.ID, content);
		}

		public void RegisterAll(CustomContent[] content)
		{
			Plugin.logger.LogInfo((object)$"[LethalLib] {modName} is registering {content.Length} content items!");
			foreach (CustomContent content2 in content)
			{
				Register(content2);
			}
		}

		public void RegisterAll(List<CustomContent> content)
		{
			Plugin.logger.LogInfo((object)$"[LethalLib] {modName} is registering {content.Count} content items!");
			foreach (CustomContent item in content)
			{
				Register(item);
			}
		}
	}
	public class Dungeon
	{
		public class CustomDungeonArchetype
		{
			public DungeonArchetype archeType;

			public Levels.LevelTypes LevelTypes;

			public int lineIndex = -1;
		}

		public class CustomGraphLine
		{
			public GraphLine graphLine;

			public Levels.LevelTypes LevelTypes;
		}

		public class CustomDungeon
		{
			public int rarity;

			public DungeonFlow dungeonFlow;

			public Levels.LevelTypes LevelTypes;

			public string[] levelOverrides;

			public int dungeonIndex = -1;

			public AudioClip firstTimeDungeonAudio;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GenerateNewFloor <0>__RoundManager_GenerateNewFloor;

			public static hook_Start <1>__RoundManager_Start;
		}

		public static List<CustomDungeonArchetype> customDungeonArchetypes = new List<CustomDungeonArchetype>();

		public static List<CustomGraphLine> customGraphLines = new List<CustomGraphLine>();

		public static Dictionary<string, TileSet> extraTileSets = new Dictionary<string, TileSet>();

		public static Dictionary<string, GameObjectChance> extraRooms = new Dictionary<string, GameObjectChance>();

		public static List<CustomDungeon> customDungeons = new List<CustomDungeon>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__RoundManager_GenerateNewFloor;
			if (obj == null)
			{
				hook_GenerateNewFloor val = RoundManager_GenerateNewFloor;
				<>O.<0>__RoundManager_GenerateNewFloor = val;
				obj = (object)val;
			}
			RoundManager.GenerateNewFloor += (hook_GenerateNewFloor)obj;
			object obj2 = <>O.<1>__RoundManager_Start;
			if (obj2 == null)
			{
				hook_Start val2 = RoundManager_Start;
				<>O.<1>__RoundManager_Start = val2;
				obj2 = (object)val2;
			}
			RoundManager.Start += (hook_Start)obj2;
		}

		private static void RoundManager_Start(orig_Start orig, RoundManager self)
		{
			orig.Invoke(self);
		}

		private static void RoundManager_GenerateNewFloor(orig_GenerateNewFloor orig, RoundManager self)
		{
			string name = ((Object)self.currentLevel).name;
			if (Enum.IsDefined(typeof(Levels.LevelTypes), name))
			{
				Levels.LevelTypes levelEnum = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name);
				int index = 0;
				self.dungeonGenerator.Generator.DungeonFlow.Lines.ForEach(delegate(GraphLine line)
				{
					foreach (CustomDungeonArchetype customDungeonArchetype in customDungeonArchetypes)
					{
						if (customDungeonArchetype.LevelTypes.HasFlag(levelEnum) && !line.DungeonArchetypes.Contains(customDungeonArchetype.archeType) && (customDungeonArchetype.lineIndex == -1 || customDungeonArchetype.lineIndex == index))
						{
							line.DungeonArchetypes.Add(customDungeonArchetype.archeType);
							if (Plugin.extendedLogging.Value)
							{
								Plugin.logger.LogInfo((object)("Added " + ((Object)customDungeonArchetype.archeType).name + " to " + name));
							}
						}
					}
					foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes)
					{
						string name2 = ((Object)dungeonArchetype).name;
						if (extraTileSets.ContainsKey(name2))
						{
							TileSet val4 = extraTileSets[name2];
							if (!dungeonArchetype.TileSets.Contains(val4))
							{
								dungeonArchetype.TileSets.Add(val4);
								if (Plugin.extendedLogging.Value)
								{
									Plugin.logger.LogInfo((object)("Added " + ((Object)val4).name + " to " + name));
								}
							}
						}
						foreach (TileSet tileSet in dungeonArchetype.TileSets)
						{
							string name3 = ((Object)tileSet).name;
							if (extraRooms.ContainsKey(name3))
							{
								GameObjectChance item = extraRooms[name3];
								if (!tileSet.TileWeights.Weights.Contains(item))
								{
									tileSet.TileWeights.Weights.Add(item);
								}
							}
						}
					}
					index++;
				});
				foreach (CustomGraphLine customGraphLine in customGraphLines)
				{
					if (customGraphLine.LevelTypes.HasFlag(levelEnum) && !self.dungeonGenerator.Generator.DungeonFlow.Lines.Contains(customGraphLine.graphLine))
					{
						self.dungeonGenerator.Generator.DungeonFlow.Lines.Add(customGraphLine.graphLine);
					}
				}
			}
			orig.Invoke(self);
			NetworkManager val = Object.FindObjectOfType<NetworkManager>();
			RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>();
			foreach (RandomMapObject val2 in array)
			{
				for (int j = 0; j < val2.spawnablePrefabs.Count; j++)
				{
					string prefabName = ((Object)val2.spawnablePrefabs[j]).name;
					NetworkPrefab val3 = ((IEnumerable<NetworkPrefab>)val.NetworkConfig.Prefabs.m_Prefabs).FirstOrDefault((Func<NetworkPrefab, bool>)((NetworkPrefab x) => ((Object)x.Prefab).name == prefabName));
					if (val3 != null && (Object)(object)val3.Prefab != (Object)(object)val2.spawnablePrefabs[j])
					{
						val2.spawnablePrefabs[j] = val3.Prefab;
					}
					else if (val3 == null)
					{
						Plugin.logger.LogError((object)("DungeonGeneration - Could not find network prefab (" + prefabName + ")! Make sure your assigned prefab is registered with the network manager, or named identically to the vanilla prefab you are referencing."));
					}
				}
			}
		}

		public static void AddArchetype(DungeonArchetype archetype, Levels.LevelTypes levelFlags, int lineIndex = -1)
		{
			CustomDungeonArchetype customDungeonArchetype = new CustomDungeonArchetype();
			customDungeonArchetype.archeType = archetype;
			customDungeonArchetype.LevelTypes = levelFlags;
			customDungeonArchetype.lineIndex = lineIndex;
			customDungeonArchetypes.Add(customDungeonArchetype);
		}

		public static void AddLine(GraphLine line, Levels.LevelTypes levelFlags)
		{
			CustomGraphLine customGraphLine = new CustomGraphLine();
			customGraphLine.graphLine = line;
			customGraphLine.LevelTypes = levelFlags;
			customGraphLines.Add(customGraphLine);
		}

		public static void AddLine(DungeonGraphLineDef line, Levels.LevelTypes levelFlags)
		{
			AddLine(line.graphLine, levelFlags);
		}

		public static void AddTileSet(TileSet set, string archetypeName)
		{
			extraTileSets.Add(archetypeName, set);
		}

		public static void AddRoom(GameObjectChance room, string tileSetName)
		{
			extraRooms.Add(tileSetName, room);
		}

		public static void AddRoom(GameObjectChanceDef room, string tileSetName)
		{
			AddRoom(room.gameObjectChance, tileSetName);
		}

		public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags)
		{
			AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, dungeon.firstTimeDungeonAudio);
		}

		public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags, string[] levelOverrides)
		{
			AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, levelOverrides, dungeon.firstTimeDungeonAudio);
		}

		public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, AudioClip firstTimeDungeonAudio = null)
		{
			customDungeons.Add(new CustomDungeon
			{
				dungeonFlow = dungeon,
				rarity = rarity,
				LevelTypes = levelFlags,
				firstTimeDungeonAudio = firstTimeDungeonAudio
			});
		}

		public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, string[] levelOverrides = null, AudioClip firstTimeDungeonAudio = null)
		{
			customDungeons.Add(new CustomDungeon
			{
				dungeonFlow = dungeon,
				rarity = rarity,
				LevelTypes = levelFlags,
				firstTimeDungeonAudio = firstTimeDungeonAudio,
				levelOverrides = levelOverrides
			});
		}
	}
	public class Enemies
	{
		public struct EnemyAssetInfo
		{
			public EnemyType EnemyAsset;

			public TerminalKeyword keyword;
		}

		public enum SpawnType
		{
			Default,
			Daytime,
			Outside
		}

		public class SpawnableEnemy
		{
			public EnemyType enemy;

			public SpawnType spawnType;

			public TerminalNode terminalNode;

			public TerminalKeyword infoKeyword;

			public string modName;

			public int rarity;

			public Levels.LevelTypes spawnLevels;

			public string[] spawnLevelOverrides;

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public SpawnableEnemy(EnemyType enemy, int rarity, Levels.LevelTypes spawnLevels, SpawnType spawnType, string[] spawnLevelOverrides = null)
			{
				this.enemy = enemy;
				this.spawnLevels = spawnLevels;
				this.spawnType = spawnType;
				if (spawnLevelOverrides != null)
				{
					foreach (string levelName in spawnLevelOverrides)
					{
						customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(levelName), rarity);
					}
				}
				if (spawnLevels == Levels.LevelTypes.None)
				{
					return;
				}
				foreach (Levels.LevelTypes value in Enum.GetValues(typeof(Levels.LevelTypes)))
				{
					if (spawnLevels.HasFlag(value))
					{
						levelRarities.Add(value, rarity);
					}
				}
			}

			public SpawnableEnemy(EnemyType enemy, SpawnType spawnType, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
			{
				this.enemy = enemy;
				this.spawnType = spawnType;
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
				if (customLevelRarities != null)
				{
					this.customLevelRarities = Levels.Compatibility.LLLifyLevelRarityDictionary(customLevelRarities);
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__RegisterLevelEnemies;

			public static hook_Start <1>__Terminal_Start;

			public static hook_Start <2>__QuickMenuManager_Start;

			public static hook_Start <3>__RegisterLevelEnemiesforLLL_RoundManager_Start;

			public static hook_Start <4>__RegisterLevelEnemiesforLE_Terminal_Start;
		}

		private static List<SelectableLevel> levelsAlreadyAddedTo = new List<SelectableLevel>();

		private static bool addedToDebug = false;

		public static Terminal terminal;

		public static List<EnemyAssetInfo> enemyAssetInfos = new List<EnemyAssetInfo>();

		public static List<SpawnableEnemy> spawnableEnemies = new List<SpawnableEnemy>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__RegisterLevelEnemies;
			if (obj == null)
			{
				hook_Awake val = RegisterLevelEnemies;
				<>O.<0>__RegisterLevelEnemies = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__Terminal_Start;
			if (obj2 == null)
			{
				hook_Start val2 = Terminal_Start;
				<>O.<1>__Terminal_Start = val2;
				obj2 = (object)val2;
			}
			Terminal.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__QuickMenuManager_Start;
			if (obj3 == null)
			{
				hook_Start val3 = QuickMenuManager_Start;
				<>O.<2>__QuickMenuManager_Start = val3;
				obj3 = (object)val3;
			}
			QuickMenuManager.Start += (hook_Start)obj3;
		}

		private static void QuickMenuManager_Start(orig_Start orig, QuickMenuManager self)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			if (addedToDebug)
			{
				orig.Invoke(self);
				return;
			}
			SelectableLevel testAllEnemiesLevel = self.testAllEnemiesLevel;
			List<SpawnableEnemyWithRarity> enemies = testAllEnemiesLevel.Enemies;
			List<SpawnableEnemyWithRarity> daytimeEnemies = testAllEnemiesLevel.DaytimeEnemies;
			List<SpawnableEnemyWithRarity> outsideEnemies = testAllEnemiesLevel.OutsideEnemies;
			foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
			{
				if (enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
				{
					continue;
				}
				SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
				{
					enemyType = spawnableEnemy.enemy,
					rarity = spawnableEnemy.rarity
				};
				switch (spawnableEnemy.spawnType)
				{
				case SpawnType.Default:
					if (!enemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						enemies.Add(item);
					}
					break;
				case SpawnType.Daytime:
					if (!daytimeEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						daytimeEnemies.Add(item);
					}
					break;
				case SpawnType.Outside:
					if (!outsideEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy))
					{
						outsideEnemies.Add(item);
					}
					break;
				}
				if (Plugin.extendedLogging.Value)
				{
					Plugin.logger.LogInfo((object)$"Added {spawnableEnemy.enemy.enemyName} to DebugList [{spawnableEnemy.spawnType}]");
				}
			}
			addedToDebug = true;
			orig.Invoke(self);
		}

		private static void Terminal_Start(orig_Start orig, Terminal self)
		{
			//IL_0252: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			terminal = self;
			TerminalKeyword val = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			List<string> list = new List<string>();
			foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
			{
				if (list.Contains(spawnableEnemy.enemy.enemyName))
				{
					Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added"));
					continue;
				}
				if ((Object)(object)spawnableEnemy.terminalNode == (Object)null)
				{
					spawnableEnemy.terminalNode = ScriptableObject.CreateInstance<TerminalNode>();
					spawnableEnemy.terminalNode.displayText = spawnableEnemy.enemy.enemyName + "\n\nDanger level: Unknown\n\n[No information about this creature was found.]\n\n";
					spawnableEnemy.terminalNode.clearPreviousText = true;
					spawnableEnemy.terminalNode.maxCharactersToType = 35;
					spawnableEnemy.terminalNode.creatureName = spawnableEnemy.enemy.enemyName;
				}
				if (self.enemyFiles.Any((TerminalNode x) => x.creatureName == spawnableEnemy.terminalNode.creatureName))
				{
					Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added"));
					continue;
				}
				TerminalKeyword keyword2 = (((Object)(object)spawnableEnemy.infoKeyword != (Object)null) ? spawnableEnemy.infoKeyword : TerminalUtils.CreateTerminalKeyword(spawnableEnemy.terminalNode.creatureName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val));
				keyword2.defaultVerb = val;
				List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList();
				if (!list2.Any((TerminalKeyword x) => x.word == keyword2.word))
				{
					list2.Add(keyword2);
					self.terminalNodes.allKeywords = list2.ToArray();
				}
				List<CompatibleNoun> list3 = val.compatibleNouns.ToList();
				if (!list3.Any((CompatibleNoun x) => x.noun.word == keyword2.word))
				{
					list3.Add(new CompatibleNoun
					{
						noun = keyword2,
						result = spawnableEnemy.terminalNode
					});
				}
				val.compatibleNouns = list3.ToArray();
				spawnableEnemy.terminalNode.creatureFileID = self.enemyFiles.Count;
				self.enemyFiles.Add(spawnableEnemy.terminalNode);
				ScanNodeProperties[] componentsInChildren = spawnableEnemy.enemy.enemyPrefab.GetComponentsInChildren<ScanNodeProperties>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].creatureScanID = spawnableEnemy.terminalNode.creatureFileID;
				}
				EnemyAssetInfo enemyAssetInfo = default(EnemyAssetInfo);
				enemyAssetInfo.EnemyAsset = spawnableEnemy.enemy;
				enemyAssetInfo.keyword = keyword2;
				EnemyAssetInfo item = enemyAssetInfo;
				enemyAssetInfos.Add(item);
			}
			orig.Invoke(self);
		}

		private static void RegisterLevelEnemies(orig_Awake orig, StartOfRound self)
		{
			//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_0049: Expected O, but got Unknown
			//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_007a: Expected O, but got Unknown
			orig.Invoke(self);
			RegisterLethalLibEnemiesForAllLevels();
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader") || Chainloader.PluginInfos.ContainsKey("iambatby.lethallevelloader"))
			{
				object obj = <>O.<3>__RegisterLevelEnemiesforLLL_RoundManager_Start;
				if (obj == null)
				{
					hook_Start val = RegisterLevelEnemiesforLLL_RoundManager_Start;
					<>O.<3>__RegisterLevelEnemiesforLLL_RoundManager_Start = val;
					obj = (object)val;
				}
				RoundManager.Start += (hook_Start)obj;
			}
			if (Chainloader.PluginInfos.ContainsKey("LethalExpansion"))
			{
				object obj2 = <>O.<4>__RegisterLevelEnemiesforLE_Terminal_Start;
				if (obj2 == null)
				{
					hook_Start val2 = RegisterLevelEnemiesforLE_Terminal_Start;
					<>O.<4>__RegisterLevelEnemiesforLE_Terminal_Start = val2;
					obj2 = (object)val2;
				}
				Terminal.Start += (hook_Start)obj2;
			}
		}

		private static void RegisterLevelEnemiesforLLL_RoundManager_Start(orig_Start orig, RoundManager self)
		{
			orig.Invoke(self);
			RegisterLethalLibEnemiesForAllLevels();
		}

		private static void RegisterLevelEnemiesforLE_Terminal_Start(orig_Start orig, Terminal self)
		{
			orig.Invoke(self);
			RegisterLethalLibEnemiesForAllLevels();
		}

		private static void RegisterLethalLibEnemiesForAllLevels()
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (levelsAlreadyAddedTo.Contains(val))
				{
					continue;
				}
				foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies)
				{
					AddEnemyToLevel(spawnableEnemy, val);
				}
				levelsAlreadyAddedTo.Add(val);
			}
		}

		private static void AddEnemyToLevel(SpawnableEnemy spawnableEnemy, SelectableLevel level)
		{
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			SpawnableEnemy spawnableEnemy2 = spawnableEnemy;
			string text = ((Object)level).name;
			bool flag = spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.All) || spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.Vanilla) || (spawnableEnemy2.customLevelRarities != null && spawnableEnemy2.customLevelRarities.ContainsKey(text));
			if (spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), text))
			{
				flag = true;
			}
			Levels.LevelTypes levelTypes = Levels.LevelTypes.None;
			bool flag2 = false;
			if (Enum.IsDefined(typeof(Levels.LevelTypes), text))
			{
				levelTypes = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), text);
				flag2 = true;
			}
			else
			{
				text = Levels.Compatibility.GetLLLNameOfLevel(text);
			}
			if (!(flag2 || flag))
			{
				return;
			}
			Levels.LevelTypes key = (flag ? Levels.LevelTypes.All : levelTypes);
			if (!flag && !spawnableEnemy2.levelRarities.ContainsKey(key))
			{
				return;
			}
			int num = 0;
			if (flag2 && spawnableEnemy2.levelRarities.ContainsKey(levelTypes))
			{
				num = spawnableEnemy2.levelRarities[levelTypes];
			}
			else if (flag2 && spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.Vanilla))
			{
				num = spawnableEnemy2.levelRarities[Levels.LevelTypes.Vanilla];
			}
			else if (!flag2 && spawnableEnemy2.customLevelRarities != null && spawnableEnemy2.customLevelRarities.ContainsKey(text))
			{
				num = spawnableEnemy2.customLevelRarities[text];
			}
			else if (!flag2 && spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.Modded))
			{
				num = spawnableEnemy2.levelRarities[Levels.LevelTypes.Modded];
			}
			else if (spawnableEnemy2.levelRarities.ContainsKey(Levels.LevelTypes.All))
			{
				num = spawnableEnemy2.levelRarities[Levels.LevelTypes.All];
			}
			SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
			{
				enemyType = spawnableEnemy2.enemy,
				rarity = num
			};
			switch (spawnableEnemy2.spawnType)
			{
			case SpawnType.Default:
				if (!level.Enemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy2.enemy))
				{
					level.Enemies.Add(item);
					if (Plugin.extendedLogging.Value)
					{
						Plugin.logger.LogInfo((object)$"To {text} added {((Object)spawnableEnemy2.enemy).name} with weight {num} and SpawnType [Default]");
					}
				}
				break;
			case SpawnType.Daytime:
				if (!level.DaytimeEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy2.enemy))
				{
					level.DaytimeEnemies.Add(item);
					if (Plugin.extendedLogging.Value)
					{
						Plugin.logger.LogInfo((object)$"To {text} added {((Object)spawnableEnemy2.enemy).name} with weight {num} andSpawnType [Daytime]");
					}
				}
				break;
			case SpawnType.Outside:
				if (!level.OutsideEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy2.enemy))
				{
					level.OutsideEnemies.Add(item);
					if (Plugin.extendedLogging.Value)
					{
						Plugin.logger.LogInfo((object)$"To {text} added {((Object)spawnableEnemy2.enemy).name} with weight {num} and SpawnType [Outside]");
					}
				}
				break;
			}
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, null, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyType enemy2 = enemy;
			EnemyNullCheck(enemy2);
			SpawnableEnemy spawnableEnemy = spawnableEnemies.FirstOrDefault((SpawnableEnemy x) => (Object)(object)x.enemy == (Object)(object)enemy2 && x.spawnType == spawnType);
			if (spawnableEnemy != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					spawnableEnemy.levelRarities.Add(levelFlags, rarity);
				}
				if (spawnLevelOverrides != null)
				{
					foreach (string levelName in spawnLevelOverrides)
					{
						spawnableEnemy.customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(levelName), rarity);
					}
				}
			}
			else
			{
				spawnableEnemy = new SpawnableEnemy(enemy2, rarity, levelFlags, spawnType, spawnLevelOverrides);
				spawnableEnemy.terminalNode = infoNode;
				spawnableEnemy.infoKeyword = infoKeyword;
				FinalizeRegisterEnemy(spawnableEnemy);
			}
		}

		public static void RegisterEnemy(EnemyType enemy, SpawnType spawnType, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyType enemy2 = enemy;
			EnemyNullCheck(enemy2);
			SpawnableEnemy spawnableEnemy = spawnableEnemies.FirstOrDefault((SpawnableEnemy x) => (Object)(object)x.enemy == (Object)(object)enemy2 && x.spawnType == spawnType);
			if (spawnableEnemy != null)
			{
				if (levelRarities != null)
				{
					foreach (KeyValuePair<Levels.LevelTypes, int> levelRarity in levelRarities)
					{
						spawnableEnemy.levelRarities.Add(levelRarity.Key, levelRarity.Value);
					}
				}
				if (customLevelRarities == null)
				{
					return;
				}
				{
					foreach (KeyValuePair<string, int> customLevelRarity in customLevelRarities)
					{
						spawnableEnemy.customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(customLevelRarity.Key), customLevelRarity.Value);
					}
					return;
				}
			}
			spawnableEnemy = new SpawnableEnemy(enemy2, spawnType, levelRarities, customLevelRarities);
			spawnableEnemy.terminalNode = infoNode;
			spawnableEnemy.infoKeyword = infoKeyword;
			FinalizeRegisterEnemy(spawnableEnemy);
		}

		private static void FinalizeRegisterEnemy(SpawnableEnemy spawnableEnemy)
		{
			string name = Assembly.GetCallingAssembly().GetName().Name;
			spawnableEnemy.modName = name;
			if (spawnableEnemy.enemy.enemyPrefab == null)
			{
				throw new NullReferenceException("Cannot register enemy '" + spawnableEnemy.enemy.enemyName + "', because enemy.enemyPrefab is null!");
			}
			EnemyAICollisionDetect[] componentsInChildren = spawnableEnemy.enemy.enemyPrefab.GetComponentsInChildren<EnemyAICollisionDetect>();
			foreach (EnemyAICollisionDetect val in componentsInChildren)
			{
				if (val.mainScript == null)
				{
					Plugin.logger.LogWarning((object)("An Enemy AI Collision Detect Script on GameObject '" + ((Object)((Component)val).gameObject).name + "' of enemy '" + spawnableEnemy.enemy.enemyName + "' does not reference a 'Main Script', and could cause Null Reference Exceptions."));
				}
			}
			spawnableEnemies.Add(spawnableEnemy);
		}

		private static void EnemyNullCheck(EnemyType enemy)
		{
			if (enemy == null)
			{
				throw new ArgumentNullException("enemy", "The first argument of RegisterEnemy was null!");
			}
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyNullCheck(enemy);
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, null, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyNullCheck(enemy);
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, rarity, levelFlags, spawnType, spawnLevelOverrides, infoNode, infoKeyword);
		}

		public static void RegisterEnemy(EnemyType enemy, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null)
		{
			EnemyNullCheck(enemy);
			SpawnType spawnType = (enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default));
			RegisterEnemy(enemy, spawnType, levelRarities, customLevelRarities, infoNode, infoKeyword);
		}

		public static void RemoveEnemyFromLevels(EnemyType enemyType, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			EnemyType enemyType2 = enemyType;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				if (!Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					name = Levels.Compatibility.GetLLLNameOfLevel(name);
				}
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => Levels.Compatibility.GetLLLNameOfLevel(item).ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					List<SpawnableEnemyWithRarity> enemies = val.Enemies;
					List<SpawnableEnemyWithRarity> daytimeEnemies = val.DaytimeEnemies;
					List<SpawnableEnemyWithRarity> outsideEnemies = val.OutsideEnemies;
					enemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
					daytimeEnemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
					outsideEnemies.RemoveAll((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyType2);
					if (Plugin.extendedLogging.Value)
					{
						Plugin.logger.LogInfo((object)("Removed Enemy " + ((Object)enemyType2).name + " from Level " + name));
					}
				}
			}
		}
	}
	public class Items
	{
		public struct ItemSaveOrderData
		{
			public int itemId;

			public string itemName;

			public string assetName;
		}

		public struct BuyableItemAssetInfo
		{
			public Item itemAsset;

			public TerminalKeyword keyword;
		}

		public class ScrapItem
		{
			public Item item;

			public Item origItem;

			public int rarity;

			public Levels.LevelTypes spawnLevels;

			public string[] spawnLevelOverrides;

			public string modName = "Unknown";

			public Dictionary<string, int> customLevelRarities = new Dictionary<string, int>();

			public Dictionary<Levels.LevelTypes, int> levelRarities = new Dictionary<Levels.LevelTypes, int>();

			public ScrapItem(Item item, int rarity, Levels.LevelTypes spawnLevels = Levels.LevelTypes.None, string[] spawnLevelOverrides = null)
			{
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				origItem = item;
				if (!item.isScrap)
				{
					item = item.Clone<Item>();
					item.isScrap = true;
					if (item.maxValue == 0 && item.minValue == 0)
					{
						item.minValue = 40;
						item.maxValue = 100;
					}
					else if (item.maxValue == 0)
					{
						item.maxValue = item.minValue * 2;
					}
					else if (item.minValue == 0)
					{
						item.minValue = item.maxValue / 2;
					}
					GameObject val = NetworkPrefabs.CloneNetworkPrefab(item.spawnPrefab);
					if ((Object)(object)val.GetComponent<GrabbableObject>() != (Object)null)
					{
						val.GetComponent<GrabbableObject>().itemProperties = item;
					}
					if ((Object)(object)val.GetComponentInChildren<ScanNodeProperties>() == (Object)null)
					{
						GameObject obj = Object.Instantiate<GameObject>(scanNodePrefab, val.transform);
						((Object)obj).name = "ScanNode";
						obj.transform.localPosition = new Vector3(0f, 0f, 0f);
						obj.GetComponent<ScanNodeProperties>().headerText = item.itemName;
					}
					item.spawnPrefab = val;
				}
				this.item = item;
				if (spawnLevelOverrides != null)
				{
					foreach (string levelName in spawnLevelOverrides)
					{
						customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(levelName), rarity);
					}
				}
				if (spawnLevels == Levels.LevelTypes.None)
				{
					return;
				}
				foreach (Levels.LevelTypes value in Enum.GetValues(typeof(Levels.LevelTypes)))
				{
					if (spawnLevels.HasFlag(value))
					{
						levelRarities.Add(value, rarity);
					}
				}
			}

			public ScrapItem(Item item, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
			{
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				origItem = item;
				if (!item.isScrap)
				{
					item = item.Clone<Item>();
					item.isScrap = true;
					if (item.maxValue == 0 && item.minValue == 0)
					{
						item.minValue = 40;
						item.maxValue = 100;
					}
					else if (item.maxValue == 0)
					{
						item.maxValue = item.minValue * 2;
					}
					else if (item.minValue == 0)
					{
						item.minValue = item.maxValue / 2;
					}
					GameObject val = NetworkPrefabs.CloneNetworkPrefab(item.spawnPrefab);
					if ((Object)(object)val.GetComponent<GrabbableObject>() != (Object)null)
					{
						val.GetComponent<GrabbableObject>().itemProperties = item;
					}
					if ((Object)(object)val.GetComponentInChildren<ScanNodeProperties>() == (Object)null)
					{
						GameObject obj = Object.Instantiate<GameObject>(scanNodePrefab, val.transform);
						((Object)obj).name = "ScanNode";
						obj.transform.localPosition = new Vector3(0f, 0f, 0f);
						obj.GetComponent<ScanNodeProperties>().headerText = item.itemName;
					}
					item.spawnPrefab = val;
				}
				this.item = item;
				if (customLevelRarities != null)
				{
					this.customLevelRarities = Levels.Compatibility.LLLifyLevelRarityDictionary(customLevelRarities);
				}
				if (levelRarities != null)
				{
					this.levelRarities = levelRarities;
				}
			}
		}

		public class PlainItem
		{
			public Item item;

			public string modName;

			public PlainItem(Item item)
			{
				this.item = item;
			}
		}

		public class ShopItem
		{
			public Item item;

			public Item origItem;

			public TerminalNode buyNode1;

			public TerminalNode buyNode2;

			public TerminalNode itemInfo;

			public bool wasRemoved;

			public int price;

			public string modName;

			public ShopItem(Item item, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = 0)
			{
				origItem = item;
				this.item = item;
				this.price = price;
				if ((Object)(object)buyNode1 != (Object)null)
				{
					this.buyNode1 = buyNode1;
				}
				if ((Object)(object)buyNode2 != (Object)null)
				{
					this.buyNode2 = buyNode2;
				}
				if ((Object)(object)itemInfo != (Object)null)
				{
					this.itemInfo = itemInfo;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__StartOfRound_Start;

			public static hook_Awake <1>__Terminal_Awake;

			public static hook_TextPostProcess <2>__Terminal_TextPostProcess;

			public static hook_Start <3>__RegisterLevelScrapforLLL_RoundManager_Start;

			public static hook_Start <4>__RegisterLevelScrapforLE_Terminal_Start;
		}

		public static ConfigEntry<bool> useSavedataFix;

		public static GameObject scanNodePrefab;

		private static List<SelectableLevel> levelsAlreadyAddedTo = new List<SelectableLevel>();

		public static List<Item> LethalLibItemList = new List<Item>();

		public static List<BuyableItemAssetInfo> buyableItemAssetInfos = new List<BuyableItemAssetInfo>();

		public static Terminal terminal;

		public static List<ScrapItem> scrapItems = new List<ScrapItem>();

		public static List<ShopItem> shopItems = new List<ShopItem>();

		public static List<PlainItem> plainItems = new List<PlainItem>();

		public static void Init()
		{
			//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_004e: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			useSavedataFix = Plugin.config.Bind<bool>("Items", "EnableItemSaveFix", false, "Allow for LethalLib to store/reorder the item list, which should fix issues where items get reshuffled when loading an old save. This is experimental and may cause save corruptions occasionally.");
			scanNodePrefab = Plugin.MainAssets.LoadAsset<GameObject>("Assets/Custom/ItemScanNode.prefab");
			object obj = <>O.<0>__StartOfRound_Start;
			if (obj == null)
			{
				hook_Start val = StartOfRound_Start;
				<>O.<0>__StartOfRound_Start = val;
				obj = (object)val;
			}
			StartOfRound.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__Terminal_Awake;
			if (obj2 == null)
			{
				hook_Awake val2 = Terminal_Awake;
				<>O.<1>__Terminal_Awake = val2;
				obj2 = (object)val2;
			}
			Terminal.Awake += (hook_Awake)obj2;
			object obj3 = <>O.<2>__Terminal_TextPostProcess;
			if (obj3 == null)
			{
				hook_TextPostProcess val3 = Terminal_TextPostProcess;
				<>O.<2>__Terminal_TextPostProcess = val3;
				obj3 = (object)val3;
			}
			Terminal.TextPostProcess += (hook_TextPostProcess)obj3;
		}

		private static string Terminal_TextPostProcess(orig_TextPostProcess orig, Terminal self, string modifiedDisplayText, TerminalNode node)
		{
			List<Item> list = self.buyableItemsList.ToList();
			List<Item> list2 = self.buyableItemsList.ToList();
			list2.RemoveAll((Item x) => shopItems.FirstOrDefault((ShopItem item) => (Object)(object)item.origItem == (Object)(object)x || (Object)(object)item.item == (Object)(object)x)?.wasRemoved ?? false);
			self.buyableItemsList = list2.ToArray();
			string result = orig.Invoke(self, modifiedDisplayText, node);
			self.buyableItemsList = list.ToArray();
			return result;
		}

		private static void StartOfRound_Start(orig_Start orig, StartOfRound self)
		{
			if (useSavedataFix.Value && ((NetworkBehaviour)self).IsHost)
			{
				Plugin.logger.LogInfo((object)"Fixing Item savedata!!");
				List<ItemSaveOrderData> itemList = new List<ItemSaveOrderData>();
				StartOfRound.Instance.allItemsList.itemsList.ForEach(delegate(Item item)
				{
					itemList.Add(new ItemSaveOrderData
					{
						itemId = item.itemId,
						itemName = item.itemName,
						assetName = ((Object)item).name
					});
				});
				if (ES3.KeyExists("LethalLibAllItemsList", GameNetworkManager.Instance.currentSaveFileName))
				{
					itemList = ES3.Load<List<ItemSaveOrderData>>("LethalLibAllItemsList", GameNetworkManager.Instance.currentSaveFileName);
				}
				List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
				List<Item> list = new List<Item>();
				foreach (ItemSaveOrderData item2 in itemList)
				{
					Item val = ((IEnumerable<Item>)itemsList).FirstOrDefault((Func<Item, bool>)((Item x) => x.itemId == item2.itemId && x.itemName == item2.itemName && item2.assetName == ((Object)x).name));
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
					else
					{
						list.Add(ScriptableObject.CreateInstance<Item>());
					}
				}
				foreach (Item item3 in itemsList)
				{
					if (!list.Contains(item3))
					{
						list.Add(item3);
					}
				}
				StartOfRound.Instance.allItemsList.itemsList = list;
				ES3.Save<List<ItemSaveOrderData>>("LethalLibAllItemsList", itemList, GameNetworkManager.Instance.currentSaveFileName);
			}
			orig.Invoke(self);
		}

		private static void RegisterLevelScrapforLLL_RoundManager_Start(orig_Start orig, RoundManager self)
		{
			orig.Invoke(self);
			RegisterLethalLibScrapItemsForAllLevels();
		}

		private static void RegisterLevelScrapforLE_Terminal_Start(orig_Start orig, Terminal self)
		{
			orig.Invoke(self);
			RegisterLethalLibScrapItemsForAllLevels();
		}

		private static void RegisterLethalLibScrapItemsForAllLevels()
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (levelsAlreadyAddedTo.Contains(val))
				{
					continue;
				}
				foreach (ScrapItem scrapItem in scrapItems)
				{
					AddScrapItemToLevel(scrapItem, val);
				}
				levelsAlreadyAddedTo.Add(val);
			}
		}

		private static void AddScrapItemToLevel(ScrapItem scrapItem, SelectableLevel level)
		{
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			ScrapItem scrapItem2 = scrapItem;
			string text = ((Object)level).name;
			bool flag = scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.All) || scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.Vanilla) || (scrapItem2.customLevelRarities != null && scrapItem2.customLevelRarities.ContainsKey(text));
			if (scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), text))
			{
				flag = true;
			}
			Levels.LevelTypes key = Levels.LevelTypes.None;
			bool flag2 = false;
			if (Enum.IsDefined(typeof(Levels.LevelTypes), text))
			{
				key = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), text);
				flag2 = true;
			}
			else
			{
				text = Levels.Compatibility.GetLLLNameOfLevel(text);
			}
			if (!(flag2 || flag))
			{
				return;
			}
			Levels.LevelTypes key2 = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), text)));
			if (!flag && !scrapItem2.levelRarities.ContainsKey(key2))
			{
				return;
			}
			int rarity = 0;
			if (flag2 && scrapItem2.levelRarities.ContainsKey(key))
			{
				rarity = scrapItem2.levelRarities[key];
			}
			else if (flag2 && scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.Vanilla))
			{
				rarity = scrapItem2.levelRarities[Levels.LevelTypes.Vanilla];
			}
			else if (!flag2 && scrapItem2.customLevelRarities != null && scrapItem2.customLevelRarities.ContainsKey(text))
			{
				rarity = scrapItem2.customLevelRarities[text];
			}
			else if (!flag2 && scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.Modded))
			{
				rarity = scrapItem2.levelRarities[Levels.LevelTypes.Modded];
			}
			else if (scrapItem2.levelRarities.ContainsKey(Levels.LevelTypes.All))
			{
				rarity = scrapItem2.levelRarities[Levels.LevelTypes.All];
			}
			SpawnableItemWithRarity item = new SpawnableItemWithRarity
			{
				spawnableItem = scrapItem2.item,
				rarity = rarity
			};
			if (!level.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)scrapItem2.item))
			{
				level.spawnableScrap.Add(item);
				if (Plugin.extendedLogging.Value)
				{
					Plugin.logger.LogInfo((object)("To " + text + " added " + ((Object)scrapItem2.item).name));
				}
			}
		}

		private static void RegisterScrapAsItem(StartOfRound startOfRound)
		{
			foreach (ScrapItem scrapItem in scrapItems)
			{
				if (startOfRound.allItemsList.itemsList.Contains(scrapItem.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (scrapItem.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(scrapItem.modName + " registered scrap item: " + scrapItem.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered scrap item: " + scrapItem.item.itemName));
					}
				}
				LethalLibItemList.Add(scrapItem.item);
				startOfRound.allItemsList.itemsList.Add(scrapItem.item);
			}
		}

		private static void Terminal_Awake(orig_Awake orig, Terminal self)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Expected O, but got Unknown
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Expected O, but got Unknown
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Expected O, but got Unknown
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Expected O, but got Unknown
			StartOfRound instance = StartOfRound.Instance;
			RegisterLethalLibScrapItemsForAllLevels();
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader") || Chainloader.PluginInfos.ContainsKey("iambatby.lethallevelloader"))
			{
				object obj = <>O.<3>__RegisterLevelScrapforLLL_RoundManager_Start;
				if (obj == null)
				{
					hook_Start val = RegisterLevelScrapforLLL_RoundManager_Start;
					<>O.<3>__RegisterLevelScrapforLLL_RoundManager_Start = val;
					obj = (object)val;
				}
				RoundManager.Start += (hook_Start)obj;
			}
			if (Chainloader.PluginInfos.ContainsKey("LethalExpansion"))
			{
				object obj2 = <>O.<4>__RegisterLevelScrapforLE_Terminal_Start;
				if (obj2 == null)
				{
					hook_Start val2 = RegisterLevelScrapforLE_Terminal_Start;
					<>O.<4>__RegisterLevelScrapforLE_Terminal_Start = val2;
					obj2 = (object)val2;
				}
				Terminal.Start += (hook_Start)obj2;
			}
			RegisterScrapAsItem(instance);
			foreach (ShopItem shopItem in shopItems)
			{
				if (instance.allItemsList.itemsList.Contains(shopItem.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (shopItem.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(shopItem.modName + " registered shop item: " + shopItem.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered shop item: " + shopItem.item.itemName));
					}
				}
				LethalLibItemList.Add(shopItem.item);
				instance.allItemsList.itemsList.Add(shopItem.item);
			}
			foreach (PlainItem plainItem in plainItems)
			{
				if (instance.allItemsList.itemsList.Contains(plainItem.item))
				{
					continue;
				}
				if (Plugin.extendedLogging.Value)
				{
					if (plainItem.modName != "LethalLib")
					{
						Plugin.logger.LogInfo((object)(plainItem.modName + " registered item: " + plainItem.item.itemName));
					}
					else
					{
						Plugin.logger.LogInfo((object)("Registered item: " + plainItem.item.itemName));
					}
				}
				LethalLibItemList.Add(plainItem.item);
				instance.allItemsList.itemsList.Add(plainItem.item);
			}
			terminal = self;
			List<Item> list = self.buyableItemsList.ToList();
			TerminalKeyword val3 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			TerminalNode result = val3.compatibleNouns[0].result.terminalOptions[1].result;
			TerminalKeyword val4 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			Plugin.logger.LogInfo((object)$"Adding {shopItems.Count} items to terminal");
			foreach (ShopItem item in shopItems)
			{
				if (list.Any((Item x) => x.itemName == item.item.itemName) && !item.wasRemoved)
				{
					Plugin.logger.LogInfo((object)("Item " + item.item.itemName + " already exists in terminal, skipping"));
					continue;
				}
				item.wasRemoved = false;
				if (item.price == -1)
				{
					item.price = item.item.creditsWorth;
				}
				else
				{
					item.item.creditsWorth = item.price;
				}
				int num = -1;
				if (!list.Any((Item x) => (Object)(object)x == (Object)(object)item.item))
				{
					list.Add(item.item);
				}
				else
				{
					num = list.IndexOf(item.item);
				}
				int buyItemIndex = ((num == -1) ? (list.Count - 1) : num);
				string itemName = item.item.itemName;
				_ = itemName[itemName.Length - 1];
				string text = itemName;
				TerminalNode val5 = item.buyNode2;
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val5).name = itemName.Replace(" ", "-") + "BuyNode2";
					val5.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n";
					val5.clearPreviousText = true;
					val5.maxCharactersToType = 15;
				}
				val5.buyItemIndex = buyItemIndex;
				val5.isConfirmationNode = false;
				val5.itemCost = item.price;
				val5.playSyncedClip = 0;
				TerminalNode val6 = item.buyNode1;
				if ((Object)(object)val6 == (Object)null)
				{
					val6 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val6).name = itemName.Replace(" ", "-") + "BuyNode1";
					val6.displayText = "You have requested to order " + text + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n";
					val6.clearPreviousText = true;
					val6.maxCharactersToType = 35;
				}
				val6.buyItemIndex = buyItemIndex;
				val6.isConfirmationNode = true;
				val6.overrideOptions = true;
				val6.itemCost = item.price;
				val6.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"),
						result = val5
					},
					new CompatibleNoun
					{
						noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"),
						result = result
					}
				};
				TerminalKeyword val7 = TerminalUtils.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val3);
				List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList();
				list2.Add(val7);
				self.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list3 = val3.compatibleNouns.ToList();
				list3.Add(new CompatibleNoun
				{
					noun = val7,
					result = val6
				});
				val3.compatibleNouns = list3.ToArray();
				TerminalNode val8 = item.itemInfo;
				if ((Object)(object)val8 == (Object)null)
				{
					val8 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val8).name = itemName.Replace(" ", "-") + "InfoNode";
					val8.displayText = "[No information about this object was found.]\n\n";
					val8.clearPreviousText = true;
					val8.maxCharactersToType = 25;
				}
				self.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list4 = val4.compatibleNouns.ToList();
				list4.Add(new CompatibleNoun
				{
					noun = val7,
					result = val8
				});
				val4.compatibleNouns = list4.ToArray();
				BuyableItemAssetInfo buyableItemAssetInfo = default(BuyableItemAssetInfo);
				buyableItemAssetInfo.itemAsset = item.item;
				buyableItemAssetInfo.keyword = val7;
				BuyableItemAssetInfo item2 = buyableItemAssetInfo;
				buyableItemAssetInfos.Add(item2);
				if (Plugin.extendedLogging.Value)
				{
					Plugin.logger.LogInfo((object)$"Added {itemName} to terminal (Item price: {val6.itemCost}, Item Index: {val6.buyItemIndex}, Terminal keyword: {val7.word})");
				}
			}
			self.buyableItemsList = list.ToArray();
			orig.Invoke(self);
		}

		public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					scrapItem.levelRarities.Add(levelFlags, rarity);
				}
			}
			else
			{
				scrapItem = new ScrapItem(spawnableItem2, rarity, levelFlags);
				string name = Assembly.GetCallingAssembly().GetName().Name;
				scrapItem.modName = name;
				scrapItems.Add(scrapItem);
			}
		}

		public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelFlags != Levels.LevelTypes.None)
				{
					scrapItem.levelRarities.Add(levelFlags, rarity);
				}
				if (levelOverrides != null)
				{
					foreach (string levelName in levelOverrides)
					{
						scrapItem.customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(levelName), rarity);
					}
				}
			}
			else
			{
				scrapItem = new ScrapItem(spawnableItem2, rarity, levelFlags, levelOverrides);
				string name = Assembly.GetCallingAssembly().GetName().Name;
				scrapItem.modName = name;
				scrapItems.Add(scrapItem);
			}
		}

		public static void RegisterScrap(Item spawnableItem, Dictionary<Levels.LevelTypes, int>? levelRarities = null, Dictionary<string, int>? customLevelRarities = null)
		{
			Item spawnableItem2 = spawnableItem;
			ScrapItem scrapItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)spawnableItem2 || (Object)(object)x.item == (Object)(object)spawnableItem2);
			if (scrapItem != null)
			{
				if (levelRarities != null)
				{
					foreach (KeyValuePair<Levels.LevelTypes, int> levelRarity in levelRarities)
					{
						scrapItem.levelRarities.Add(levelRarity.Key, levelRarity.Value);
					}
				}
				if (customLevelRarities == null)
				{
					return;
				}
				{
					foreach (KeyValuePair<string, int> customLevelRarity in customLevelRarities)
					{
						scrapItem.customLevelRarities.Add(Levels.Compatibility.GetLLLNameOfLevel(customLevelRarity.Key), customLevelRarity.Value);
					}
					return;
				}
			}
			scrapItem = new ScrapItem(spawnableItem2, levelRarities, customLevelRarities);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			scrapItem.modName = name;
			scrapItems.Add(scrapItem);
		}

		public static void RegisterShopItem(Item shopItem, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1)
		{
			ShopItem shopItem2 = new ShopItem(shopItem, buyNode1, buyNode2, itemInfo, price);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			shopItem2.modName = name;
			shopItems.Add(shopItem2);
		}

		public static void RegisterShopItem(Item shopItem, int price = -1)
		{
			ShopItem shopItem2 = new ShopItem(shopItem, null, null, null, price);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			shopItem2.modName = name;
			shopItems.Add(shopItem2);
		}

		public static void RegisterItem(Item plainItem)
		{
			PlainItem plainItem2 = new PlainItem(plainItem);
			string name = Assembly.GetCallingAssembly().GetName().Name;
			plainItem2.modName = name;
			plainItems.Add(plainItem2);
		}

		public static void RemoveScrapFromLevels(Item scrapItem, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null)
		{
			Item scrapItem2 = scrapItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				if (!Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					name = Levels.Compatibility.GetLLLNameOfLevel(name);
				}
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => Levels.Compatibility.GetLLLNameOfLevel(item).ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (!flag && !levelFlags.HasFlag(levelTypes))
				{
					continue;
				}
				ScrapItem actualItem = scrapItems.FirstOrDefault((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)scrapItem2 || (Object)(object)x.item == (Object)(object)scrapItem2);
				SpawnableItemWithRarity val2 = ((IEnumerable<SpawnableItemWithRarity>)val.spawnableScrap).FirstOrDefault((Func<SpawnableItemWithRarity, bool>)((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)actualItem.item));
				if (val2 != null)
				{
					if (Plugin.extendedLogging.Value)
					{
						Plugin.logger.LogInfo((object)("Removed Item " + ((Object)val2.spawnableItem).name + " from Level " + name));
					}
					val.spawnableScrap.Remove(val2);
				}
			}
		}

		public static void RemoveShopItem(Item shopItem)
		{
			Item shopItem2 = shopItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			ShopItem actualItem = shopItems.FirstOrDefault((ShopItem x) => (Object)(object)x.origItem == (Object)(object)shopItem2 || (Object)(object)x.item == (Object)(object)shopItem2);
			actualItem.wasRemoved = true;
			List<TerminalKeyword> list = terminal.terminalNodes.allKeywords.ToList();
			TerminalKeyword obj = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
			TerminalKeyword val = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			List<CompatibleNoun> list2 = val.compatibleNouns.ToList();
			List<CompatibleNoun> list3 = obj.compatibleNouns.ToList();
			if (buyableItemAssetInfos.Any((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item))
			{
				BuyableItemAssetInfo asset = buyableItemAssetInfos.First((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item);
				list.Remove(asset.keyword);
				list2.RemoveAll((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword);
				list3.RemoveAll((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword);
			}
			terminal.terminalNodes.allKeywords = list.ToArray();
			val.compatibleNouns = list2.ToArray();
			obj.compatibleNouns = list3.ToArray();
		}

		public static void UpdateShopItemPrice(Item shopItem, int price)
		{
			Item shopItem2 = shopItem;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			ShopItem actualItem = shopItems.FirstOrDefault((ShopItem x) => (Object)(object)x.origItem == (Object)(object)shopItem2 || (Object)(object)x.item == (Object)(object)shopItem2);
			actualItem.item.creditsWorth = price;
			TerminalKeyword obj = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			_ = obj.compatibleNouns[0].result.terminalOptions[1].result;
			List<CompatibleNoun> source = obj.compatibleNouns.ToList();
			if (!buyableItemAssetInfos.Any((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item))
			{
				return;
			}
			BuyableItemAssetInfo asset = buyableItemAssetInfos.First((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)actualItem.item);
			if (!source.Any((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword))
			{
				return;
			}
			TerminalNode result = source.First((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword).result;
			result.itemCost = price;
			if (result.terminalOptions.Length == 0)
			{
				return;
			}
			CompatibleNoun[] terminalOptions = result.terminalOptions;
			foreach (CompatibleNoun val in terminalOptions)
			{
				if ((Object)(object)val.result != (Object)null && val.result.buyItemIndex != -1)
				{
					val.result.itemCost = price;
				}
			}
		}
	}
	public class Levels
	{
		[Flags]
		public enum LevelTypes
		{
			None = 1,
			ExperimentationLevel = 4,
			AssuranceLevel = 8,
			VowLevel = 0x10,
			OffenseLevel = 0x20,
			MarchLevel = 0x40,
			RendLevel = 0x80,
			DineLevel = 0x100,
			TitanLevel = 0x200,
			AdamanceLevel = 0x800,
			ArtificeLevel = 0x1000,
			EmbrionLevel = 0x2000,
			Vanilla = 0x3BFC,
			Modded = 0x400,
			All = -1
		}

		internal static class Compatibility
		{
			private const string illegalCharacters = ".,?!@#$%^&*()_+-=';:'\"";

			private static string GetNumberlessPlanetName(string planetName)
			{
				if (planetName != null)
				{
					return new string(planetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
				}
				return string.Empty;
			}

			private static string StripSpecialCharacters(string input)
			{
				string text = string.Empty;
				for (int i = 0; i < input.Length; i++)
				{
					char c = input[i];
					if ((!".,?!@#$%^&*()_+-=';:'\"".ToCharArray().Contains(c) && char.IsLetterOrDigit(c)) || c.ToString() == " ")
					{
						text += c;
					}
				}
				return text;
			}

			internal static string GetLLLNameOfLevel(string levelName)
			{
				string text = StripSpecialCharacters(GetNumberlessPlanetName(levelName));
				if (!text.EndsWith("Level"))
				{
					text += "Level";
				}
				return text;
			}

			internal static Dictionary<string, int> LLLifyLevelRarityDictionary(Dictionary<string, int> keyValuePairs)
			{
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				List<string> list = keyValuePairs.Keys.ToList();
				List<int> list2 = keyValuePairs.Values.ToList();
				for (int i = 0; i < keyValuePairs.Count; i++)
				{
					dictionary.Add(GetLLLNameOfLevel(list[i]), list2[i]);
				}
				return dictionary;
			}
		}
	}
	public class MapObjects
	{
		public class RegisteredMapObject
		{
			public SpawnableMapObject mapObject;

			public SpawnableOutsideObjectWithRarity outsideObject;

			public Levels.LevelTypes levels;

			public string[] spawnLevelOverrides;

			public Func<SelectableLevel, AnimationCurve> spawnRateFunction;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__StartOfRound_Awake;

			public static hook_SpawnMapObjects <1>__RoundManager_SpawnMapObjects;
		}

		public static List<RegisteredMapObject> mapObjects = new List<RegisteredMapObject>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Awake;
			if (obj == null)
			{
				hook_Awake val = StartOfRound_Awake;
				<>O.<0>__StartOfRound_Awake = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__RoundManager_SpawnMapObjects;
			if (obj2 == null)
			{
				hook_SpawnMapObjects val2 = RoundManager_SpawnMapObjects;
				<>O.<1>__RoundManager_SpawnMapObjects = val2;
				obj2 = (object)val2;
			}
			RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj2;
		}

		private static void RoundManager_SpawnMapObjects(orig_SpawnMapObjects orig, RoundManager self)
		{
			RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>();
			foreach (RandomMapObject val in array)
			{
				foreach (RegisteredMapObject mapObject in mapObjects)
				{
					if (mapObject.mapObject != null && !val.spawnablePrefabs.Any((GameObject prefab) => (Object)(object)prefab == (Object)(object)mapObject.mapObject.prefabToSpawn))
					{
						val.spawnablePrefabs.Add(mapObject.mapObject.prefabToSpawn);
					}
				}
			}
			orig.Invoke(self);
		}

		private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
			foreach (RegisteredMapObject mapObject in mapObjects)
			{
				SelectableLevel[] levels = self.levels;
				foreach (SelectableLevel val in levels)
				{
					string name = ((Object)val).name;
					bool flag = mapObject.levels.HasFlag(Levels.LevelTypes.All) || (mapObject.spawnLevelOverrides != null && mapObject.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()));
					if (mapObject.levels.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
					{
						flag = true;
					}
					if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
					{
						continue;
					}
					Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
					if (!flag && !mapObject.levels.HasFlag(levelTypes))
					{
						continue;
					}
					if (mapObject.mapObject != null)
					{
						if (val.spawnableMapObjects.Any((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn))
						{
							List<SpawnableMapObject> list = val.spawnableMapObjects.ToList();
							list.RemoveAll((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn);
							val.spawnableMapObjects = list.ToArray();
						}
						SpawnableMapObject mapObject2 = mapObject.mapObject;
						if (mapObject.spawnRateFunction != null)
						{
							mapObject2.numberToSpawn = mapObject.spawnRateFunction(val);
						}
						List<SpawnableMapObject> list2 = val.spawnableMapObjects.ToList();
						list2.Add(mapObject2);
						val.spawnableMapObjects = list2.ToArray();
						if (Plugin.extendedLogging.Value)
						{
							Plugin.logger.LogInfo((object)("Added " + ((Object)mapObject2.prefabToSpawn).name + " to " + name));
						}
					}
					else
					{
						if (mapObject.outsideObject == null)
						{
							continue;
						}
						if (val.spawnableOutsideObjects.Any((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn))
						{
							List<SpawnableOutsideObjectWithRarity> list3 = val.spawnableOutsideObjects.ToList();
							list3.RemoveAll((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn);
							val.spawnableOutsideObjects = list3.ToArray();
						}
						SpawnableOutsideObjectWithRarity outsideObject = mapObject.outsideObject;
						if (mapObject.spawnRateFunction != null)
						{
							outsideObject.randomAmount = mapObject.spawnRateFunction(val);
						}
						List<SpawnableOutsideObjectWithRarity> list4 = val.spawnableOutsideObjects.ToList();
						list4.Add(outsideObject);
						val.spawnableOutsideObjects = list4.ToArray();
						if (Plugin.extendedLogging.Value)
						{
							Plugin.logger.LogInfo((object)("Added " + ((Object)outsideObject.spawnableObject.prefabToSpawn).name + " to " + name));
						}
					}
				}
			}
		}

		public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterMapObject(mapObject.spawnableMapObject, levels, spawnRateFunction);
		}

		public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterMapObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction);
		}

		public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				mapObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction
			});
		}

		public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				mapObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction,
				spawnLevelOverrides = levelOverrides
			});
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterOutsideObject(mapObject.spawnableMapObject, levels, spawnRateFunction);
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			RegisterOutsideObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction);
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				outsideObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction
			});
		}

		public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null)
		{
			mapObjects.Add(new RegisteredMapObject
			{
				outsideObject = mapObject,
				levels = levels,
				spawnRateFunction = spawnRateFunction,
				spawnLevelOverrides = levelOverrides
			});
		}

		public static void RemoveMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			RemoveMapObject(mapObject.spawnableMapObject, levelFlags, levelOverrides);
		}

		public static void RemoveMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			SpawnableMapObject mapObject2 = mapObject;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					val.spawnableMapObjects = val.spawnableMapObjects.Where((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn != (Object)(object)mapObject2.prefabToSpawn).ToArray();
				}
			}
		}

		public static void RemoveOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			RemoveOutsideObject(mapObject.spawnableMapObject, levelFlags, levelOverrides);
		}

		public static void RemoveOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levelFlags, string[] levelOverrides = null)
		{
			SpawnableOutsideObjectWithRarity mapObject2 = mapObject;
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				string name = ((Object)val).name;
				bool flag = levelFlags.HasFlag(Levels.LevelTypes.All) || (levelOverrides?.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant()) ?? false);
				if (levelFlags.HasFlag(Levels.LevelTypes.Modded) && !Enum.IsDefined(typeof(Levels.LevelTypes), name))
				{
					flag = true;
				}
				if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag))
				{
					continue;
				}
				Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name)));
				if (flag || levelFlags.HasFlag(levelTypes))
				{
					val.spawnableOutsideObjects = val.spawnableOutsideObjects.Where((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn != (Object)(object)mapObject2.spawnableObject.prefabToSpawn).ToArray();
				}
			}
		}
	}
	public class NetworkPrefabs
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__GameNetworkManager_Start;
		}

		private static List<GameObject> _networkPrefabs = new List<GameObject>();

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__GameNetworkManager_Start;
			if (obj == null)
			{
				hook_Start val = GameNetworkManager_Start;
				<>O.<0>__GameNetworkManager_Start = val;
				obj = (object)val;
			}
			GameNetworkManager.Start += (hook_Start)obj;
		}

		public static void RegisterNetworkPrefab(GameObject prefab)
		{
			if (prefab == null)
			{
				throw new ArgumentNullException("prefab", "The given argument for RegisterNetworkPrefab is null!");
			}
			if (!_networkPrefabs.Contains(prefab))
			{
				_networkPrefabs.Add(prefab);
			}
		}

		public static GameObject CreateNetworkPrefab(string name)
		{
			GameObject obj = PrefabUtils.CreatePrefab(name);
			obj.AddComponent<NetworkObject>();
			byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + name));
			obj.GetComponent<NetworkObject>().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0);
			RegisterNetworkPrefab(obj);
			return obj;
		}

		public static GameObject CloneNetworkPrefab(GameObject prefabToClone, string newName = null)
		{
			GameObject val = PrefabUtils.ClonePrefab(prefabToClone, newName);
			byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + ((Object)val).name));
			val.GetComponent<NetworkObject>().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0);
			RegisterNetworkPrefab(val);
			return val;
		}

		private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			foreach (GameObject networkPrefab in _networkPrefabs)
			{
				if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(networkPrefab))
				{
					NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				}
			}
		}
	}
	public class Player
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__StartOfRound_Awake;
		}

		public static Dictionary<string, GameObject> ragdollRefs = new Dictionary<string, GameObject>();

		public static Dictionary<string, int> ragdollIndexes = new Dictionary<string, int>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Awake;
			if (obj == null)
			{
				hook_Awake val = StartOfRound_Awake;
				<>O.<0>__StartOfRound_Awake = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
		}

		private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
			foreach (KeyValuePair<string, GameObject> ragdollRef in ragdollRefs)
			{
				if (!self.playerRagdolls.Contains(ragdollRef.Value))
				{
					self.playerRagdolls.Add(ragdollRef.Value);
					int value = self.playerRagdolls.Count - 1;
					if (ragdollIndexes.ContainsKey(ragdollRef.Key))
					{
						ragdollIndexes[ragdollRef.Key] = value;
					}
					else
					{
						ragdollIndexes.Add(ragdollRef.Key, value);
					}
				}
			}
		}

		public static int GetRagdollIndex(string id)
		{
			return ragdollIndexes[id];
		}

		public static GameObject GetRagdoll(string id)
		{
			return ragdollRefs[id];
		}

		public static void RegisterPlayerRagdoll(string id, GameObject ragdoll)
		{
			Plugin.logger.LogInfo((object)("Registering player ragdoll " + id));
			ragdollRefs.Add(id, ragdoll);
		}
	}
	public class PrefabUtils
	{
		internal static Lazy<GameObject> _prefabParent;

		internal static GameObject prefabParent => _prefabParent.Value;

		static PrefabUtils()
		{
			_prefabParent = new Lazy<GameObject>((Func<GameObject>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected O, but got Unknown
				GameObject val = new GameObject("LethalLibGeneratedPrefabs")
				{
					hideFlags = (HideFlags)61
				};
				val.SetActive(false);
				return val;
			});
		}

		public static GameObject ClonePrefab(GameObject prefabToClone, string newName = null)
		{
			GameObject val = Object.Instantiate<GameObjec

plugins/RuntimeIcons.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CullFactory.Behaviours.API;
using HarmonyLib;
using JetBrains.Annotations;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLevelLoader;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using RuntimeIcons.Components;
using RuntimeIcons.Config;
using RuntimeIcons.Dependency;
using RuntimeIcons.Patches;
using RuntimeIcons.Utils;
using Unity.Collections;
using Unity.Mathematics;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Pool;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering.RendererUtils;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using VertexLibrary;
using VertexLibrary.Caches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("LethalCompanyModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.5")]
[assembly: AssemblyInformationalVersion("0.1.5+11f8eb7b1948c246c87151bb487ff080731e7b60")]
[assembly: AssemblyProduct("RuntimeIcons")]
[assembly: AssemblyTitle("RuntimeIcons - Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RuntimeIcons
{
	[BepInPlugin("com.github.lethalcompanymodding.runtimeicons", "RuntimeIcons", "0.1.5")]
	[BepInDependency("com.github.lethalcompanymodding.vertexlibrary", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class RuntimeIcons : BaseUnityPlugin
	{
		internal static readonly ISet<Hook> Hooks = new HashSet<Hook>();

		internal static readonly Harmony Harmony = new Harmony("com.github.lethalcompanymodding.runtimeicons");

		public const string GUID = "com.github.lethalcompanymodding.runtimeicons";

		public const string NAME = "RuntimeIcons";

		public const string VERSION = "0.1.5";

		internal static ManualLogSource Log;

		internal static StageComponent CameraStage;

		public static RuntimeIcons INSTANCE { get; private set; }

		internal static void VerboseMeshLog(LogType logLevel, Func<string> message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			//IL_0099: 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_0053: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_008c: 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_0012: Invalid comparison between Unknown and I4
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0090: 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_0016: Invalid comparison between Unknown and I4
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			LogLevel val;
			if ((int)logLevel <= 128)
			{
				if ((int)logLevel <= 8)
				{
					if ((int)logLevel != 2)
					{
						if ((int)logLevel != 4)
						{
							if ((int)logLevel != 8)
							{
								goto IL_00a6;
							}
							val = (LogLevel)4;
						}
						else
						{
							val = (LogLevel)2;
						}
					}
					else
					{
						val = (LogLevel)1;
					}
					goto IL_00a8;
				}
				if ((int)logLevel <= 32)
				{
					if ((int)logLevel == 16 || (int)logLevel == 32)
					{
						goto IL_0097;
					}
				}
				else if ((int)logLevel == 64 || (int)logLevel == 128)
				{
					goto IL_0097;
				}
			}
			else if ((int)logLevel <= 512)
			{
				if ((int)logLevel == 240)
				{
					goto IL_0097;
				}
				if ((int)logLevel == 256 || (int)logLevel == 512)
				{
					goto IL_009c;
				}
			}
			else if ((int)logLevel <= 2048)
			{
				if ((int)logLevel == 1024 || (int)logLevel == 2048)
				{
					goto IL_009c;
				}
			}
			else
			{
				if ((int)logLevel == 3840)
				{
					goto IL_009c;
				}
				if ((int)logLevel == 4094)
				{
					val = (LogLevel)63;
					goto IL_00a8;
				}
			}
			goto IL_00a6;
			IL_0097:
			val = (LogLevel)16;
			goto IL_00a8;
			IL_00a6:
			val = (LogLevel)0;
			goto IL_00a8;
			IL_009c:
			val = (LogLevel)32;
			goto IL_00a8;
			IL_00a8:
			LogLevel val2 = val;
			if ((val2 & PluginConfig.VerboseMeshLogs) != 0)
			{
				VerboseMeshLog(val2, message);
			}
		}

		internal static void VerboseMeshLog(LogLevel logLevel, Func<string> message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Log.Log(logLevel, (object)message());
		}

		private void Awake()
		{
			INSTANCE = this;
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				if (LobbyCompatibilityChecker.Enabled)
				{
					LobbyCompatibilityChecker.Init();
				}
				Log.LogInfo((object)"Initializing Configs");
				PluginConfig.Init();
				Log.LogInfo((object)"Preparing Stage");
				SetStage();
				Log.LogInfo((object)"Patching Methods");
				Harmony.PatchAll();
				Log.LogInfo((object)"RuntimeIcons v0.1.5 Loaded!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Exception while initializing: \n" + ex));
			}
		}

		private void SetStage()
		{
			//IL_00b7: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: 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_028c: 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_02ac: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			CameraStage = StageComponent.CreateStage((HideFlags)61, LayerMask.GetMask(new string[13]
			{
				"Default", "Player", "Water", "Props", "Room", "InteractableObject", "Foliage", "PhysicsObject", "Enemies", "PlayerRagdoll",
				"MapHazards", "MiscLevelGeometry", "Terrain"
			}), "RuntimeIcons.Stage");
			Object.DontDestroyOnLoad((Object)(object)((Component)CameraStage).gameObject);
			((Component)CameraStage).gameObject.transform.position = new Vector3(0f, 1000f, 1000f);
			CameraStage.Resolution = new Vector2Int(256, 256);
			CameraStage.MarginPixels = new Vector2(32f, 32f);
			GameObject val = new GameObject("SpotLight 1")
			{
				hideFlags = ((Object)this).hideFlags,
				layer = 1
			};
			val.transform.parent = CameraStage.LightTransform;
			val.transform.localPosition = new Vector3(0f, 3f, 0f);
			val.transform.rotation = Quaternion.LookRotation(Vector3.down);
			GameObject val2 = val;
			Light val3 = val2.AddComponent<Light>();
			val3.type = (LightType)0;
			val3.shape = (LightShape)0;
			val3.color = Color.white;
			val3.colorTemperature = 6901f;
			val3.useColorTemperature = true;
			val3.shadows = (LightShadows)2;
			val3.spotAngle = 50f;
			val3.innerSpotAngle = 21.8f;
			val3.range = 7.11f;
			HDAdditionalLightData val4 = val2.AddComponent<HDAdditionalLightData>();
			val4.affectDiffuse = true;
			val4.affectSpecular = true;
			val4.affectsVolumetric = true;
			val4.applyRangeAttenuation = true;
			val4.color = Color.white;
			val4.colorShadow = true;
			val4.shadowDimmer = 0.8f;
			((ScalableSettingValue<int>)(object)val4.shadowResolution).@override = 1024;
			val4.customSpotLightShadowCone = 30f;
			val4.distance = 1.5E+11f;
			val4.fadeDistance = 10000f;
			val4.innerSpotPercent = 82.7f;
			val4.intensity = 75f;
			GameObject val5 = new GameObject("SpotLight 2")
			{
				hideFlags = ((Object)this).hideFlags,
				layer = 1
			};
			val5.transform.parent = CameraStage.LightTransform;
			val5.transform.localPosition = new Vector3(-2.7f, 0f, -2.7f);
			val5.transform.rotation = Quaternion.Euler(0f, 45f, 0f);
			GameObject val6 = val5;
			Light val7 = val6.AddComponent<Light>();
			val7.type = (LightType)0;
			val7.shape = (LightShape)0;
			val7.color = Color.white;
			val7.colorTemperature = 6901f;
			val7.useColorTemperature = true;
			val7.shadows = (LightShadows)2;
			val7.spotAngle = 50f;
			val7.innerSpotAngle = 21.8f;
			val7.range = 7.11f;
			HDAdditionalLightData val8 = val6.AddComponent<HDAdditionalLightData>();
			val8.affectDiffuse = true;
			val8.affectSpecular = true;
			val8.affectsVolumetric = true;
			val8.applyRangeAttenuation = true;
			val8.color = Color.white;
			val8.colorShadow = true;
			val8.shadowDimmer = 0.6f;
			((ScalableSettingValue<int>)(object)val8.shadowResolution).@override = 1024;
			val8.customSpotLightShadowCone = 30f;
			val8.distance = 1.5E+11f;
			val8.fadeDistance = 10000f;
			val8.innerSpotPercent = 82.7f;
			val8.intensity = 50f;
			val8.shapeRadius = 0.5f;
			GameObject val9 = new GameObject("SpotLight 3")
			{
				hideFlags = ((Object)this).hideFlags,
				layer = 1
			};
			val9.transform.parent = CameraStage.LightTransform;
			val9.transform.localPosition = new Vector3(2.7f, 0f, -2.7f);
			val9.transform.rotation = Quaternion.Euler(0f, -45f, 0f);
			GameObject val10 = val9;
			Light val11 = val10.AddComponent<Light>();
			val11.type = (LightType)0;
			val11.shape = (LightShape)0;
			val11.color = Color.white;
			val11.colorTemperature = 6901f;
			val11.useColorTemperature = true;
			val11.shadows = (LightShadows)2;
			val11.spotAngle = 50f;
			val11.innerSpotAngle = 21.8f;
			val11.range = 7.11f;
			HDAdditionalLightData val12 = val10.AddComponent<HDAdditionalLightData>();
			val12.affectDiffuse = true;
			val12.affectSpecular = false;
			val12.affectsVolumetric = true;
			val12.applyRangeAttenuation = true;
			val12.color = Color.white;
			val12.colorShadow = true;
			val12.shadowDimmer = 0.4f;
			((ScalableSettingValue<int>)(object)val12.shadowResolution).@override = 1024;
			val12.customSpotLightShadowCone = 30f;
			val12.distance = 1.5E+11f;
			val12.fadeDistance = 10000f;
			val12.innerSpotPercent = 82.7f;
			val12.intensity = 30f;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.lethalcompanymodding.runtimeicons";

		public const string PLUGIN_NAME = "RuntimeIcons";

		public const string PLUGIN_VERSION = "0.1.5";
	}
}
namespace RuntimeIcons.Utils
{
	public static class TextureUtils
	{
		private struct RGBA
		{
			public half r;

			public half g;

			public half b;

			public half a;

			public RGBA(half r, half g, half b, half a)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				this.r = r;
				this.g = g;
				this.b = b;
				this.a = a;
			}

			public static implicit operator Color(RGBA color)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: 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)
				return new Color(half.op_Implicit(color.r), half.op_Implicit(color.g), half.op_Implicit(color.b), half.op_Implicit(color.a));
			}

			public static implicit operator RGBA(Color color)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: 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_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				return new RGBA((half)color.r, (half)color.g, (half)color.b, (half)color.a);
			}
		}

		private static string SanitizeFilename(string dirty)
		{
			string arg = Regex.Escape(new string(Path.GetInvalidFileNameChars()));
			string pattern = string.Format("([{0}]*\\.+$)|([{0}]+)", arg);
			return Regex.Replace(dirty, pattern, "_");
		}

		public static FileInfo SaveFile(byte[] bytes, string filename, string directory, string extension)
		{
			directory = Directory.CreateDirectory(directory).FullName;
			filename = ((filename != "") ? (SanitizeFilename(filename) + extension) : (DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + extension));
			string text = Path.Combine(directory, filename);
			File.WriteAllBytes(text, bytes);
			return new FileInfo(text);
		}

		public static FileInfo SavePNG(this Texture2D tex, string filename = "", string directory = "")
		{
			return SaveFile(ImageConversion.EncodeToPNG(tex), Utility.IsNullOrWhiteSpace(filename) ? ((Object)tex).name : filename, Utility.IsNullOrWhiteSpace(directory) ? "" : directory, ".png");
		}

		public static FileInfo SaveEXR(this Texture2D tex, string filename = "", string directory = "")
		{
			return SaveFile(ImageConversion.EncodeToEXR(tex), Utility.IsNullOrWhiteSpace(filename) ? ((Object)tex).name : filename, Utility.IsNullOrWhiteSpace(directory) ? "" : directory, ".exr");
		}

		public static Texture2D GetNonPremultipliedTexture(this Texture2D tex)
		{
			Texture2D val = Object.Instantiate<Texture2D>(tex);
			((Object)val).name = ((Object)tex).name + "-NonPremultiplied";
			val.UnPremultiply();
			return val;
		}

		public static void UnPremultiply(this Texture2D tex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((Texture)tex).graphicsFormat != 48)
			{
				throw new NotImplementedException("Texture to un-premultiply must have 16-bit floating point components");
			}
			NativeArray<RGBA> pixelData = tex.GetPixelData<RGBA>(0);
			for (int i = 0; i < pixelData.Length; i++)
			{
				RGBA rGBA = pixelData[i];
				if (half.op_Implicit(rGBA.a) != 0f)
				{
					ref half r = ref rGBA.r;
					r = (half)(half.op_Implicit(r) / half.op_Implicit(rGBA.a));
					ref half g = ref rGBA.g;
					g = (half)(half.op_Implicit(g) / half.op_Implicit(rGBA.a));
					ref half b = ref rGBA.b;
					b = (half)(half.op_Implicit(b) / half.op_Implicit(rGBA.a));
					pixelData[i] = rGBA;
				}
			}
		}

		public static bool IsTransparent(this Texture2D tex)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < ((Texture)tex).width; i++)
			{
				for (int j = 0; j < ((Texture)tex).height; j++)
				{
					if (tex.GetPixel(i, j).a != 0f)
					{
						return false;
					}
				}
			}
			return true;
		}

		public static long GetTransparentCount(this Texture2D tex)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < ((Texture)tex).width; i++)
			{
				for (int j = 0; j < ((Texture)tex).height; j++)
				{
					if (tex.GetPixel(i, j).a == 0f)
					{
						num++;
					}
				}
			}
			return num;
		}
	}
}
namespace RuntimeIcons.Patches
{
	[HarmonyPatch]
	public static class GrabbableObjectPatch
	{
		public static Sprite BrokenSprite { get; private set; }

		public static Sprite BrokenSprite2 { get; private set; }

		internal static bool ItemHasIcon(Item item)
		{
			if (!Object.op_Implicit((Object)(object)item.itemIcon))
			{
				return false;
			}
			if (((Object)item.itemIcon).name == "ScrapItemIcon")
			{
				return false;
			}
			if (((Object)item.itemIcon).name == "ScrapItemIcon2")
			{
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		private static void AfterStart(GrabbableObject __instance)
		{
			if (!ItemHasIcon(__instance.itemProperties))
			{
				if (!Object.op_Implicit((Object)(object)BrokenSprite) && Object.op_Implicit((Object)(object)__instance.itemProperties.itemIcon))
				{
					BrokenSprite = Object.Instantiate<Sprite>(__instance.itemProperties.itemIcon);
					((Object)BrokenSprite).name = "RuntimeIcons.ScrapItemIcon";
				}
				if (!Object.op_Implicit((Object)(object)BrokenSprite2) && Object.op_Implicit((Object)(object)__instance.itemProperties.itemIcon))
				{
					BrokenSprite2 = Object.Instantiate<Sprite>(__instance.itemProperties.itemIcon);
					((Object)BrokenSprite).name = "RuntimeIcons.ScrapItemIcon2";
				}
				bool flag = PluginConfig.ItemList.Contains(__instance.itemProperties.itemName);
				if (PluginConfig.ItemListBehaviour switch
				{
					PluginConfig.ListBehaviour.BlackList => flag ? 1 : 0, 
					PluginConfig.ListBehaviour.WhiteList => (!flag) ? 1 : 0, 
					PluginConfig.ListBehaviour.None => 0, 
					_ => 0, 
				} == 0)
				{
					((MonoBehaviour)__instance).StartCoroutine(ComputeSpriteCoroutine(__instance));
				}
			}
		}

		private static IEnumerator ComputeSpriteCoroutine(GrabbableObject @this)
		{
			yield return null;
			yield return null;
			yield return (object)new WaitUntil((Func<bool>)(() => StartOfRoundPatch.AvailableRenders > 0));
			if (!ItemHasIcon(@this.itemProperties))
			{
				ComputeSprite(@this);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "EquipItem")]
		private static void OnGrab(GrabbableObject __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && !((Object)(object)__instance.itemProperties.itemIcon != (Object)(object)BrokenSprite))
			{
				RuntimeIcons.Log.LogInfo((object)("Attempting to refresh BrokenIcon for " + __instance.itemProperties.itemName + "!"));
				ComputeSprite(__instance);
				if ((Object)(object)__instance.itemProperties.itemIcon == (Object)(object)BrokenSprite)
				{
					__instance.itemProperties.itemIcon = BrokenSprite2;
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ComputeSprite(GrabbableObject grabbableObject)
		{
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			RuntimeIcons.Log.LogWarning((object)("Computing " + grabbableObject.itemProperties.itemName + " icon"));
			if (PluginConfig.FileOverrides.TryGetValue(grabbableObject.itemProperties.itemName, out var value))
			{
				RuntimeIcons.Log.LogWarning((object)("Assigning " + value + " to " + grabbableObject.itemProperties.itemName));
				try
				{
					if (File.Exists(value))
					{
						byte[] array = File.ReadAllBytes(value);
						Texture2D val = new Texture2D(128, 128);
						ImageConversion.LoadImage(val, array);
						if (((Texture)val).width != ((Texture)val).height)
						{
							Object.Destroy((Object)(object)val);
							RuntimeIcons.Log.LogError((object)("Expected Icon " + value + " was not square!"));
						}
						else if (!val.IsTransparent())
						{
							Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2((float)((Texture)val).width / 2f, (float)((Texture)val).height / 2f));
							((Object)val2).name = "RuntimeIcons." + grabbableObject.itemProperties.itemName;
							grabbableObject.itemProperties.itemIcon = val2;
							UpdateIconsInHUD(grabbableObject.itemProperties);
							RuntimeIcons.Log.LogInfo((object)(grabbableObject.itemProperties.itemName + " now has a new icon | 1"));
							return;
						}
					}
				}
				catch (Exception arg)
				{
					RuntimeIcons.Log.LogError((object)$"Failed to read {value}:\n{arg}");
				}
				finally
				{
					RuntimeIcons.Log.LogWarning((object)("Fallback to Staged image for " + grabbableObject.itemProperties.itemName));
				}
			}
			StartOfRoundPatch.AvailableRenders--;
			StageComponent cameraStage = RuntimeIcons.CameraStage;
			try
			{
				Quaternion value2 = Quaternion.Euler(grabbableObject.itemProperties.restingRotation.x, (float)grabbableObject.itemProperties.floorYOffset + 90f, grabbableObject.itemProperties.restingRotation.z);
				RuntimeIcons.Log.LogInfo((object)("Setting stage for " + ((Object)((Component)((NetworkBehaviour)grabbableObject).NetworkObject).gameObject).name));
				cameraStage.SetObjectOnStage(((Component)((NetworkBehaviour)grabbableObject).NetworkObject).gameObject);
				cameraStage.CenterObjectOnPivot(value2);
				ManualLogSource log = RuntimeIcons.Log;
				object arg2 = cameraStage.StagedTransform.localPosition;
				Quaternion val3 = cameraStage.StagedTransform.localRotation;
				log.LogInfo((object)$"StagedObject offset {arg2} rotation {((Quaternion)(ref val3)).eulerAngles}");
				FindOptimalRotation(cameraStage, grabbableObject);
				ManualLogSource log2 = RuntimeIcons.Log;
				val3 = cameraStage.PivotTransform.rotation;
				log2.LogInfo((object)$"Stage rotation {((Quaternion)(ref val3)).eulerAngles}");
				cameraStage.PrepareCameraForShot();
				Texture2D val4 = cameraStage.TakeSnapshot();
				val4.UnPremultiply();
				val4.Apply();
				if (PluginConfig.DumpToCache)
				{
					string itemName = grabbableObject.itemProperties.itemName;
					string filename = string.Join("_", itemName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
					string path = "";
					if (StartOfRoundPatch.ItemModMap.TryGetValue(grabbableObject.itemProperties, out var value3) && !value3.Item1.Equals("Vanilla"))
					{
						string arg3 = string.Join("_", value3.Item2.Split(Path.GetInvalidPathChars(), StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
						path = $"{value3.Item1}{Path.DirectorySeparatorChar}{arg3}";
					}
					val4.SavePNG(filename, Path.Combine(Paths.CachePath, "RuntimeIcons.PNG", path));
					val4.SaveEXR(filename, Path.Combine(Paths.CachePath, "RuntimeIcons.EXR", path));
				}
				long transparentCount = val4.GetTransparentCount();
				int num = ((Texture)val4).width * ((Texture)val4).height;
				float num2 = (float)transparentCount / (float)num;
				if (num2 <= PluginConfig.TransparencyRatio)
				{
					Sprite val5 = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), new Vector2((float)((Texture)val4).width / 2f, (float)((Texture)val4).height / 2f));
					((Object)val5).name = "RuntimeIcons." + grabbableObject.itemProperties.itemName;
					grabbableObject.itemProperties.itemIcon = val5;
					RuntimeIcons.Log.LogInfo((object)(grabbableObject.itemProperties.itemName + " now has a new icon | 2"));
				}
				else
				{
					RuntimeIcons.Log.LogError((object)$"{grabbableObject.itemProperties.itemName} Generated {num2 * 100f}% Empty Sprite!");
					grabbableObject.itemProperties.itemIcon = BrokenSprite;
				}
				UpdateIconsInHUD(grabbableObject.itemProperties);
			}
			finally
			{
				cameraStage.ResetStage();
			}
		}

		public static void FindOptimalRotation(StageComponent stage, GrabbableObject grabbable)
		{
			//IL_0008: 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_002c: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: 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_02c7: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			Transform pivotTransform = stage.PivotTransform;
			pivotTransform.rotation = Quaternion.identity;
			if (PluginConfig.RotationOverrides.TryGetValue(grabbable.itemProperties.itemName, out var value))
			{
				pivotTransform.Rotate(value, (Space)0);
				return;
			}
			pivotTransform.rotation = Quaternion.identity;
			ExecutionOptions val = default(ExecutionOptions);
			((ExecutionOptions)(ref val))..ctor();
			((ExecutionOptions)(ref val)).VertexCache = stage.VertexCache;
			((ExecutionOptions)(ref val)).CullingMask = stage.CullingMask;
			((ExecutionOptions)(ref val)).LogHandler = RuntimeIcons.VerboseMeshLog;
			ExecutionOptions val2 = val;
			Bounds val3 = default(Bounds);
			if (!VertexesExtensions.TryGetBounds(pivotTransform, ref val3, val2))
			{
				throw new InvalidOperationException("This object has no Renders!");
			}
			if (((Bounds)(ref val3)).size == Vector3.zero)
			{
				throw new InvalidOperationException("This object has no Bounds!");
			}
			if (((Bounds)(ref val3)).size.y < ((Bounds)(ref val3)).size.x / 2f && ((Bounds)(ref val3)).size.y < ((Bounds)(ref val3)).size.z / 2f)
			{
				if (((Bounds)(ref val3)).size.z < ((Bounds)(ref val3)).size.x * 0.5f)
				{
					RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -45 y | 1"));
					pivotTransform.Rotate(Vector3.up, -45f, (Space)0);
				}
				else if (((Bounds)(ref val3)).size.z < ((Bounds)(ref val3)).size.x * 0.85f)
				{
					RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -90 y | 2"));
					pivotTransform.Rotate(Vector3.up, -90f, (Space)0);
				}
				else if (((Bounds)(ref val3)).size.x < ((Bounds)(ref val3)).size.z * 0.5f)
				{
					RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -90 y | 3"));
					pivotTransform.Rotate(Vector3.up, -45f, (Space)0);
				}
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -80 x"));
				pivotTransform.Rotate(Vector3.right, -80f, (Space)0);
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated 15 y"));
				pivotTransform.Rotate(Vector3.up, 15f, (Space)0);
			}
			else if (((Bounds)(ref val3)).size.x < ((Bounds)(ref val3)).size.z * 0.85f)
			{
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -25 x | 1"));
				pivotTransform.Rotate(Vector3.right, -25f, (Space)0);
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -45 y | 1"));
				pivotTransform.Rotate(Vector3.up, -45f, (Space)0);
			}
			else if (Mathf.Abs(((Bounds)(ref val3)).size.y - ((Bounds)(ref val3)).size.x) / ((Bounds)(ref val3)).size.x < 0.01f && ((Bounds)(ref val3)).size.x < ((Bounds)(ref val3)).size.z * 0.85f)
			{
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -25 x | 2"));
				pivotTransform.Rotate(Vector3.right, -25f, (Space)0);
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated 45 y | 2"));
				pivotTransform.Rotate(Vector3.up, 45f, (Space)0);
			}
			else if (Mathf.Abs(((Bounds)(ref val3)).size.y - ((Bounds)(ref val3)).size.z) / ((Bounds)(ref val3)).size.z < 0.01f && ((Bounds)(ref val3)).size.z < ((Bounds)(ref val3)).size.x * 0.85f)
			{
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated 25 z | 3"));
				pivotTransform.Rotate(Vector3.forward, 25f, (Space)0);
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -45 y | 3"));
				pivotTransform.Rotate(Vector3.up, -45f, (Space)0);
			}
			else if (((Bounds)(ref val3)).size.y < ((Bounds)(ref val3)).size.x / 2f || ((Bounds)(ref val3)).size.x < ((Bounds)(ref val3)).size.y / 2f)
			{
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated 45 z | 4"));
				pivotTransform.Rotate(Vector3.forward, 45f, (Space)0);
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -25 x | 4"));
				pivotTransform.Rotate(Vector3.right, -25f, (Space)0);
			}
			else
			{
				RuntimeIcons.Log.LogDebug((object)(grabbable.itemProperties.itemName + " rotated -25 x | 5"));
				pivotTransform.Rotate(Vector3.right, -25f, (Space)0);
			}
		}

		private static void UpdateIconsInHUD(Item item)
		{
			if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance) || !Object.op_Implicit((Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				return;
			}
			GrabbableObject[] itemSlots = GameNetworkManager.Instance.localPlayerController.ItemSlots;
			Image[] itemSlotIcons = HUDManager.Instance.itemSlotIcons;
			for (int i = 0; i < itemSlots.Length && i < itemSlotIcons.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)itemSlots[i]) && !((Object)(object)itemSlots[i].itemProperties != (Object)(object)item))
				{
					itemSlotIcons[i].sprite = item.itemIcon;
				}
			}
		}
	}
	[HarmonyPatch]
	public class StartOfRoundPatch
	{
		internal static readonly Dictionary<Item, Tuple<string, string>> ItemModMap = new Dictionary<Item, Tuple<string, string>>();

		internal static int AvailableRenders { get; set; } = 0;


		[HarmonyFinalizer]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void PrepareItemCache(StartOfRound __instance)
		{
			ItemModMap.Clear();
			if (LethalLibProxy.Enabled)
			{
				LethalLibProxy.GetModdedItems(in ItemModMap);
			}
			if (LethalLevelLoaderProxy.Enabled)
			{
				LethalLevelLoaderProxy.GetModdedItems(in ItemModMap);
			}
			foreach (Item items in __instance.allItemsList.itemsList)
			{
				ItemModMap.TryAdd(items, new Tuple<string, string>("Vanilla", ""));
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(StartOfRound), "LateUpdate")]
		private static void TrackNewRenders(StartOfRound __instance)
		{
			AvailableRenders = 1;
		}
	}
}
namespace RuntimeIcons.Dependency
{
	internal class CullFactoryCompatibility
	{
		public const string GUID = "com.fumiko.CullFactory";

		public const string VERSION = "1.4.0";

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					if (Chainloader.PluginInfos.TryGetValue("com.fumiko.CullFactory", out var value) && value.Metadata.Version >= Version.Parse("1.4.0"))
					{
						_enabled = true;
					}
					else
					{
						_enabled = false;
					}
				}
				return _enabled.Value;
			}
		}

		public static void DisableCullingForCamera(Camera camera)
		{
			if (Enabled)
			{
				DisableCullingForCameraImpl(camera);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void DisableCullingForCameraImpl(Camera camera)
		{
			CameraCullingOptions val = ((Component)camera).gameObject.AddComponent<CameraCullingOptions>();
			val.disableCulling = true;
		}
	}
	public static class LethalConfigProxy
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c__7<T> where T : Enum
		{
			public static readonly <>c__7<T> <>9 = new <>c__7<T>();

			public static CanModifyDelegate <>9__7_0;

			public static CanModifyDelegate <>9__7_1;

			internal CanModifyResult <AddConfig>b__7_0()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				return CanModifyResult.op_Implicit((ValueTuple<bool, string>)(true, null));
			}

			internal CanModifyResult <AddConfig>b__7_1()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return CanModifyResult.op_Implicit((false, "THIS IS A FLAG TYPE ENUM, EDITING CURRENTLY NOT SUPPORTED!"));
			}
		}

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig(ConfigEntry<string> entry, bool requiresRestart = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(entry, new TextInputFieldOptions
			{
				RequiresRestart = requiresRestart,
				Name = GetPrettyConfigName<string>(entry)
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig(ConfigEntry<bool> entry, bool requiresRestart = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(entry, new BoolCheckBoxOptions
			{
				RequiresRestart = requiresRestart,
				Name = GetPrettyConfigName<bool>(entry)
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig(ConfigEntry<float> entry, bool requiresRestart = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry, new FloatInputFieldOptions
			{
				RequiresRestart = requiresRestart,
				Name = GetPrettyConfigName<float>(entry)
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig(ConfigEntry<int> entry, bool requiresRestart = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(entry, new IntInputFieldOptions
			{
				RequiresRestart = requiresRestart,
				Name = GetPrettyConfigName<int>(entry)
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig<T>(ConfigEntry<T> entry, bool requiresRestart = false) where T : Enum
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			object obj = <>c__7<T>.<>9__7_0;
			if (obj == null)
			{
				CanModifyDelegate val = () => CanModifyResult.op_Implicit((ValueTuple<bool, string>)(true, null));
				<>c__7<T>.<>9__7_0 = val;
				obj = (object)val;
			}
			CanModifyDelegate canModifyCallback = (CanModifyDelegate)obj;
			if (((ConfigEntryBase)entry).SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: true).Any())
			{
				object obj2 = <>c__7<T>.<>9__7_1;
				if (obj2 == null)
				{
					CanModifyDelegate val2 = () => CanModifyResult.op_Implicit((false, "THIS IS A FLAG TYPE ENUM, EDITING CURRENTLY NOT SUPPORTED!"));
					<>c__7<T>.<>9__7_1 = val2;
					obj2 = (object)val2;
				}
				canModifyCallback = (CanModifyDelegate)obj2;
			}
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<T>(entry, new EnumDropDownOptions
			{
				RequiresRestart = requiresRestart,
				CanModifyCallback = canModifyCallback
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddButton(string section, string name, string description, string buttonText, Action callback)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
			{
				callback?.Invoke();
			}));
		}

		private static string GetPrettyConfigName<T>(ConfigEntry<T> entry)
		{
			return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(((ConfigEntryBase)entry).Definition.Key.Replace("_", " "));
		}
	}
	public static class LethalLevelLoaderProxy
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void GetModdedItems([NotNull] in Dictionary<Item, Tuple<string, string>> items)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			RuntimeIcons.Log.LogWarning((object)"LethalLevelLoader found, reading PatchedContent.ExtendedItems");
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				if ((int)((ExtendedContent)extendedItem).ContentType != 0)
				{
					items.TryAdd(extendedItem.Item, new Tuple<string, string>("LethalLevelLoader", ((ExtendedContent)extendedItem).ModName));
				}
			}
		}
	}
	public static class LethalLibProxy
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("evaisa.lethallib");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void GetModdedItems([NotNull] in Dictionary<Item, Tuple<string, string>> items)
		{
			RuntimeIcons.Log.LogWarning((object)"LethalLib found, reading Items.scrapItems");
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				items.TryAdd(scrapItem.item, new Tuple<string, string>("LethalLib", scrapItem.modName));
			}
		}
	}
	public static class LobbyCompatibilityChecker
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			PluginHelper.RegisterPlugin("com.github.lethalcompanymodding.runtimeicons", Version.Parse("0.1.5"), (CompatibilityLevel)2, (VersionStrictness)2);
		}
	}
}
namespace RuntimeIcons.Config
{
	internal static class PluginConfig
	{
		public enum ListBehaviour
		{
			None,
			BlackList,
			WhiteList
		}

		private static ConfigEntry<string> _rotationOverridesConfig;

		private static ConfigEntry<string> _fileOverridesConfig;

		private static ConfigEntry<ListBehaviour> _itemListBehaviourConfig;

		private static ConfigEntry<string> _itemListConfig;

		private static ConfigEntry<float> _failPercentage;

		private static ConfigEntry<LogLevel> _verboseMeshLogs;

		private static ConfigEntry<bool> _dumpToCache;

		internal static LogLevel VerboseMeshLogs => _verboseMeshLogs.Value;

		internal static bool DumpToCache => _dumpToCache.Value;

		internal static float TransparencyRatio => _failPercentage.Value;

		internal static ISet<string> ItemList { get; private set; }

		internal static ListBehaviour ItemListBehaviour => _itemListBehaviourConfig.Value;

		internal static IDictionary<string, Vector3> RotationOverrides { get; private set; }

		internal static IDictionary<string, string> FileOverrides { get; private set; }

		internal static void Init()
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)RuntimeIcons.INSTANCE).Config;
			_verboseMeshLogs = config.Bind<LogLevel>("Debug", "Verbose Mesh Logs", (LogLevel)0, "Print Extra logs!");
			_dumpToCache = config.Bind<bool>("Debug", "Dump sprites to cache", false, "Save the generated sprites into the cache folder");
			_fileOverridesConfig = config.Bind<string>("Overrides", "Manual Files", "", "Dictionary of files to use for specific items");
			_rotationOverridesConfig = config.Bind<string>("Overrides", "Manual Rotation", "Airhorn:-45,90,-80|Whoopie cushion:-75,0,0|Toy robot:-15,180,0|Sticky note:0,105,-90", "Dictionary of alternate rotations for items\nListSeparator=|");
			_itemListBehaviourConfig = config.Bind<ListBehaviour>("Config", "List Behaviour", ListBehaviour.BlackList, "What mode to use to filter what items will get new icons");
			_itemListConfig = config.Bind<string>("Config", "Item List", "Body,", "List of items to filter");
			_failPercentage = config.Bind<float>("Config", "Transparency Threshold", 0.95f, new ConfigDescription("Maximum percentage of transparent pixels to consider a valid image", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ParseBlacklist();
			_itemListConfig.SettingChanged += delegate
			{
				ParseBlacklist();
			};
			ParseFileOverrides();
			_fileOverridesConfig.SettingChanged += delegate
			{
				ParseFileOverrides();
			};
			ParseRotationOverrides();
			_rotationOverridesConfig.SettingChanged += delegate
			{
				ParseRotationOverrides();
			};
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.AddConfig<LogLevel>(_verboseMeshLogs, requiresRestart: false);
				LethalConfigProxy.AddConfig(_dumpToCache);
				LethalConfigProxy.AddConfig(_itemListConfig);
				LethalConfigProxy.AddConfig<ListBehaviour>(_itemListBehaviourConfig);
				LethalConfigProxy.AddConfig(_failPercentage);
				LethalConfigProxy.AddConfig(_fileOverridesConfig);
				LethalConfigProxy.AddConfig(_rotationOverridesConfig);
				LethalConfigProxy.AddButton("Debug", "Refresh Held Item", "Regenerate Sprite for held Item", "Refresh", delegate
				{
					if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController.currentlyHeldObjectServer))
					{
						GrabbableObjectPatch.ComputeSprite(StartOfRound.Instance.localPlayerController.currentlyHeldObjectServer);
					}
				});
				LethalConfigProxy.AddButton("Debug", "Render All Loaded Items", "Finds all items in the resources of the game to render them. Must be in a game.", "Render All Items", delegate
				{
					if (!((Object)(object)StartOfRound.Instance == (Object)null))
					{
						((MonoBehaviour)StartOfRound.Instance).StartCoroutine(RenderAllCoroutine());
					}
				});
			}
			CleanAndSave();
			RotationEditor.Init();
			static void ParseBlacklist()
			{
				string[] source3 = _itemListConfig.Value.Split(",");
				ItemList = (from s in source3
					select s.Trim() into s
					where !Utility.IsNullOrWhiteSpace(s)
					select s).ToHashSet();
			}
			static void ParseFileOverrides()
			{
				string[] source2 = _fileOverridesConfig.Value.Split(",");
				FileOverrides = (from s in source2
					where !Utility.IsNullOrWhiteSpace(s)
					select s.Split(":") into a
					where a.Length >= 2
					select a).ToDictionary((string[] a) => a[0].Trim(), (string[] a) => a[1].Trim());
			}
			static void ParseRotationOverrides()
			{
				string[] source = _rotationOverridesConfig.Value.Split("|");
				RotationOverrides = (from s in source
					where !Utility.IsNullOrWhiteSpace(s)
					select s.Split(":") into a
					where a.Length >= 2
					select a).ToDictionary((Func<string[], string>)((string[] a) => a[0].Trim()), (Func<string[], Vector3>)delegate(string[] a)
				{
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0051: Unknown result type (might be due to invalid IL or missing references)
					string[] array = a[1].Trim().Split(",");
					if (array.Length < 3)
					{
						return Vector3.zero;
					}
					float[] array2 = new float[3];
					int i;
					float result;
					for (i = 0; i < 3 && float.TryParse(array[i], NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); i++)
					{
						array2[i] = result;
					}
					return (Vector3)((i != 3) ? Vector3.zero : new Vector3(array2[0], array2[1], array2[2]));
				});
			}
		}

		internal static void CleanAndSave()
		{
			ConfigFile config = ((BaseUnityPlugin)RuntimeIcons.INSTANCE).Config;
			PropertyInfo propertyInfo = AccessTools.Property(((object)config).GetType(), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config, null);
			dictionary.Clear();
			config.Save();
		}

		private static IEnumerator RenderAllCoroutine()
		{
			Item[] items = Resources.FindObjectsOfTypeAll<Item>();
			HashSet<Item> renderedItems = new HashSet<Item>();
			Item[] array = items;
			foreach (Item val in array)
			{
				if ((Object)(object)val.spawnPrefab == (Object)null)
				{
					continue;
				}
				Sprite itemIcon = val.itemIcon;
				val.itemIcon = null;
				GameObject val2 = Object.Instantiate<GameObject>(val.spawnPrefab);
				try
				{
					GrabbableObject componentInChildren = val2.GetComponentInChildren<GrabbableObject>();
					componentInChildren.Start();
					componentInChildren.Update();
					Animator[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren<Animator>();
					Animator[] array2 = componentsInChildren;
					foreach (Animator val3 in array2)
					{
						val3.Update(Time.deltaTime);
					}
					GrabbableObjectPatch.ComputeSprite(componentInChildren);
				}
				catch
				{
				}
				finally
				{
					Object.Destroy((Object)(object)val2);
				}
				if ((Object)(object)val.itemIcon != (Object)null && (Object)(object)val.itemIcon != (Object)(object)GrabbableObjectPatch.BrokenSprite)
				{
					renderedItems.Add(val);
				}
				val.itemIcon = itemIcon;
				yield return null;
			}
			StringBuilder stringBuilder = new StringBuilder("Items that failed to render: ");
			bool flag = false;
			Item[] array3 = items;
			foreach (Item val4 in array3)
			{
				if (!renderedItems.Contains(val4))
				{
					stringBuilder.Append(val4.itemName);
					if (GrabbableObjectPatch.ItemHasIcon(val4))
					{
						stringBuilder.Append(" (✓)");
					}
					else
					{
						stringBuilder.Append(" (✗)");
					}
					stringBuilder.Append(", ");
					flag = true;
				}
			}
			if (flag)
			{
				stringBuilder.Length -= 2;
				RuntimeIcons.Log.LogInfo((object)stringBuilder);
			}
			else
			{
				RuntimeIcons.Log.LogInfo((object)"No items failed to render.");
			}
		}
	}
	internal static class RotationEditor
	{
		internal static void Init()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			ConfigEntry<string> eulerAngles;
			if (LethalConfigProxy.Enabled)
			{
				ConfigFile val = new ConfigFile(Path.GetTempFileName(), false, MetadataHelper.GetMetadata((object)RuntimeIcons.INSTANCE));
				eulerAngles = val.Bind<string>("Rotation Calculator", "Euler Angles", "0,0,0", "The Euler angles representing this rotation");
				ConfigEntry<float> angle2 = val.Bind<float>("Rotation Calculator", "Angle", 0f, new ConfigDescription("rotation angle", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-360f, 360f), Array.Empty<object>()));
				LethalConfigProxy.AddConfig(eulerAngles);
				LethalConfigProxy.AddConfig(angle2);
				LethalConfigProxy.AddButton("Rotation Calculator", "Apply X Rotation", "translate current EulerAngles around world X Axis by Rotation amount", "X Rot", delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ApplyRotation(angle2.Value, Vector3.right);
				});
				LethalConfigProxy.AddButton("Rotation Calculator", "Apply Y Rotation", "translate current EulerAngles around world X Axis by Rotation amount", "Y Rot", delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ApplyRotation(angle2.Value, Vector3.up);
				});
				LethalConfigProxy.AddButton("Rotation Calculator", "Apply Z Rotation", "translate current EulerAngles around world X Axis by Rotation amount", "Z Rot", delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ApplyRotation(angle2.Value, Vector3.forward);
				});
			}
			void ApplyRotation(float angle, Vector3 axis)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_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_0081: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
				Vector3 zero = Vector3.zero;
				string[] array = eulerAngles.Value.Split(",");
				if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
				{
					((Vector3)(ref zero))..ctor(result, result2, result3);
				}
				Quaternion val2 = Quaternion.Euler(zero);
				Quaternion val3 = Quaternion.AngleAxis(angle, axis);
				Quaternion val4 = val3 * val2;
				eulerAngles.Value = $"{WrapAroundAngle(((Quaternion)(ref val4)).eulerAngles.x)},{WrapAroundAngle(((Quaternion)(ref val4)).eulerAngles.y)},{WrapAroundAngle(((Quaternion)(ref val4)).eulerAngles.z)}";
			}
		}

		private static float WrapAroundAngle(float angle)
		{
			angle %= 360f;
			angle = (angle + 360f) % 360f;
			if (angle > 180f)
			{
				angle -= 360f;
			}
			angle = (float)Math.Round(angle, 2);
			return angle;
		}
	}
}
namespace RuntimeIcons.Components
{
	public class StageComponent : MonoBehaviour
	{
		private class IsolateStageLights : IDisposable
		{
			private readonly HashSet<Light> _lightMemory;

			private readonly Color _ambientLight;

			public IsolateStageLights(GameObject stagePivot)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				_lightMemory = CollectionPool<HashSet<Light>, Light>.Get();
				_ambientLight = RenderSettings.ambientLight;
				RenderSettings.ambientLight = Color.black;
				Light[] localLights = stagePivot.GetComponentsInChildren<Light>();
				Light[] array = (from l in Object.FindObjectsOfType<Light>()
					where !localLights.Contains(l)
					where ((Behaviour)l).enabled
					select l).ToArray();
				Light[] array2 = array;
				foreach (Light val in array2)
				{
					((Behaviour)val).enabled = false;
					_lightMemory.Add(val);
				}
			}

			public void Dispose()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				RenderSettings.ambientLight = _ambientLight;
				foreach (Light item in _lightMemory)
				{
					((Behaviour)item).enabled = true;
				}
				CollectionPool<HashSet<Light>, Light>.Release(_lightMemory);
			}
		}

		public record struct TransformMemory
		{
			public readonly Transform Parent;

			public readonly Vector3 LocalPosition;

			public readonly Quaternion LocalRotation;

			public readonly Vector3 LocalScale;

			public TransformMemory(Transform target)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_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)
				Parent = target.parent;
				LocalPosition = target.localPosition;
				LocalRotation = target.localRotation;
				LocalScale = target.localScale;
			}

			[CompilerGenerated]
			private readonly bool PrintMembers(StringBuilder builder)
			{
				//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_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_0075: 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)
				builder.Append("Parent = ");
				builder.Append(Parent);
				builder.Append(", LocalPosition = ");
				Vector3 val = LocalPosition;
				builder.Append(((object)(Vector3)(ref val)).ToString());
				builder.Append(", LocalRotation = ");
				Quaternion localRotation = LocalRotation;
				builder.Append(((object)(Quaternion)(ref localRotation)).ToString());
				builder.Append(", LocalScale = ");
				val = LocalScale;
				builder.Append(((object)(Vector3)(ref val)).ToString());
				return true;
			}
		}

		private Camera _camera;

		private HDAdditionalCameraData _cameraSettings;

		private TransparentRenderTexturePass _cameraPass;

		private GameObject _targetGo;

		private Vector2Int _resolution = new Vector2Int(128, 128);

		public Vector2 MarginPixels = new Vector2(0f, 0f);

		public IVertexCache VertexCache { get; set; } = VertexesExtensions.GlobalPartialCache;


		public GameObject LightGo { get; private set; }

		public GameObject PivotGo
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_targetGo))
				{
					_targetGo = CreatePivotGo();
				}
				return _targetGo;
			}
		}

		private GameObject CameraGo { get; set; }

		public Transform LightTransform => LightGo.transform;

		public Transform PivotTransform => PivotGo.transform;

		private Transform CameraTransform => CameraGo.transform;

		public Vector2Int Resolution
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _resolution;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				_resolution = value;
				_camera.aspect = (float)((Vector2Int)(ref _resolution)).x / (float)((Vector2Int)(ref _resolution)).y;
			}
		}

		public int CullingMask => _camera.cullingMask;

		public Transform StagedTransform { get; private set; }

		private TransformMemory Memory { get; set; }

		private StageComponent()
		{
		}//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_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)


		private GameObject CreatePivotGo()
		{
			//IL_0015: 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_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			GameObject val = new GameObject(((Object)((Component)this).transform).name + ".Pivot");
			val.transform.position = ((Component)this).transform.position;
			val.transform.rotation = ((Component)this).transform.rotation;
			return val;
		}

		public static StageComponent CreateStage(HideFlags hideFlags, int cameraLayerMask = 1, string stageName = "Stage", bool orthographic = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0069: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(stageName)
			{
				hideFlags = hideFlags
			};
			StageComponent stageComponent = val.AddComponent<StageComponent>();
			GameObject val2 = new GameObject("Stage Lights")
			{
				hideFlags = hideFlags
			};
			val2.transform.parent = val.transform;
			GameObject val3 = val2;
			val3.SetActive(false);
			stageComponent.LightGo = val3;
			GameObject val4 = new GameObject("Camera")
			{
				hideFlags = hideFlags
			};
			val4.transform.parent = val.transform;
			GameObject val6 = (stageComponent.CameraGo = val4);
			Camera val7 = (stageComponent._camera = val6.AddComponent<Camera>());
			CullFactoryCompatibility.DisableCullingForCamera(val7);
			val7.cullingMask = cameraLayerMask;
			val7.orthographic = orthographic;
			Vector2Int resolution = stageComponent.Resolution;
			float num = ((Vector2Int)(ref resolution)).x;
			resolution = stageComponent.Resolution;
			val7.aspect = num / (float)((Vector2Int)(ref resolution)).y;
			val7.clearFlags = (CameraClearFlags)2;
			val7.backgroundColor = Color.clear;
			val7.nearClipPlane = 0.1f;
			val7.farClipPlane = 10f;
			((Behaviour)val7).enabled = false;
			HDAdditionalCameraData val8 = (stageComponent._cameraSettings = val6.AddComponent<HDAdditionalCameraData>());
			val8.clearDepth = true;
			val8.clearColorMode = (ClearColorMode)1;
			val8.backgroundColorHDR = Color.clear;
			val8.customRenderingSettings = true;
			val8.customRenderingSettings = true;
			((BitArray128)(ref val8.renderingPathCustomFrameSettingsOverrideMask.mask))[96u] = true;
			((FrameSettings)(ref val8.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)96, false);
			CustomPassVolume val9 = val6.AddComponent<CustomPassVolume>();
			val9.targetCamera = val7;
			TransparentRenderTexturePass transparentRenderTexturePass = (stageComponent._cameraPass = (TransparentRenderTexturePass)(object)val9.AddPassOfType<TransparentRenderTexturePass>());
			((CustomPass)transparentRenderTexturePass).targetColorBuffer = (TargetBuffer)1;
			((CustomPass)transparentRenderTexturePass).targetDepthBuffer = (TargetBuffer)1;
			((CustomPass)transparentRenderTexturePass).clearFlags = (ClearFlag)7;
			return stageComponent;
		}

		public void SetObjectOnStage(GameObject targetGameObject)
		{
			SetObjectOnStage(targetGameObject.transform);
		}

		public void SetObjectOnStage(GameObject targetGameObject, Quaternion rotation)
		{
			SetObjectOnStage(targetGameObject.transform);
		}

		public void SetObjectOnStage(Transform targetTransform)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SetObjectOnStage(targetTransform, targetTransform.rotation);
		}

		public void SetObjectOnStage(Transform targetTransform, Quaternion rotation)
		{
			//IL_0038: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)StagedTransform) && (Object)(object)StagedTransform != (Object)(object)targetTransform)
			{
				throw new InvalidOperationException("An Object is already on stage!");
			}
			PivotTransform.parent = null;
			PivotTransform.position = Vector3.zero;
			PivotTransform.rotation = Quaternion.identity;
			SceneManager.MoveGameObjectToScene(PivotGo, ((Component)targetTransform).gameObject.scene);
			StagedTransform = targetTransform;
			Memory = new TransformMemory(StagedTransform);
			StagedTransform.SetParent(PivotTransform, false);
			StagedTransform.localPosition = Vector3.zero;
		}

		public void CenterObjectOnPivot(Quaternion? overrideRotation = null)
		{
			//IL_0033: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			if (!Object.op_Implicit((Object)(object)StagedTransform))
			{
				throw new InvalidOperationException("No Object on stage!");
			}
			if (overrideRotation.HasValue)
			{
				StagedTransform.rotation = overrideRotation.Value;
			}
			Matrix4x4 overrideMatrix = Matrix4x4.TRS(Vector3.zero, StagedTransform.rotation, StagedTransform.localScale);
			ExecutionOptions val = default(ExecutionOptions);
			((ExecutionOptions)(ref val))..ctor();
			((ExecutionOptions)(ref val)).VertexCache = VertexCache;
			((ExecutionOptions)(ref val)).CullingMask = CullingMask;
			((ExecutionOptions)(ref val)).LogHandler = RuntimeIcons.VerboseMeshLog;
			((ExecutionOptions)(ref val)).OverrideMatrix = overrideMatrix;
			ExecutionOptions val2 = val;
			Bounds val3 = default(Bounds);
			if (!VertexesExtensions.TryGetBounds(((Component)StagedTransform).gameObject, ref val3, val2))
			{
				throw new InvalidOperationException("This object has no Renders!");
			}
			StagedTransform.localPosition = -((Bounds)(ref val3)).center;
		}

		public void PrepareCameraForShot(Vector3 offset, float fov)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			if (!Object.op_Implicit((Object)(object)StagedTransform))
			{
				throw new InvalidOperationException("No Object on stage!");
			}
			PivotTransform.position = ((Component)_camera).transform.position + offset;
			LightTransform.position = PivotTransform.position;
			if (_camera.orthographic)
			{
				_camera.orthographicSize = fov;
			}
			else
			{
				_camera.fieldOfView = fov;
			}
		}

		public void PrepareCameraForShot()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)StagedTransform))
			{
				throw new InvalidOperationException("No Object on stage!");
			}
			PivotTransform.position = Vector3.zero;
			ExecutionOptions val = default(ExecutionOptions);
			((ExecutionOptions)(ref val))..ctor();
			((ExecutionOptions)(ref val)).VertexCache = VertexCache;
			((ExecutionOptions)(ref val)).CullingMask = CullingMask;
			((ExecutionOptions)(ref val)).LogHandler = RuntimeIcons.VerboseMeshLog;
			((ExecutionOptions)(ref val)).OverrideMatrix = PivotTransform.localToWorldMatrix;
			ExecutionOptions val2 = val;
			Matrix4x4 worldToLocalMatrix = PivotTransform.worldToLocalMatrix;
			Vector3[] vertexes = VertexesExtensions.GetVertexes(PivotGo, val2);
			if (vertexes.Length == 0)
			{
				throw new InvalidOperationException("This object has no Renders!");
			}
			Bounds? bounds = VertexesExtensions.GetBounds((IEnumerable<Vector3>)vertexes);
			if (!bounds.HasValue)
			{
				throw new InvalidOperationException("This object has no Bounds!");
			}
			float nearClipPlane = _camera.nearClipPlane;
			Bounds value = bounds.Value;
			float num = Math.Max(nearClipPlane + ((Bounds)(ref value)).size.z, 3f);
			Transform pivotTransform = PivotTransform;
			Vector3 position = ((Component)_camera).transform.position;
			value = bounds.Value;
			pivotTransform.position = position - ((Bounds)(ref value)).center + ((Component)_camera).transform.forward * num;
			Vector2 val3 = MarginPixels / Vector2Int.op_Implicit(_resolution);
			Vector2 val4 = Vector2.one / (Vector2.one - val3);
			if (_camera.orthographic)
			{
				value = bounds.Value;
				float val5 = ((Bounds)(ref value)).extents.y * val4.y;
				value = bounds.Value;
				float val6 = ((Bounds)(ref value)).extents.x * val4.x * _camera.aspect;
				float orthographicSize = Math.Max(val6, val5);
				_camera.orthographicSize = orthographicSize;
			}
			else
			{
				Matrix4x4 val7 = PivotTransform.localToWorldMatrix * worldToLocalMatrix;
				for (int i = 0; i < vertexes.Length; i++)
				{
					vertexes[i] = ((Matrix4x4)(ref val7)).MultiplyPoint3x4(vertexes[i]);
				}
				float angleMin;
				float angleMax;
				float angleMin2;
				float angleMax2;
				for (int j = 0; j < 2; j++)
				{
					GetCameraAngles(_camera, CameraTransform.right, vertexes, out angleMin, out angleMax);
					((Component)_camera).transform.Rotate(Vector3.up, (angleMin + angleMax) / 2f, (Space)0);
					GetCameraAngles(_camera, -CameraTransform.up, vertexes, out angleMin2, out angleMax2);
					((Component)_camera).transform.Rotate(Vector3.right, (angleMin2 + angleMax2) / 2f, (Space)1);
				}
				GetCameraAngles(_camera, CameraTransform.right, vertexes, out angleMin, out angleMax);
				GetCameraAngles(_camera, -CameraTransform.up, vertexes, out angleMin2, out angleMax2);
				float val8 = Math.Max(0f - angleMin2, angleMax2) * 2f * val4.y;
				float val9 = Camera.HorizontalToVerticalFieldOfView(Math.Max(0f - angleMin, angleMax) * 2f, _camera.aspect) * val4.x;
				_camera.fieldOfView = Math.Max(val8, val9);
			}
			LightTransform.position = PivotTransform.position;
		}

		public void ResetStage()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)StagedTransform))
			{
				StagedTransform.SetParent(Memory.Parent, false);
				StagedTransform.localScale = Memory.LocalScale;
				StagedTransform.SetLocalPositionAndRotation(Memory.LocalPosition, Memory.LocalRotation);
			}
			StagedTransform = null;
			Memory = default(TransformMemory);
			PivotTransform.parent = null;
			PivotTransform.position = ((Component)this).transform.position;
			PivotTransform.rotation = Quaternion.identity;
			LightTransform.localPosition = Vector3.zero;
			LightTransform.rotation = Quaternion.identity;
			CameraTransform.localRotation = Quaternion.identity;
		}

		public Texture2D TakeSnapshot()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return TakeSnapshot(Color.clear);
		}

		public Texture2D TakeSnapshot(Color backgroundColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			_camera.backgroundColor = backgroundColor;
			Vector2Int resolution = Resolution;
			int x = ((Vector2Int)(ref resolution)).x;
			resolution = Resolution;
			RenderTexture temporary = RenderTexture.GetTemporary(x, ((Vector2Int)(ref resolution)).y, 8, (GraphicsFormat)48);
			resolution = Resolution;
			int x2 = ((Vector2Int)(ref resolution)).x;
			resolution = Resolution;
			RenderTexture temporary2 = RenderTexture.GetTemporary(x2, ((Vector2Int)(ref resolution)).y, 0, (RenderTextureFormat)16);
			_camera.targetTexture = temporary2;
			_cameraPass.targetTexture = temporary;
			using (new IsolateStageLights(PivotGo))
			{
				LightGo.SetActive(true);
				_camera.Render();
				LightGo.SetActive(false);
			}
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(((Texture)temporary).width, ((Texture)temporary).height, (GraphicsFormat)48, 1, (TextureCreationFlags)4)
			{
				name = "RuntimeIcons." + ((Object)StagedTransform).name + "Texture",
				filterMode = (FilterMode)0
			};
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			_camera.targetTexture = null;
			RenderTexture.ReleaseTemporary(temporary2);
			_cameraPass.targetTexture = null;
			RenderTexture.ReleaseTemporary(temporary);
			RuntimeIcons.Log.LogInfo((object)(((Object)val).name + " Rendered"));
			return val;
		}

		private static void GetCameraAngles(Camera camera, Vector3 direction, IEnumerable<Vector3> vertices, out float angleMin, out float angleMax)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_004a: 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)
			Vector3 position = ((Component)camera).transform.position;
			Plane val = default(Plane);
			((Plane)(ref val))..ctor(((Component)camera).transform.forward, position);
			Plane val2 = default(Plane);
			((Plane)(ref val2))..ctor(direction, position);
			float num = float.PositiveInfinity;
			float num2 = float.NegativeInfinity;
			foreach (Vector3 vertex in vertices)
			{
				float val3 = ((Plane)(ref val2)).GetDistanceToPoint(vertex) / ((Plane)(ref val)).GetDistanceToPoint(vertex);
				num = Math.Min(val3, num);
				num2 = Math.Max(val3, num2);
			}
			angleMin = Mathf.Atan(num) * 57.29578f;
			angleMax = Mathf.Atan(num2) * 57.29578f;
		}
	}
	public enum MarginType
	{
		Fraction,
		Pixels
	}
	public class TransparentRenderTexturePass : CustomPass
	{
		public RenderTexture targetTexture;

		private bool printedError;

		private static ShaderTagId[] depthPrepassTags;

		private static ShaderTagId[] forwardTags;

		protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			depthPrepassTags = (ShaderTagId[])(object)new ShaderTagId[5]
			{
				HDShaderPassNames.s_DepthForwardOnlyName,
				HDShaderPassNames.s_ForwardOnlyName,
				HDShaderPassNames.s_DepthOnlyName,
				HDShaderPassNames.s_TransparentDepthPrepassName,
				HDShaderPassNames.s_TransparentBackfaceName
			};
			forwardTags = (ShaderTagId[])(object)new ShaderTagId[4]
			{
				HDShaderPassNames.s_ForwardOnlyName,
				HDShaderPassNames.s_ForwardName,
				HDShaderPassNames.s_SRPDefaultUnlitName,
				HDShaderPassNames.s_DecalMeshForwardEmissiveName
			};
		}

		private void Render(ref CustomPassContext ctx, in RenderQueueRange range, SortingCriteria sorting, ShaderTagId[] shaderTags, PerObjectData configuration, bool fptl)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_002d: 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_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Camera camera = ctx.hdCamera.camera;
			ScriptableRenderContext renderContext = ctx.renderContext;
			RendererListDesc val = default(RendererListDesc);
			((RendererListDesc)(ref val))..ctor(shaderTags, ctx.cullingResults, camera);
			val.renderQueueRange = range;
			val.rendererConfiguration = configuration;
			val.sortingCriteria = sorting;
			val.excludeObjectMotionVectors = false;
			val.layerMask = camera.cullingMask;
			RendererList val2 = ((ScriptableRenderContext)(ref renderContext)).CreateRendererList(val);
			CoreUtils.SetKeyword(ctx.cmd, "USE_FPTL_LIGHTLIST", fptl);
			CoreUtils.SetKeyword(ctx.cmd, "USE_CLUSTERED_LIGHTLIST", !fptl);
			CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, val2);
		}

		private bool ShouldUseFPTL(in FrameSettings frameSettings)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			FrameSettings val = frameSettings;
			if ((int)((FrameSettings)(ref val)).litShaderMode == 1)
			{
				return true;
			}
			val = frameSettings;
			return ((FrameSettings)(ref val)).IsEnabled((FrameSettingsField)120);
		}

		protected override void Execute(CustomPassContext ctx)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0066: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetTexture == (Object)null)
			{
				if (!printedError)
				{
					RuntimeIcons.Log.LogError((object)$"{this} is missing a target texture to render to.");
					printedError = true;
				}
				return;
			}
			printedError = false;
			ctx.cmd.SetRenderTarget(RenderTargetIdentifier.op_Implicit(targetTexture.colorBuffer), RenderTargetIdentifier.op_Implicit(targetTexture.depthBuffer));
			ctx.cmd.ClearRenderTarget(true, true, Color.clear);
			FrameSettings frameSettings = ctx.hdCamera.frameSettings;
			PerObjectData rendererConfiguration = HDUtils.GetRendererConfiguration(((FrameSettings)(ref frameSettings)).IsEnabled((FrameSettingsField)127), ((FrameSettings)(ref frameSettings)).IsEnabled((FrameSettingsField)22));
			RenderQueueRange range = RenderQueueRange.opaque;
			Render(ref ctx, 

plugins/LethalLevelLoader.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using LethalLevelLoader.NetcodePatcher;
using LethalLevelLoader.Tools;
using LethalLib.Modules;
using LethalModDataLib.Base;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("LethalLevelLoader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Custom API to support the manual and dynamic integration of custom levels and dungeons in Lethal Company.")]
[assembly: AssemblyFileVersion("1.3.10.0")]
[assembly: AssemblyInformationalVersion("1.3.10+3d766ca73db4a92480e5660bdab20010a91666e4")]
[assembly: AssemblyProduct("LethalLevelLoader")]
[assembly: AssemblyTitle("LethalLevelLoader")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/IAmBatby/LethalLevelLoader/")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public enum ContentType
{
	Vanilla,
	Custom,
	Any
}
internal static class HookHelper
{
	public class DisposableHookCollection
	{
		private List<ILHook> ilHooks = new List<ILHook>();

		private List<Hook> hooks = new List<Hook>();

		public void Clear()
		{
			foreach (Hook hook in hooks)
			{
				hook.Dispose();
			}
			hooks.Clear();
			foreach (ILHook ilHook in ilHooks)
			{
				ilHook.Dispose();
			}
			ilHooks.Clear();
		}

		public void ILHook<T>(string methodName, Manipulator to, Type[] parameters = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			ilHooks.Add(new ILHook((MethodBase)EzGetMethod<T>(methodName, parameters), to));
		}

		public void Hook<T>(string methodName, Delegate to, Type[] parameters = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			hooks.Add(new Hook((MethodBase)EzGetMethod<T>(methodName, parameters), to));
		}
	}

	public static MethodInfo methodof(Delegate method)
	{
		return method.Method;
	}

	public static MethodInfo EzGetMethod(Type type, string name, Type[] parameters = null)
	{
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
		if (parameters == null)
		{
			return type.GetMethod(name, bindingAttr);
		}
		return type.GetMethod(name, bindingAttr, null, parameters, null);
	}

	public static MethodInfo EzGetMethod<T>(string name, Type[] parameters = null)
	{
		return EzGetMethod(typeof(T), name, parameters);
	}
}
public static class NetworkScenePatcher
{
	[CompilerGenerated]
	private static class <>O
	{
		public static Action<Action<NetworkSceneManager>, NetworkSceneManager> <0>__GenerateScenesInBuild_Hook;

		public static Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string> <1>__SceneNameFromHash_Hook;

		public static Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, NetworkSceneManager, int, string, LoadSceneMode, bool> <2>__ValidateSceneBeforeLoading_Hook;

		public static Manipulator <3>__ReplaceBuildIndexByScenePath;

		public static Manipulator <4>__ReplaceScenePathByBuildIndex;

		public static Func<int, string> <5>__GetScenePathByBuildIndex;

		public static Func<string, int> <6>__GetBuildIndexByScenePath;
	}

	private static List<string> scenePaths = new List<string>();

	private static Dictionary<string, int> scenePathToBuildIndex = new Dictionary<string, int>();

	private static Dictionary<int, string> buildIndexToScenePath = new Dictionary<int, string>();

	private static Dictionary<uint, string> sceneHashToScenePath = new Dictionary<uint, string>();

	private static HookHelper.DisposableHookCollection hooks = new HookHelper.DisposableHookCollection();

	internal static bool patched { get; private set; }

	public static void AddScenePath(string scenePath)
	{
		if (!scenePaths.Contains(scenePath))
		{
			DebugHelper.Log("Adding ScenePath: " + scenePath, DebugType.User);
			scenePaths.Add(scenePath);
		}
	}

	internal static void Patch()
	{
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Expected O, but got Unknown
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Expected O, but got Unknown
		if (!patched)
		{
			patched = true;
			hooks.Hook<NetworkSceneManager>("GenerateScenesInBuild", new Action<Action<NetworkSceneManager>, NetworkSceneManager>(GenerateScenesInBuild_Hook));
			hooks.Hook<NetworkSceneManager>("SceneNameFromHash", new Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string>(SceneNameFromHash_Hook));
			hooks.Hook<NetworkSceneManager>("ValidateSceneBeforeLoading", new Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, NetworkSceneManager, int, string, LoadSceneMode, bool>(ValidateSceneBeforeLoading_Hook), new Type[3]
			{
				typeof(int),
				typeof(string),
				typeof(LoadSceneMode)
			});
			HookHelper.DisposableHookCollection disposableHookCollection = hooks;
			object obj = <>O.<3>__ReplaceBuildIndexByScenePath;
			if (obj == null)
			{
				Manipulator val = ReplaceBuildIndexByScenePath;
				<>O.<3>__ReplaceBuildIndexByScenePath = val;
				obj = (object)val;
			}
			disposableHookCollection.ILHook<NetworkSceneManager>("SceneHashFromNameOrPath", (Manipulator)obj);
			HookHelper.DisposableHookCollection disposableHookCollection2 = hooks;
			object obj2 = <>O.<3>__ReplaceBuildIndexByScenePath;
			if (obj2 == null)
			{
				Manipulator val2 = ReplaceBuildIndexByScenePath;
				<>O.<3>__ReplaceBuildIndexByScenePath = val2;
				obj2 = (object)val2;
			}
			disposableHookCollection2.ILHook<NetworkSceneManager>("ValidateSceneEvent", (Manipulator)obj2);
			HookHelper.DisposableHookCollection disposableHookCollection3 = hooks;
			object obj3 = <>O.<4>__ReplaceScenePathByBuildIndex;
			if (obj3 == null)
			{
				Manipulator val3 = ReplaceScenePathByBuildIndex;
				<>O.<4>__ReplaceScenePathByBuildIndex = val3;
				obj3 = (object)val3;
			}
			disposableHookCollection3.ILHook<NetworkSceneManager>("ScenePathFromHash", (Manipulator)obj3);
		}
	}

	internal static void Unpatch()
	{
		if (patched)
		{
			patched = false;
			hooks.Clear();
		}
	}

	private static void ReplaceScenePathByBuildIndex(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		MethodInfo methodInfo = HookHelper.methodof(new Func<int, string>(GetScenePathByBuildIndex));
		while (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetScenePathByBuildIndex")
		}))
		{
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)methodInfo);
		}
	}

	private static void ReplaceBuildIndexByScenePath(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		MethodInfo methodInfo = HookHelper.methodof(new Func<string, int>(GetBuildIndexByScenePath));
		while (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetBuildIndexByScenePath")
		}))
		{
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)methodInfo);
		}
	}

	private static string GetScenePathByBuildIndex(int buildIndex)
	{
		if (buildIndexToScenePath.ContainsKey(buildIndex))
		{
			return buildIndexToScenePath[buildIndex];
		}
		return SceneUtility.GetScenePathByBuildIndex(buildIndex);
	}

	private static int GetBuildIndexByScenePath(string scenePath)
	{
		int num = SceneUtility.GetBuildIndexByScenePath(scenePath);
		if (num == -1 && scenePathToBuildIndex.ContainsKey(scenePath))
		{
			num = scenePathToBuildIndex[scenePath];
		}
		return num;
	}

	private static void GenerateScenesInBuild_Hook(Action<NetworkSceneManager> orig, NetworkSceneManager self)
	{
		scenePathToBuildIndex.Clear();
		buildIndexToScenePath.Clear();
		sceneHashToScenePath.Clear();
		orig(self);
		int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings;
		for (int i = 0; i < scenePaths.Count; i++)
		{
			int num = sceneCountInBuildSettings + i;
			string text = scenePaths[i];
			uint num2 = XXHash.Hash32(text);
			self.HashToBuildIndex.Add(num2, num);
			self.BuildIndexToHash.Add(num, num2);
			scenePathToBuildIndex.Add(text, num);
			buildIndexToScenePath.Add(num, text);
			sceneHashToScenePath.Add(num2, text);
		}
	}

	private static string SceneNameFromHash_Hook(Func<NetworkSceneManager, uint, string> orig, NetworkSceneManager self, uint sceneHash)
	{
		if (sceneHash == 0)
		{
			return "No Scene";
		}
		if (sceneHashToScenePath.ContainsKey(sceneHash))
		{
			return sceneHashToScenePath[sceneHash];
		}
		return orig(self, sceneHash);
	}

	private static bool ValidateSceneBeforeLoading_Hook(Func<NetworkSceneManager, int, string, LoadSceneMode, bool> orig, NetworkSceneManager self, int sceneIndex, string sceneName, LoadSceneMode loadSceneMode)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		bool flag = orig(self, sceneIndex, sceneName, loadSceneMode);
		return true;
	}
}
namespace LethalLevelLoader
{
	[CreateAssetMenu(fileName = "ExtendedBuyableVehicle", menuName = "Lethal Level Loader/Extended Content/ExtendedBuyableVehicle", order = 21)]
	public class ExtendedBuyableVehicle : ExtendedContent
	{
		[field: SerializeField]
		public BuyableVehicle BuyableVehicle { get; set; }

		[field: SerializeField]
		public string TerminalKeywordName { get; set; } = string.Empty;


		public int VehicleID { get; set; }

		public TerminalNode VehicleBuyNode { get; set; }

		public TerminalNode VehicleBuyConfirmNode { get; set; }

		public TerminalNode VehicleInfoNode { get; set; }

		internal static ExtendedBuyableVehicle Create(BuyableVehicle newBuyableVehicle)
		{
			ExtendedBuyableVehicle extendedBuyableVehicle = ScriptableObject.CreateInstance<ExtendedBuyableVehicle>();
			((Object)extendedBuyableVehicle).name = ((Object)newBuyableVehicle.vehiclePrefab).name;
			extendedBuyableVehicle.BuyableVehicle = newBuyableVehicle;
			return extendedBuyableVehicle;
		}
	}
	public class ExtendedContent : ScriptableObject
	{
		public ExtendedMod ExtendedMod { get; internal set; }

		public ContentType ContentType { get; internal set; }

		public List<string> ContentTagStrings { get; internal set; } = new List<string>();


		[field: SerializeField]
		public List<ContentTag> ContentTags { get; internal set; } = new List<ContentTag>();


		public string ModName => ExtendedMod.ModName;

		public string AuthorName => ExtendedMod.AuthorName;

		internal virtual void TryCreateMatchingProperties()
		{
		}

		public bool TryGetTag(string tag)
		{
			foreach (ContentTag contentTag in ContentTags)
			{
				if (contentTag.contentTagName == tag)
				{
					return true;
				}
			}
			return false;
		}

		public bool TryGetTag(string tag, out ContentTag returnTag)
		{
			returnTag = null;
			foreach (ContentTag contentTag in ContentTags)
			{
				if (contentTag.contentTagName == tag)
				{
					returnTag = contentTag;
					return true;
				}
			}
			return false;
		}

		public bool TryAddTag(string tag)
		{
			if (!TryGetTag(tag))
			{
				ContentTags.Add(ContentTag.Create(tag));
				return true;
			}
			return false;
		}
	}
	[Serializable]
	public class StringWithRarity
	{
		[SerializeField]
		private string _name;

		[SerializeField]
		[Range(0f, 300f)]
		private int _rarity;

		[HideInInspector]
		public string Name
		{
			get
			{
				return _name;
			}
			set
			{
				_name = value;
			}
		}

		[HideInInspector]
		public int Rarity
		{
			get
			{
				return _rarity;
			}
			set
			{
				_rarity = value;
			}
		}

		[HideInInspector]
		public StringWithRarity(string newName, int newRarity)
		{
			_name = newName;
			_rarity = newRarity;
		}
	}
	[Serializable]
	public class Vector2WithRarity
	{
		[SerializeField]
		private Vector2 _minMax;

		[SerializeField]
		private int _rarity;

		[HideInInspector]
		public float Min
		{
			get
			{
				return _minMax.x;
			}
			set
			{
				_minMax.x = value;
			}
		}

		[HideInInspector]
		public float Max
		{
			get
			{
				return _minMax.y;
			}
			set
			{
				_minMax.y = value;
			}
		}

		[HideInInspector]
		public int Rarity
		{
			get
			{
				return _rarity;
			}
			set
			{
				_rarity = value;
			}
		}

		public Vector2WithRarity(Vector2 vector2, int newRarity)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			_minMax.x = vector2.x;
			_minMax.y = vector2.y;
			_rarity = newRarity;
		}

		public Vector2WithRarity(float newMin, float newMax, int newRarity)
		{
			_minMax.x = newMin;
			_minMax.y = newMax;
			_rarity = newRarity;
		}
	}
	[CreateAssetMenu(fileName = "ExtendedDungeonFlow", menuName = "Lethal Level Loader/Extended Content/ExtendedDungeonFlow", order = 21)]
	public class ExtendedDungeonFlow : ExtendedContent
	{
		[Space(25f)]
		[Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")]
		[Obsolete]
		public bool generateAutomaticConfigurationOptions = true;

		[Obsolete]
		public bool enableDynamicDungeonSizeRestriction;

		[Obsolete]
		public float dungeonSizeMin = 1f;

		[Obsolete]
		public float dungeonSizeMax = 1f;

		[Obsolete]
		[Range(0f, 1f)]
		public float dungeonSizeLerpPercentage = 1f;

		[Obsolete]
		public AudioClip dungeonFirstTimeAudio;

		[Obsolete]
		public DungeonFlow dungeonFlow;

		[Obsolete]
		public string dungeonDisplayName = string.Empty;

		[Obsolete]
		public string contentSourceName = string.Empty;

		[Obsolete]
		public List<StringWithRarity> dynamicLevelTagsList = new List<StringWithRarity>();

		[Obsolete]
		public List<Vector2WithRarity> dynamicRoutePricesList = new List<Vector2WithRarity>();

		[Obsolete]
		public List<StringWithRarity> dynamicCurrentWeatherList = new List<StringWithRarity>();

		[Obsolete]
		public List<StringWithRarity> manualPlanetNameReferenceList = new List<StringWithRarity>();

		[Obsolete]
		public List<StringWithRarity> manualContentSourceNameReferenceList = new List<StringWithRarity>();

		[Obsolete]
		[HideInInspector]
		public int dungeonDefaultRarity;

		[field: Header("General Settings")]
		[field: SerializeField]
		public DungeonFlow DungeonFlow { get; set; }

		[field: SerializeField]
		public string DungeonName { get; set; } = string.Empty;


		[field: SerializeField]
		public float MapTileSize { get; set; } = 1f;


		[field: SerializeField]
		public AudioClip FirstTimeDungeonAudio { get; set; }

		[field: Space(5f)]
		[field: Header("Dynamic Injection Matching Settings")]
		[field: SerializeField]
		public LevelMatchingProperties LevelMatchingProperties { get; set; }

		[field: Space(5f)]
		[field: Header("Extended Feature Settings")]
		[field: SerializeField]
		public GameObject OverrideKeyPrefab { get; set; }

		[field: SerializeField]
		public List<SpawnableMapObject> SpawnableMapObjects { get; set; } = new List<SpawnableMapObject>();


		[field: SerializeField]
		public List<GlobalPropCountOverride> GlobalPropCountOverridesList { get; set; } = new List<GlobalPropCountOverride>();


		[field: Space(5f)]
		[field: SerializeField]
		public bool IsDynamicDungeonSizeRestrictionEnabled { get; set; }

		[field: SerializeField]
		public Vector2 DynamicDungeonSizeMinMax { get; set; } = new Vector2(1f, 1f);


		[field: SerializeField]
		[field: Range(0f, 1f)]
		public float DynamicDungeonSizeLerpRate { get; set; } = 1f;


		[field: Space(10f)]
		[field: Header("Misc. Settings")]
		[field: SerializeField]
		public bool GenerateAutomaticConfigurationOptions { get; set; } = true;


		public int DungeonID { get; internal set; }

		public bool IsCurrentDungeon => (Object)(object)DungeonManager.CurrentExtendedDungeonFlow == (Object)(object)this;

		[HideInInspector]
		public DungeonEvents DungeonEvents { get; internal set; } = new DungeonEvents();


		internal static ExtendedDungeonFlow Create(DungeonFlow newDungeonFlow, AudioClip newFirstTimeDungeonAudio)
		{
			ExtendedDungeonFlow extendedDungeonFlow = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			extendedDungeonFlow.DungeonFlow = newDungeonFlow;
			extendedDungeonFlow.FirstTimeDungeonAudio = newFirstTimeDungeonAudio;
			if ((Object)(object)extendedDungeonFlow.LevelMatchingProperties == (Object)null)
			{
				extendedDungeonFlow.LevelMatchingProperties = LevelMatchingProperties.Create(extendedDungeonFlow);
			}
			return extendedDungeonFlow;
		}

		internal void Initialize()
		{
			if ((Object)(object)LevelMatchingProperties == (Object)null)
			{
				LevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
			GetDungeonFlowID();
			if (DungeonName == null || DungeonName == string.Empty)
			{
				DungeonName = ((Object)DungeonFlow).name;
			}
			((Object)this).name = ((Object)DungeonFlow).name.Replace("Flow", "") + "ExtendedDungeonFlow";
			if ((Object)(object)FirstTimeDungeonAudio == (Object)null)
			{
				DebugHelper.LogWarning("Custom Dungeon: " + DungeonName + " Is Missing A DungeonFirstTimeAudio Reference! Assigning Facility Audio To Prevent Errors.", DebugType.Developer);
				FirstTimeDungeonAudio = Patches.RoundManager.firstTimeDungeonAudios[0];
			}
			if ((Object)(object)OverrideKeyPrefab == (Object)null)
			{
				OverrideKeyPrefab = DungeonLoader.defaultKeyPrefab;
			}
		}

		private void GetDungeonFlowID()
		{
			if (base.ContentType == ContentType.Custom)
			{
				DungeonID = PatchedContent.ExtendedDungeonFlows.Count;
			}
			if (base.ContentType != 0)
			{
				return;
			}
			IndoorMapType[] dungeonFlowTypes = Patches.RoundManager.dungeonFlowTypes;
			foreach (IndoorMapType val in dungeonFlowTypes)
			{
				if ((Object)(object)val.dungeonFlow == (Object)(object)DungeonFlow)
				{
					DungeonID = Patches.RoundManager.dungeonFlowTypes.ToList().IndexOf(val);
				}
			}
		}

		internal override void TryCreateMatchingProperties()
		{
			if ((Object)(object)LevelMatchingProperties == (Object)null)
			{
				LevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
			LevelMatchingProperties.ApplyValues(null, manualContentSourceNameReferenceList, newPlanetNames: manualPlanetNameReferenceList, newLevelTags: dynamicLevelTagsList, newRoutePrices: dynamicRoutePricesList, newCurrentWeathers: dynamicCurrentWeatherList);
		}

		internal void ConvertObsoleteValues()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DungeonFlow == (Object)null && (Object)(object)dungeonFlow != (Object)null)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonFlow is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DungeonFlow instead.", DebugType.Developer);
				DungeonFlow = dungeonFlow;
				dungeonFlow = null;
			}
			if (string.IsNullOrEmpty(DungeonName) && !string.IsNullOrEmpty(dungeonDisplayName))
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonDisplayName is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DungeonName instead.", DebugType.Developer);
				DungeonName = dungeonDisplayName;
				dungeonDisplayName = string.Empty;
			}
			if ((Object)(object)FirstTimeDungeonAudio == (Object)null && (Object)(object)dungeonFirstTimeAudio != (Object)null)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonFirstTimeAudio is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.FirstTimeDungeonAudio instead.", DebugType.Developer);
				FirstTimeDungeonAudio = dungeonFirstTimeAudio;
				dungeonFirstTimeAudio = null;
			}
			if (dungeonSizeLerpPercentage != 1f)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonSizeLerpPercentage is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DynamicDungeonSizeLerpRate instead.", DebugType.Developer);
			}
			if (dungeonSizeMax != 1f || dungeonSizeMin != 1f)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonSizeMin and ExtendedDungeonFlow.dungeonSizeMax are Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DynamicSungeonSizeMinMax instead.", DebugType.Developer);
				DynamicDungeonSizeMinMax = new Vector2(dungeonSizeMin, dungeonSizeMax);
			}
			if (!string.IsNullOrEmpty(contentSourceName))
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.contentSourceName is Obsolete and will be removed in following releases, Please use ExtendedMod.AuthorName instead.", DebugType.Developer);
			}
			if ((Object)(object)LevelMatchingProperties == (Object)null && (dynamicLevelTagsList.Count > 0 || dynamicRoutePricesList.Count > 0 || dynamicCurrentWeatherList.Count > 0 || manualContentSourceNameReferenceList.Count > 0 || manualContentSourceNameReferenceList.Count > 0))
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow dynamic and manual match reference lists are Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.LevelMatchingProperties instead.", DebugType.Developer);
				TryCreateMatchingProperties();
			}
			if (enableDynamicDungeonSizeRestriction || IsDynamicDungeonSizeRestrictionEnabled != enableDynamicDungeonSizeRestriction)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.enableDynamicDungeonSizeRestriction Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.IsDynamicDungeonRestrictionEnabled instead.", DebugType.Developer);
				IsDynamicDungeonSizeRestrictionEnabled = enableDynamicDungeonSizeRestriction;
			}
			if (!generateAutomaticConfigurationOptions || GenerateAutomaticConfigurationOptions != generateAutomaticConfigurationOptions)
			{
				DebugHelper.LogWarning("ExtendedDungeonFlow.generateAutomaticConfigurationOptions Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.GenerateAutomaticConfigurationOptions instead.", DebugType.Developer);
				GenerateAutomaticConfigurationOptions = generateAutomaticConfigurationOptions;
			}
		}
	}
	[Serializable]
	public class GlobalPropCountOverride
	{
		public int globalPropID;

		[Range(0f, 1f)]
		public float globalPropCountScaleRate;
	}
	[Serializable]
	public class DungeonEvents
	{
		public ExtendedEvent<RoundManager> onBeforeDungeonGenerate = new ExtendedEvent<RoundManager>();

		public ExtendedEvent onShipLand = new ExtendedEvent();

		public ExtendedEvent onShipLeave = new ExtendedEvent();

		public ExtendedEvent<List<GameObject>> onSpawnedSyncedObjects = new ExtendedEvent<List<GameObject>>();

		public ExtendedEvent<List<GameObject>> onSpawnedMapObjects = new ExtendedEvent<List<GameObject>>();

		public ExtendedEvent<List<GrabbableObject>> onSpawnedScrapObjects = new ExtendedEvent<List<GrabbableObject>>();

		public ExtendedEvent<(EnemyVent, EnemyAI)> onEnemySpawnedFromVent = new ExtendedEvent<(EnemyVent, EnemyAI)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<bool> onPowerSwitchToggle = new ExtendedEvent<bool>();

		public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>();
	}
	[CreateAssetMenu(fileName = "ExtendedEnemyType", menuName = "Lethal Level Loader/Extended Content/ExtendedEnemyType", order = 24)]
	public class ExtendedEnemyType : ExtendedContent
	{
		[field: Header("General Settings")]
		[field: SerializeField]
		public EnemyType EnemyType { get; set; }

		[field: SerializeField]
		public string EnemyDisplayName { get; set; }

		[field: Space(5f)]
		[field: Header("Dynamic Injection Matching Settings")]
		[field: SerializeField]
		public LevelMatchingProperties OutsideLevelMatchingProperties { get; set; }

		[field: SerializeField]
		public LevelMatchingProperties DaytimeLevelMatchingProperties { get; set; }

		[field: SerializeField]
		public LevelMatchingProperties InsideLevelMatchingProperties { get; set; }

		[field: SerializeField]
		public DungeonMatchingProperties InsideDungeonMatchingProperties { get; set; }

		[field: Space(5f)]
		[field: Header("Terminal Bestiary Override Settings")]
		[field: SerializeField]
		[field: TextArea(2, 20)]
		public string InfoNodeDescription { get; set; } = string.Empty;


		[field: SerializeField]
		public VideoClip InfoNodeVideoClip { get; set; }

		public ScanNodeProperties ScanNodeProperties { get; internal set; }

		public int EnemyID { get; internal set; }

		public TerminalNode EnemyInfoNode { get; internal set; }

		public static ExtendedEnemyType Create(EnemyType enemyType, ExtendedMod extendedMod, ContentType contentType)
		{
			ExtendedEnemyType extendedEnemyType = ScriptableObject.CreateInstance<ExtendedEnemyType>();
			extendedEnemyType.EnemyType = enemyType;
			((Object)extendedEnemyType).name = enemyType.enemyName.SkipToLetters().RemoveWhitespace() + "ExtendedEnemyType";
			extendedEnemyType.ContentType = contentType;
			extendedMod.RegisterExtendedContent(extendedEnemyType);
			extendedEnemyType.TryCreateMatchingProperties();
			return extendedEnemyType;
		}

		public void Initalize()
		{
			DebugHelper.Log("Initializing Custom Enemy: " + EnemyType.enemyName, DebugType.Developer);
			TryCreateMatchingProperties();
		}

		internal override void TryCreateMatchingProperties()
		{
			if ((Object)(object)InsideLevelMatchingProperties == (Object)null)
			{
				InsideLevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
			if ((Object)(object)InsideDungeonMatchingProperties == (Object)null)
			{
				InsideDungeonMatchingProperties = DungeonMatchingProperties.Create(this);
			}
			if ((Object)(object)OutsideLevelMatchingProperties == (Object)null)
			{
				OutsideLevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
			if ((Object)(object)DaytimeLevelMatchingProperties == (Object)null)
			{
				DaytimeLevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
		}
	}
	[CreateAssetMenu(fileName = "ExtendedFootstepSurface", menuName = "Lethal Level Loader/Extended Content/ExtendedFootstepSurface", order = 27)]
	public class ExtendedFootstepSurface : ExtendedContent
	{
		public FootstepSurface footstepSurface;

		public List<Material> associatedMaterials;
	}
	[CreateAssetMenu(fileName = "ExtendedItem", menuName = "Lethal Level Loader/Extended Content/ExtendedItem", order = 23)]
	public class ExtendedItem : ExtendedContent
	{
		[field: Header("General Settings")]
		[field: SerializeField]
		public Item Item { get; set; }

		[field: SerializeField]
		public string PluralisedItemName { get; set; } = string.Empty;


		[field: SerializeField]
		public bool IsBuyableItem { get; set; }

		[field: Space(5f)]
		[field: Header("Dynamic Injection Matching Settings")]
		[field: SerializeField]
		public LevelMatchingProperties LevelMatchingProperties { get; set; }

		[field: SerializeField]
		public DungeonMatchingProperties DungeonMatchingProperties { get; set; }

		[field: Space(5f)]
		[field: Header("Terminal Store & Info Override Settings")]
		[field: SerializeField]
		public string OverrideInfoNodeDescription { get; set; } = string.Empty;


		[field: SerializeField]
		public string OverrideBuyNodeDescription { get; set; } = string.Empty;


		[field: SerializeField]
		public string OverrideBuyConfirmNodeDescription { get; set; } = string.Empty;


		public TerminalNode BuyNode { get; internal set; }

		public TerminalNode BuyConfirmNode { get; internal set; }

		public TerminalNode BuyInfoNode { get; internal set; }

		public int CreditsWorth
		{
			get
			{
				if ((Object)(object)BuyNode != (Object)null && (Object)(object)BuyConfirmNode != (Object)null)
				{
					BuyNode.itemCost = Item.creditsWorth;
					BuyConfirmNode.itemCost = Item.creditsWorth;
				}
				else
				{
					Debug.LogWarning((object)"BuyNode And/Or BuyConfirm Node Missing!");
				}
				return Item.creditsWorth;
			}
			set
			{
				if (value >= 0)
				{
					if ((Object)(object)BuyNode != (Object)null && (Object)(object)BuyConfirmNode != (Object)null)
					{
						BuyNode.itemCost = value;
						BuyConfirmNode.itemCost = value;
					}
					else
					{
						Debug.LogWarning((object)"BuyNode And/Or BuyConfirm Node Missing!");
					}
					Item.creditsWorth = value;
				}
			}
		}

		public static ExtendedItem Create(Item newItem, ExtendedMod extendedMod, ContentType contentType)
		{
			ExtendedItem extendedItem = ScriptableObject.CreateInstance<ExtendedItem>();
			extendedItem.Item = newItem;
			((Object)extendedItem).name = newItem.itemName.SkipToLetters().RemoveWhitespace() + "ExtendedItem";
			extendedItem.ContentType = contentType;
			extendedMod.RegisterExtendedContent(extendedItem);
			extendedItem.TryCreateMatchingProperties();
			return extendedItem;
		}

		public void Initialize()
		{
			DebugHelper.Log("Initializing Custom Item: " + Item.itemName + ". Is Buyable: " + IsBuyableItem + ". Is Scrap: " + Item.isScrap, DebugType.Developer);
			TryCreateMatchingProperties();
			Patches.StartOfRound.allItemsList.itemsList.Add(Item);
			if (IsBuyableItem)
			{
				TerminalManager.CreateItemTerminalData(this);
			}
		}

		internal override void TryCreateMatchingProperties()
		{
			if ((Object)(object)LevelMatchingProperties == (Object)null)
			{
				LevelMatchingProperties = LevelMatchingProperties.Create(this);
			}
			if ((Object)(object)DungeonMatchingProperties == (Object)null)
			{
				DungeonMatchingProperties = DungeonMatchingProperties.Create(this);
			}
		}

		public void SetLevelMatchingProperties(LevelMatchingProperties newLevelMatchingProperties)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Debug.LogError((object)"SetLevelMatchingProperties() Should Only Be Used In Editor!");
			}
			LevelMatchingProperties = newLevelMatchingProperties;
		}
	}
	[CreateAssetMenu(fileName = "ExtendedLevel", menuName = "Lethal Level Loader/Extended Content/ExtendedLevel", order = 20)]
	public class ExtendedLevel : ExtendedContent
	{
		[Space(5f)]
		[SerializeField]
		private int routePrice;

		[Space(25f)]
		[Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")]
		[Obsolete]
		public SelectableLevel selectableLevel;

		[Obsolete]
		[Space(5f)]
		public string contentSourceName = string.Empty;

		[Obsolete]
		[Space(5f)]
		public List<string> levelTags = new List<string>();

		[field: Header("General Settings")]
		[field: SerializeField]
		public SelectableLevel SelectableLevel { get; set; }

		[field: Header("Extended Feature Settings")]
		[field: SerializeField]
		public bool OverrideDynamicRiskLevelAssignment { get; set; }

		[field: Space(5f)]
		[field: SerializeField]
		public GameObject OverrideQuicksandPrefab { get; set; }

		[field: Space(5f)]
		[field: SerializeField]
		public bool IsRouteHidden { get; set; }

		[field: SerializeField]
		public bool IsRouteLocked { get; set; }

		[field: SerializeField]
		public string LockedRouteNodeText { get; set; } = string.Empty;


		[field: Space(5f)]
		[field: SerializeField]
		public AnimationClip ShipFlyToMoonClip { get; set; }

		[field: SerializeField]
		public AnimationClip ShipFlyFromMoonClip { get; set; }

		[field: Space(5f)]
		[field: SerializeField]
		public List<StringWithRarity> SceneSelections { get; set; } = new List<StringWithRarity>();


		[field: Space(5f)]
		[field: Header("Weather Fog Distance Override Settings")]
		[field: SerializeField]
		public Vector3 OverrideDustStormVolumeSize { get; set; } = Vector3.zero;


		[field: SerializeField]
		public Vector3 OverrideFoggyVolumeSize { get; set; } = Vector3.zero;


		[field: Space(5f)]
		[field: Header("Terminal Route Override Settings")]
		[field: SerializeField]
		[field: TextArea(2, 20)]
		public string OverrideInfoNodeDescription { get; set; } = string.Empty;


		[field: SerializeField]
		[field: TextArea(2, 20)]
		public string OverrideRouteNodeDescription { get; set; } = string.Empty;


		[field: SerializeField]
		[field: TextArea(2, 20)]
		public string OverrideRouteConfirmNodeDescription { get; set; } = string.Empty;


		[field: Space(10f)]
		[field: Header("Misc. Settings")]
		[field: Space(5f)]
		[field: SerializeField]
		public bool GenerateAutomaticConfigurationOptions { get; set; } = true;


		public int RoutePrice
		{
			get
			{
				if ((Object)(object)RouteNode != (Object)null)
				{
					routePrice = RouteNode.itemCost;
					RouteConfirmNode.itemCost = routePrice;
					return RouteNode.itemCost;
				}
				DebugHelper.LogWarning("routeNode Is Missing! Using internal value!", DebugType.Developer);
				return routePrice;
			}
			set
			{
				if ((Object)(object)RouteNode != (Object)null && (Object)(object)RouteConfirmNode != (Object)null)
				{
					RouteNode.itemCost = value;
					RouteConfirmNode.itemCost = value;
				}
				else
				{
					DebugHelper.LogWarning("routeNode Is Missing! Only setting internal value!", DebugType.Developer);
				}
				routePrice = value;
			}
		}

		public string NumberlessPlanetName => GetNumberlessPlanetName(SelectableLevel);

		public int CalculatedDifficultyRating => LevelManager.CalculateExtendedLevelDifficultyRating(this);

		public bool IsCurrentLevel => (Object)(object)LevelManager.CurrentExtendedLevel == (Object)(object)this;

		public bool IsLevelLoaded
		{
			get
			{
				//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)
				Scene sceneByName = SceneManager.GetSceneByName(SelectableLevel.sceneName);
				return ((Scene)(ref sceneByName)).isLoaded;
			}
		}

		[HideInInspector]
		public LevelEvents LevelEvents { get; internal set; } = new LevelEvents();


		public TerminalNode RouteNode { get; internal set; }

		public TerminalNode RouteConfirmNode { get; internal set; }

		public TerminalNode InfoNode { get; internal set; }

		public List<ExtendedWeatherEffect> EnabledExtendedWeatherEffects { get; set; } = new List<ExtendedWeatherEffect>();


		public ExtendedWeatherEffect CurrentExtendedWeatherEffect { get; set; }

		internal static ExtendedLevel Create(SelectableLevel newSelectableLevel)
		{
			ExtendedLevel extendedLevel = ScriptableObject.CreateInstance<ExtendedLevel>();
			extendedLevel.SelectableLevel = newSelectableLevel;
			return extendedLevel;
		}

		internal void Initialize(string newContentSourceName, bool generateTerminalAssets)
		{
			bool flag = false;
			foreach (StringWithRarity sceneSelection in SceneSelections)
			{
				if (sceneSelection.Name == SelectableLevel.sceneName)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				StringWithRarity item = new StringWithRarity(SelectableLevel.sceneName, 300);
				SceneSelections.Add(item);
			}
			foreach (StringWithRarity item2 in new List<StringWithRarity>(SceneSelections))
			{
				if (!PatchedContent.AllLevelSceneNames.Contains(item2.Name))
				{
					DebugHelper.LogWarning("Removing SceneSelection From: " + SelectableLevel.PlanetName + " As SceneName: " + item2.Name + " Is Not Loaded!", DebugType.Developer);
					SceneSelections.Remove(item2);
				}
			}
			if ((Object)(object)ShipFlyToMoonClip == (Object)null)
			{
				ShipFlyToMoonClip = LevelLoader.defaultShipFlyToMoonClip;
			}
			if ((Object)(object)ShipFlyFromMoonClip == (Object)null)
			{
				ShipFlyFromMoonClip = LevelLoader.defaultShipFlyFromMoonClip;
			}
			if ((Object)(object)OverrideQuicksandPrefab == (Object)null)
			{
				OverrideQuicksandPrefab = LevelLoader.defaultQuicksandPrefab;
			}
			if (base.ContentType == ContentType.Custom)
			{
				((Object)this).name = NumberlessPlanetName.StripSpecialCharacters() + "ExtendedLevel";
				((Object)SelectableLevel).name = NumberlessPlanetName.StripSpecialCharacters() + "Level";
				if (generateTerminalAssets)
				{
					TerminalManager.CreateLevelTerminalData(this, routePrice);
				}
			}
			if (base.ContentType == ContentType.Vanilla)
			{
				GetVanillaInfoNode();
			}
			SetExtendedDungeonFlowMatches();
		}

		internal void ConvertObsoleteValues()
		{
			if (levelTags.Count > 0 && base.ContentTags.Count == 0)
			{
				DebugHelper.LogWarning("ExtendedLevel.levelTags Is Obsolete and will be removed in following releases, Please use .ContentTags instead.", DebugType.Developer);
				foreach (ContentTag item in ContentTagManager.CreateNewContentTags(levelTags))
				{
					base.ContentTags.Add(item);
				}
			}
			levelTags.Clear();
			if ((Object)(object)SelectableLevel == (Object)null && (Object)(object)selectableLevel != (Object)null)
			{
				DebugHelper.LogWarning("ExtendedLevel.selectableLevel Is Obsolete and will be removed in following releases, Please use .SelectableLevel instead.", DebugType.Developer);
				SelectableLevel = selectableLevel;
			}
			if (!string.IsNullOrEmpty(contentSourceName))
			{
				DebugHelper.LogWarning("ExtendedLevel.contentSourceName is Obsolete and will be removed in following releases, Please use ExtendedMod.AuthorName instead.", DebugType.Developer);
			}
		}

		internal static string GetNumberlessPlanetName(SelectableLevel selectableLevel)
		{
			if ((Object)(object)selectableLevel != (Object)null)
			{
				return new string(selectableLevel.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
			}
			return string.Empty;
		}

		internal void SetLevelID()
		{
			if (base.ContentType == ContentType.Custom)
			{
				SelectableLevel.levelID = PatchedContent.ExtendedLevels.IndexOf(this);
				if ((Object)(object)RouteNode != (Object)null)
				{
					RouteNode.displayPlanetInfo = SelectableLevel.levelID;
				}
				if ((Object)(object)RouteConfirmNode != (Object)null)
				{
					RouteConfirmNode.buyRerouteToMoon = SelectableLevel.levelID;
				}
			}
		}

		internal void SetExtendedDungeonFlowMatches()
		{
			IntWithRarity[] dungeonFlowTypes = SelectableLevel.dungeonFlowTypes;
			foreach (IntWithRarity val in dungeonFlowTypes)
			{
				if (DungeonManager.TryGetExtendedDungeonFlow(Patches.RoundManager.dungeonFlowTypes[val.id].dungeonFlow, out var returnExtendedDungeonFlow))
				{
					returnExtendedDungeonFlow.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, val.rarity));
				}
			}
			if (!(SelectableLevel.sceneName == "Level4March"))
			{
				return;
			}
			IndoorMapType[] dungeonFlowTypes2 = Patches.RoundManager.dungeonFlowTypes;
			foreach (IndoorMapType val2 in dungeonFlowTypes2)
			{
				if (((Object)val2.dungeonFlow).name == "Level1Flow3Exits" && DungeonManager.TryGetExtendedDungeonFlow(val2.dungeonFlow, out var returnExtendedDungeonFlow2))
				{
					returnExtendedDungeonFlow2.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, 300));
				}
			}
		}

		internal void GetVanillaInfoNode()
		{
			CompatibleNoun[] compatibleNouns = TerminalManager.routeInfoKeyword.compatibleNouns;
			foreach (CompatibleNoun val in compatibleNouns)
			{
				if (val.noun.word == NumberlessPlanetName.ToLower())
				{
					InfoNode = val.result;
					break;
				}
			}
		}

		public void ForceSetRoutePrice(int newValue)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Debug.LogWarning((object)"ForceSetRoutePrice Should Only Be Used In Editor! Consider Using RoutePrice Property To Sync TerminalNode's With New Value.");
			}
			routePrice = newValue;
		}
	}
	[Serializable]
	public class LevelEvents
	{
		public ExtendedEvent onLevelLoaded = new ExtendedEvent();

		public ExtendedEvent onShipLand = new ExtendedEvent();

		public ExtendedEvent onShipLeave = new ExtendedEvent();

		public ExtendedEvent<EnemyAI> onDaytimeEnemySpawn = new ExtendedEvent<EnemyAI>();

		public ExtendedEvent<EnemyAI> onNighttimeEnemySpawn = new ExtendedEvent<EnemyAI>();

		public ExtendedEvent<StoryLog> onStoryLogCollected = new ExtendedEvent<StoryLog>();

		public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>();

		public ExtendedEvent<bool> onPowerSwitchToggle = new ExtendedEvent<bool>();

		public ExtendedEvent<DayMode> onDayModeToggle = new ExtendedEvent<DayMode>();
	}
	public enum ModMergeSetting
	{
		MatchingAuthorName,
		MatchingModName,
		Disabled
	}
	[CreateAssetMenu(fileName = "ExtendedMod", menuName = "Lethal Level Loader/ExtendedMod", order = 30)]
	public class ExtendedMod : ScriptableObject
	{
		[field: SerializeField]
		public string ModName { get; internal set; } = "Unspecified";


		[field: SerializeField]
		public string AuthorName { get; internal set; } = "Unknown";


		public List<string> ModNameAliases { get; internal set; } = new List<string>();


		[field: SerializeField]
		public ModMergeSetting ModMergeSetting { get; internal set; }

		[field: SerializeField]
		public List<ExtendedLevel> ExtendedLevels { get; private set; } = new List<ExtendedLevel>();


		[field: SerializeField]
		public List<ExtendedDungeonFlow> ExtendedDungeonFlows { get; private set; } = new List<ExtendedDungeonFlow>();


		[field: SerializeField]
		public List<ExtendedItem> ExtendedItems { get; private set; } = new List<ExtendedItem>();


		[field: SerializeField]
		public List<ExtendedEnemyType> ExtendedEnemyTypes { get; private set; } = new List<ExtendedEnemyType>();


		[field: SerializeField]
		public List<ExtendedWeatherEffect> ExtendedWeatherEffects { get; private set; } = new List<ExtendedWeatherEffect>();


		[field: SerializeField]
		public List<ExtendedFootstepSurface> ExtendedFootstepSurfaces { get; private set; } = new List<ExtendedFootstepSurface>();


		[field: SerializeField]
		public List<ExtendedStoryLog> ExtendedStoryLogs { get; private set; } = new List<ExtendedStoryLog>();


		[field: SerializeField]
		public List<ExtendedBuyableVehicle> ExtendedBuyableVehicles { get; private set; } = new List<ExtendedBuyableVehicle>();


		public List<ExtendedContent> ExtendedContents
		{
			get
			{
				List<ExtendedContent> list = new List<ExtendedContent>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					list.Add(extendedLevel);
				}
				foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
				{
					list.Add(extendedDungeonFlow);
				}
				foreach (ExtendedItem extendedItem in ExtendedItems)
				{
					list.Add(extendedItem);
				}
				foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes)
				{
					list.Add(extendedEnemyType);
				}
				foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects)
				{
					list.Add(extendedWeatherEffect);
				}
				foreach (ExtendedFootstepSurface extendedFootstepSurface in ExtendedFootstepSurfaces)
				{
					list.Add(extendedFootstepSurface);
				}
				foreach (ExtendedStoryLog extendedStoryLog in ExtendedStoryLogs)
				{
					list.Add(extendedStoryLog);
				}
				foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles)
				{
					list.Add(extendedBuyableVehicle);
				}
				return list;
			}
		}

		internal static ExtendedMod Create(string modName)
		{
			ExtendedMod extendedMod = ScriptableObject.CreateInstance<ExtendedMod>();
			extendedMod.ModName = modName;
			((Object)extendedMod).name = modName.Sanitized() + "Mod";
			DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName, DebugType.Developer);
			return extendedMod;
		}

		public static ExtendedMod Create(string modName, string authorName)
		{
			ExtendedMod extendedMod = ScriptableObject.CreateInstance<ExtendedMod>();
			extendedMod.ModName = modName;
			((Object)extendedMod).name = modName.SkipToLetters().RemoveWhitespace() + "Mod";
			extendedMod.AuthorName = authorName;
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName + " by " + authorName, DebugType.Developer);
			}
			return extendedMod;
		}

		public static ExtendedMod Create(string modName, string authorName, ExtendedContent[] extendedContents)
		{
			ExtendedMod extendedMod = ScriptableObject.CreateInstance<ExtendedMod>();
			extendedMod.ModName = modName;
			((Object)extendedMod).name = modName.SkipToLetters().RemoveWhitespace() + "Mod";
			extendedMod.AuthorName = authorName;
			foreach (ExtendedContent newExtendedContent in extendedContents)
			{
				extendedMod.RegisterExtendedContent(newExtendedContent);
			}
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName + " by " + authorName, DebugType.Developer);
			}
			return extendedMod;
		}

		internal void RegisterExtendedContent(ExtendedContent newExtendedContent)
		{
			if ((Object)(object)newExtendedContent != (Object)null)
			{
				if (!ExtendedContents.Contains(newExtendedContent))
				{
					if (newExtendedContent is ExtendedLevel extendedLevel)
					{
						RegisterExtendedContent(extendedLevel);
						return;
					}
					if (newExtendedContent is ExtendedDungeonFlow extendedDungeonFlow)
					{
						RegisterExtendedContent(extendedDungeonFlow);
						return;
					}
					if (newExtendedContent is ExtendedItem extendedItem)
					{
						RegisterExtendedContent(extendedItem);
						return;
					}
					if (newExtendedContent is ExtendedEnemyType extendedEnemyType)
					{
						RegisterExtendedContent(extendedEnemyType);
						return;
					}
					if (newExtendedContent is ExtendedWeatherEffect extendedWeatherEffect)
					{
						RegisterExtendedContent(extendedWeatherEffect);
						return;
					}
					if (newExtendedContent is ExtendedFootstepSurface extendedFootstepSurface)
					{
						RegisterExtendedContent(extendedFootstepSurface);
						return;
					}
					if (newExtendedContent is ExtendedStoryLog extendedStoryLog)
					{
						RegisterExtendedContent(extendedStoryLog);
						return;
					}
					throw new ArgumentException("newExtendedContent", ((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ")  Could Not Be Registered To ExtendedMod: " + ModName + " Due To Unimplemented Registration Check!");
				}
				throw new ArgumentException("newExtendedContent", ((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ")  Could Not Be Registered To ExtendedMod: " + ModName + " Due To Already Being Registered To This Mod!");
			}
			throw new ArgumentNullException("newExtendedContent", "Null ExtendedContent Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check!");
		}

		internal void RegisterExtendedContent(ExtendedLevel extendedLevel)
		{
			extendedLevel.ConvertObsoleteValues();
			TryThrowInvalidContentException(extendedLevel, Validators.ValidateExtendedContent(extendedLevel));
			ExtendedLevels.Add(extendedLevel);
			extendedLevel.ContentTags.Add(ContentTag.Create("Custom"));
			extendedLevel.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedDungeonFlow extendedDungeonFlow)
		{
			extendedDungeonFlow.ConvertObsoleteValues();
			TryThrowInvalidContentException(extendedDungeonFlow, Validators.ValidateExtendedContent(extendedDungeonFlow));
			ExtendedDungeonFlows.Add(extendedDungeonFlow);
			extendedDungeonFlow.ContentTags.Add(ContentTag.Create("Custom"));
			extendedDungeonFlow.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedItem extendedItem)
		{
			TryThrowInvalidContentException(extendedItem, Validators.ValidateExtendedContent(extendedItem));
			ExtendedItems.Add(extendedItem);
			extendedItem.ContentTags.Add(ContentTag.Create("Custom"));
			extendedItem.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedEnemyType extendedEnemyType)
		{
			TryThrowInvalidContentException(extendedEnemyType, Validators.ValidateExtendedContent(extendedEnemyType));
			ExtendedEnemyTypes.Add(extendedEnemyType);
			extendedEnemyType.ContentTags.Add(ContentTag.Create("Custom"));
			extendedEnemyType.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedWeatherEffect extendedWeatherEffect)
		{
			TryThrowInvalidContentException(extendedWeatherEffect, Validators.ValidateExtendedContent(extendedWeatherEffect));
			ExtendedWeatherEffects.Add(extendedWeatherEffect);
			extendedWeatherEffect.ContentTags.Add(ContentTag.Create("Custom"));
			extendedWeatherEffect.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedFootstepSurface extendedFootstepSurface)
		{
			TryThrowInvalidContentException(extendedFootstepSurface, Validators.ValidateExtendedContent(extendedFootstepSurface));
			ExtendedFootstepSurfaces.Add(extendedFootstepSurface);
			extendedFootstepSurface.ContentTags.Add(ContentTag.Create("Custom"));
			extendedFootstepSurface.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedStoryLog extendedStoryLog)
		{
			TryThrowInvalidContentException(extendedStoryLog, Validators.ValidateExtendedContent(extendedStoryLog));
			ExtendedStoryLogs.Add(extendedStoryLog);
			extendedStoryLog.ContentTags.Add(ContentTag.Create("Custom"));
			extendedStoryLog.ExtendedMod = this;
		}

		internal void RegisterExtendedContent(ExtendedBuyableVehicle extendedBuyableVehicle)
		{
			TryThrowInvalidContentException(extendedBuyableVehicle, Validators.ValidateExtendedContent(extendedBuyableVehicle));
			ExtendedBuyableVehicles.Add(extendedBuyableVehicle);
			extendedBuyableVehicle.ContentTags.Add(ContentTag.Create("Custom"));
			extendedBuyableVehicle.ExtendedMod = this;
		}

		internal void TryThrowInvalidContentException(ExtendedContent extendedContent, (bool, string) result)
		{
			if (!result.Item1)
			{
				if ((Object)(object)extendedContent == (Object)null)
				{
					throw new ArgumentNullException("extendedContent", "Null ExtendedContent Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check! " + result.Item2);
				}
				throw new ArgumentException("extendedContent", ((Object)extendedContent).name + " (" + ((object)extendedContent).GetType().Name + ")  Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check! " + result.Item2);
			}
		}

		internal void UnregisterExtendedContent(ExtendedContent currentExtendedContent)
		{
			if (currentExtendedContent is ExtendedLevel item)
			{
				ExtendedLevels.Remove(item);
			}
			else if (currentExtendedContent is ExtendedDungeonFlow item2)
			{
				ExtendedDungeonFlows.Remove(item2);
			}
			else if (currentExtendedContent is ExtendedItem item3)
			{
				ExtendedItems.Remove(item3);
			}
			currentExtendedContent.ExtendedMod = null;
			DebugHelper.LogWarning("Unregistered ExtendedContent: " + ((Object)currentExtendedContent).name + " In ExtendedMod: " + ModName, DebugType.Developer);
		}

		internal void UnregisterAllExtendedContent()
		{
			ExtendedLevels.Clear();
			ExtendedDungeonFlows.Clear();
			ExtendedItems.Clear();
			ExtendedEnemyTypes.Clear();
			ExtendedWeatherEffects.Clear();
			ExtendedFootstepSurfaces.Clear();
			ExtendedStoryLogs.Clear();
			ExtendedBuyableVehicles.Clear();
		}

		internal void SortRegisteredContent()
		{
			ExtendedLevels.Sort((ExtendedLevel s1, ExtendedLevel s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedDungeonFlows.Sort((ExtendedDungeonFlow s1, ExtendedDungeonFlow s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedItems.Sort((ExtendedItem s1, ExtendedItem s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedEnemyTypes.Sort((ExtendedEnemyType s1, ExtendedEnemyType s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedWeatherEffects.Sort((ExtendedWeatherEffect s1, ExtendedWeatherEffect s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedFootstepSurfaces.Sort((ExtendedFootstepSurface s1, ExtendedFootstepSurface s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedStoryLogs.Sort((ExtendedStoryLog s1, ExtendedStoryLog s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
			ExtendedBuyableVehicles.Sort((ExtendedBuyableVehicle s1, ExtendedBuyableVehicle s2) => ((Object)s1).name.CompareTo(((Object)s2).name));
		}

		internal void Example()
		{
			AssetBundle val = null;
			ExtendedDungeonFlow extendedDungeonFlow = val.LoadAsset<ExtendedDungeonFlow>("Assets/CoolDungeonFlow");
			ExtendedEnemyType extendedEnemyType = val.LoadAsset<ExtendedEnemyType>("Assets/Ghost");
			ExtendedMod extendedMod = Create("BatbysMod", "IAmBatby", new ExtendedContent[2] { extendedDungeonFlow, extendedEnemyType });
			PatchedContent.RegisterExtendedMod(extendedMod);
		}
	}
	[CreateAssetMenu(fileName = "ExtendedStoryLog", menuName = "Lethal Level Loader/Extended Content/ExtendedStoryLog", order = 26)]
	public class ExtendedStoryLog : ExtendedContent
	{
		public string sceneName = string.Empty;

		public int storyLogID;

		[Space(5f)]
		public string terminalKeywordNoun = string.Empty;

		[Space(5f)]
		public string storyLogTitle = string.Empty;

		[TextArea]
		public string storyLogDescription = string.Empty;

		[HideInInspector]
		internal int newStoryLogID;
	}
	[CreateAssetMenu(fileName = "ExtendedWeatherEffect", menuName = "Lethal Level Loader/Extended Content/ExtendedWeatherEffect", order = 25)]
	public class ExtendedWeatherEffect : ExtendedContent
	{
		public ContentType contentType;

		[field: Header("General Settings")]
		[field: SerializeField]
		public LevelWeatherType BaseWeatherType { get; set; } = (LevelWeatherType)(-1);


		[field: SerializeField]
		public string WeatherDisplayName { get; set; } = string.Empty;


		[field: SerializeField]
		public GameObject WorldObject { get; set; }

		[field: SerializeField]
		public GameObject GlobalObject { get; set; }

		internal static ExtendedWeatherEffect Create(LevelWeatherType levelWeatherType, WeatherEffect weatherEffect, string weatherDisplayName, ContentType newContentType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Create(levelWeatherType, weatherEffect.effectObject, weatherEffect.effectPermanentObject, weatherDisplayName, newContentType);
		}

		internal static ExtendedWeatherEffect Create(LevelWeatherType levelWeatherType, GameObject worldObject, GameObject globalObject, string newWeatherDisplayName, ContentType newContentType)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ExtendedWeatherEffect extendedWeatherEffect = ScriptableObject.CreateInstance<ExtendedWeatherEffect>();
			extendedWeatherEffect.WeatherDisplayName = newWeatherDisplayName;
			((Object)extendedWeatherEffect).name = extendedWeatherEffect.WeatherDisplayName + "ExtendedWeatherEffect";
			extendedWeatherEffect.BaseWeatherType = levelWeatherType;
			extendedWeatherEffect.WorldObject = worldObject;
			extendedWeatherEffect.GlobalObject = globalObject;
			return extendedWeatherEffect;
		}
	}
	public class LLLSaveFile : ModDataContainer
	{
		public int parityStepsTaken;

		public Dictionary<int, AllItemsListItemData> itemSaveData = new Dictionary<int, AllItemsListItemData>();

		public string CurrentLevelName { get; internal set; } = string.Empty;


		public void Reset()
		{
			CurrentLevelName = string.Empty;
			parityStepsTaken = 0;
			itemSaveData = new Dictionary<int, AllItemsListItemData>();
		}
	}
	public struct AllItemsListItemData
	{
		public string itemObjectName;

		public string itemName;

		public string modName;

		public string modAuthor;

		public int allItemsListIndex;

		public int modItemsListIndex;

		public int itemNameDuplicateIndex;

		public bool isScrap;

		public bool saveItemVariable;

		public AllItemsListItemData(string newItemObjectName, string newItemName, string newModName, string newModAuthor, int newAllItemsListIndex, int newModItemsListIndex, int newItemNameDuplicateIndex, bool newIsScrap, bool newSaveItemVariable)
		{
			itemObjectName = newItemObjectName;
			itemName = newItemName;
			modName = newModName;
			modAuthor = newModAuthor;
			allItemsListIndex = newAllItemsListIndex;
			modItemsListIndex = newModItemsListIndex;
			itemNameDuplicateIndex = newItemNameDuplicateIndex;
			isScrap = newIsScrap;
			saveItemVariable = newSaveItemVariable;
		}
	}
	[CreateAssetMenu(fileName = "ContentTag", menuName = "Lethal Level Loader/Utility/ContentTag", order = 11)]
	public class ContentTag : ScriptableObject
	{
		public string contentTagName;

		public Color contentTagColor;

		public static ContentTag Create(string tag, Color color)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			ContentTag contentTag = ScriptableObject.CreateInstance<ContentTag>();
			contentTag.contentTagName = tag;
			contentTag.contentTagColor = color;
			((Object)contentTag).name = tag + "ContentTag";
			return contentTag;
		}

		public static ContentTag Create(string tag)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Create(tag, Color.white);
		}
	}
	[CreateAssetMenu(fileName = "DungeonMatchingProperties", menuName = "Lethal Level Loader/Utility/DungeonMatchingProperties", order = 13)]
	public class DungeonMatchingProperties : MatchingProperties
	{
		[Space(5f)]
		public List<StringWithRarity> dungeonTags = new List<StringWithRarity>();

		[Space(5f)]
		public List<StringWithRarity> dungeonNames = new List<StringWithRarity>();

		public new static DungeonMatchingProperties Create(ExtendedContent extendedContent)
		{
			DungeonMatchingProperties dungeonMatchingProperties = ScriptableObject.CreateInstance<DungeonMatchingProperties>();
			((Object)dungeonMatchingProperties).name = ((Object)extendedContent).name + "DungeonMatchingProperties";
			return dungeonMatchingProperties;
		}

		public int GetDynamicRarity(ExtendedDungeonFlow extendedDungeonFlow)
		{
			int currentValue = 0;
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedTags(extendedDungeonFlow.ContentTags, dungeonNames), ((Object)extendedDungeonFlow).name, "Content Tags");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedDungeonFlow.AuthorName, authorNames), ((Object)extendedDungeonFlow).name, "Author Name");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedStrings(extendedDungeonFlow.ExtendedMod.ModNameAliases, modNames), ((Object)extendedDungeonFlow).name, "Mod Name Name");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(((Object)extendedDungeonFlow.DungeonFlow).name, dungeonNames), ((Object)extendedDungeonFlow).name, "Dungeon Name");
			return currentValue;
		}

		public void ApplyValues(List<StringWithRarity> newModNames = null, List<StringWithRarity> newAuthorNames = null, List<StringWithRarity> newDungeonTags = null, List<StringWithRarity> newDungeonNames = null)
		{
			if (newModNames != null && newModNames.Count != 0)
			{
				modNames = new List<StringWithRarity>(newModNames);
			}
			if (newAuthorNames != null && newAuthorNames.Count != 0)
			{
				authorNames = new List<StringWithRarity>(newAuthorNames);
			}
			if (newDungeonTags != null && newDungeonTags.Count != 0)
			{
				dungeonTags = new List<StringWithRarity>(newDungeonTags);
			}
			if (newDungeonNames != null && newDungeonNames.Count != 0)
			{
				dungeonNames = new List<StringWithRarity>(newDungeonNames);
			}
		}
	}
	[CreateAssetMenu(fileName = "LevelMatchingProperties", menuName = "Lethal Level Loader/Utility/LevelMatchingProperties", order = 12)]
	public class LevelMatchingProperties : MatchingProperties
	{
		[Space(5f)]
		public List<StringWithRarity> levelTags = new List<StringWithRarity>();

		[Space(5f)]
		public List<Vector2WithRarity> currentRoutePrice = new List<Vector2WithRarity>();

		[Space(5f)]
		public List<StringWithRarity> currentWeather = new List<StringWithRarity>();

		[Space(5f)]
		public List<StringWithRarity> planetNames = new List<StringWithRarity>();

		public new static LevelMatchingProperties Create(ExtendedContent extendedContent)
		{
			LevelMatchingProperties levelMatchingProperties = ScriptableObject.CreateInstance<LevelMatchingProperties>();
			((Object)levelMatchingProperties).name = ((Object)extendedContent).name + "LevelMatchingProperties";
			return levelMatchingProperties;
		}

		public int GetDynamicRarity(ExtendedLevel extendedLevel)
		{
			int currentValue = 0;
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedTags(extendedLevel.ContentTags, levelTags), ((Object)extendedLevel).name, "Content Tags");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedLevel.AuthorName, authorNames), ((Object)extendedLevel).name, "Author Name");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedStrings(extendedLevel.ExtendedMod.ModNameAliases, modNames), ((Object)extendedLevel).name, "Mod Name");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingWithinRanges(extendedLevel.RoutePrice, currentRoutePrice), ((Object)extendedLevel).name, "Route Price");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedLevel.NumberlessPlanetName, planetNames), ((Object)extendedLevel).name, "Planet Name");
			MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(((object)(LevelWeatherType)(ref extendedLevel.SelectableLevel.currentWeather)).ToString(), currentWeather), ((Object)extendedLevel).name, "Current Weather");
			return currentValue;
		}

		public void ApplyValues(List<StringWithRarity> newModNames = null, List<StringWithRarity> newAuthorNames = null, List<StringWithRarity> newLevelTags = null, List<Vector2WithRarity> newRoutePrices = null, List<StringWithRarity> newCurrentWeathers = null, List<StringWithRarity> newPlanetNames = null)
		{
			if (newModNames != null && newModNames.Count != 0)
			{
				modNames = new List<StringWithRarity>(newModNames);
			}
			if (newAuthorNames != null && newAuthorNames.Count != 0)
			{
				authorNames = new List<StringWithRarity>(newAuthorNames);
			}
			if (newLevelTags != null && newLevelTags.Count != 0)
			{
				levelTags = new List<StringWithRarity>(newLevelTags);
			}
			if (newRoutePrices != null && newRoutePrices.Count != 0)
			{
				currentRoutePrice = new List<Vector2WithRarity>(newRoutePrices);
			}
			if (newCurrentWeathers != null && newCurrentWeathers.Count != 0)
			{
				currentWeather = new List<StringWithRarity>(newCurrentWeathers);
			}
			if (newPlanetNames != null && newPlanetNames.Count != 0)
			{
				planetNames = new List<StringWithRarity>(newPlanetNames);
			}
		}
	}
	public class MatchingProperties : ScriptableObject
	{
		[Space(5f)]
		public List<StringWithRarity> modNames = new List<StringWithRarity>();

		[Space(5f)]
		public List<StringWithRarity> authorNames = new List<StringWithRarity>();

		public static MatchingProperties Create(ExtendedContent extendedContent)
		{
			MatchingProperties matchingProperties = ScriptableObject.CreateInstance<MatchingProperties>();
			((Object)matchingProperties).name = ((Object)extendedContent).name + "MatchingProperties";
			return matchingProperties;
		}

		internal static bool UpdateRarity(ref int currentValue, int newValue, string debugActionObject = null, string debugActionReason = null)
		{
			if (newValue > currentValue)
			{
				if (!string.IsNullOrEmpty(debugActionReason))
				{
					if (!string.IsNullOrEmpty(debugActionObject))
					{
						DebugHelper.Log("Raised Rarity Of: " + debugActionObject + " From (" + currentValue + ") To (" + newValue + ") Due To Matching " + debugActionReason, DebugType.Developer);
					}
					else
					{
						DebugHelper.Log("Raised Rarity From (" + currentValue + ") To (" + newValue + ") Due To Matching " + debugActionReason, DebugType.Developer);
					}
				}
				currentValue = newValue;
				return true;
			}
			return false;
		}

		internal static int GetHighestRarityViaMatchingWithinRanges(int comparingValue, List<Vector2WithRarity> matchingVectors)
		{
			int num = 0;
			foreach (Vector2WithRarity matchingVector in matchingVectors)
			{
				if (matchingVector.Rarity >= num && (float)comparingValue >= matchingVector.Min && (float)comparingValue <= matchingVector.Max)
				{
					num = matchingVector.Rarity;
				}
			}
			return num;
		}

		internal static int GetHighestRarityViaMatchingNormalizedString(string comparingString, List<StringWithRarity> matchingStrings)
		{
			return GetHighestRarityViaMatchingNormalizedStrings(new List<string> { comparingString }, matchingStrings);
		}

		internal static int GetHighestRarityViaMatchingNormalizedTags(List<ContentTag> comparingTags, List<StringWithRarity> matchingStrings)
		{
			List<string> comparingStrings = comparingTags.Select((ContentTag t) => t.contentTagName).ToList();
			return GetHighestRarityViaMatchingNormalizedStrings(comparingStrings, matchingStrings);
		}

		internal static int GetHighestRarityViaMatchingNormalizedStrings(List<string> comparingStrings, List<StringWithRarity> matchingStrings)
		{
			int num = 0;
			foreach (StringWithRarity matchingString in matchingStrings)
			{
				foreach (string item in new List<string>(comparingStrings))
				{
					if (matchingString.Rarity >= num && (matchingString.Name.Sanitized().Contains(item.Sanitized()) || item.Sanitized().Contains(matchingString.Name.Sanitized())))
					{
						num = matchingString.Rarity;
					}
				}
			}
			return num;
		}
	}
	public class MoonsCataloguePage
	{
		private List<ExtendedLevelGroup> extendedLevelGroups;

		public List<ExtendedLevelGroup> ExtendedLevelGroups => extendedLevelGroups;

		public List<ExtendedLevel> ExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups)
				{
					foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList)
					{
						list.Add(extendedLevels);
					}
				}
				return list;
			}
		}

		public MoonsCataloguePage(List<ExtendedLevelGroup> newExtendedLevelGroupList)
		{
			extendedLevelGroups = new List<ExtendedLevelGroup>();
			extendedLevelGroups.Clear();
			foreach (ExtendedLevelGroup newExtendedLevelGroup in newExtendedLevelGroupList)
			{
				extendedLevelGroups.Add(new ExtendedLevelGroup(newExtendedLevelGroup.extendedLevelsList));
			}
		}

		public void RebuildLevelGroups(List<ExtendedLevelGroup> newExtendedLevelGroups, int splitCount)
		{
			List<ExtendedLevel> list = new List<ExtendedLevel>();
			foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups)
			{
				foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList)
				{
					list.Add(extendedLevels);
				}
			}
			RebuildLevelGroups(list.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(List<ExtendedLevel> newExtendedLevels, int splitCount)
		{
			RebuildLevelGroups(newExtendedLevels.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(IOrderedEnumerable<ExtendedLevel> orderedExtendedLevels, int splitCount)
		{
			RebuildLevelGroups(orderedExtendedLevels.ToArray(), splitCount);
		}

		public void RebuildLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount)
		{
			extendedLevelGroups = TerminalManager.GetExtendedLevelGroups(newExtendedLevels, splitCount);
		}

		public void RefreshLevelGroups(List<ExtendedLevelGroup> newLevelGroups)
		{
			extendedLevelGroups.Clear();
			foreach (ExtendedLevelGroup newLevelGroup in newLevelGroups)
			{
				if (newLevelGroup.extendedLevelsList.Count != 0)
				{
					extendedLevelGroups.Add(new ExtendedLevelGroup(newLevelGroup.extendedLevelsList));
				}
			}
		}
	}
	[Serializable]
	public class ExtendedLevelGroup
	{
		public List<ExtendedLevel> extendedLevelsList;

		public int AverageCalculatedDifficulty => GetAverageCalculatedDifficulty();

		public ExtendedLevelGroup(List<ExtendedLevel> newExtendedLevelsList)
		{
			extendedLevelsList = new List<ExtendedLevel>(newExtendedLevelsList);
		}

		public ExtendedLevelGroup(List<SelectableLevel> newSelectableLevelsList)
		{
			extendedLevelsList = new List<ExtendedLevel>();
			foreach (SelectableLevel newSelectableLevels in newSelectableLevelsList)
			{
				extendedLevelsList.Add(LevelManager.GetExtendedLevel(newSelectableLevels));
			}
		}

		public int GetAverageCalculatedDifficulty()
		{
			List<int> list = new List<int>();
			foreach (ExtendedLevel extendedLevels in extendedLevelsList)
			{
				list.Add(extendedLevels.CalculatedDifficultyRating);
			}
			return (int)list.Average();
		}
	}
	public static class PatchedContent
	{
		internal static Dictionary<SelectableLevel, ExtendedLevel> ExtendedLevelDictionary = new Dictionary<SelectableLevel, ExtendedLevel>();

		internal static Dictionary<DungeonFlow, ExtendedDungeonFlow> ExtendedDungeonFlowDictionary = new Dictionary<DungeonFlow, ExtendedDungeonFlow>();

		internal static Dictionary<Item, ExtendedItem> ExtendedItemDictionary = new Dictionary<Item, ExtendedItem>();

		internal static Dictionary<EnemyType, ExtendedEnemyType> ExtendedEnemyTypeDictionary = new Dictionary<EnemyType, ExtendedEnemyType>();

		internal static Dictionary<BuyableVehicle, ExtendedBuyableVehicle> ExtendedBuyableVehicleDictionary = new Dictionary<BuyableVehicle, ExtendedBuyableVehicle>();

		public static ExtendedMod VanillaMod { get; internal set; }

		public static List<string> AllLevelSceneNames { get; internal set; } = new List<string>();


		public static List<ExtendedMod> ExtendedMods { get; internal set; } = new List<ExtendedMod>();


		public static List<ExtendedLevel> ExtendedLevels { get; internal set; } = new List<ExtendedLevel>();


		public static List<ExtendedLevel> VanillaExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.ContentType == ContentType.Vanilla)
					{
						list.Add(extendedLevel);
					}
				}
				return list;
			}
		}

		public static List<ExtendedLevel> CustomExtendedLevels
		{
			get
			{
				List<ExtendedLevel> list = new List<ExtendedLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.ContentType == ContentType.Custom)
					{
						list.Add(extendedLevel);
					}
				}
				return list;
			}
		}

		[Obsolete("Use PatchedContent.SelectableLevels instead.")]
		public static List<SelectableLevel> SeletectableLevels => SelectableLevels;

		public static List<SelectableLevel> SelectableLevels
		{
			get
			{
				List<SelectableLevel> list = new List<SelectableLevel>();
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					list.Add(extendedLevel.SelectableLevel);
				}
				return list;
			}
		}

		public static List<SelectableLevel> MoonsCatalogue
		{
			get
			{
				List<SelectableLevel> list = new List<SelectableLevel>();
				foreach (SelectableLevel item in OriginalContent.MoonsCatalogue)
				{
					list.Add(item);
				}
				foreach (ExtendedLevel extendedLevel in ExtendedLevels)
				{
					if (extendedLevel.ContentType == ContentType.Custom)
					{
						list.Add(extendedLevel.SelectableLevel);
					}
				}
				return list;
			}
		}

		public static List<ExtendedDungeonFlow> ExtendedDungeonFlows { get; internal set; } = new List<ExtendedDungeonFlow>();


		public static List<ExtendedDungeonFlow> VanillaExtendedDungeonFlows
		{
			get
			{
				List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>();
				foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
				{
					if (extendedDungeonFlow.ContentType == ContentType.Vanilla)
					{
						list.Add(extendedDungeonFlow);
					}
				}
				return list;
			}
		}

		public static List<ExtendedDungeonFlow> CustomExtendedDungeonFlows
		{
			get
			{
				List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>();
				foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
				{
					if (extendedDungeonFlow.ContentType == ContentType.Custom)
					{
						list.Add(extendedDungeonFlow);
					}
				}
				return list;
			}
		}

		public static List<ExtendedWeatherEffect> ExtendedWeatherEffects { get; internal set; } = new List<ExtendedWeatherEffect>();


		public static List<ExtendedWeatherEffect> VanillaExtendedWeatherEffects
		{
			get
			{
				List<ExtendedWeatherEffect> list = new List<ExtendedWeatherEffect>();
				foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects)
				{
					if (extendedWeatherEffect.contentType == ContentType.Vanilla)
					{
						list.Add(extendedWeatherEffect);
					}
				}
				return list;
			}
		}

		public static List<ExtendedWeatherEffect> CustomExtendedWeatherEffects
		{
			get
			{
				List<ExtendedWeatherEffect> list = new List<ExtendedWeatherEffect>();
				foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects)
				{
					if (extendedWeatherEffect.contentType == ContentType.Custom)
					{
						list.Add(extendedWeatherEffect);
					}
				}
				return list;
			}
		}

		public static List<ExtendedItem> ExtendedItems { get; internal set; } = new List<ExtendedItem>();


		public static List<ExtendedItem> CustomExtendedItems
		{
			get
			{
				List<ExtendedItem> list = new List<ExtendedItem>();
				foreach (ExtendedItem extendedItem in ExtendedItems)
				{
					if (extendedItem.ContentType == ContentType.Custom)
					{
						list.Add(extendedItem);
					}
				}
				return list;
			}
		}

		public static List<ExtendedEnemyType> ExtendedEnemyTypes { get; internal set; } = new List<ExtendedEnemyType>();


		public static List<ExtendedEnemyType> CustomExtendedEnemyTypes
		{
			get
			{
				List<ExtendedEnemyType> list = new List<ExtendedEnemyType>();
				foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes)
				{
					if (extendedEnemyType.ContentType == ContentType.Custom)
					{
						list.Add(extendedEnemyType);
					}
				}
				return list;
			}
		}

		public static List<ExtendedEnemyType> VanillaExtendedEnemyTypes
		{
			get
			{
				List<ExtendedEnemyType> list = new List<ExtendedEnemyType>();
				foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes)
				{
					if (extendedEnemyType.ContentType == ContentType.Vanilla)
					{
						list.Add(extendedEnemyType);
					}
				}
				return list;
			}
		}

		public static List<ExtendedBuyableVehicle> ExtendedBuyableVehicles { get; internal set; } = new List<ExtendedBuyableVehicle>();


		public static List<ExtendedBuyableVehicle> CustomExtendedBuyableVehicles
		{
			get
			{
				List<ExtendedBuyableVehicle> list = new List<ExtendedBuyableVehicle>();
				foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles)
				{
					if (extendedBuyableVehicle.ContentType == ContentType.Custom)
					{
						list.Add(extendedBuyableVehicle);
					}
				}
				return list;
			}
		}

		public static List<ExtendedBuyableVehicle> VanillaExtendedBuyableVehicles
		{
			get
			{
				List<ExtendedBuyableVehicle> list = new List<ExtendedBuyableVehicle>();
				foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles)
				{
					if (extendedBuyableVehicle.ContentType == ContentType.Vanilla)
					{
						list.Add(extendedBuyableVehicle);
					}
				}
				return list;
			}
		}

		public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>();


		public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>();


		public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>();


		public static List<Item> Items { get; internal set; } = new List<Item>();


		public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>();


		public static void RegisterExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow)
		{
			extendedDungeonFlow.ConvertObsoleteValues();
			if (string.IsNullOrEmpty(((Object)extendedDungeonFlow).name))
			{
				DebugHelper.LogWarning("Tried to register ExtendedDungeonFlow with missing name! Setting to DungeonFlow name for safety!", DebugType.Developer);
				((Object)extendedDungeonFlow).name = ((Object)extendedDungeonFlow.DungeonFlow).name;
			}
			AssetBundleLoader.RegisterNewExtendedContent(extendedDungeonFlow, ((Object)extendedDungeonFlow).name);
		}

		public static void RegisterExtendedLevel(ExtendedLevel extendedLevel)
		{
			AssetBundleLoader.RegisterNewExtendedContent(extendedLevel, ((Object)extendedLevel).name);
		}

		public static void RegisterExtendedMod(ExtendedMod extendedMod)
		{
			DebugHelper.Log("Registering ExtendedMod: " + extendedMod.ModName + " Manually.", DebugType.Developer);
			AssetBundleLoader.RegisterExtendedMod(extendedMod);
		}

		internal static void SortExtendedMods()
		{
			ExtendedMods = new List<ExtendedMod>(ExtendedMods.OrderBy((ExtendedMod o) => o.ModName).ToList());
			foreach (ExtendedMod extendedMod in ExtendedMods)
			{
				extendedMod.SortRegisteredContent();
			}
		}

		internal static void PopulateContentDictionaries()
		{
			foreach (ExtendedLevel extendedLevel in ExtendedLevels)
			{
				TryAdd(ExtendedLevelDictionary, extendedLevel.SelectableLevel, extendedLevel);
			}
			foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
			{
				TryAdd(ExtendedDungeonFlowDictionary, extendedDungeonFlow.DungeonFlow, extendedDungeonFlow);
			}
			foreach (ExtendedItem extendedItem in ExtendedItems)
			{
				TryAdd(ExtendedItemDictionary, extendedItem.Item, extendedItem);
			}
			foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes)
			{
				TryAdd(ExtendedEnemyTypeDictionary, extendedEnemyType.EnemyType, extendedEnemyType);
			}
			foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles)
			{
				TryAdd(ExtendedBuyableVehicleDictionary, extendedBuyableVehicle.BuyableVehicle, extendedBuyableVehicle);
			}
		}

		internal static void TryAdd<T1, T2>(Dictionary<T1, T2> dict, T1 key, T2 value)
		{
			if (!dict.ContainsKey(key))
			{
				dict.Add(key, value);
			}
			else
			{
				DebugHelper.LogError("Could not add " + key.ToString() + " to dictionary.", DebugType.Developer);
			}
		}

		public static bool TryGetExtendedContent(SelectableLevel selectableLevel, out ExtendedLevel extendedLevel)
		{
			return ExtendedLevelDictionary.TryGetValue(selectableLevel, out extendedLevel);
		}

		public static bool TryGetExtendedContent(DungeonFlow dungeonFlow, out ExtendedDungeonFlow extendedDungeonFlow)
		{
			return ExtendedDungeonFlowDictionary.TryGetValue(dungeonFlow, out extendedDungeonFlow);
		}

		public static bool TryGetExtendedContent(Item item, out ExtendedItem extendedItem)
		{
			return ExtendedItemDictionary.TryGetValue(item, out extendedItem);
		}

		public static bool TryGetExtendedContent(EnemyType enemyType, out ExtendedEnemyType extendedEnemyType)
		{
			return ExtendedEnemyTypeDictionary.TryGetValue(enemyType, out extendedEnemyType);
		}

		public static bool TryGetExtendedContent(BuyableVehicle buyableVehicle, out ExtendedBuyableVehicle extendedBuyableVehicle)
		{
			return ExtendedBuyableVehicleDictionary.TryGetValue(buyableVehicle, out extendedBuyableVehicle);
		}
	}
	public static class OriginalContent
	{
		public static StartOfRound StartOfRound => Patches.StartOfRound;

		public static RoundManager RoundManager => Patches.RoundManager;

		public static Terminal Terminal => Patches.Terminal;

		public static TimeOfDay TimeOfDay => Patches.TimeOfDay;

		public static List<SelectableLevel> SelectableLevels { get; internal set; } = new List<SelectableLevel>();


		public static List<SelectableLevel> MoonsCatalogue { get; internal set; } = new List<SelectableLevel>();


		public static List<DungeonFlow> DungeonFlows { get; internal set; } = new List<DungeonFlow>();


		public static List<Item> Items { get; internal set; } = new List<Item>();


		public static List<ItemGroup> ItemGroups { get; internal set; } = new List<ItemGroup>();


		public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>();


		public static List<SpawnableOutsideObject> SpawnableOutsideObjects { get; internal set; } = new List<SpawnableOutsideObject>();


		public static List<GameObject> SpawnableMapObjects { get; internal set; } = new List<GameObject>();


		public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>();


		public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>();


		public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>();


		public static List<LevelAmbienceLibrary> LevelAmbienceLibraries { get; internal set; } = new List<LevelAmbienceLibrary>();


		public static List<ReverbPreset> ReverbPresets { get; internal set; } = new List<ReverbPreset>();


		public static List<TerminalKeyword> TerminalKeywords { get; internal set; } = new List<TerminalKeyword>();


		public static List<TerminalNode> TerminalNodes { get; internal set; } = new List<TerminalNode>();

	}
	internal class EventPatches
	{
		internal static DayMode previousDayMode = (DayMode)(-1);

		internal static bool firedDawnEvent = false;

		private static EnemyVent cachedSelectedVent;

		internal static void InvokeExtendedEvent<T>(ExtendedEvent<T> extendedEvent, T eventParameter)
		{
			extendedEvent.Invoke(eventParameter);
		}

		internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLevelLoaded)
			{
				previousDayMode = (DayMode)(-1);
				LevelManager.CurrentExtendedLevel.LevelEvents.onLevelLoaded.Invoke();
				LevelManager.GlobalLevelEvents.onLevelLoaded.Invoke();
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StoryLog), "CollectLog")]
		[HarmonyPrefix]
		internal static void StoryLogCollectLog_Prefix(StoryLog __instance)
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && ((NetworkBehaviour)__instance).IsServer)
			{
				LevelManager.CurrentExtendedLevel.LevelEvents.onStoryLogCollected.Invoke(__instance);
				LevelManager.GlobalLevelEvents.onStoryLogCollected.Invoke(__instance);
			}
		}

		[HarmonyPriority(201)]
		[HarmonyPatch(typeof(DungeonGenerator), "Generate")]
		[HarmonyPrefix]
		internal static void DungeonGeneratorGenerate_Prefix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onBeforeDungeonGenerate.Invoke(Patches.RoundManager);
				DungeonManager.GlobalDungeonEvents.onBeforeDungeonGenerate.Invoke(Patches.RoundManager);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SwitchPower")]
		[HarmonyPrefix]
		internal static void RoundManagerSwitchPower_Prefix(bool on)
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPowerSwitchToggle.Invoke(on);
				DungeonManager.GlobalDungeonEvents.onPowerSwitchToggle.Invoke(on);
			}
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				LevelManager.CurrentExtendedLevel.LevelEvents.onPowerSwitchToggle.Invoke(on);
				LevelManager.GlobalLevelEvents.onPowerSwitchToggle.Invoke(on);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnScrapInLevel_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				List<GrabbableObject> param = Object.FindObjectsOfType<GrabbableObject>().ToList();
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedScrapObjects.Invoke(param);
				DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects.Invoke(param);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnSyncedProps")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnSyncedProps_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedSyncedObjects.Invoke(Patches.RoundManager.spawnedSyncedObjects);
				DungeonManager.GlobalDungeonEvents.onSpawnedSyncedObjects.Invoke(Patches.RoundManager.spawnedSyncedObjects);
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")]
		[HarmonyPrefix]
		internal static void RoundManagerSpawnEventFromVent_Prefix(EnemyVent vent)
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				cachedSelectedVent = vent;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnEnemyGameObject")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnEventFromVent_Postfix()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && (Object)(object)cachedSelectedVent != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onEnemySpawnedFromVent.Invoke((cachedSelectedVent, Patches.RoundManager.SpawnedEnemies.Last()));
				DungeonManager.GlobalDungeonEvents.onEnemySpawnedFromVent.Invoke((cachedSelectedVent, Patches.RoundManager.SpawnedEnemies.Last()));
				cachedSelectedVent = null;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")]
		[HarmonyPostfix]
		internal static void RoundManagerSpawnMapObjects_Postfix()
		{
			//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)
			if (!((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null))
			{
				return;
			}
			List<GameObject> list = new List<GameObject>();
			Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.SelectableLevel.sceneName);
			GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				SpawnableMapObject[] spawnableMapObjects = LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (((Object)val).name.Sanitized().Contains(((Object)val2.prefabToSpawn).name.Sanitized()))
					{
						list.Add(val);
					}
				}
			}
			DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedMapObjects.Invoke(list);
			DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects.Invoke(list);
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		[HarmonyPrefix]
		internal static void StartOfRoundOnShipLandedMiscEvents_Prefix()
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				LevelManager.CurrentExtendedLevel.LevelEvents.onShipLand.Invoke();
				LevelManager.GlobalLevelEvents.onShipLand.Invoke();
			}
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onShipLand.Invoke();
				DungeonManager.GlobalDungeonEvents.onShipLand.Invoke();
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPrefix]
		internal static void StartOfRoundShipLeave_Prefix()
		{
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				LevelManager.CurrentExtendedLevel.LevelEvents.onShipLeave.Invoke();
				LevelManager.GlobalLevelEvents.onShipLeave.Invoke();
			}
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onShipLeave.Invoke();
				DungeonManager.GlobalDungeonEvents.onShipLeave.Invoke();
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")]
		[HarmonyPrefix]
		internal static void EntranceTeleportTeleportPlayerServerRpc_Prefix(EntranceTeleport __instance, int playerObj)
		{
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				return;
			}
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
			{
				PlayerControllerB item = Patches.StartOfRound.allPlayerScripts[playerObj];
				if (__instance.isEntranceToBuilding)
				{
					DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerEnterDungeon.Invoke((__instance, item));
					DungeonManager.GlobalDungeonEvents.onPlayerEnterDungeon.Invoke((__instance, item));
				}
				else
				{
					DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerExitDungeon.Invoke((__instance, item));
					DungeonManager.GlobalDungeonEvents.onPlayerExitDungeon.Invoke((__instance, item));
				}
			}
			if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
			{
				PlayerControllerB item2 = Patches.StartOfRound.allPlayerScripts[playerObj];
				if (__instance.isEntranceToBuilding)
				{
					LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerEnterDungeon.Invoke((__instance, item2));
					LevelManager.GlobalLevelEvents.onPlayerEnterDungeon.Invoke((__instance, item2));
				}
				else
				{
					LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerExitDungeon.Invoke((__instance, item2));
					LevelManager.GlobalLevelEvents.onPlayerExitDungeon.Invoke((__instance, item2));
				}
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(LungProp), "EquipItem")]
		[HarmonyPrefix]
		internal static void LungPropEquipItem_Prefix(LungProp __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && __instance.isLungDocked)
			{
				if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
				{
					DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onApparatusTaken.Invoke(__instance);
					DungeonManager.GlobalDungeonEvents.onApparatusTaken.Invoke(__instance);
				}
				if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
				{
					LevelManager.CurrentExtendedLevel.LevelEvents.onApparatusTaken.Invoke(__instance);
					LevelManager.GlobalLevelEvents.onApparatusTaken.Invoke(__instance);
				}
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(TimeOfDay), "GetDayPhase")]
		[HarmonyPostfix]
		internal static void TimeOfDayGetDayPhase_Postfix(DayMode __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_001f: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			if ((int)previousDayMode == -1 || previousDayMode != __result)
			{
				LevelManager.CurrentExtendedLevel.LevelEvents.onDayModeToggle.Invoke(__result);
				LevelManager.GlobalLevelEvents.onDayModeToggle.Invoke(__result);
			}
			previousDayMode = __result;
		}
	}
	public class ExtendedEvent<T>
	{
		public delegate void ParameterEvent(T param);

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event ParameterEvent onParameterEvent;

		private event Action onEvent;

		public void Invoke(T param)
		{
			this.onParameterEvent?.Invoke(param);
			this.onEvent?.Invoke();
		}

		public void Invoke()
		{
			this.onEvent?.Invoke();
		}

		public void AddListener(ParameterEvent listener)
		{
			onParameterEvent += listener;
			Listeners++;
		}

		public void AddListener(Action listener)
		{
			onEvent += listener;
			Listeners++;
		}

		public void RemoveListener(ParameterEvent listener)
		{
			onParameterEvent -= listener;
			Listeners--;
		}

		public void RemoveListener(Action listener)
		{
			onEvent -= listener;
			Listeners--;
		}
	}
	public class ExtendedEvent
	{
		public delegate void Event();

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event Event onEvent;

		public void Invoke()
		{
			this.onEvent?.Invoke();
		}

		public void AddListener(Event listener)
		{
			onEvent += listener;
			Listeners++;
		}

		public void RemoveListener(Event listener)
		{
			onEvent -= listener;
			Listeners--;
		}
	}
	public static class Extensions
	{
		public static List<Tile> GetTiles(this DungeonFlow dungeonFlow)
		{
			List<Tile> list = new List<Tile>();
			foreach (GraphNode node in dungeonFlow.Nodes)
			{
				foreach (TileSet tileSet in node.TileSets)
				{
					list.AddRange(GetTilesInTileSet(tileSet));
				}
			}
			foreach (GraphLine line in dungeonFlow.Lines)
			{
				foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes)
				{
					foreach (TileSet branchCapTileSet in dungeonArchetype.BranchCapTileSets)
					{
						list.AddRange(GetTilesInTileSet(branchCapTileSet));
					}
					foreach (TileSet tileSet2 in dungeonArchetype.TileSets)
					{
						list.AddRange(GetTilesInTileSet(tileSet2));
					}
				}
			}
			foreach (Tile item in new List<Tile>(list))
			{
				if ((Object)(object)item == (Object)null)
				{
					list.Remove(item);
				}
			}
			return list;
		}

		public static List<Tile> GetTilesInTileSet(TileSet tileSet)
		{
			List<Tile> list = new List<Tile>();
			if (tileSet.TileWeights != null && tileSet.TileWeights.Weights != null)
			{
				foreach (GameObjectChance weight in tileSet.TileWeights.Weights)
				{
					Tile[] componentsInChildren = weight.Value.GetComponentsInChildren<Tile>();
					foreach (Tile item in componentsInChildren)
					{
						list.Add(item);
					}
				}
			}
			return list;
		}

		public static List<RandomMapObject> GetRandomMapObjects(this DungeonFlow dungeonFlow)
		{
			List<RandomMapObject> list = new List<RandomMapObject>();
			foreach (Tile tile in dungeonFlow.GetTiles())
			{
				RandomMapObject[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<RandomMapObject>();
				foreach (RandomMapObject item in componentsInChildren)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static List<SpawnSyncedObject> GetSpawnSyncedObjects(this DungeonFlow dungeonFlow)
		{
			List<SpawnSyncedObject> list = new List<SpawnSyncedObject>();
			foreach (Tile tile in dungeonFlow.GetTiles())
			{
				Doorway[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<Doorway>();
				foreach (Doorway val in componentsInChildren)
				{
					foreach (GameObjectWeight connectorPrefabWeight in val.ConnectorPrefabWeights)
					{
						SpawnSyncedObject[] componentsInChildren2 = connectorPrefabWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>();
						foreach (SpawnSyncedObject item in componentsInChildren2)
						{
							list.Add(item);
						}
					}
					foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights)
					{
						SpawnSyncedObject[] componentsInChildren3 = blockerPrefabWeight.GameObject.GetComponentsInCh