Decompiled source of LethalExpansionCorePatch v1.3.18

LethalExpansionCore.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Adapters;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalExpansionCore.MonoBehaviours;
using LethalExpansionCore.Netcode;
using LethalExpansionCore.Patches;
using LethalExpansionCore.Utils;
using LethalSDK.Component;
using LethalSDK.ScriptableObjects;
using LethalSDK.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.AI.Navigation;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalExpansionCore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalExpansionCore")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cbb249e6-fea3-431f-bd6a-ff05f9616e3a")]
[assembly: AssemblyFileVersion("1.3.18")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.3.18.0")]
[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;
		}
	}
}
public class AutoScrollText : MonoBehaviour
{
	public TextMeshProUGUI textMeshPro;

	public float scrollSpeed = 15f;

	private Vector2 startPosition;

	private float textHeight;

	private bool startScrolling = false;

	private bool isWaitingToReset = false;

	private float displayHeight;

	private float fontSize;

	private void Start()
	{
		textMeshPro = ((Component)this).GetComponent<TextMeshProUGUI>();
		InitializeScrolling();
	}

	private void InitializeScrolling()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)textMeshPro != (Object)null)
		{
			startPosition = ((TMP_Text)textMeshPro).rectTransform.anchoredPosition;
			textHeight = ((TMP_Text)textMeshPro).preferredHeight;
			displayHeight = ((TMP_Text)textMeshPro).rectTransform.sizeDelta.y;
			fontSize = ((TMP_Text)textMeshPro).fontSize;
		}
		((MonoBehaviour)this).StartCoroutine(WaitBeforeScrolling(5f));
	}

	private IEnumerator WaitBeforeScrolling(float waitTime)
	{
		yield return (object)new WaitForSeconds(waitTime);
		startScrolling = true;
	}

	private IEnumerator WaitBeforeResetting(float waitTime)
	{
		isWaitingToReset = true;
		yield return (object)new WaitForSeconds(waitTime);
		((TMP_Text)textMeshPro).rectTransform.anchoredPosition = startPosition;
		isWaitingToReset = false;
		((MonoBehaviour)this).StartCoroutine(WaitBeforeScrolling(5f));
	}

	private void Update()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)textMeshPro != (Object)null && startScrolling && !isWaitingToReset)
		{
			RectTransform rectTransform = ((TMP_Text)textMeshPro).rectTransform;
			rectTransform.anchoredPosition += new Vector2(0f, scrollSpeed * Time.deltaTime);
			if (((TMP_Text)textMeshPro).rectTransform.anchoredPosition.y >= startPosition.y + textHeight - displayHeight - fontSize)
			{
				startScrolling = false;
				((MonoBehaviour)this).StartCoroutine(WaitBeforeResetting(5f));
			}
		}
	}

	public void ResetScrolling()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		((MonoBehaviour)this).StopAllCoroutines();
		if ((Object)(object)textMeshPro != (Object)null)
		{
			((TMP_Text)textMeshPro).rectTransform.anchoredPosition = startPosition;
		}
		isWaitingToReset = false;
		InitializeScrolling();
	}
}
namespace LethalExpansionCore
{
	public static class PluginInformation
	{
		public const string PLUGIN_GUID = "com.github.lethalmods.lethalexpansioncorepatch";

		public const string PLUGIN_NAME = "LethalExpansion(core) - Patched";

		public const string PLUGIN_VERSION = "1.3.18";
	}
	[BepInPlugin("com.github.lethalmods.lethalexpansioncorepatch", "LethalExpansion(core) - Patched", "1.3.18")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LethalExpansion : BaseUnityPlugin
	{
		public static class Settings
		{
			public static ConfigEntry<bool> IgnoreRequiredBundles;

			public static ConfigEntry<bool> UseOriginalLethalExpansion;

			public static ConfigEntry<bool> LoadDefaultBundles;

			public static ConfigEntry<bool> DebugLogs;

			public static ConfigEntry<string> ExcludedMoons;

			public static ConfigEntry<string> ExcludedScrap;

			public static ConfigEntry<bool> ShowVersionNumberOnMainMenu;

			public static void Bind(ConfigFile config)
			{
				IgnoreRequiredBundles = config.Bind<bool>("Core", "IgnoreRequiredBundles", true, "Whether or not to allow a bundle to load without its required bundles");
				UseOriginalLethalExpansion = config.Bind<bool>("Core", "UseOriginalLethalExpansion", false, "Whether or not to use the original LethalExpansion instead of LethalExpansion(core) when they are both loaded");
				LoadDefaultBundles = config.Bind<bool>("Core", "LoadDefaultBundles", false, "Whether or not to load the default bundles from LethalExpansion when both LethalExpansion and LethalExpansion(core) are present");
				ExcludedMoons = config.Bind<string>("Moons & Scrap", "ExcludedMoons", "hidden", "Comma separated list of LethalExpansion based moons to exclude from the game, use `hidden` (without `) to remove all the hidden moons (better LLL compatibility)");
				ExcludedScrap = config.Bind<string>("Moons & Scrap", "ExcludedScrap", "", "Comma separated list of LethalExpansion based scrap to exclude from the game");
				ShowVersionNumberOnMainMenu = config.Bind<bool>("Main Menu", "ShowVersionNumberOnMainMenu", true, "Set true to show the version number of LethalExpansionCore on the main menu");
				DebugLogs = config.Bind<bool>("Debug", "DebugLogs", false, "Debug logs :D");
			}
		}

		public static readonly Version ModVersion = new Version("1.3.18");

		public static string LethalExpansionPath = null;

		public static bool isInGame = false;

		public static ManualLogSource Log;

		public static ManualLogSource DebugLog;

		public static NetworkManager networkManager;

		public GameObject terrainFixer;

		public static Transform currentWaterSurface;

		private int width = 256;

		private int height = 256;

		private int depth = 20;

		private float scale = 20f;

		private static bool LethalExpansion_Awake()
		{
			Log.LogInfo((object)"Prevented LethalExpansion from initializing");
			return false;
		}

		private static Assembly LoadLethalExpansion()
		{
			try
			{
				Assembly assembly = AppDomain.CurrentDomain.Load("LethalExpansion");
				Log.LogInfo((object)$"Loaded LethalExpansion: {assembly}");
				return assembly;
			}
			catch (FileNotFoundException)
			{
				return null;
			}
		}

		private static void PatchLethalExpansion(Harmony harmony, Assembly assembly)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			if (assembly == null)
			{
				Log.LogInfo((object)"LethalExpansion is not present, all is well!");
				return;
			}
			Type type = assembly.GetType("LethalExpansion.LethalExpansion");
			MethodInfo method = type.GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method2 = typeof(LethalExpansion).GetMethod("LethalExpansion_Awake", BindingFlags.Static | BindingFlags.NonPublic);
			harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Log.LogInfo((object)"Patched LethalExpansion#Awake");
		}

		private void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin: LethalExpansion(core) - Patched (version: 1.3.18) is loading...");
			Settings.Bind(((BaseUnityPlugin)this).Config);
			if (Settings.DebugLogs.Value)
			{
				DebugLog = Log;
			}
			else
			{
				DebugLog = new ManualLogSource(Log.SourceName);
			}
			Assembly assembly = LoadLethalExpansion();
			if (assembly != null)
			{
				if (Settings.UseOriginalLethalExpansion.Value)
				{
					Log.LogInfo((object)"Using original LethalExpansion instead");
					return;
				}
				LethalExpansionPath = Path.GetDirectoryName(assembly.Location);
			}
			Harmony val = new Harmony("com.github.lethalmods.lethalexpansioncorepatch");
			PatchLethalExpansion(val, assembly);
			AssetBundlesManager.Instance.LoadAllAssetBundles();
			SceneManager.sceneLoaded += OnSceneLoaded;
			SceneManager.sceneUnloaded += OnSceneUnloaded;
			val.PatchAll(typeof(GameNetworkManager_Patch));
			val.PatchAll(typeof(Terminal_Patch));
			val.PatchAll(typeof(MenuManager_Patch));
			val.PatchAll(typeof(RoundManager_Patch));
			val.PatchAll(typeof(StartOfRound_Patch));
			val.PatchAll(typeof(EntranceTeleport_Patch));
			val.PatchAll(typeof(AudioReverbTrigger_Patch));
			val.PatchAll(typeof(InteractTrigger_Patch));
			val.PatchAll(typeof(DungeonGenerator_Patch));
			val.PatchAll(typeof(RuntimeDungeon));
			RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline;
			HDRenderPipelineAsset val2 = (HDRenderPipelineAsset)(object)((currentRenderPipeline is HDRenderPipelineAsset) ? currentRenderPipeline : null);
			if ((Object)(object)val2 != (Object)null)
			{
				RenderPipelineSettings currentPlatformRenderPipelineSettings = val2.currentPlatformRenderPipelineSettings;
				currentPlatformRenderPipelineSettings.supportWater = true;
				val2.currentPlatformRenderPipelineSettings = currentPlatformRenderPipelineSettings;
				Log.LogInfo((object)"Water support applied to the HDRenderPipelineAsset.");
			}
			else
			{
				Log.LogError((object)"HDRenderPipelineAsset not found.");
			}
			Log.LogInfo((object)"Plugin: LethalExpansion(core) - Patched (version: 1.3.18) is loaded.");
			Log.LogError((object)"This patch is no longer needed, as the preview version of LethalExpansion now supports v50: https://thunderstore.io/c/lethal-company/p/HolographicWings/LethalExpansion_Preview/");
		}

		private float[,] GenerateHeights()
		{
			float[,] array = new float[width, height];
			for (int i = 0; i < width; i++)
			{
				for (int j = 0; j < height; j++)
				{
					array[i, j] = CalculateHeight(i, j);
				}
			}
			return array;
		}

		private float CalculateHeight(int x, int y)
		{
			float num = (float)x / (float)width * scale;
			float num2 = (float)y / (float)height * scale;
			return Mathf.PerlinNoise(num, num2);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_006a: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo((object)("Loading scene '" + ((Scene)(ref scene)).name + "'"));
			try
			{
				if (((Scene)(ref scene)).name == "InitScene")
				{
					networkManager = GameObject.Find("NetworkManager").GetComponent<NetworkManager>();
				}
				else if (((Scene)(ref scene)).name == "MainMenu")
				{
					OnMainMenuLoaded(scene);
				}
				else if (((Scene)(ref scene)).name == "CompanyBuilding" || ((Scene)(ref scene)).name.StartsWith("Level"))
				{
					terrainFixer.SetActive(false);
					Log.LogInfo((object)"Disabled TerrainFixer");
				}
				else if (((Scene)(ref scene)).name == "SampleSceneRelay")
				{
					OnSampleSceneRelayLoaded(scene);
				}
				else if (((Scene)(ref scene)).name == "InitSceneLaunchOptions" && isInGame)
				{
					OnInitSceneLaunchOptionsLoaded(scene);
				}
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Something went wrong when loading scene '{((Scene)(ref scene)).name}'. {arg}");
			}
		}

		private void OnMainMenuLoaded(Scene scene)
		{
			isInGame = false;
			AssetGather.Instance.AddAudioMixer(GameObject.Find("Canvas/MenuManager").GetComponent<AudioSource>().outputAudioMixerGroup.audioMixer);
		}

		private void OnSampleSceneRelayLoaded(Scene scene)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(GameObject.Find("Systems/GameSystems/TimeAndWeather/Flooding"));
			Object.Destroy((Object)(object)val.GetComponent<FloodWeather>());
			((Object)val).name = "WaterSurface";
			val.transform.position = Vector3.zero;
			((Component)val.transform.Find("Water")).GetComponent<MeshFilter>().sharedMesh = null;
			SpawnPrefab.Instance.waterSurface = val;
			((Component)StartOfRound.Instance.screenLevelDescription).gameObject.AddComponent<AutoScrollText>();
			AssetGather.Instance.AddAudioMixer(GameObject.Find("Systems/Audios/DiageticBackground").GetComponent<AudioSource>().outputAudioMixerGroup.audioMixer);
			SetupTerrainFixer();
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Volume));
			foreach (Object obj in array)
			{
				Volume val2 = (Volume)(object)((obj is Volume) ? obj : null);
				if (!((Object)(object)val2.sharedProfile != (Object)null))
				{
					val2.sharedProfile = AssetBundlesManager.Instance.mainAssetBundle.LoadAsset<VolumeProfile>("Assets/Mods/LethalExpansion/Sky and Fog Global Volume Profile.asset");
				}
			}
			isInGame = true;
		}

		private void SetupTerrainFixer()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			terrainFixer = new GameObject();
			((Object)terrainFixer).name = "terrainfixer";
			terrainFixer.transform.position = new Vector3(0f, -500f, 0f);
			TerrainData val = new TerrainData();
			val.heightmapResolution = width + 1;
			val.size = new Vector3((float)width, (float)depth, (float)height);
			val.SetHeights(0, 0, GenerateHeights());
			Terrain val2 = terrainFixer.AddComponent<Terrain>();
			val2.terrainData = val;
		}

		private void OnInitSceneLaunchOptionsLoaded(Scene scene)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			terrainFixer.SetActive(false);
			if (!Terminal_Patch.newMoons.ContainsKey(RoundManager.Instance.currentLevel.levelID))
			{
				Log.LogInfo((object)("Skipped custom moon loading in InitSceneLaunchOptions for moon '" + RoundManager.Instance.currentLevel.PlanetName + "', it is not our moon"));
				return;
			}
			Log.LogInfo((object)"OnInitSceneLaunchOptionsLoaded");
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				val.SetActive(false);
			}
			LoadCustomMoon(scene);
			string[] array = new string[5] { "MapPropsContainer", "OutsideAINode", "SpawnDenialPoint", "ItemShipLandingNode", "OutsideLevelNavMesh" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				if ((Object)(object)GameObject.FindGameObjectWithTag(text) == (Object)null || GameObject.FindGameObjectsWithTag(text).Any(delegate(GameObject o)
				{
					//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)
					Scene scene2 = o.scene;
					return ((Scene)(ref scene2)).name != "InitSceneLaunchOptions";
				}))
				{
					GameObject val2 = new GameObject();
					((Object)val2).name = text;
					val2.tag = text;
					val2.transform.position = new Vector3(0f, -200f, 0f);
					SceneManager.MoveGameObjectToScene(val2, scene);
					Log.LogInfo((object)("Added required object with tag '" + text + "'"));
				}
			}
			GameObject val3 = GameObject.Find("ItemShipAnimContainer");
			if ((Object)(object)val3 != (Object)null)
			{
				Transform val4 = val3.transform.Find("ItemShip");
				if ((Object)(object)val4 != (Object)null)
				{
					((Component)val4).GetComponent<AudioSource>().outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
				}
				Transform val5 = val3.transform.Find("ItemShip/Music");
				if ((Object)(object)val5 != (Object)null)
				{
					((Component)val5).GetComponent<AudioSource>().outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
				}
				Transform val6 = val3.transform.Find("ItemShip/Music/Music (1)");
				if ((Object)(object)val6 != (Object)null)
				{
					((Component)val6).GetComponent<AudioSource>().outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
				}
			}
			RuntimeDungeon val7 = Object.FindObjectOfType<RuntimeDungeon>(false);
			if ((Object)(object)val7 == (Object)null)
			{
				Log.LogInfo((object)"Adding 'DungeonGenerator'");
				GameObject val8 = CreateDungeonGenerator();
				val7 = val8.GetComponent<RuntimeDungeon>();
				SceneManager.MoveGameObjectToScene(val8, scene);
			}
			else if ((Object)(object)val7.Generator.DungeonFlow == (Object)null)
			{
				val7.Generator.DungeonFlow = RoundManager.Instance.dungeonFlowTypes[0].dungeonFlow;
				Log.LogInfo((object)"Setting missing DungeonFlow in DungeonGenerator");
			}
			GameObject val9 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val9).name = "OutOfBounds";
			val9.layer = 13;
			val9.transform.position = new Vector3(0f, -300f, 0f);
			val9.transform.localScale = new Vector3(1000f, 5f, 1000f);
			BoxCollider component = val9.GetComponent<BoxCollider>();
			((Collider)component).isTrigger = true;
			val9.AddComponent<OutOfBoundsTrigger>();
			Rigidbody val10 = val9.AddComponent<Rigidbody>();
			val10.useGravity = false;
			val10.isKinematic = true;
			val10.collisionDetectionMode = (CollisionDetectionMode)1;
			SceneManager.MoveGameObjectToScene(val9, scene);
			WaitForEntrancesSync(scene).GetAwaiter();
			EntranceTeleport[] array3 = Object.FindObjectsOfType<EntranceTeleport>();
			Log.LogInfo((object)$"Moving {array3.Length} EntranceTeleport(s) to scene");
			EntranceTeleport[] array4 = array3;
			foreach (EntranceTeleport val11 in array4)
			{
				if ((Object)(object)((Component)val11).transform.parent == (Object)null)
				{
					SceneManager.MoveGameObjectToScene(((Component)val11).gameObject, scene);
				}
			}
		}

		private async Task WaitForEntrancesSync(Scene scene)
		{
			//IL_0019: 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)
			int expectedEntranceTeleports = 0;
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject root in rootGameObjects)
			{
				LECore_InactiveNetworkPrefabInstancier[] componentsInChildren = root.GetComponentsInChildren<LECore_InactiveNetworkPrefabInstancier>(true);
				foreach (LECore_InactiveNetworkPrefabInstancier instancier in componentsInChildren)
				{
					GameObject prefab = instancier.prefab;
					if (!((Object)(object)((prefab != null) ? prefab.GetComponent<SI_EntranceTeleport>() : null) == (Object)null))
					{
						expectedEntranceTeleports++;
					}
				}
			}
			Log.LogInfo((object)$"Expecting {expectedEntranceTeleports} EntranceTeleports");
			if (expectedEntranceTeleports == 0)
			{
				return;
			}
			double maxSyncTime = 2.0;
			double timeStarted = Time.timeAsDouble;
			while (true)
			{
				EntranceTeleport[] entranceTeleports = Object.FindObjectsOfType<EntranceTeleport>();
				if (entranceTeleports.Length == expectedEntranceTeleports)
				{
					Log.LogInfo((object)$"EntranceTeleports was synced in {(Time.timeAsDouble - timeStarted) * 1000.0}ms");
					return;
				}
				if (Time.timeAsDouble - timeStarted > maxSyncTime)
				{
					break;
				}
				await Task.Delay(25);
			}
			Log.LogWarning((object)"Failed to sync EntranceTeleports in time, this may have unintended consequences");
		}

		private GameObject CreateDungeonGenerator()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0034: 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_00a4: 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)
			GameObject val = new GameObject();
			((Object)val).name = "DungeonGenerator";
			val.tag = "DungeonGenerator";
			val.transform.position = new Vector3(0f, -200f, 0f);
			RuntimeDungeon val2 = val.AddComponent<RuntimeDungeon>();
			val2.Generator.DungeonFlow = RoundManager.Instance.dungeonFlowTypes[0].dungeonFlow;
			val2.Generator.LengthMultiplier = 0.8f;
			val2.Generator.PauseBetweenRooms = 0.2f;
			val2.GenerateOnStart = false;
			val2.Root = val;
			UnityNavMeshAdapter val3 = val.AddComponent<UnityNavMeshAdapter>();
			val3.BakeMode = (RuntimeNavMeshBakeMode)3;
			val3.LayerMask = LayerMask.op_Implicit(35072);
			return val;
		}

		private void LoadCustomMoon(Scene scene)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject mainPrefab = Terminal_Patch.newMoons[StartOfRound.Instance.currentLevelID].MainPrefab;
			if ((Object)(object)mainPrefab == (Object)null || (Object)(object)mainPrefab.transform == (Object)null)
			{
				return;
			}
			ComponentWhitelist.CheckAndRemoveIllegalComponents(mainPrefab.transform, ComponentWhitelist.MoonPrefabComponentWhitelist);
			GameObject val = Object.Instantiate<GameObject>(mainPrefab);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			currentWaterSurface = val.transform.Find("Environment/Water");
			SceneManager.MoveGameObjectToScene(val, scene);
			Transform val2 = val.transform.Find("Systems/Audio/DiageticBackground");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).GetComponent<AudioSource>().outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
			}
			Terrain[] componentsInChildren = val.GetComponentsInChildren<Terrain>();
			if (componentsInChildren != null && componentsInChildren.Length != 0)
			{
				Terrain[] array = componentsInChildren;
				foreach (Terrain val3 in array)
				{
					val3.drawInstanced = true;
				}
			}
		}

		private void OnSceneUnloaded(Scene scene)
		{
			if (((Scene)(ref scene)).name.Length > 0)
			{
				Log.LogInfo((object)("Unloading scene: " + ((Scene)(ref scene)).name));
			}
			if (((Scene)(ref scene)).name.StartsWith("Level") || ((Scene)(ref scene)).name == "CompanyBuilding" || (((Scene)(ref scene)).name == "InitSceneLaunchOptions" && isInGame))
			{
				currentWaterSurface = null;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalExpansionCore";

		public const string PLUGIN_NAME = "";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace LethalExpansionCore.Utils
{
	public class AssetBundlesManager
	{
		private static AssetBundlesManager _instance;

		public AssetBundle mainAssetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("LethalExpansionCore.dll", "lethalexpansion.lem"));

		public Dictionary<string, (AssetBundle, ModManifest)> assetBundles = new Dictionary<string, (AssetBundle, ModManifest)>();

		public Dictionary<string, (AssetBundle, ModManifest)> contentAssetBundles = new Dictionary<string, (AssetBundle, ModManifest)>();

		public DirectoryInfo modPath = new DirectoryInfo(Assembly.GetExecutingAssembly().Location);

		public DirectoryInfo modDirectory;

		public DirectoryInfo pluginsDirectory;

		public static AssetBundlesManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new AssetBundlesManager();
				}
				return _instance;
			}
		}

		public (AssetBundle, ModManifest) Load(string name)
		{
			return assetBundles[name.ToLower()];
		}

		public void LoadAllAssetBundles()
		{
			modDirectory = modPath.Parent;
			pluginsDirectory = modDirectory;
			while (pluginsDirectory != null && pluginsDirectory.Name != "plugins")
			{
				pluginsDirectory = pluginsDirectory.Parent;
			}
			if (pluginsDirectory == null)
			{
				LethalExpansion.Log.LogWarning((object)"Mod is not in a plugins folder.");
				return;
			}
			LethalExpansion.Log.LogInfo((object)("Plugins folder found: " + pluginsDirectory.FullName));
			LethalExpansion.Log.LogInfo((object)("Mod path is: " + modDirectory.FullName));
			if (modDirectory.FullName == pluginsDirectory.FullName)
			{
				LethalExpansion.Log.LogWarning((object)("LethalExpansion is Rooting the Plugins folder, this is not recommended. " + modDirectory.FullName));
			}
			string[] files = Directory.GetFiles(pluginsDirectory.FullName, "*.lem", SearchOption.AllDirectories);
			foreach (string file in files)
			{
				LoadBundle(file);
			}
		}

		public void LoadBundle(string file)
		{
			string fileName = Path.GetFileName(file);
			if (fileName == "lethalexpansion.lem")
			{
				return;
			}
			string text = Path.GetFileNameWithoutExtension(file).ToLower();
			if (assetBundles.ContainsKey(text))
			{
				LethalExpansion.Log.LogWarning((object)("An AssetBundle with the same name '" + fileName + "' has already been loaded"));
				return;
			}
			Stopwatch stopwatch = new Stopwatch();
			AssetBundle val = null;
			try
			{
				stopwatch.Start();
				val = AssetBundle.LoadFromFile(file);
				stopwatch.Stop();
			}
			catch (Exception ex)
			{
				LethalExpansion.Log.LogError((object)ex);
			}
			if ((Object)(object)val == (Object)null)
			{
				LethalExpansion.Log.LogWarning((object)("File '" + fileName + "' is not an AssetBundle"));
				return;
			}
			string text2 = "Assets/Mods/" + text + "/ModManifest.asset";
			ModManifest modManifest = val.LoadAsset<ModManifest>(text2);
			if ((Object)(object)modManifest == (Object)null)
			{
				LethalExpansion.Log.LogWarning((object)("AssetBundle '" + fileName + "' does not have a ModManifest"));
				val.Unload(true);
				LethalExpansion.Log.LogInfo((object)("AssetBundle '" + fileName + "' unloaded"));
				return;
			}
			if (assetBundles.Any((KeyValuePair<string, (AssetBundle, ModManifest)> b) => b.Value.Item2.modName == modManifest.modName))
			{
				LethalExpansion.Log.LogWarning((object)("Another mod with same name '" + modManifest.modName + "' is already loaded"));
				val.Unload(true);
				LethalExpansion.Log.LogInfo((object)("AssetBundle '" + fileName + "' unloaded"));
				return;
			}
			ManualLogSource log = LethalExpansion.Log;
			string modName = modManifest.modName;
			ModManifest obj = modManifest;
			log.LogInfo((object)string.Format("Module '{0}' v{1} was loaded in {2}ms", modName, ((obj == null) ? null : ((object)obj.GetVersion())?.ToString()) ?? "0.0.0.0", stopwatch.ElapsedMilliseconds));
			if (modManifest.GetVersion() == null || ((object)modManifest.GetVersion()).ToString() == "0.0.0.0")
			{
				LethalExpansion.Log.LogWarning((object)("Module '" + modManifest.modName + "' does not have a version number, this is unsafe!"));
			}
			assetBundles.Add(text, (val, modManifest));
			if (!LethalExpansion.Settings.LoadDefaultBundles.Value && LethalExpansion.LethalExpansionPath != null && Path.GetDirectoryName(file).StartsWith(LethalExpansion.LethalExpansionPath))
			{
				LethalExpansion.Log.LogWarning((object)("Ignorning content from default AssetBundle '" + fileName + "'"));
			}
			else
			{
				contentAssetBundles.Add(text, (val, modManifest));
			}
		}

		public bool BundleLoaded(string bundleName)
		{
			return assetBundles.ContainsKey(bundleName.ToLower());
		}

		public IEnumerable<string> GetMissingBundles(string[] bundleNames)
		{
			foreach (string bundleName in bundleNames)
			{
				if (!assetBundles.ContainsKey(bundleName.ToLower()))
				{
					yield return bundleName;
				}
			}
		}

		public IEnumerable<string> GetLoadedBundles(string[] bundleNames)
		{
			foreach (string bundleName in bundleNames)
			{
				if (assetBundles.ContainsKey(bundleName.ToLower()))
				{
					yield return bundleName;
				}
			}
		}

		public bool BundlesLoaded(string[] bundleNames)
		{
			foreach (string text in bundleNames)
			{
				if (!assetBundles.ContainsKey(text.ToLower()))
				{
					return false;
				}
			}
			return true;
		}

		public bool IncompatibleBundlesLoaded(string[] bundleNames)
		{
			foreach (string text in bundleNames)
			{
				if (assetBundles.ContainsKey(text.ToLower()))
				{
					return true;
				}
			}
			return false;
		}

		public bool IsScrapCompatible(Scrap scrap)
		{
			if ((Object)(object)scrap == (Object)null || (Object)(object)scrap.prefab == (Object)null)
			{
				return false;
			}
			if (scrap.RequiredBundles != null)
			{
				List<string> list = Instance.GetMissingBundles(scrap.RequiredBundles).ToList();
				if (list.Count > 0)
				{
					if (!LethalExpansion.Settings.IgnoreRequiredBundles.Value)
					{
						LethalExpansion.Log.LogWarning((object)("Scrap '" + scrap.itemName + "' can't be added, missing required bundles: " + string.Join(", ", list)));
						return false;
					}
					LethalExpansion.Log.LogWarning((object)("Scrap '" + scrap.itemName + "' may not work as intended, missing required bundles: " + string.Join(", ", list)));
				}
			}
			if (scrap.IncompatibleBundles != null)
			{
				List<string> list2 = Instance.GetLoadedBundles(scrap.IncompatibleBundles).ToList();
				if (list2.Count > 0)
				{
					LethalExpansion.Log.LogWarning((object)("Scrap '" + scrap.itemName + "' can't be added, incompatible bundles: " + string.Join(", ", list2)));
					return false;
				}
			}
			return true;
		}

		public bool IsMoonCompatible(Moon moon)
		{
			if ((Object)(object)moon == (Object)null || !moon.IsEnabled)
			{
				return false;
			}
			if (moon.RequiredBundles != null)
			{
				List<string> list = Instance.GetMissingBundles(moon.RequiredBundles).ToList();
				if (list.Count > 0)
				{
					if (!LethalExpansion.Settings.IgnoreRequiredBundles.Value)
					{
						LethalExpansion.Log.LogWarning((object)("Moon '" + moon.MoonName + "' can't be added, missing required bundles: " + string.Join(", ", list)));
						return false;
					}
					LethalExpansion.Log.LogWarning((object)("Moon '" + moon.MoonName + "' may not work as intended, missing required bundles: " + string.Join(", ", list)));
				}
			}
			if (moon.IncompatibleBundles != null)
			{
				List<string> list2 = Instance.GetLoadedBundles(moon.IncompatibleBundles).ToList();
				if (list2.Count > 0)
				{
					LethalExpansion.Log.LogWarning((object)("Moon '" + moon.MoonName + "' can't be added, incompatible bundles: " + string.Join(", ", list2)));
					return false;
				}
			}
			return true;
		}
	}
	public class AssetGather
	{
		private static AssetGather _instance;

		public Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>();

		public Dictionary<string, (AudioMixer, AudioMixerGroup[])> audioMixers = new Dictionary<string, (AudioMixer, AudioMixerGroup[])>();

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

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

		public Dictionary<string, SpawnableOutsideObject> outsideObjects = new Dictionary<string, SpawnableOutsideObject>();

		public Dictionary<string, Item> scraps = new Dictionary<string, Item>();

		public Dictionary<string, LevelAmbienceLibrary> levelAmbiances = new Dictionary<string, LevelAmbienceLibrary>();

		public Dictionary<string, EnemyType> enemies = new Dictionary<string, EnemyType>();

		public Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();

		public static AssetGather Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new AssetGather();
				}
				return _instance;
			}
		}

		public void GetList()
		{
			LethalExpansion.Log.LogInfo((object)"Audio Clips");
			foreach (KeyValuePair<string, AudioClip> audioClip in audioClips)
			{
				LethalExpansion.Log.LogInfo((object)audioClip.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Audio Mixers");
			foreach (KeyValuePair<string, (AudioMixer, AudioMixerGroup[])> audioMixer in audioMixers)
			{
				LethalExpansion.Log.LogInfo((object)audioMixer.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Planet Prefabs");
			foreach (KeyValuePair<string, GameObject> planetPrefab in planetPrefabs)
			{
				LethalExpansion.Log.LogInfo((object)planetPrefab.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Map Objects");
			foreach (KeyValuePair<string, GameObject> mapObject in mapObjects)
			{
				LethalExpansion.Log.LogInfo((object)mapObject.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Outside Objects");
			foreach (KeyValuePair<string, SpawnableOutsideObject> outsideObject in outsideObjects)
			{
				LethalExpansion.Log.LogInfo((object)outsideObject.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Scraps");
			foreach (KeyValuePair<string, Item> scrap in scraps)
			{
				LethalExpansion.Log.LogInfo((object)scrap.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Level Ambiances");
			foreach (KeyValuePair<string, LevelAmbienceLibrary> levelAmbiance in levelAmbiances)
			{
				LethalExpansion.Log.LogInfo((object)levelAmbiance.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Enemies");
			foreach (KeyValuePair<string, EnemyType> enemy in enemies)
			{
				LethalExpansion.Log.LogInfo((object)enemy.Key);
			}
			LethalExpansion.Log.LogInfo((object)"Sprites");
			foreach (KeyValuePair<string, Sprite> sprite in sprites)
			{
				LethalExpansion.Log.LogInfo((object)sprite.Key);
			}
		}

		public AudioMixerGroup GetDiageticMasterAudioMixer()
		{
			if (!audioMixers.TryGetValue("Diagetic", out var value))
			{
				return null;
			}
			return value.Item2.First((AudioMixerGroup a) => ((Object)a).name == "Master");
		}

		private void Add<T>(Dictionary<string, T> dictionary, string key, T value)
		{
			if (key != null && value != null && !dictionary.ContainsKey(key) && !dictionary.ContainsValue(value))
			{
				dictionary[key] = value;
			}
		}

		public void AddAudioClip(AudioClip clip)
		{
			AddAudioClip((clip != null) ? ((Object)clip).name : null, clip);
		}

		public void AddAudioClip(string name, AudioClip clip)
		{
			Add(audioClips, name, clip);
		}

		public void AddAudioClip(AudioClip[] clips)
		{
			if (clips != null)
			{
				foreach (AudioClip clip in clips)
				{
					AddAudioClip(clip);
				}
			}
		}

		public void AddAudioClip(string[] names, AudioClip[] clips)
		{
			if (names != null && clips != null)
			{
				for (int i = 0; i < clips.Length && i < names.Length; i++)
				{
					AddAudioClip(names[i], clips[i]);
				}
			}
		}

		public void AddAudioMixer(AudioMixer audioMixer)
		{
			if ((Object)(object)audioMixer == (Object)null || audioMixers.ContainsKey(((Object)audioMixer).name))
			{
				return;
			}
			List<AudioMixerGroup> list = new List<AudioMixerGroup>();
			AudioMixerGroup[] array = audioMixer.FindMatchingGroups(string.Empty);
			foreach (AudioMixerGroup val in array)
			{
				if (!((Object)(object)val == (Object)null) && !list.Contains(val))
				{
					list.Add(val);
				}
			}
			Add(audioMixers, ((Object)audioMixer).name, (audioMixer, list.ToArray()));
		}

		public void AddPlanetPrefabs(GameObject prefab)
		{
			AddPlanetPrefabs((prefab != null) ? ((Object)prefab).name : null, prefab);
		}

		public void AddPlanetPrefabs(string name, GameObject prefab)
		{
			Add(planetPrefabs, name, prefab);
		}

		public void AddMapObjects(GameObject mapObject)
		{
			Add(mapObjects, (mapObject != null) ? ((Object)mapObject).name : null, mapObject);
		}

		public void AddOutsideObject(SpawnableOutsideObject outsideObject)
		{
			Add(outsideObjects, (outsideObject != null) ? ((Object)outsideObject).name : null, outsideObject);
		}

		public void AddScrap(Item scrap)
		{
			Add(scraps, (scrap != null) ? ((Object)scrap).name : null, scrap);
		}

		public void AddLevelAmbiances(LevelAmbienceLibrary levelAmbiance)
		{
			Add(levelAmbiances, (levelAmbiance != null) ? ((Object)levelAmbiance).name : null, levelAmbiance);
		}

		public void AddEnemies(EnemyType enemy)
		{
			Add(enemies, (enemy != null) ? ((Object)enemy).name : null, enemy);
		}

		public void AddSprites(Sprite sprite)
		{
			AddSprites((sprite != null) ? ((Object)sprite).name : null, sprite);
		}

		public void AddSprites(string name, Sprite sprite)
		{
			Add(sprites, name, sprite);
		}
	}
	public static class ComponentWhitelist
	{
		public static List<Type> MoonPrefabComponentWhitelist = new List<Type>
		{
			typeof(Transform),
			typeof(MeshFilter),
			typeof(MeshRenderer),
			typeof(SkinnedMeshRenderer),
			typeof(MeshCollider),
			typeof(BoxCollider),
			typeof(SphereCollider),
			typeof(CapsuleCollider),
			typeof(SphereCollider),
			typeof(TerrainCollider),
			typeof(WheelCollider),
			typeof(ArticulationBody),
			typeof(ConstantForce),
			typeof(ConfigurableJoint),
			typeof(FixedJoint),
			typeof(HingeJoint),
			typeof(Cloth),
			typeof(Rigidbody),
			typeof(NetworkObject),
			typeof(NetworkRigidbody),
			typeof(NetworkTransform),
			typeof(NetworkAnimator),
			typeof(Animator),
			typeof(Animation),
			typeof(Terrain),
			typeof(Tree),
			typeof(WindZone),
			typeof(DecalProjector),
			typeof(LODGroup),
			typeof(Light),
			typeof(HDAdditionalLightData),
			typeof(LightProbeGroup),
			typeof(LightProbeProxyVolume),
			typeof(LocalVolumetricFog),
			typeof(OcclusionArea),
			typeof(OcclusionPortal),
			typeof(ReflectionProbe),
			typeof(PlanarReflectionProbe),
			typeof(HDAdditionalReflectionData),
			typeof(Skybox),
			typeof(SortingGroup),
			typeof(SpriteRenderer),
			typeof(Volume),
			typeof(AudioSource),
			typeof(AudioReverbZone),
			typeof(AudioReverbFilter),
			typeof(AudioChorusFilter),
			typeof(AudioDistortionFilter),
			typeof(AudioEchoFilter),
			typeof(AudioHighPassFilter),
			typeof(AudioLowPassFilter),
			typeof(AudioListener),
			typeof(LensFlare),
			typeof(TrailRenderer),
			typeof(LineRenderer),
			typeof(ParticleSystem),
			typeof(ParticleSystemRenderer),
			typeof(ParticleSystemForceField),
			typeof(Projector),
			typeof(VideoPlayer),
			typeof(NavMeshSurface),
			typeof(NavMeshModifier),
			typeof(NavMeshModifierVolume),
			typeof(NavMeshLink),
			typeof(NavMeshObstacle),
			typeof(OffMeshLink),
			typeof(SI_AudioReverbPresets),
			typeof(SI_AudioReverbTrigger),
			typeof(SI_DungeonGenerator),
			typeof(SI_MatchLocalPlayerPosition),
			typeof(SI_AnimatedSun),
			typeof(SI_EntranceTeleport),
			typeof(SI_ScanNode),
			typeof(SI_DoorLock),
			typeof(SI_WaterSurface),
			typeof(SI_Ladder),
			typeof(SI_ItemDropship),
			typeof(SI_NetworkPrefabInstancier),
			typeof(SI_InteractTrigger),
			typeof(SI_DamagePlayer),
			typeof(SI_SoundYDistance),
			typeof(SI_AudioOutputInterface),
			typeof(SI_NetworkDataInterfacing),
			typeof(PlayerShip),
			typeof(LECore_InactiveNetworkPrefabInstancier)
		};

		public static List<Type> ScrapPrefabComponentWhitelist = new List<Type>
		{
			typeof(Transform),
			typeof(MeshFilter),
			typeof(MeshRenderer),
			typeof(SkinnedMeshRenderer),
			typeof(MeshCollider),
			typeof(BoxCollider),
			typeof(SphereCollider),
			typeof(CapsuleCollider),
			typeof(SphereCollider),
			typeof(TerrainCollider),
			typeof(WheelCollider),
			typeof(ArticulationBody),
			typeof(ConstantForce),
			typeof(ConfigurableJoint),
			typeof(FixedJoint),
			typeof(HingeJoint),
			typeof(Cloth),
			typeof(Rigidbody),
			typeof(NetworkObject),
			typeof(NetworkRigidbody),
			typeof(NetworkTransform),
			typeof(NetworkAnimator),
			typeof(Animator),
			typeof(Animation),
			typeof(DecalProjector),
			typeof(LODGroup),
			typeof(Light),
			typeof(HDAdditionalLightData),
			typeof(LightProbeGroup),
			typeof(LightProbeProxyVolume),
			typeof(LocalVolumetricFog),
			typeof(OcclusionArea),
			typeof(OcclusionPortal),
			typeof(ReflectionProbe),
			typeof(PlanarReflectionProbe),
			typeof(HDAdditionalReflectionData),
			typeof(SortingGroup),
			typeof(SpriteRenderer),
			typeof(AudioSource),
			typeof(AudioReverbZone),
			typeof(AudioReverbFilter),
			typeof(AudioChorusFilter),
			typeof(AudioDistortionFilter),
			typeof(AudioEchoFilter),
			typeof(AudioHighPassFilter),
			typeof(AudioLowPassFilter),
			typeof(AudioListener),
			typeof(LensFlare),
			typeof(TrailRenderer),
			typeof(LineRenderer),
			typeof(ParticleSystem),
			typeof(ParticleSystemRenderer),
			typeof(ParticleSystemForceField),
			typeof(VideoPlayer),
			typeof(SI_DamagePlayer),
			typeof(SI_AudioOutputInterface)
		};

		public static void CheckAndRemoveIllegalComponents(Transform prefab, List<Type> whitelist)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			try
			{
				Component[] components = ((Component)prefab).GetComponents<Component>();
				Component[] array = components;
				foreach (Component component in array)
				{
					if (!whitelist.Any((Type whitelistType) => ((object)component).GetType() == whitelistType))
					{
						LethalExpansion.Log.LogWarning((object)$"Removed illegal component '{((object)component).GetType().Name}' from prefab '{prefab}'");
						Object.Destroy((Object)(object)component);
					}
				}
				foreach (Transform item in prefab)
				{
					Transform prefab2 = item;
					CheckAndRemoveIllegalComponents(prefab2, whitelist);
				}
			}
			catch (Exception arg)
			{
				LethalExpansion.Log.LogError((object)$"Failed to remove illegal components from prefab '{prefab}'. {arg}");
			}
		}
	}
	public static class VanillaAssetGatherer
	{
		public static void GatherAssets()
		{
			GatherIconAssets();
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				GatherItemAssets(items);
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel level in levels)
			{
				GatherLevelAssets(level);
			}
		}

		public static void GatherIconAssets()
		{
			AssetGather.Instance.AddSprites(GameObject.Find("Environment/HangarShip/StartGameLever").GetComponent<InteractTrigger>().hoverIcon);
			AssetGather.Instance.AddSprites(GameObject.Find("Environment/HangarShip/Terminal/TerminalTrigger/TerminalScript").GetComponent<InteractTrigger>().hoverIcon);
			AssetGather.Instance.AddSprites(GameObject.Find("Environment/HangarShip/OutsideShipRoom/Ladder/LadderTrigger").GetComponent<InteractTrigger>().hoverIcon);
		}

		public static void GatherItemAssets(Item item)
		{
			AssetGather.Instance.AddAudioClip(item.grabSFX);
			AssetGather.Instance.AddAudioClip(item.dropSFX);
			AssetGather.Instance.AddAudioClip(item.pocketSFX);
			AssetGather.Instance.AddAudioClip(item.throwSFX);
			GameObject spawnPrefab = item.spawnPrefab;
			if ((Object)(object)spawnPrefab != (Object)null)
			{
				GatherItemPrefabAssets(spawnPrefab);
			}
		}

		public static void GatherItemPrefabAssets(GameObject spawnPrefab)
		{
			Component[] components = spawnPrefab.GetComponents<Component>();
			foreach (Component component in components)
			{
				GatherItemPrefabComponentAssets(component);
			}
		}

		public static void GatherItemPrefabComponentAssets(Component component)
		{
			Shovel val = (Shovel)(object)((component is Shovel) ? component : null);
			if (val != null)
			{
				AssetGather.Instance.AddAudioClip(val.reelUp);
				AssetGather.Instance.AddAudioClip(val.swing);
				AssetGather.Instance.AddAudioClip(val.hitSFX);
				return;
			}
			FlashlightItem val2 = (FlashlightItem)(object)((component is FlashlightItem) ? component : null);
			if (val2 != null)
			{
				AssetGather.Instance.AddAudioClip(val2.flashlightClips);
				AssetGather.Instance.AddAudioClip(val2.outOfBatteriesClip);
				AssetGather.Instance.AddAudioClip(val2.flashlightFlicker);
				return;
			}
			WalkieTalkie val3 = (WalkieTalkie)(object)((component is WalkieTalkie) ? component : null);
			if (val3 != null)
			{
				AssetGather.Instance.AddAudioClip(val3.stopTransmissionSFX);
				AssetGather.Instance.AddAudioClip(val3.startTransmissionSFX);
				AssetGather.Instance.AddAudioClip(val3.switchWalkieTalkiePowerOff);
				AssetGather.Instance.AddAudioClip(val3.switchWalkieTalkiePowerOn);
				AssetGather.Instance.AddAudioClip(val3.talkingOnWalkieTalkieNotHeldSFX);
				AssetGather.Instance.AddAudioClip(val3.playerDieOnWalkieTalkieSFX);
				return;
			}
			ExtensionLadderItem val4 = (ExtensionLadderItem)(object)((component is ExtensionLadderItem) ? component : null);
			if (val4 != null)
			{
				AssetGather.Instance.AddAudioClip(val4.hitRoof);
				AssetGather.Instance.AddAudioClip(val4.fullExtend);
				AssetGather.Instance.AddAudioClip(val4.hitWall);
				AssetGather.Instance.AddAudioClip(val4.ladderExtendSFX);
				AssetGather.Instance.AddAudioClip(val4.ladderFallSFX);
				AssetGather.Instance.AddAudioClip(val4.ladderShrinkSFX);
				AssetGather.Instance.AddAudioClip(val4.blinkWarningSFX);
				AssetGather.Instance.AddAudioClip(val4.lidOpenSFX);
				return;
			}
			NoisemakerProp val5 = (NoisemakerProp)(object)((component is NoisemakerProp) ? component : null);
			if (val5 != null)
			{
				AssetGather.Instance.AddAudioClip(val5.noiseSFX);
				AssetGather.Instance.AddAudioClip(val5.noiseSFXFar);
				return;
			}
			PatcherTool val6 = (PatcherTool)(object)((component is PatcherTool) ? component : null);
			if (val6 != null)
			{
				AssetGather.Instance.AddAudioClip(val6.activateClips);
				AssetGather.Instance.AddAudioClip(val6.beginShockClips);
				AssetGather.Instance.AddAudioClip(val6.overheatClips);
				AssetGather.Instance.AddAudioClip(val6.finishShockClips);
				AssetGather.Instance.AddAudioClip(val6.outOfBatteriesClip);
				AssetGather.Instance.AddAudioClip(val6.detectAnomaly);
				AssetGather.Instance.AddAudioClip(val6.scanAnomaly);
				return;
			}
			WhoopieCushionItem val7 = (WhoopieCushionItem)(object)((component is WhoopieCushionItem) ? component : null);
			if (val7 != null)
			{
				AssetGather.Instance.AddAudioClip(val7.fartAudios);
				return;
			}
			ShotgunItem val8 = (ShotgunItem)(object)((component is ShotgunItem) ? component : null);
			if (val8 != null)
			{
				AssetGather.Instance.AddAudioClip(val8.gunShootSFX);
				AssetGather.Instance.AddAudioClip(val8.gunReloadSFX);
				AssetGather.Instance.AddAudioClip(val8.gunReloadFinishSFX);
				AssetGather.Instance.AddAudioClip(val8.noAmmoSFX);
				AssetGather.Instance.AddAudioClip(val8.gunSafetySFX);
				AssetGather.Instance.AddAudioClip(val8.switchSafetyOnSFX);
				AssetGather.Instance.AddAudioClip(val8.switchSafetyOffSFX);
			}
			else
			{
				AudioSource val9 = (AudioSource)(object)((component is AudioSource) ? component : null);
				if (val9 != null)
				{
					AssetGather.Instance.AddAudioClip(val9.clip);
				}
			}
		}

		public static void GatherLevelAssets(SelectableLevel level)
		{
			AssetGather.Instance.AddPlanetPrefabs(level.planetPrefab);
			AssetGather.Instance.AddLevelAmbiances(level.levelAmbienceClips);
			level.spawnableMapObjects.ToList().ForEach(delegate(SpawnableMapObject e)
			{
				AssetGather.Instance.AddMapObjects(e.prefabToSpawn);
			});
			level.spawnableOutsideObjects.ToList().ForEach(delegate(SpawnableOutsideObjectWithRarity e)
			{
				AssetGather.Instance.AddOutsideObject(e.spawnableObject);
			});
			level.spawnableScrap.ForEach(delegate(SpawnableItemWithRarity e)
			{
				AssetGather.Instance.AddScrap(e.spawnableItem);
			});
			level.Enemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				AssetGather.Instance.AddEnemies(e.enemyType);
			});
			level.OutsideEnemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				AssetGather.Instance.AddEnemies(e.enemyType);
			});
			level.DaytimeEnemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				AssetGather.Instance.AddEnemies(e.enemyType);
			});
		}
	}
	public static class VanillaItemInstancier
	{
		public static Item GetItem(Scrap scrap)
		{
			object result;
			if (scrap == null)
			{
				result = null;
			}
			else
			{
				GameObject prefab = scrap.prefab;
				result = ((prefab == null) ? null : prefab.GetComponent<GrabbableObject>()?.itemProperties);
			}
			return (Item)result;
		}

		public static void UpdateAudio(Scrap scrap)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_0011: 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_0029: Expected I4, but got Unknown
			UpdateItemAudio(scrap);
			ScrapType scrapType = scrap.scrapType;
			ScrapType val = scrapType;
			switch (val - 1)
			{
			case 0:
				UpdateShovelAudio(scrap);
				break;
			case 1:
				UpdateFlashlightAudio(scrap);
				break;
			case 2:
				UpdateNoisemakerAudio(scrap);
				break;
			case 3:
				UpdateWhoopieCushionAudio(scrap);
				break;
			}
		}

		public static void UpdateItemAudio(Scrap scrap)
		{
			Item item = GetItem(scrap);
			AudioSource component = scrap.prefab.GetComponent<AudioSource>();
			if ((Object)(object)component != (Object)null)
			{
				component.outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
			}
			item.grabSFX = GetAudioClip(scrap.grabSFX, "ShovelPickUp");
			item.dropSFX = GetAudioClip(scrap.dropSFX, "DropCan");
		}

		public static void UpdateShovelAudio(Scrap scrap)
		{
			Shovel component = scrap.prefab.GetComponent<Shovel>();
			if (!((Object)(object)component == (Object)null))
			{
				component.reelUp = GetAudioClip(scrap.reelUp, "ShovelReelUp");
				component.swing = GetAudioClip(scrap.swing, "ShovelSwing");
				component.hitSFX = GetAudioClips(scrap.hitSFX, "ShovelHitDefault", "ShovelHitDefault2");
			}
		}

		public static void UpdateFlashlightAudio(Scrap scrap)
		{
			FlashlightItem component = scrap.prefab.GetComponent<FlashlightItem>();
			if (!((Object)(object)component == (Object)null))
			{
				component.outOfBatteriesClip = GetAudioClip(scrap.outOfBatteriesClip, "FlashlightOutOfBatteries");
				component.flashlightFlicker = GetAudioClip(scrap.flashlightFlicker, "FlashlightFlicker");
				component.flashlightClips = GetAudioClips(scrap.flashlightClips, "FlashlightClick");
			}
		}

		public static void UpdateNoisemakerAudio(Scrap scrap)
		{
			NoisemakerProp component = scrap.prefab.GetComponent<NoisemakerProp>();
			if (!((Object)(object)component == (Object)null))
			{
				component.noiseAudio.outputAudioMixerGroup = AssetGather.Instance.GetDiageticMasterAudioMixer();
				component.noiseSFX = GetAudioClips(scrap.noiseSFX, "ClownHorn1");
				component.noiseSFXFar = GetAudioClips(scrap.noiseSFXFar, "ClownHornFar");
			}
		}

		public static void UpdateWhoopieCushionAudio(Scrap scrap)
		{
			WhoopieCushionItem component = scrap.prefab.GetComponent<WhoopieCushionItem>();
			if (!((Object)(object)component == (Object)null))
			{
				component.fartAudios = GetAudioClips(scrap.fartAudios, "Fart1", "Fart2", "Fart3", "Fart5");
			}
		}

		public static AudioClip GetAudioClip(string audioClipName, string defaultAudioClipName)
		{
			AudioClip value = null;
			if (!string.IsNullOrWhiteSpace(audioClipName))
			{
				AssetGather.Instance.audioClips.TryGetValue(audioClipName, out value);
			}
			if ((Object)(object)value != (Object)null)
			{
				return value;
			}
			return AssetGather.Instance.audioClips[defaultAudioClipName];
		}

		public static AudioClip[] GetAudioClips(string[] audioClipNames, params string[] defaultAudioClipNames)
		{
			List<AudioClip> list = new List<AudioClip>();
			if (audioClipNames != null)
			{
				foreach (string key in audioClipNames)
				{
					if (AssetGather.Instance.audioClips.TryGetValue(key, out var value))
					{
						list.Add(value);
					}
				}
			}
			if (list.Count > 0)
			{
				return list.ToArray();
			}
			return defaultAudioClipNames.Select((string audioClipName) => AssetGather.Instance.audioClips[audioClipName]).ToArray();
		}

		public static void AddItemToScrap(Scrap scrap, Sprite scrapSprite)
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			AudioSource val = scrap.prefab.AddComponent<AudioSource>();
			val.playOnAwake = false;
			val.spatialBlend = 1f;
			Item val2 = ScriptableObject.CreateInstance<Item>();
			((Object)val2).name = ((Object)scrap).name;
			val2.itemName = scrap.itemName;
			val2.canBeGrabbedBeforeGameStart = true;
			val2.isScrap = true;
			val2.minValue = scrap.minValue;
			val2.maxValue = scrap.maxValue;
			val2.weight = (float)scrap.weight / 100f + 1f;
			ComponentWhitelist.CheckAndRemoveIllegalComponents(scrap.prefab.transform, ComponentWhitelist.ScrapPrefabComponentWhitelist);
			val2.spawnPrefab = scrap.prefab;
			val2.twoHanded = scrap.twoHanded;
			val2.requiresBattery = scrap.requiresBattery;
			val2.isConductiveMetal = scrap.isConductiveMetal;
			(bool, string) grabAnimation = GetGrabAnimation(scrap);
			bool item = grabAnimation.Item1;
			string item2 = grabAnimation.Item2;
			val2.twoHandedAnimation = item;
			val2.grabAnim = item2;
			val2.itemIcon = scrapSprite;
			val2.syncGrabFunction = false;
			val2.syncUseFunction = false;
			val2.syncDiscardFunction = false;
			val2.syncInteractLRFunction = false;
			val2.verticalOffset = scrap.verticalOffset;
			val2.restingRotation = scrap.restingRotation;
			val2.positionOffset = scrap.positionOffset;
			val2.rotationOffset = scrap.rotationOffset;
			val2.meshOffset = false;
			val2.meshVariants = scrap.meshVariants;
			val2.materialVariants = scrap.materialVariants;
			val2.canBeInspected = false;
			GrabbableObject val3 = AddGrabbableObject(scrap, val2);
			val3.grabbable = true;
			val3.itemProperties = val2;
			val3.mainObjectRenderer = scrap.prefab.GetComponent<MeshRenderer>();
			Transform val4 = scrap.prefab.transform.Find("ScanNode");
			if ((Object)(object)val4 != (Object)null)
			{
				ScanNodeProperties val5 = ((Component)val4).gameObject.AddComponent<ScanNodeProperties>();
				val5.maxRange = 13;
				val5.minRange = 1;
				val5.headerText = scrap.itemName;
				val5.subText = "Value: ";
				val5.nodeType = 2;
			}
		}

		public static GrabbableObject AddGrabbableObject(Scrap scrap, Item item)
		{
			//IL_0002: 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_0009: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Expected I4, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			ScrapType scrapType = scrap.scrapType;
			ScrapType val = scrapType;
			switch ((int)val)
			{
			case 0:
				return (GrabbableObject)(object)scrap.prefab.AddComponent<PhysicsProp>();
			case 1:
			{
				item.holdButtonUse = true;
				Shovel val3 = scrap.prefab.AddComponent<Shovel>();
				val3.shovelHitForce = scrap.shovelHitForce;
				val3.shovelAudio = scrap.shovelAudio ?? scrap.prefab.GetComponent<AudioSource>() ?? scrap.prefab.AddComponent<AudioSource>();
				if ((Object)(object)scrap.prefab.GetComponent<OccludeAudio>() == (Object)null)
				{
					scrap.prefab.AddComponent<OccludeAudio>();
				}
				return (GrabbableObject)(object)val3;
			}
			case 2:
			{
				FlashlightItem val4 = scrap.prefab.AddComponent<FlashlightItem>();
				val4.usingPlayerHelmetLight = scrap.usingPlayerHelmetLight;
				val4.flashlightInterferenceLevel = scrap.flashlightInterferenceLevel;
				val4.flashlightBulb = scrap.flashlightBulb;
				if ((Object)(object)val4.flashlightBulb == (Object)null)
				{
					val4.flashlightBulb = new Light();
					val4.flashlightBulb.intensity = 0f;
				}
				val4.flashlightBulbGlow = scrap.flashlightBulbGlow;
				if ((Object)(object)val4.flashlightBulbGlow == (Object)null)
				{
					val4.flashlightBulbGlow = new Light();
					val4.flashlightBulbGlow.intensity = 0f;
				}
				val4.flashlightAudio = scrap.flashlightAudio ?? scrap.prefab.GetComponent<AudioSource>() ?? scrap.prefab.AddComponent<AudioSource>();
				if ((Object)(object)scrap.prefab.GetComponent<OccludeAudio>() == (Object)null)
				{
					scrap.prefab.AddComponent<OccludeAudio>();
				}
				val4.bulbLight = (Material)(((object)scrap.bulbLight) ?? ((object)new Material(Shader.Find("HDRP/Lit"))));
				val4.bulbDark = (Material)(((object)scrap.bulbDark) ?? ((object)new Material(Shader.Find("HDRP/Lit"))));
				val4.flashlightMesh = scrap.flashlightMesh ?? ((GrabbableObject)val4).mainObjectRenderer;
				val4.flashlightTypeID = scrap.flashlightTypeID;
				val4.changeMaterial = scrap.changeMaterial;
				return (GrabbableObject)(object)val4;
			}
			case 3:
			{
				NoisemakerProp val5 = scrap.prefab.AddComponent<NoisemakerProp>();
				val5.noiseAudio = scrap.noiseAudio;
				if ((Object)(object)val5.noiseAudio == (Object)null)
				{
					val5.noiseAudio = scrap.prefab.AddComponent<AudioSource>();
					val5.noiseAudio.playOnAwake = false;
					val5.noiseAudio.priority = 128;
					val5.noiseAudio.pitch = 1f;
					val5.noiseAudio.panStereo = 0f;
					val5.noiseAudio.spatialBlend = 1f;
					val5.noiseAudio.reverbZoneMix = 1f;
					val5.noiseAudio.dopplerLevel = 4f;
					val5.noiseAudio.spread = 26f;
					val5.noiseAudio.minDistance = 4f;
					val5.noiseAudio.maxDistance = 21f;
					val5.noiseAudio.rolloffMode = (AudioRolloffMode)1;
				}
				val5.noiseAudioFar = scrap.noiseAudioFar;
				if ((Object)(object)val5.noiseAudioFar == (Object)null)
				{
					val5.noiseAudioFar = scrap.prefab.AddComponent<AudioSource>();
					val5.noiseAudioFar.playOnAwake = true;
					val5.noiseAudioFar.priority = 128;
					val5.noiseAudioFar.pitch = 1f;
					val5.noiseAudioFar.panStereo = 0f;
					val5.noiseAudioFar.spatialBlend = 1f;
					val5.noiseAudioFar.reverbZoneMix = 1f;
					val5.noiseAudioFar.dopplerLevel = 1.4f;
					val5.noiseAudioFar.spread = 87f;
					val5.noiseAudioFar.maxDistance = 75f;
					val5.noiseAudioFar.rolloffMode = (AudioRolloffMode)2;
					val5.noiseAudioFar.SetCustomCurve((AudioSourceCurveType)0, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(18f, 0f, 0f, 0.065f),
						new Keyframe(25.59f, 0.866f, -0.01f, -0.01f),
						new Keyframe(87f, 0f, -0.018f, 0f)
					}));
				}
				val5.noiseRange = scrap.noiseRange;
				val5.maxLoudness = scrap.maxLoudness;
				val5.minLoudness = scrap.minLoudness;
				val5.minPitch = scrap.minPitch;
				val5.maxPitch = scrap.maxPitch;
				val5.triggerAnimator = scrap.triggerAnimator;
				item.syncUseFunction = true;
				return (GrabbableObject)(object)val5;
			}
			case 4:
			{
				WhoopieCushionItem val2 = scrap.prefab.AddComponent<WhoopieCushionItem>();
				val2.whoopieCushionAudio = scrap.whoopieCushionAudio ?? scrap.prefab.GetComponent<AudioSource>() ?? scrap.prefab.AddComponent<AudioSource>();
				return (GrabbableObject)(object)val2;
			}
			default:
				LethalExpansion.Log.LogWarning((object)$"Unknown scrap type '{(int)scrap.scrapType}' for scrap '{scrap.itemName}'");
				return (GrabbableObject)(object)scrap.prefab.AddComponent<PhysicsProp>();
			}
		}

		public static (bool, string) GetGrabAnimation(Scrap scrap)
		{
			//IL_0002: 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_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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected I4, but got Unknown
			GrabAnim handedAnimation = scrap.HandedAnimation;
			GrabAnim val = handedAnimation;
			return (int)val switch
			{
				0 => (false, string.Empty), 
				1 => (true, "HoldLung"), 
				2 => (true, "HoldShotgun"), 
				3 => (true, "HoldJetpack"), 
				4 => (false, "GrabClipboard"), 
				_ => (false, string.Empty), 
			};
		}
	}
}
namespace LethalExpansionCore.Patches
{
	[HarmonyPatch(typeof(AudioReverbTrigger))]
	internal class AudioReverbTrigger_Patch
	{
		[HarmonyPatch("ChangeAudioReverbForPlayer")]
		[HarmonyPostfix]
		public static void SChangeAudioReverbForPlayer_Postfix(AudioReverbTrigger __instance)
		{
			if ((Object)(object)LethalExpansion.currentWaterSurface != (Object)null)
			{
				((Component)LethalExpansion.currentWaterSurface).gameObject.SetActive(!__instance.disableAllWeather);
			}
		}
	}
	[HarmonyPatch(typeof(DungeonGenerator))]
	public class DungeonGenerator_Patch
	{
		[HarmonyPatch("Generate")]
		[HarmonyPrefix]
		public static void Generate_Prefix(DungeonGenerator __instance, out IntRange __state)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			if (!Terminal_Patch.newMoons.ContainsKey(RoundManager.Instance.currentLevel.levelID))
			{
				__state = null;
				return;
			}
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			EntranceTeleport[] array2 = array.OrderBy((EntranceTeleport entrance) => entrance.entranceId).ToArray();
			for (int i = 0; i < array2.Length; i++)
			{
				EntranceTeleport val = array2[i];
				if (val.entranceId != i)
				{
					LethalExpansion.Log.LogWarning((object)$"Entrance '{((Component)val).gameObject}' has an unexpected id, updating id from '{val.entranceId}' to '{i}'");
				}
				val.entranceId = i;
			}
			IntRange val2 = SetFireExitAmount(__instance.DungeonFlow, new IntRange(array.Length - 1, array.Length - 1));
			__state = val2;
		}

		[HarmonyPatch("Generate")]
		[HarmonyPostfix]
		public static void Generate_Postfix(DungeonGenerator __instance, IntRange __state)
		{
			if (__state != null)
			{
				SetFireExitAmount(__instance.DungeonFlow, __state);
			}
		}

		public static IntRange SetFireExitAmount(DungeonFlow dungeonFlow, IntRange newRange)
		{
			GlobalPropSettings val = dungeonFlow.GlobalProps.Where((GlobalPropSettings props) => props.ID == 1231).First();
			LethalExpansion.Log.LogInfo((object)$"Updating fire exit count from ({val.Count}) to ({newRange})");
			IntRange count = val.Count;
			val.Count = newRange;
			return count;
		}
	}
	[HarmonyPatch(typeof(EntranceTeleport))]
	public class EntranceTeleport_Patch
	{
		[HarmonyPatch("SetAudioPreset")]
		[HarmonyPrefix]
		public static bool SetAudioPreset_Prefix(EntranceTeleport __instance, int playerObj)
		{
			if ((Object)(object)Object.FindObjectOfType<AudioReverbPresets>() == (Object)null)
			{
				__instance.PlayAudioAtTeleportPositions();
				return false;
			}
			if (Object.FindObjectOfType<AudioReverbPresets>().audioPresets.Length <= __instance.audioReverbPreset)
			{
				__instance.PlayAudioAtTeleportPositions();
				return false;
			}
			return true;
		}

		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPostfix]
		public static void TeleportPlayer_Postfix(EntranceTeleport __instance)
		{
			SI_WaterSurface val = Object.FindObjectOfType<SI_WaterSurface>();
			if (!((Object)(object)val == (Object)null))
			{
				if (__instance.isEntranceToBuilding)
				{
					((Behaviour)((Component)val).GetComponentInChildren<AudioSource>()).enabled = false;
				}
				else
				{
					((Behaviour)((Component)val).GetComponentInChildren<AudioSource>()).enabled = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManager_Patch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void Start_Prefix(GameNetworkManager __instance)
		{
			AssetBundle mainAssetBundle = AssetBundlesManager.Instance.mainAssetBundle;
			ModManifest manifest = mainAssetBundle.LoadAsset<ModManifest>("Assets/Mods/LethalExpansion/modmanifest.asset");
			LoadNetworkPrefabs(__instance, mainAssetBundle, manifest, allowIllegalComponents: true);
			List<GameObject> usedPrefabs = new List<GameObject>();
			Sprite scrapSprite = mainAssetBundle.LoadAsset<Sprite>("Assets/Mods/LethalExpansion/Sprites/ScrapItemIcon2.png");
			foreach (KeyValuePair<string, (AssetBundle, ModManifest)> assetBundle in AssetBundlesManager.Instance.assetBundles)
			{
				var (val, val2) = AssetBundlesManager.Instance.Load(assetBundle.Key);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					try
					{
						LoadScrapPrefabs(__instance, val, val2, scrapSprite, usedPrefabs);
						LoadNetworkPrefabs(__instance, val, val2);
						LoadMoonPrefabs(__instance, val, val2);
					}
					catch (Exception ex)
					{
						LethalExpansion.Log.LogError((object)("Failed to register AssetBundle prefabs for '" + val2.modName + "', this may cause issues. " + ex.Message));
					}
				}
			}
		}

		private static void LoadScrapPrefabs(GameNetworkManager networkManager, AssetBundle assetBundle, ModManifest manifest, Sprite scrapSprite, List<GameObject> usedPrefabs)
		{
			Scrap[] scraps = manifest.scraps;
			if (scraps == null || scraps.Length == 0)
			{
				return;
			}
			NetworkPrefabHandler prefabHandler = ((Component)networkManager).GetComponent<NetworkManager>().PrefabHandler;
			Scrap[] scraps2 = manifest.scraps;
			foreach (Scrap scrap in scraps2)
			{
				if (!AssetBundlesManager.Instance.IsScrapCompatible(scrap))
				{
					continue;
				}
				if (usedPrefabs.Any((GameObject prefab) => prefab == scrap.prefab))
				{
					LethalExpansion.Log.LogWarning((object)("Prefab used by scrap '" + scrap.itemName + "' from '" + manifest.modName + "' is already in use by another scrap"));
					continue;
				}
				usedPrefabs.Add(scrap.prefab);
				try
				{
					VanillaItemInstancier.AddItemToScrap(scrap, scrapSprite);
					prefabHandler.AddNetworkPrefab(scrap.prefab);
					LethalExpansion.Log.LogInfo((object)("Registered scrap '" + scrap.itemName + "' from '" + manifest.modName + "'"));
				}
				catch (Exception arg)
				{
					LethalExpansion.Log.LogError((object)$"Failed to register scrap '{scrap.itemName}' from '{manifest.modName}'. {arg}");
				}
			}
		}

		private static void LoadNetworkPrefabs(GameNetworkManager networkManager, AssetBundle assetBundle, ModManifest manifest, bool allowIllegalComponents = false)
		{
			//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_004b: 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)
			AssetBank assetBank = manifest.assetBank;
			PrefabInfoPair[] array = ((assetBank != null) ? assetBank.NetworkPrefabs() : null);
			if (array == null || array.Length == 0)
			{
				return;
			}
			NetworkPrefabHandler prefabHandler = ((Component)networkManager).GetComponent<NetworkManager>().PrefabHandler;
			PrefabInfoPair[] array2 = array;
			foreach (PrefabInfoPair val in array2)
			{
				string prefabPath = val.PrefabPath;
				if (!string.IsNullOrEmpty(prefabPath))
				{
					GameObject val2 = assetBundle.LoadAsset<GameObject>(prefabPath);
					if (!allowIllegalComponents)
					{
						ComponentWhitelist.CheckAndRemoveIllegalComponents(val2.transform, ComponentWhitelist.ScrapPrefabComponentWhitelist);
					}
					prefabHandler.AddNetworkPrefab(val2);
					LethalExpansion.Log.LogInfo((object)("Registered prefab '" + val.PrefabName + "' from '" + manifest.modName + "'"));
				}
			}
		}

		private static void LoadMoonPrefabs(GameNetworkManager networkManager, AssetBundle assetBundle, ModManifest manifest)
		{
			Moon[] moons = manifest.moons;
			if (moons == null || moons.Length == 0)
			{
				return;
			}
			NetworkPrefabHandler prefabHandler = ((Component)networkManager).GetComponent<NetworkManager>().PrefabHandler;
			Moon[] moons2 = manifest.moons;
			foreach (Moon val in moons2)
			{
				if (!AssetBundlesManager.Instance.IsMoonCompatible(val))
				{
					continue;
				}
				if ((Object)(object)val.MainPrefab == (Object)null)
				{
					LethalExpansion.Log.LogWarning((object)("Moon '" + val.PlanetName + "' does not have a MainPrefab"));
					continue;
				}
				try
				{
					InitializeMoon(val, prefabHandler);
					LethalExpansion.Log.LogInfo((object)("Registered moon '" + val.MoonName + "' from '" + manifest.modName + "'"));
				}
				catch (Exception arg)
				{
					LethalExpansion.Log.LogError((object)$"Failed to register moon '{val.MoonName}' from '{manifest.modName}'. {arg}");
				}
			}
		}

		private static NetworkObject AddNetworkObject(GameObject gameObject)
		{
			List<NetworkPrefab> networkPrefabs = Traverse.Create((object)NetworkManager.Singleton.NetworkConfig.Prefabs).Field("m_Prefabs").GetValue<List<NetworkPrefab>>();
			uint id = networkPrefabs.First((NetworkPrefab i) => networkPrefabs.Any((NetworkPrefab x) => x.SourcePrefabGlobalObjectIdHash != i.SourcePrefabGlobalObjectIdHash + 1)).SourcePrefabGlobalObjectIdHash + 1;
			return AddNetworkObject(gameObject, id);
		}

		private static NetworkObject AddNetworkObject(GameObject gameObject, string uniqueIdentifier)
		{
			uint id = BitConverter.ToUInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(uniqueIdentifier)), 0);
			return AddNetworkObject(gameObject, id);
		}

		private static NetworkObject AddNetworkObject(GameObject gameObject, uint id)
		{
			NetworkObject val = gameObject.AddComponent<NetworkObject>();
			Traverse.Create((object)val).Field("GlobalObjectIdHash").SetValue((object)id);
			LethalExpansion.Log.LogInfo((object)$"Added NetworkObject with id '{id}' to '{gameObject}'");
			return val;
		}

		private static void InitializeMoon(Moon moon, NetworkPrefabHandler prefabHandler)
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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)
			SI_EntranceTeleport[] componentsInChildren = moon.MainPrefab.GetComponentsInChildren<SI_EntranceTeleport>();
			foreach (SI_EntranceTeleport val in componentsInChildren)
			{
				NetworkObject val2 = ((Component)val).GetComponent<NetworkObject>();
				if (!Object.op_Implicit((Object)(object)val2))
				{
					if (Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<NetworkObject>()))
					{
						continue;
					}
					LethalExpansion.Log.LogInfo((object)$"Adding missing NetworkObject to EntranceTeleport '{((Component)val).gameObject}' to fix desync issue");
					val2 = AddNetworkObject(((Component)val).gameObject, $"{moon.MoonName}_{((Object)((Component)val).gameObject).name}_{val.EntranceID}_{val.EntrancePoint.position}");
				}
				GameObject gameObject = ((Component)val2).gameObject;
				gameObject.AddComponent<NetworkTransform>();
				gameObject.SetActive(false);
				GameObject gameObject2 = ((Component)gameObject.transform.parent).gameObject;
				GameObject val3 = new GameObject("NetworkPrefabInstancier");
				val3.transform.parent = gameObject2.transform;
				val3.transform.position = gameObject.transform.position;
				val3.transform.rotation = gameObject.transform.rotation;
				val3.AddComponent<LECore_InactiveNetworkPrefabInstancier>().prefab = gameObject;
				prefabHandler.AddNetworkPrefab(gameObject);
				prefabHandler.AddHandler(gameObject, (INetworkPrefabInstanceHandler)(object)new InactiveNetworkPrefabInstanceHandler(gameObject));
			}
		}
	}
	[HarmonyPatch(typeof(InteractTrigger))]
	internal class InteractTrigger_Patch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start_Postfix(AudioReverbTrigger __instance)
		{
			((Component)__instance).gameObject.AddComponent<InteractTrigger_Extension>();
		}
	}
	public class InteractTrigger_Extension : MonoBehaviour
	{
		private InteractTrigger trigger;

		private void Awake()
		{
			trigger = ((Component)this).GetComponent<InteractTrigger>();
		}

		private void OnTriggerExit(Collider other)
		{
			if (!((Object)(object)trigger == (Object)null) && trigger.touchTrigger)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if (((Component)other).gameObject.CompareTag("Player") && (Object)(object)component != (Object)null && ((NetworkBehaviour)component).IsOwner)
				{
					((UnityEvent<PlayerControllerB>)(object)trigger.onStopInteract).Invoke(component);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManager_Patch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void Awake_Postfix(MenuManager __instance)
		{
			if (LethalExpansion.Settings.ShowVersionNumberOnMainMenu.Value && (Object)(object)__instance.versionNumberText != (Object)null)
			{
				((TMP_Text)__instance.versionNumberText).enableWordWrapping = false;
				TextMeshProUGUI versionNumberText = __instance.versionNumberText;
				((TMP_Text)versionNumberText).text = ((TMP_Text)versionNumberText).text + $"     LE(core)patch v{LethalExpansion.ModVersion}";
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManager_Patch
	{
		[HarmonyPatch("SpawnMapObjects")]
		[HarmonyPrefix]
		public static bool SpawnMapObjects_Prefix(RoundManager __instance)
		{
			return __instance.currentLevel.spawnableMapObjects != null;
		}

		[HarmonyPatch("PlotOutEnemiesForNextHour")]
		[HarmonyPrefix]
		public static bool PlotOutEnemiesForNextHour_Prefix(RoundManager __instance)
		{
			return __instance.currentLevel.enemySpawnChanceThroughoutDay != null;
		}

		[HarmonyPatch("SpawnEnemiesOutside")]
		[HarmonyPrefix]
		public static bool SpawnEnemiesOutside_Prefix(RoundManager __instance)
		{
			return __instance.currentLevel.outsideEnemySpawnChanceThroughDay != null;
		}

		[HarmonyPatch("SpawnDaytimeEnemiesOutside")]
		[HarmonyPrefix]
		public static bool SpawnDaytimeEnemiesOutside_Prefix(RoundManager __instance)
		{
			return __instance.currentLevel.daytimeEnemySpawnChanceThroughDay != null;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRound_Patch
	{
		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		public static void StartGame_Postfix(StartOfRound __instance)
		{
			if (((Object)__instance.currentLevel).name.StartsWith("Assets/Mods/"))
			{
				SceneManager.LoadScene(((Object)__instance.currentLevel).name, (LoadSceneMode)1);
			}
			LethalExpansion.Log.LogInfo((object)"Game started.");
		}

		[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
		[HarmonyPostfix]
		private static void SetMapScreenInfoToCurrentLevel_Postfix(StartOfRound __instance)
		{
			AutoScrollText component = ((Component)__instance.screenLevelDescription).GetComponent<AutoScrollText>();
			if ((Object)(object)component != (Object)null)
			{
				component.ResetScrolling();
			}
		}

		[HarmonyPatch("ChangeLevel")]
		[HarmonyPrefix]
		private static void ChangeLevel_Prefix(StartOfRound __instance, ref int levelID)
		{
			if (levelID >= __instance.levels.Length)
			{
				levelID = 0;
				LethalExpansion.Log.LogError((object)$"Error loading moon ID {levelID}.");
			}
		}
	}
	internal class Terminal_Patch
	{
		private static TerminalKeyword[] defaultTerminalKeywords;

		public static bool scrapsPatched = false;

		public static bool moonsPatched = false;

		public static bool moonsTerminalPatched = false;

		public static bool assetsGotten = false;

		public static TerminalKeyword routeKeyword;

		public static TerminalKeyword infoKeyword;

		public static List<string> newScrapsNames = new List<string>();

		public static List<string> newMoonsNames = new List<string>();

		public static Dictionary<int, Moon> newMoons = new Dictionary<int, Moon>();

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		public static void StartOfRound_Awake()
		{
			AddContent();
		}

		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPrefix]
		public static void Terminal_Start(Terminal __instance)
		{
			UpdateTerminal(__instance);
		}

		public static void AddContent()
		{
			scrapsPatched = false;
			moonsPatched = false;
			GatherAssets();
			AddScraps();
			AddMoons();
			UpdateAllScrapSpawnRate();
			LethalExpansion.Log.LogInfo((object)"Finished adding moons and scrap");
		}

		public static void UpdateTerminal(Terminal terminal)
		{
			moonsTerminalPatched = false;
			routeKeyword = terminal.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "route");
			infoKeyword = terminal.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "info");
			Hotfix_DoubleRoutes();
			ResetTerminalKeywords(terminal);
			AddMoonTerminalEntries(terminal);
			UpdateMoonsCatalogue(terminal);
			StartOfRound.Instance.SetPlanetsWeather(0);
			LethalExpansion.Log.LogInfo((object)"Finished updating terminal");
		}

		private static void GatherAssets()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00de: Unknown result type (might be due to invalid IL or missing references)
			if (assetsGotten)
			{
				return;
			}
			VanillaAssetGatherer.GatherAssets();
			foreach (KeyValuePair<string, (AssetBundle, ModManifest)> contentAssetBundle in AssetBundlesManager.Instance.contentAssetBundles)
			{
				var (val, val2) = AssetBundlesManager.Instance.Load(contentAssetBundle.Key);
				if ((Object)(object)val2.assetBank == (Object)null)
				{
					continue;
				}
				try
				{
					AudioClipInfoPair[] array = val2.assetBank.AudioClips();
					foreach (AudioClipInfoPair val3 in array)
					{
						AssetGather.Instance.AddAudioClip(val3.AudioClipName, val.LoadAsset<AudioClip>(val3.AudioClipPath));
					}
					PlanetPrefabInfoPair[] array2 = val2.assetBank.PlanetPrefabs();
					foreach (PlanetPrefabInfoPair val4 in array2)
					{
						GameObject val5 = val.LoadAsset<GameObject>(val4.PlanetPrefabPath);
						if (!((Object)(object)val5 == (Object)null))
						{
							Animator val6;
							if ((Object)(object)val5.GetComponent<Animator>() == (Object)null)
							{
								val6 = val5.AddComponent<Animator>();
							}
							val6 = AssetGather.Instance.planetPrefabs.First().Value.GetComponent<Animator>();
							AssetGather.Instance.AddPlanetPrefabs(val5);
						}
					}
				}
				catch (Exception ex)
				{
					LethalExpansion.Log.LogError((object)("Failed to collect prefabs from AssetBundle '" + val2.modName + "'. " + ex.Message));
				}
			}
			AssetGatherDialog.audioClips = AssetGather.Instance.audioClips;
			AssetGatherDialog.audioMixers = AssetGather.Instance.audioMixers;
			AssetGatherDialog.sprites = AssetGather.Instance.sprites;
			assetsGotten = true;
		}

		public static void AddScraps()
		{
			if (scrapsPatched)
			{
				return;
			}
			List<string> list = (from excludedScrap in LethalExpansion.Settings.ExcludedScrap.Value.Split(new char[1] { ',' })
				select excludedScrap.ToLower()).ToList();
			foreach (KeyValuePair<string, (AssetBundle, ModManifest)> contentAssetBundle in AssetBundlesManager.Instance.contentAssetBundles)
			{
				var (val, val2) = AssetBundlesManager.Instance.Load(contentAssetBundle.Key);
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || val2.scraps == null)
				{
					continue;
				}
				Scrap[] scraps = val2.scraps;
				foreach (Scrap val3 in scraps)
				{
					if (!AssetBundlesManager.Instance.IsScrapCompatible(val3))
					{
						continue;
					}
					if (newScrapsNames.Contains(val3.itemName))
					{
						LethalExpansion.Log.LogWarning((object)("Scrap '" + val3.itemName + "' has already been added"));
						continue;
					}
					if (list.Contains(val3.itemName?.ToLower()))
					{
						LethalExpansion.Log.LogWarning((object)("Scrap '" + val3.itemName + "' was excluded in the config"));
						continue;
					}
					try
					{
						VanillaItemInstancier.UpdateAudio(val3);
						AddScrap(val3);
						LethalExpansion.Log.LogInfo((object)("Added scrap '" + val3.itemName + "'"));
					}
					catch (Exception ex)
					{
						LethalExpansion.Log.LogError((object)("Failed to add scrap '" + val3.itemName + "'. " + ex.Message));
					}
				}
			}
			scrapsPatched = true;
		}

		public static void UpdateAllScrapSpawnRate()
		{
			foreach (KeyValuePair<string, (AssetBundle, ModManifest)> contentAssetBundle in AssetBundlesManager.Instance.contentAssetBundles)
			{
				var (val, val2) = AssetBundlesManager.Instance.Load(contentAssetBundle.Key);
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || val2.scraps == null)
				{
					continue;
				}
				Scrap[] scraps = val2.scraps;
				foreach (Scrap val3 in scraps)
				{
					if (AssetBundlesManager.Instance.IsScrapCompatible(val3))
					{
						try
						{
							UpdateScrapSpawnRate(val3);
						}
						catch (Exception arg)
						{
							LethalExpansion.Log.LogError((object)$"Failed to update scrap '{val3.itemName}' spawn rate. {arg}");
						}
					}
				}
			}
		}

		public static void UpdateScrapSpawnRate(Scrap scrap)
		{
			Item item = VanillaItemInstancier.GetItem(scrap);
			if ((Object)(object)item == (Object)null)
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				try
				{
					int? num = GetSpawnableItemRarity(val);
					if (num.HasValue)
					{
						UpdateOrAddItemSpawnRate(val, item, num.Value);
					}
				}
				catch (Exception ex)
				{
					LethalExpansion.Log.LogError((object)("Failed to add scrap '" + scrap.itemName + "' spawn chance to moon '" + val.PlanetName + "'. " + ex.Message));
				}
			}
			int? GetSpawnableItemRarity(SelectableLevel level)
			{
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				if (scrap.useGlobalSpawnWeight)
				{
					LethalExpansion.Log.LogDebug((object)$"Using global spawn rate for '{scrap.itemName}' on '{level.PlanetName}': {scrap.globalSpawnWeight}.");
					return scrap.globalSpawnWeight;
				}
				ScrapSpawnChancePerScene[] source = scrap.perPlanetSpawnWeight();
				if (!source.Any((ScrapSpawnChancePerScene l) => l.SceneName == level.PlanetName))
				{
					if (source.Any((ScrapSpawnChancePerScene l) => l.SceneName == "Others"))
					{
						ScrapSpawnChancePerScene val2 = source.First((ScrapSpawnChancePerScene l) => l.SceneName == "Others");
						LethalExpansion.Log.LogDebug((object)$"Spawn rate for '{scrap.itemName}' on '{level.PlanetName}': {val2.SpawnWeight} (Others).");
						return val2.SpawnWeight;
					}
					LethalExpansion.Log.LogWarning((object)("No spawn rate for '" + scrap.itemName + "' on '" + level.PlanetName + "', scrap will not spawn."));
					return null;
				}
				ScrapSpawnChancePerScene val3 = source.First((ScrapSpawnChancePerScene l) => l.SceneName == level.PlanetName);
				LethalExpansion.Log.LogDebug((object)$"Spawn rate for '{scrap.itemName}' on '{level.PlanetName}': {val3.SpawnWeight}.");
				return val3.SpawnWeight;
			}
		}

		public static void UpdateOrAddItemSpawnRate(SelectableLevel level, Item item, int rarity)
		{
			//IL_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			int num = level.spawnableScrap.FindIndex((SpawnableItemWithRarity spawnableScrap) => (Object)(object)spawnableScrap.spawnableItem == (Object)(object)item);
			if (num == -1)
			{
				LethalExpansion.DebugLog.LogInfo((object)$"Added new spawn rate '{rarity}' for scrap '{item.itemName}' on moon '{level.PlanetName}'");
				level.spawnableScrap.Add(new SpawnableItemWithRarity
				{
					spawnableItem = item,
					rarity = rarity
				});
				return;
			}
			SpawnableItemWithRarity val = level.spawnableScrap[num];
			if (val.rarity != rarity)
			{
				LethalExpansion.DebugLog.LogInfo((object)$"Updated spawn rate from '{val.rarity}' to '{rarity}' for scrap '{item.itemName}' on moon '{level.PlanetName}'");
				level.spawnableScrap[num] = new SpawnableItemWithRarity
				{
					spawnableItem = item,
					rarity = rarity
				};
			}
		}

		public static void AddScrap(Scrap scrap)
		{
			Item item = VanillaItemInstancier.GetItem(scrap);
			StartOfRound.Instance.allItemsList.itemsList.Add(item);
			newScrapsNames.Add(item.itemName);
			AssetGather.Instance.AddScrap(item);
		}

		public static void RemoveMoonTerminalEntry(Terminal terminal, string moonName)
		{
			if (moonName == null)
			{
				return;
			}
			try
			{
				int num = countEntries();
				terminal.moonsCatalogueList = terminal.moonsCatalogueList.Where((SelectableLevel moon) => !((Object)moon).name.Contains(moonName)).ToArray();
				routeKeyword.compatibleNouns = routeKeyword.compatibleNouns.Where((CompatibleNoun noun) => !((Object)noun.noun).name.Contains(moonName)).ToArray();
				infoKeyword.compatibleNouns = infoKeyword.compatibleNouns.Where((CompatibleNoun noun) => !((Object)noun.noun).name.Contains(moonName)).ToArray();
				if (num - countEntries() != 0)
				{
					LethalExpansion.Log.LogInfo((object)("Removed terminal entry for moon '" + moonName + "'"));
				}
				else
				{
					LethalExpansion.Log.LogInfo((object)("Terminal entry for moon '" + moonName + "' does not exist"));
				}
			}
			catch (Exception ex)
			{
				LethalExpansion.Log.LogError((object)("Failed to remove terminal entry for moon '" + moonName + "'. " + ex.Message));
			}
			int countEntries()
			{
				return terminal.moonsCatalogueList.Length + routeKeyword.compatibleNouns.Length + infoKeyword.compatibleNouns.Length;
			}
		}

		public static void AddMoons()
		{
			if (moonsPatched)
			{
				return;
			}
			newMoonsNames.Clear();
			newMoons.Clear();
			List<string> list = (from excludedMoon in LethalExpansion.Settings.ExcludedMoons.Value.Split(new char[1] { ',' })
				select excludedMoon.ToLower()).ToList();
			bool flag = list.Contains("hidden");
			foreach (KeyValuePair<string, (AssetBundle, ModManifest)> contentAssetBundle in AssetBundlesManager.Instance.contentAssetBundles)
			{
				var (val, val2) = AssetBundlesManager.Instance.Load(contentAssetBundle.Key);
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || val2.moons == null)
				{
					continue;
				}
				Moon[] moons = val2.moons;
				foreach (Moon val3 in moons)
				{
					if (!AssetBundlesManager.Instance.IsMoonCompatible(val3))
					{
						continue;
					}
					if (newMoonsNames.Contains(val3.MoonName))
					{
						LethalExpansion.Log.LogWarning((object)("Moon '" + val3.MoonName + "' has already been added"));
						continue;
					}
					if (flag && val3.IsHidden)
					{
						LethalExpansion.Log.LogWarning((object)("Hidden moon '" + val3.MoonName + "' was excluded in the config"));
						continue;
					}
					if (list.Contains(val3.MoonName?.ToLower()) || list.Contains(val3.PlanetName?.ToLower()))
					{
						LethalExpansion.Log.LogWarning((object)("Moon '" + val3.MoonName + "' was excluded in the config"));
						continue;
					}
					try
					{
						SelectableLevel val4 = CreateMoon(val3);
						StartOfRound.Instance.levels = CollectionExtensions.AddItem<SelectableLevel>((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels, val4).ToArray();
						newMoons.Add(val4.levelID, val3);
						newMoonsNames.Add(val3.MoonName);
						LethalExpansion.Log.LogInfo((object)("Added moon '" + val3.MoonName + "'"));
					}
					catch (Exception ex)
					{
						LethalExpansion.Log.LogError((object)("Failed to add moon '" + val3.MoonName + "'. " + ex.Message));
					}
				}
			}
			moonsPatched = true;
		}

		public static void AddMoonTerminalEntries(Terminal __instance)
		{
			if (moonsTerminalPatched)
			{
				return;
			}
			foreach (KeyValuePair<int, Moon> moonEntry in newMoons)
			{
				SelectableLevel val = ((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel level) => level.levelID == moonEntry.Key));
				if ((Object)(object)val == (Object)null)
				{
					LethalExpansion.Log.LogWarning((object)("Unable to add terminal entry for moon '" + moonEntry.Value.MoonName + "', it does not exist"));
					continue;
				}
				AddMoonTerminalEntry(__instance, moonEntry.Value, val);
				LethalExpansion.Log.LogInfo((object)("Added terminal entry for moon '" + moonEntry.Value.MoonName + "'"));
			}
			moonsTerminalPatched = true;
		}

		public static SelectableLevel CreateMoon(Moon moon)
		{
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel val = ScriptableObject.CreateInstance<SelectableLevel>();
			((Object)val).name = moon.PlanetName;
			val.PlanetName = moon.PlanetName;
			val.sceneName = "InitSceneLaunchOptions";
			val.levelID = StartOfRound.Instance.levels.Length;
			if (!string.IsNullOrEmpty(moon.OrbitPrefabName) && AssetGather.Instance.planetPrefabs.ContainsKey(moon.OrbitPrefabName))
			{
				val.planetPrefab = AssetGather.Instance.planetPrefabs[moon.OrbitPrefabName];
			}
			else
			{
				val.planetPrefab = AssetGather.Instance.planetPrefabs.First().Value;
			}
			val.lockedForDemo = true;
			val.spawnEnemiesAndScrap = moon.SpawnEnemiesAndScrap;
			if (!string.IsNullOrWhiteSpace(moon.PlanetDescription))
			{
				val.LevelDescription = moon.PlanetDescription;
			}
			else
			{
				val.LevelDescription = string.Empty;
			}
			val.videoReel = moon.PlanetVideo;
			if (!string.IsNullOrEmpty(moon.RiskLevel))
			{
				val.riskLevel = moon.RiskLevel ?? string.Empty;
			}
			else
			{
				val.riskLevel = string.Empty;
			}
			val.timeToArrive = moon.TimeToArrive;
			val.DaySpeedMultiplier = moon.DaySpeedMultiplier;
			val.planetHasTime = moon.PlanetHasTime;
			val.factorySizeMultiplier = moon.FactorySizeMultiplier;
			val.overrideWeather = moon.OverwriteWeather;
			val.overrideWeatherType = (LevelWeatherType)moon.OverwriteWeatherType;
			val.currentWeather = (LevelWeatherType)(-1);
			val.randomWeathers = ((IEnumerable<RandomWeatherPair>)moon.RandomWeatherTypes()).Select((Func<RandomWeatherPair, RandomWeatherWithVariables>)((RandomWeatherPair weather) => new RandomWeatherWithVariables
			{
				weatherType = (LevelWeatherType)weather.Weather,
				weatherVariable = weather.WeatherVariable1,
				weatherVariable2 = weather.WeatherVariable2
			})).ToArray();
			val.dungeonFlowTypes = ((IEnumerable<DungeonFlowPair>)moon.DungeonFlowTypes()).Select((Func<DungeonFlowPair, IntWithRarity>)((DungeonFlowPair dungeonFlow) => new IntWithRarity
			{
				id = dungeonFlow.ID,
				rarity = dungeonFlow.Rarity
			})).ToArray();
			val.spawnableScrap = new List<SpawnableItemWithRarity>();
			SpawnableScrapPair[] array = moon.SpawnableScrap();
			foreach (SpawnableScrapPair val2 in array)
			{
				if (!AssetGather.Instance.scraps.TryGetValue(val2.ObjectName, out var value))
				{
					LethalExpansion.Log.LogWarning((object)("Scrap '" + val2.ObjectName + "' on moon '" + moon.MoonName + "' could not be found, it has not been registered"));
				}
				else
				{
					UpdateOrAddItemSpawnRate(val, value, val2.SpawnWeight);
				}
			}
			val.minScrap = moon.MinScrap;
			val.maxScrap = moon.MaxScrap;
			if (!string.IsNullOrEmpty(moon.LevelAmbienceClips) && AssetGather.Instance.levelAmbiances.ContainsKey(moon.LevelAmbienceClips))
			{
				val.levelAmbienceClips = AssetGather.Instance.levelAmbiances[moon.LevelAmbienceClips];
			}
			else
			{
				val.levelAmbienceClips = AssetGather.Instance.levelAmbiances.First().Value;
			}
			val.maxEnemyPowerCount = moon.MaxEnemyPowerCount;
			val.Enemies = ((IEnumerable<SpawnableEnemiesPair>)moon.Enemies()).Select((Func<SpawnableEnemiesPair, SpawnableEnemyWithRarity>)((SpawnableEnemiesPair enemy) => new SpawnableEnemyWithRarity
			{
				enemyType = AssetGather.Instance.enemies[enemy.EnemyName],
				rarity = enemy.SpawnWeight
			})).ToList();
			val.enemySpawnChanceThroughoutDay = moon.EnemySpawnChanceThroughoutDay;
			val.spawnProbabilityRange = moon.SpawnProbabilityRange;
			val.spawnableMapObjects = ((IEnumerable<SpawnableMapObjectPair>)moon.SpawnableMapObjects()).Select((Func<SpawnableMapObjectPair, SpawnableMapObject>)((SpawnableMapObjectPair item) => new SpawnableMapObject
			{
				prefabToSpawn = AssetGather.Instance.mapObjects[item.ObjectName],
				spawnFacingAwayFromWall = item.SpawnFacingAwayFromWall,
				numberToSpawn = item.SpawnRate
			})).ToArray();
			val.spawnableOutsideObjects = ((IEnumerable<SpawnableOutsideObjectPair>)moon.SpawnableOutsideObjects()).Select((Func<SpawnableOutsideObjectPair, SpawnableOutsideObjectWithRarity>)((SpawnableOutsideObjectPair item) => new SpawnableOutsideObjectWithRarity
			{
				spawnableObject = AssetGather.Instance.outsideObjects[item.ObjectName],
				randomAmount = item.SpawnRate
			})).ToArray();
			val.maxOutsideEnemyPowerCount = moon.MaxOutsideEnemyPowerCount;
			val.maxDaytimeEnemyPowerCount = moon.MaxDaytimeEnemyPowerCount;
			val.OutsideEnemies = ((IEnumerable<SpawnableEnemiesPair>)moon.OutsideEnemies()).Select((Func<SpawnableEnemiesPair, SpawnableEnemyWithRarity>)((SpawnableEnemiesPair enemy) => new SpawnableEnemyWithRarity
			{
				enemyType = AssetGather.Instance.enemies[enemy.EnemyName],
				rarity = enemy.SpawnWeight
			})).ToList();
			val.DaytimeEnemies = ((IEnumerable<SpawnableEnemiesPair>)moon.DaytimeEnemies()).Select((Func<SpawnableEnemiesPair, SpawnableEnemyWithRarity>)((SpawnableEnemiesPair enemy) => new SpawnableEnemyWithRarity
			{
				enemyType = AssetGather.Instance.enemies[enemy.EnemyName],
				rarity = enemy.SpawnWeight
			})).ToList();
			val.outsideEnemySpawnChanceThroughDay = moon.OutsideEnemySpawnChanceThroughDay;
			val.daytimeEnemySpawnChanceThroughDay = moon.DaytimeEnemySpawnChanceThroughDay;
			val.daytimeEnemiesProbabilityRange = moon.DaytimeEnemiesProbabilityRange;
			val.levelIncludesSnowFootprints = moon.LevelIncludesSnowFootprints;
			return val;
		}

		public static void AddMoonTerminalEntry(Terminal terminal, Moon newMoon, SelectableLevel newLevel)
		{
			//IL_0267: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Expected O, but got Unknown
			TerminalKeyword noun = terminal.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "confirm");
			TerminalKeyword noun2 = terminal.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "deny");
			TerminalNode val = null;
			CompatibleNoun[] terminalOptions = routeKeyword.compatibleNouns[0].result.terminalOptions;
			foreach (Com

LethalSDK.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using DunGen;
using DunGen.Adapters;
using GameNetcodeStuff;
using LethalSDK.Component;
using LethalSDK.ScriptableObjects;
using LethalSDK.Utils;
using Unity.Netcode;
using UnityEditor;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalSDK")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalSDK")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4d234a4d-c807-438a-b717-4c6d77706054")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class AssetModificationProcessor : AssetPostprocessor
{
	private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
	{
		foreach (string assetPath in importedAssets)
		{
			ProcessAsset(assetPath);
		}
		foreach (string assetPath2 in movedAssets)
		{
			ProcessAsset(assetPath2);
		}
	}

	private static void ProcessAsset(string assetPath)
	{
		if (assetPath.Contains("NavMesh-Environment"))
		{
			AssetDatabase.RenameAsset(assetPath, (SelectionLogger.name != string.Empty) ? (SelectionLogger.name + "NavMesh") : "New NavMesh");
		}
		if (assetPath.Contains("New Terrain"))
		{
			AssetDatabase.RenameAsset(assetPath, (SelectionLogger.name != string.Empty) ? SelectionLogger.name : "New Terrain");
		}
		if (assetPath.ToLower().StartsWith("assets/mods/") && assetPath.Split(new char[1] { '/' }).Length > 3 && !assetPath.ToLower().EndsWith(".unity") && !assetPath.ToLower().Contains("/scenes"))
		{
			AssetImporter atPath = AssetImporter.GetAtPath(assetPath);
			if ((Object)(object)atPath != (Object)null)
			{
				string text2 = (atPath.assetBundleName = ExtractBundleNameFromPath(assetPath));
				atPath.assetBundleVariant = "lem";
				Debug.Log((object)(assetPath + " asset moved to " + text2 + " asset bundle."));
			}
			if (assetPath != "Assets/Mods/" + assetPath.ToLower().Replace("assets/mods/", string.Empty).RemoveNonAlphanumeric(4))
			{
				AssetDatabase.MoveAsset(assetPath, "Assets/Mods/" + assetPath.ToLower().Replace("assets/mods/", string.Empty).RemoveNonAlphanumeric(4));
			}
		}
		else
		{
			AssetImporter atPath2 = AssetImporter.GetAtPath(assetPath);
			if ((Object)(object)atPath2 != (Object)null)
			{
				atPath2.assetBundleName = null;
				Debug.Log((object)(assetPath + " asset removed from asset bundle."));
			}
		}
	}

	public static string ExtractBundleNameFromPath(string path)
	{
		string[] array = path.Split(new char[1] { '/' });
		if (array.Length > 3)
		{
			return array[2].ToLower();
		}
		return "";
	}
}
[InitializeOnLoad]
public class SelectionLogger
{
	public static string name;

	static SelectionLogger()
	{
		Selection.selectionChanged = (Action)Delegate.Combine(Selection.selectionChanged, new Action(OnSelectionChanged));
	}

	private static void OnSelectionChanged()
	{
		if ((Object)(object)Selection.activeGameObject != (Object)null)
		{
			name = ((Object)GetRootParent(Selection.activeGameObject)).name;
		}
		else
		{
			name = string.Empty;
		}
	}

	public static GameObject GetRootParent(GameObject obj)
	{
		if ((Object)(object)obj != (Object)null && (Object)(object)obj.transform.parent != (Object)null)
		{
			return GetRootParent(((Component)obj.transform.parent).gameObject);
		}
		return obj;
	}
}
[InitializeOnLoad]
public class AssetBundleVariantAssigner
{
	static AssetBundleVariantAssigner()
	{
		AssignVariantToAssetBundles();
	}

	[InitializeOnLoadMethod]
	private static void AssignVariantToAssetBundles()
	{
		string[] allAssetBundleNames = AssetDatabase.GetAllAssetBundleNames();
		string[] array = allAssetBundleNames;
		foreach (string text in array)
		{
			if (!text.Contains("."))
			{
				string[] assetPathsFromAssetBundle = AssetDatabase.GetAssetPathsFromAssetBundle(text);
				string[] array2 = assetPathsFromAssetBundle;
				foreach (string text2 in array2)
				{
					AssetImporter.GetAtPath(text2).SetAssetBundleNameAndVariant(text, "lem");
				}
				Debug.Log((object)("File extention added to AssetBundle: " + text));
			}
		}
		AssetDatabase.SaveAssets();
		string text3 = "Assets/AssetBundles";
		if (!Directory.Exists(text3))
		{
			Debug.LogError((object)("Le dossier n'existe pas : " + text3));
			return;
		}
		string[] files = Directory.GetFiles(text3);
		string[] array3 = files;
		foreach (string text4 in array3)
		{
			if (Path.GetExtension(text4) == "" && Path.GetFileName(text4) != "AssetBundles")
			{
				string path = text4 + ".meta";
				string text5 = text4 + ".manifest";
				string path2 = text5 + ".meta";
				File.Delete(text4);
				if (File.Exists(path))
				{
					File.Delete(path);
				}
				if (File.Exists(text5))
				{
					File.Delete(text5);
				}
				if (File.Exists(path2))
				{
					File.Delete(path2);
				}
				Debug.Log((object)("Fichier supprimé : " + text4));
			}
		}
		AssetDatabase.Refresh();
	}
}
public class CubemapTextureBuilder : EditorWindow
{
	private Texture2D[] textures = (Texture2D[])(object)new Texture2D[6];

	private string[] labels = new string[6] { "Right", "Left", "Top", "Bottom", "Front", "Back" };

	private TextureFormat[] HDRFormats;

	private Vector2Int[] placementRects;

	[MenuItem("LethalSDK/Cubemap Builder", false, 100)]
	public static void OpenWindow()
	{
		EditorWindow.GetWindow<CubemapTextureBuilder>();
	}

	private Texture2D UpscaleTexture(Texture2D original, int targetWidth, int targetHeight)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		RenderTexture val = (RenderTexture.active = RenderTexture.GetTemporary(targetWidth, targetHeight));
		Graphics.Blit((Texture)(object)original, val);
		Texture2D val2 = new Texture2D(targetWidth, targetHeight);
		val2.ReadPixels(new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), 0, 0);
		val2.Apply();
		RenderTexture.ReleaseTemporary(val);
		return val2;
	}

	private void OnGUI()
	{
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Expected O, but got Unknown
		for (int i = 0; i < 6; i++)
		{
			ref Texture2D reference = ref textures[i];
			Object obj = EditorGUILayout.ObjectField(labels[i], (Object)(object)textures[i], typeof(Texture2D), false, Array.Empty<GUILayoutOption>());
			reference = (Texture2D)(object)((obj is Texture2D) ? obj : null);
		}
		if (!GUILayout.Button("Build Cubemap", Array.Empty<GUILayoutOption>()))
		{
			return;
		}
		if (textures.Any((Texture2D t) => (Object)(object)t == (Object)null))
		{
			EditorUtility.DisplayDialog("Cubemap Builder Error", "One or more texture is missing.", "Ok");
			return;
		}
		int size = ((Texture)textures[0]).width;
		if (textures.Any((Texture2D t) => ((Texture)t).width != size || ((Texture)t).height != size))
		{
			EditorUtility.DisplayDialog("Cubemap Builder Error", "All the textures need to be the same size and square.", "Ok");
			return;
		}
		bool flag = HDRFormats.Any((TextureFormat f) => f == textures[0].format);
		string[] array = textures.Select((Texture2D t) => AssetDatabase.GetAssetPath((Object)(object)t)).ToArray();
		string text = EditorUtility.SaveFilePanel("Save Cubemap", Path.GetDirectoryName(array[0]), "Cubemap", flag ? "exr" : "png");
		if (!string.IsNullOrEmpty(text))
		{
			bool[] array2 = textures.Select((Texture2D t) => ((Texture)t).isReadable).ToArray();
			TextureImporter[] array3 = array.Select(delegate(string p)
			{
				AssetImporter atPath2 = AssetImporter.GetAtPath(p);
				return (TextureImporter)(object)((atPath2 is TextureImporter) ? atPath2 : null);
			}).ToArray();
			TextureImporter[] array4 = array3;
			foreach (TextureImporter val in array4)
			{
				val.isReadable = true;
			}
			AssetDatabase.Refresh();
			string[] array5 = array;
			foreach (string text2 in array5)
			{
				AssetDatabase.ImportAsset(text2);
			}
			Texture2D val2 = new Texture2D(size * 4, size * 3, (TextureFormat)(flag ? 20 : 4), false);
			for (int l = 0; l < 6; l++)
			{
				val2.SetPixels(((Vector2Int)(ref placementRects[l])).x * size, ((Vector2Int)(ref placementRects[l])).y * size, size, size, textures[l].GetPixels(0));
			}
			val2.Apply(false);
			byte[] bytes = (flag ? ImageConversion.EncodeToEXR(val2) : ImageConversion.EncodeToPNG(val2));
			File.WriteAllBytes(text, bytes);
			Object.Destroy((Object)(object)val2);
			for (int m = 0; m < 6; m++)
			{
				array3[m].isReadable = array2[m];
			}
			text = text.Remove(0, Application.dataPath.Length - 6);
			AssetDatabase.ImportAsset(text);
			AssetImporter atPath = AssetImporter.GetAtPath(text);
			TextureImporter val3 = (TextureImporter)(object)((atPath is TextureImporter) ? atPath : null);
			val3.textureShape = (TextureImporterShape)2;
			val3.sRGBTexture = false;
			val3.generateCubemap = (TextureImporterGenerateCubemap)5;
			string[] array6 = array;
			foreach (string text3 in array6)
			{
				AssetDatabase.ImportAsset(text3);
			}
			AssetDatabase.ImportAsset(text);
			AssetDatabase.Refresh();
		}
	}

	public CubemapTextureBuilder()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		TextureFormat[] array = new TextureFormat[9];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		HDRFormats = (TextureFormat[])(object)array;
		placementRects = (Vector2Int[])(object)new Vector2Int[6]
		{
			new Vector2Int(2, 1),
			new Vector2Int(0, 1),
			new Vector2Int(1, 2),
			new Vector2Int(1, 0),
			new Vector2Int(1, 1),
			new Vector2Int(3, 1)
		};
		((EditorWindow)this)..ctor();
	}
}
public class PlayerShip : MonoBehaviour
{
	public readonly Vector3 shipPosition = new Vector3(-17.5f, 5.75f, -16.55f);

	private void Start()
	{
		Object.Destroy((Object)(object)this);
	}
}
[CustomEditor(typeof(PlayerShip))]
public class PlayerShipEditor : Editor
{
	public override void OnInspectorGUI()
	{
		//IL_001a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
		((Editor)this).OnInspectorGUI();
		PlayerShip playerShip = (PlayerShip)(object)((Editor)this).target;
		if (((Component)playerShip).transform.position != playerShip.shipPosition)
		{
			((Component)playerShip).transform.position = playerShip.shipPosition;
		}
	}
}
namespace LethalSDK.ScriptableObjects
{
	[CreateAssetMenu(fileName = "AssetBank", menuName = "LethalSDK/Asset Bank")]
	public class AssetBank : ScriptableObject
	{
		[Header("Audio Clips")]
		[SerializeField]
		private AudioClipInfoPair[] _audioClips = new AudioClipInfoPair[0];

		[SerializeField]
		private PlanetPrefabInfoPair[] _planetPrefabs = new PlanetPrefabInfoPair[0];

		[SerializeField]
		private PrefabInfoPair[] _networkPrefabs = new PrefabInfoPair[0];

		[HideInInspector]
		public string serializedAudioClips;

		[HideInInspector]
		public string serializedPlanetPrefabs;

		[HideInInspector]
		public string serializedNetworkPrefabs;

		private void OnValidate()
		{
			for (int i = 0; i < _audioClips.Length; i++)
			{
				_audioClips[i].AudioClipName = _audioClips[i].AudioClipName.RemoveNonAlphanumeric(1);
				_audioClips[i].AudioClipPath = _audioClips[i].AudioClipPath.RemoveNonAlphanumeric(4);
			}
			for (int j = 0; j < _planetPrefabs.Length; j++)
			{
				_planetPrefabs[j].PlanetPrefabName = _planetPrefabs[j].PlanetPrefabName.RemoveNonAlphanumeric(1);
				_planetPrefabs[j].PlanetPrefabPath = _planetPrefabs[j].PlanetPrefabPath.RemoveNonAlphanumeric(4);
			}
			for (int k = 0; k < _networkPrefabs.Length; k++)
			{
				_networkPrefabs[k].PrefabName = _networkPrefabs[k].PrefabName.RemoveNonAlphanumeric(1);
				_networkPrefabs[k].PrefabPath = _networkPrefabs[k].PrefabPath.RemoveNonAlphanumeric(4);
			}
			serializedAudioClips = string.Join(";", _audioClips.Select((AudioClipInfoPair p) => ((p.AudioClipName.Length != 0) ? p.AudioClipName : (((Object)(object)p.AudioClip != (Object)null) ? ((Object)p.AudioClip).name : "")) + "," + AssetDatabase.GetAssetPath((Object)(object)p.AudioClip)));
			serializedPlanetPrefabs = string.Join(";", _planetPrefabs.Select((PlanetPrefabInfoPair p) => ((p.PlanetPrefabName.Length != 0) ? p.PlanetPrefabName : (((Object)(object)p.PlanetPrefab != (Object)null) ? ((Object)p.PlanetPrefab).name : "")) + "," + AssetDatabase.GetAssetPath((Object)(object)p.PlanetPrefab)));
			serializedNetworkPrefabs = string.Join(";", _networkPrefabs.Select((PrefabInfoPair p) => ((p.PrefabName.Length != 0) ? p.PrefabName : (((Object)(object)p.Prefab != (Object)null) ? ((Object)p.Prefab).name : "")) + "," + AssetDatabase.GetAssetPath((Object)(object)p.Prefab)));
		}

		public AudioClipInfoPair[] AudioClips()
		{
			if (serializedAudioClips != null)
			{
				return (from s in serializedAudioClips.Split(new char[1] { ';' })
					select s.Split(new char[1] { ',' }) into split
					where split.Length == 2
					select new AudioClipInfoPair(split[0], split[1])).ToArray();
			}
			return new AudioClipInfoPair[0];
		}

		public bool HaveAudioClip(string audioClipName)
		{
			if (serializedAudioClips != null)
			{
				return AudioClips().Any((AudioClipInfoPair a) => a.AudioClipName == audioClipName);
			}
			return false;
		}

		public string AudioClipPath(string audioClipName)
		{
			if (serializedAudioClips != null)
			{
				return AudioClips().First((AudioClipInfoPair c) => c.AudioClipName == audioClipName).AudioClipPath;
			}
			return string.Empty;
		}

		public Dictionary<string, string> AudioClipsDictionary()
		{
			if (serializedAudioClips != null)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				AudioClipInfoPair[] audioClips = _audioClips;
				for (int i = 0; i < audioClips.Length; i++)
				{
					AudioClipInfoPair audioClipInfoPair = audioClips[i];
					dictionary.Add(audioClipInfoPair.AudioClipName, audioClipInfoPair.AudioClipPath);
				}
				return dictionary;
			}
			return new Dictionary<string, string>();
		}

		public PlanetPrefabInfoPair[] PlanetPrefabs()
		{
			if (serializedPlanetPrefabs != null)
			{
				return (from s in serializedPlanetPrefabs.Split(new char[1] { ';' })
					select s.Split(new char[1] { ',' }) into split
					where split.Length == 2
					select new PlanetPrefabInfoPair(split[0], split[1])).ToArray();
			}
			return new PlanetPrefabInfoPair[0];
		}

		public bool HavePlanetPrefabs(string planetPrefabName)
		{
			if (serializedPlanetPrefabs != null)
			{
				return PlanetPrefabs().Any((PlanetPrefabInfoPair a) => a.PlanetPrefabName == planetPrefabName);
			}
			return false;
		}

		public string PlanetPrefabsPath(string planetPrefabName)
		{
			if (serializedPlanetPrefabs != null)
			{
				return PlanetPrefabs().First((PlanetPrefabInfoPair c) => c.PlanetPrefabName == planetPrefabName).PlanetPrefabPath;
			}
			return string.Empty;
		}

		public Dictionary<string, string> PlanetPrefabsDictionary()
		{
			if (serializedPlanetPrefabs != null)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				PlanetPrefabInfoPair[] planetPrefabs = _planetPrefabs;
				for (int i = 0; i < planetPrefabs.Length; i++)
				{
					PlanetPrefabInfoPair planetPrefabInfoPair = planetPrefabs[i];
					dictionary.Add(planetPrefabInfoPair.PlanetPrefabName, planetPrefabInfoPair.PlanetPrefabPath);
				}
				return dictionary;
			}
			return new Dictionary<string, string>();
		}

		public PrefabInfoPair[] NetworkPrefabs()
		{
			if (serializedNetworkPrefabs != null)
			{
				return (from s in serializedNetworkPrefabs.Split(new char[1] { ';' })
					select s.Split(new char[1] { ',' }) into split
					where split.Length == 2
					select new PrefabInfoPair(split[0], split[1])).ToArray();
			}
			return new PrefabInfoPair[0];
		}

		public bool HaveNetworkPrefabs(string networkPrefabName)
		{
			if (serializedNetworkPrefabs != null)
			{
				return NetworkPrefabs().Any((PrefabInfoPair a) => a.PrefabName == networkPrefabName);
			}
			return false;
		}

		public string NetworkPrefabsPath(string networkPrefabName)
		{
			if (serializedNetworkPrefabs != null)
			{
				return NetworkPrefabs().First((PrefabInfoPair c) => c.PrefabName == networkPrefabName).PrefabPath;
			}
			return string.Empty;
		}

		public Dictionary<string, string> NetworkPrefabsDictionary()
		{
			if (serializedNetworkPrefabs != null)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				PrefabInfoPair[] networkPrefabs = _networkPrefabs;
				for (int i = 0; i < networkPrefabs.Length; i++)
				{
					PrefabInfoPair prefabInfoPair = networkPrefabs[i];
					dictionary.Add(prefabInfoPair.PrefabName, prefabInfoPair.PrefabPath);
				}
				return dictionary;
			}
			return new Dictionary<string, string>();
		}
	}
	[CreateAssetMenu(fileName = "ModManifest", menuName = "LethalSDK/Mod Manifest")]
	public class ModManifest : ScriptableObject
	{
		public string modName = "New Mod";

		[Space]
		[SerializeField]
		private SerializableVersion version = new SerializableVersion(0, 0, 0, 0);

		[HideInInspector]
		public string serializedVersion;

		[Space]
		public string author = "Author";

		[Space]
		[TextArea(5, 15)]
		public string description = "Mod Description";

		[Space]
		[Header("Content")]
		public Scrap[] scraps = new Scrap[0];

		public Moon[] moons = new Moon[0];

		[Space]
		public AssetBank assetBank;

		private void OnValidate()
		{
			serializedVersion = version.ToString();
		}

		public SerializableVersion GetVersion()
		{
			int[] array = ((serializedVersion != null) ? serializedVersion.Split(new char[1] { '.' }).Select(int.Parse).ToArray() : new int[4]);
			return new SerializableVersion(array[0], array[1], array[2], array[3]);
		}
	}
	[CreateAssetMenu(fileName = "New Moon", menuName = "LethalSDK/Moon")]
	public class Moon : ScriptableObject
	{
		public string MoonName = "NewMoon";

		public string[] RequiredBundles;

		public string[] IncompatibleBundles;

		public bool IsEnabled = true;

		public bool IsHidden = false;

		public bool IsLocked = false;

		[Header("Info")]
		public string OrbitPrefabName = "Moon1";

		public bool SpawnEnemiesAndScrap = true;

		public string PlanetName = "New Moon";

		public GameObject MainPrefab;

		[TextArea(5, 15)]
		public string PlanetDescription;

		public VideoClip PlanetVideo;

		public string RiskLevel = "X";

		[Range(0f, 16f)]
		public float TimeToArrive = 1f;

		[Header("Time")]
		[Range(0.1f, 5f)]
		public float DaySpeedMultiplier = 1f;

		public bool PlanetHasTime = true;

		[SerializeField]
		private RandomWeatherPair[] _RandomWeatherTypes = new RandomWeatherPair[6]
		{
			new RandomWeatherPair(LevelWeatherType.None, 0, 0),
			new RandomWeatherPair(LevelWeatherType.Rainy, 0, 0),
			new RandomWeatherPair(LevelWeatherType.Stormy, 1, 0),
			new RandomWeatherPair(LevelWeatherType.Foggy, 1, 0),
			new RandomWeatherPair(LevelWeatherType.Flooded, -4, 5),
			new RandomWeatherPair(LevelWeatherType.Eclipsed, 1, 0)
		};

		public bool OverwriteWeather = false;

		public LevelWeatherType OverwriteWeatherType = LevelWeatherType.None;

		[Header("Route")]
		public string RouteWord = "newmoon";

		public int RoutePrice;

		public string BoughtComment = "Please enjoy your flight.";

		[Header("Dungeon")]
		[Range(1f, 5f)]
		public float FactorySizeMultiplier = 1f;

		public int FireExitsAmountOverwrite = 1;

		[SerializeField]
		private DungeonFlowPair[] _DungeonFlowTypes = new DungeonFlowPair[2]
		{
			new DungeonFlowPair(0, 300),
			new DungeonFlowPair(1, 1)
		};

		[SerializeField]
		private SpawnableScrapPair[] _SpawnableScrap = new SpawnableScrapPair[19]
		{
			new SpawnableScrapPair("Cog1", 80),
			new SpawnableScrapPair("EnginePart1", 90),
			new SpawnableScrapPair("FishTestProp", 12),
			new SpawnableScrapPair("MetalSheet", 88),
			new SpawnableScrapPair("FlashLaserPointer", 4),
			new SpawnableScrapPair("BigBolt", 80),
			new SpawnableScrapPair("BottleBin", 19),
			new SpawnableScrapPair("Ring", 3),
			new SpawnableScrapPair("SteeringWheel", 32),
			new SpawnableScrapPair("MoldPan", 5),
			new SpawnableScrapPair("EggBeater", 10),
			new SpawnableScrapPair("PickleJar", 10),
			new SpawnableScrapPair("DustPan", 32),
			new SpawnableScrapPair("Airhorn", 3),
			new SpawnableScrapPair("ClownHorn", 3),
			new SpawnableScrapPair("CashRegister", 3),
			new SpawnableScrapPair("Candy", 2),
			new SpawnableScrapPair("GoldBar", 1),
			new SpawnableScrapPair("YieldSign", 6)
		};

		[Range(0f, 100f)]
		public int MinScrap = 8;

		[Range(0f, 100f)]
		public int MaxScrap = 12;

		public string LevelAmbienceClips = "Level1TypeAmbience";

		[Range(0f, 30f)]
		public int MaxEnemyPowerCount = 4;

		[SerializeField]
		private SpawnableEnemiesPair[] _Enemies = new SpawnableEnemiesPair[8]
		{
			new SpawnableEnemiesPair("Centipede", 51),
			new SpawnableEnemiesPair("SandSpider", 58),
			new SpawnableEnemiesPair("HoarderBug", 28),
			new SpawnableEnemiesPair("Flowerman", 13),
			new SpawnableEnemiesPair("Crawler", 16),
			new SpawnableEnemiesPair("Blob", 31),
			new SpawnableEnemiesPair("DressGirl", 1),
			new SpawnableEnemiesPair("Puffer", 28)
		};

		public AnimationCurve EnemySpawnChanceThroughoutDay = CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0015411376953125,\"value\":-3.0,\"inSlope\":19.556997299194337,\"outSlope\":19.556997299194337,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.0,\"outWeight\":0.12297855317592621},{\"serializedVersion\":\"3\",\"time\":0.4575331211090088,\"value\":4.796203136444092,\"inSlope\":24.479534149169923,\"outSlope\":24.479534149169923,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.396077424287796,\"outWeight\":0.35472238063812258},{\"serializedVersion\":\"3\",\"time\":0.7593884468078613,\"value\":4.973001480102539,\"inSlope\":2.6163148880004885,\"outSlope\":2.6163148880004885,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.2901076376438141,\"outWeight\":0.5360636115074158},{\"serializedVersion\":\"3\",\"time\":1.0,\"value\":15.0,\"inSlope\":35.604026794433597,\"outSlope\":35.604026794433597,\"tangentMode\":0,\"weightedMode\":1,\"inWeight\":0.04912583902478218,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}");

		[Range(0f, 30f)]
		public float SpawnProbabilityRange = 4f;

		[Header("Outside")]
		[SerializeField]
		private SpawnableMapObjectPair[] _SpawnableMapObjects = new SpawnableMapObjectPair[2]
		{
			new SpawnableMapObjectPair("Landmine", spawnFacingAwayFromWall: false, CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":-0.003082275390625,\"value\":0.0,\"inSlope\":0.23179344832897187,\"outSlope\":0.23179344832897187,\"tangentMode\":0,\"weightedMode\":2,\"inWeight\":0.0,\"outWeight\":0.27936428785324099},{\"serializedVersion\":\"3\",\"time\":0.8171924352645874,\"value\":1.7483322620391846,\"inSlope\":7.064207077026367,\"outSlope\":7.064207077026367,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.2631833553314209,\"outWeight\":0.6898177862167358},{\"serializedVersion\":\"3\",\"time\":1.0002186298370362,\"value\":11.760997772216797,\"inSlope\":968.80810546875,\"outSlope\":968.80810546875,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.029036391526460649,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableMapObjectPair("TurretContainer", spawnFacingAwayFromWall: true, CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":0.354617178440094,\"outSlope\":0.354617178440094,\"tangentMode\":0,\"weightedMode\":2,\"inWeight\":0.0,\"outWeight\":0.0},{\"serializedVersion\":\"3\",\"time\":0.9190289974212647,\"value\":1.0005745887756348,\"inSlope\":Infinity,\"outSlope\":1.7338485717773438,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.0,\"outWeight\":0.6534967422485352},{\"serializedVersion\":\"3\",\"time\":1.0038425922393799,\"value\":7.198680877685547,\"inSlope\":529.4945068359375,\"outSlope\":529.4945068359375,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.14589552581310273,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}"))
		};

		[SerializeField]
		private SpawnableOutsideObjectPair[] _SpawnableOutsideObjects = new SpawnableOutsideObjectPair[7]
		{
			new SpawnableOutsideObjectPair("LargeRock1", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":0.0,\"outSlope\":0.0,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.0,\"outWeight\":0.0},{\"serializedVersion\":\"3\",\"time\":0.7571572661399841,\"value\":0.6448163986206055,\"inSlope\":2.974250078201294,\"outSlope\":2.974250078201294,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.3333333432674408,\"outWeight\":0.3333333432674408},{\"serializedVersion\":\"3\",\"time\":0.9995536804199219,\"value\":5.883961200714111,\"inSlope\":65.30631256103516,\"outSlope\":65.30631256103516,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.12097536772489548,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("LargeRock2", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":0.0,\"outSlope\":0.0,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.0,\"outWeight\":0.0},{\"serializedVersion\":\"3\",\"time\":0.7562879920005798,\"value\":1.2308543920516968,\"inSlope\":5.111926555633545,\"outSlope\":5.111926555633545,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.3333333432674408,\"outWeight\":0.21955738961696626},{\"serializedVersion\":\"3\",\"time\":1.0010795593261719,\"value\":7.59307336807251,\"inSlope\":92.0470199584961,\"outSlope\":92.0470199584961,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.05033162236213684,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("LargeRock3", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":0.0,\"outSlope\":0.0,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.0,\"outWeight\":0.0},{\"serializedVersion\":\"3\",\"time\":0.9964686632156372,\"value\":2.0009398460388185,\"inSlope\":6.82940673828125,\"outSlope\":6.82940673828125,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.06891261041164398,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("LargeRock4", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":0.0,\"outSlope\":0.0,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.0,\"outWeight\":0.0},{\"serializedVersion\":\"3\",\"time\":0.9635604619979858,\"value\":2.153383493423462,\"inSlope\":6.251225471496582,\"outSlope\":6.251225471496582,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.07428120821714401,\"outWeight\":0.3333333432674408},{\"serializedVersion\":\"3\",\"time\":0.9995394349098206,\"value\":5.0,\"inSlope\":15.746581077575684,\"outSlope\":15.746581077575684,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.06317413598299027,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("TreeLeafless1", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":1.6912956237792969,\"outSlope\":1.6912956237792969,\"tangentMode\":0,\"weightedMode\":2,\"inWeight\":0.0,\"outWeight\":0.27726083993911745},{\"serializedVersion\":\"3\",\"time\":0.776531994342804,\"value\":6.162014007568359,\"inSlope\":30.075166702270509,\"outSlope\":30.075166702270509,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.15920747816562653,\"outWeight\":0.5323987007141113},{\"serializedVersion\":\"3\",\"time\":1.0002281665802003,\"value\":38.093849182128909,\"inSlope\":1448.839111328125,\"outSlope\":1448.839111328125,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.0620061457157135,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("SmallGreyRocks1", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":1.6912956237792969,\"outSlope\":1.6912956237792969,\"tangentMode\":0,\"weightedMode\":2,\"inWeight\":0.0,\"outWeight\":0.27726083993911745},{\"serializedVersion\":\"3\",\"time\":0.802714467048645,\"value\":1.5478605031967164,\"inSlope\":9.096116065979004,\"outSlope\":9.096116065979004,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.15920747816562653,\"outWeight\":0.58766108751297},{\"serializedVersion\":\"3\",\"time\":1.0002281665802003,\"value\":14.584033966064454,\"inSlope\":1244.9173583984375,\"outSlope\":1244.9173583984375,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.054620321840047839,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}")),
			new SpawnableOutsideObjectPair("GiantPumpkin", CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":0.0,\"inSlope\":1.6912956237792969,\"outSlope\":1.6912956237792969,\"tangentMode\":0,\"weightedMode\":2,\"inWeight\":0.0,\"outWeight\":0.27726083993911745},{\"serializedVersion\":\"3\",\"time\":0.8832725882530212,\"value\":0.5284063816070557,\"inSlope\":3.2962090969085695,\"outSlope\":29.38977813720703,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.19772815704345704,\"outWeight\":0.8989489078521729},{\"serializedVersion\":\"3\",\"time\":0.972209095954895,\"value\":6.7684478759765629,\"inSlope\":140.27394104003907,\"outSlope\":140.27394104003907,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.39466607570648196,\"outWeight\":0.47049039602279665},{\"serializedVersion\":\"3\",\"time\":1.0002281665802003,\"value\":23.0,\"inSlope\":579.3037109375,\"outSlope\":14.8782377243042,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.648808479309082,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}"))
		};

		[Range(0f, 30f)]
		public int MaxOutsideEnemyPowerCount = 8;

		[Range(0f, 30f)]
		public int MaxDaytimeEnemyPowerCount = 5;

		[SerializeField]
		private SpawnableEnemiesPair[] _OutsideEnemies = new SpawnableEnemiesPair[3]
		{
			new SpawnableEnemiesPair("MouthDog", 75),
			new SpawnableEnemiesPair("ForestGiant", 0),
			new SpawnableEnemiesPair("SandWorm", 56)
		};

		[SerializeField]
		private SpawnableEnemiesPair[] _DaytimeEnemies = new SpawnableEnemiesPair[3]
		{
			new SpawnableEnemiesPair("RedLocustBees", 22),
			new SpawnableEnemiesPair("Doublewing", 74),
			new SpawnableEnemiesPair("DocileLocustBees", 52)
		};

		public AnimationCurve OutsideEnemySpawnChanceThroughDay = CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":-7.736962288618088e-7,\"value\":-2.996999979019165,\"inSlope\":Infinity,\"outSlope\":0.5040292143821716,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.0,\"outWeight\":0.08937685936689377},{\"serializedVersion\":\"3\",\"time\":0.7105481624603272,\"value\":-0.6555822491645813,\"inSlope\":9.172262191772461,\"outSlope\":9.172262191772461,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.3333333432674408,\"outWeight\":0.7196550369262695},{\"serializedVersion\":\"3\",\"time\":1.0052626132965088,\"value\":5.359400749206543,\"inSlope\":216.42247009277345,\"outSlope\":11.374387741088868,\"tangentMode\":0,\"weightedMode\":3,\"inWeight\":0.044637180864810947,\"outWeight\":0.48315444588661196}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}");

		public AnimationCurve DaytimeEnemySpawnChanceThroughDay = CurveContainer.DeserializeCurve("{\"curve\":{\"serializedVersion\":\"2\",\"m_Curve\":[{\"serializedVersion\":\"3\",\"time\":0.0,\"value\":2.2706568241119386,\"inSlope\":-7.500085353851318,\"outSlope\":-7.500085353851318,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.3333333432674408,\"outWeight\":0.20650266110897065},{\"serializedVersion\":\"3\",\"time\":0.38507816195487978,\"value\":-0.0064108967781066898,\"inSlope\":-2.7670974731445314,\"outSlope\":-2.7670974731445314,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.28388944268226626,\"outWeight\":0.30659767985343935},{\"serializedVersion\":\"3\",\"time\":0.6767024993896484,\"value\":-7.021658420562744,\"inSlope\":-27.286888122558595,\"outSlope\":-27.286888122558595,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.10391546785831452,\"outWeight\":0.12503522634506226},{\"serializedVersion\":\"3\",\"time\":0.9998173117637634,\"value\":-14.818100929260254,\"inSlope\":0.0,\"outSlope\":0.0,\"tangentMode\":0,\"weightedMode\":0,\"inWeight\":0.0,\"outWeight\":0.0}],\"m_PreInfinity\":2,\"m_PostInfinity\":2,\"m_RotationOrder\":4}}");

		[Range(0f, 30f)]
		public float DaytimeEnemiesProbabilityRange = 5f;

		public bool LevelIncludesSnowFootprints = false;

		[HideInInspector]
		public string serializedRandomWeatherTypes;

		[HideInInspector]
		public string serializedDungeonFlowTypes;

		[HideInInspector]
		public string serializedSpawnableScrap;

		[HideInInspector]
		public string serializedEnemies;

		[HideInInspector]
		public string serializedOutsideEnemies;

		[HideInInspector]
		public string serializedDaytimeEnemies;

		[HideInInspector]
		public string serializedSpawnableMapObjects;

		[HideInInspector]
		public string serializedSpawnableOutsideObjects;

		private void OnValidate()
		{
			RequiredBundles = RequiredBundles.RemoveNonAlphanumeric(1);
			IncompatibleBundles = IncompatibleBundles.RemoveNonAlphanumeric(1);
			MoonName = MoonName.RemoveNonAlphanumeric(1);
			OrbitPrefabName = OrbitPrefabName.RemoveNonAlphanumeric(1);
			RiskLevel = RiskLevel.RemoveNonAlphanumeric();
			RouteWord = RouteWord.RemoveNonAlphanumeric(2);
			BoughtComment = BoughtComment.RemoveNonAlphanumeric();
			LevelAmbienceClips = LevelAmbienceClips.RemoveNonAlphanumeric(1);
			TimeToArrive = Mathf.Clamp(TimeToArrive, 0f, 16f);
			DaySpeedMultiplier = Mathf.Clamp(DaySpeedMultiplier, 0.1f, 5f);
			RoutePrice = Mathf.Clamp(RoutePrice, 0, int.MaxValue);
			FactorySizeMultiplier = Mathf.Clamp(FactorySizeMultiplier, 1f, 5f);
			FireExitsAmountOverwrite = Mathf.Clamp(FireExitsAmountOverwrite, 0, 20);
			MinScrap = Mathf.Clamp(MinScrap, 0, MaxScrap);
			MaxScrap = Mathf.Clamp(MaxScrap, MinScrap, 100);
			MaxEnemyPowerCount = Mathf.Clamp(MaxEnemyPowerCount, 0, 30);
			MaxOutsideEnemyPowerCount = Mathf.Clamp(MaxOutsideEnemyPowerCount, 0, 30);
			MaxDaytimeEnemyPowerCount = Mathf.Clamp(MaxDaytimeEnemyPowerCount, 0, 30);
			SpawnProbabilityRange = Mathf.Clamp(SpawnProbabilityRange, 0f, 30f);
			DaytimeEnemiesProbabilityRange = Mathf.Clamp(DaytimeEnemiesProbabilityRange, 0f, 30f);
			for (int i = 0; i < _SpawnableScrap.Length; i++)
			{
				_SpawnableScrap[i].ObjectName = _SpawnableScrap[i].ObjectName.RemoveNonAlphanumeric(1);
			}
			for (int j = 0; j < _Enemies.Length; j++)
			{
				_Enemies[j].EnemyName = _Enemies[j].EnemyName.RemoveNonAlphanumeric(1);
			}
			for (int k = 0; k < _SpawnableMapObjects.Length; k++)
			{
				_SpawnableMapObjects[k].ObjectName = _SpawnableMapObjects[k].ObjectName.RemoveNonAlphanumeric(1);
			}
			for (int l = 0; l < _SpawnableOutsideObjects.Length; l++)
			{
				_SpawnableOutsideObjects[l].ObjectName = _SpawnableOutsideObjects[l].ObjectName.RemoveNonAlphanumeric(1);
			}
			for (int m = 0; m < _OutsideEnemies.Length; m++)
			{
				_OutsideEnemies[m].EnemyName = _OutsideEnemies[m].EnemyName.RemoveNonAlphanumeric(1);
			}
			for (int n = 0; n < _DaytimeEnemies.Length; n++)
			{
				_DaytimeEnemies[n].EnemyName = _DaytimeEnemies[n].EnemyName.RemoveNonAlphanumeric(1);
			}
			serializedRandomWeatherTypes = string.Join(";", _RandomWeatherTypes.Select((RandomWeatherPair p) => $"{(int)p.Weather},{p.WeatherVariable1},{p.WeatherVariable2}"));
			serializedDungeonFlowTypes = string.Join(";", _DungeonFlowTypes.Select((DungeonFlowPair p) => $"{p.ID},{p.Rarity}"));
			serializedSpawnableScrap = string.Join(";", _SpawnableScrap.Select((SpawnableScrapPair p) => $"{p.ObjectName},{p.SpawnWeight}"));
			serializedEnemies = string.Join(";", _Enemies.Select((SpawnableEnemiesPair p) => $"{p.EnemyName},{p.SpawnWeight}"));
			serializedOutsideEnemies = string.Join(";", _OutsideEnemies.Select((SpawnableEnemiesPair p) => $"{p.EnemyName},{p.SpawnWeight}"));
			serializedDaytimeEnemies = string.Join(";", _DaytimeEnemies.Select((SpawnableEnemiesPair p) => $"{p.EnemyName},{p.SpawnWeight}"));
			serializedSpawnableMapObjects = string.Join(";", _SpawnableMapObjects.Select((SpawnableMapObjectPair p) => $"{p.ObjectName}|{p.SpawnFacingAwayFromWall}|{CurveContainer.SerializeCurve(p.SpawnRate)}"));
			serializedSpawnableOutsideObjects = string.Join(";", _SpawnableOutsideObjects.Select((SpawnableOutsideObjectPair p) => p.ObjectName + "|" + CurveContainer.SerializeCurve(p.SpawnRate)));
		}

		public RandomWeatherPair[] RandomWeatherTypes()
		{
			return (from s in serializedRandomWeatherTypes.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 3
				select new RandomWeatherPair((LevelWeatherType)int.Parse(split[0]), int.Parse(split[1]), int.Parse(split[2]))).ToArray();
		}

		public DungeonFlowPair[] DungeonFlowTypes()
		{
			return (from s in serializedDungeonFlowTypes.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new DungeonFlowPair(int.Parse(split[0]), int.Parse(split[1]))).ToArray();
		}

		public SpawnableScrapPair[] SpawnableScrap()
		{
			return (from s in serializedSpawnableScrap.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new SpawnableScrapPair(split[0], int.Parse(split[1]))).ToArray();
		}

		public SpawnableEnemiesPair[] Enemies()
		{
			return (from s in serializedEnemies.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new SpawnableEnemiesPair(split[0], int.Parse(split[1]))).ToArray();
		}

		public SpawnableEnemiesPair[] OutsideEnemies()
		{
			return (from s in serializedOutsideEnemies.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new SpawnableEnemiesPair(split[0], int.Parse(split[1]))).ToArray();
		}

		public SpawnableEnemiesPair[] DaytimeEnemies()
		{
			return (from s in serializedDaytimeEnemies.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new SpawnableEnemiesPair(split[0], int.Parse(split[1]))).ToArray();
		}

		public SpawnableMapObjectPair[] SpawnableMapObjects()
		{
			return (from s in serializedSpawnableMapObjects.Split(new char[1] { ';' })
				select s.Split(new char[1] { '|' }) into split
				where split.Length == 3
				select new SpawnableMapObjectPair(split[0], bool.Parse(split[1]), CurveContainer.DeserializeCurve(split[2]))).ToArray();
		}

		public SpawnableOutsideObjectPair[] SpawnableOutsideObjects()
		{
			return (from s in serializedSpawnableOutsideObjects.Split(new char[1] { ';' })
				select s.Split(new char[1] { '|' }) into split
				where split.Length == 2
				select new SpawnableOutsideObjectPair(split[0], CurveContainer.DeserializeCurve(split[1]))).ToArray();
		}
	}
	[CreateAssetMenu(fileName = "New Scrap", menuName = "LethalSDK/Scrap")]
	public class Scrap : ScriptableObject
	{
		public string[] RequiredBundles;

		public string[] IncompatibleBundles;

		[Header("Base")]
		public ScrapType scrapType = ScrapType.Normal;

		public string itemName = string.Empty;

		public int minValue = 0;

		public int maxValue = 0;

		public bool twoHanded = false;

		public GrabAnim HandedAnimation = GrabAnim.OneHanded;

		public bool requiresBattery = false;

		public bool isConductiveMetal = false;

		public int weight = 0;

		public GameObject prefab;

		[Header("Sounds")]
		public string grabSFX = string.Empty;

		public string dropSFX = string.Empty;

		[Header("Offsets")]
		public float verticalOffset = 0f;

		public Vector3 restingRotation = Vector3.zero;

		public Vector3 positionOffset = Vector3.zero;

		public Vector3 rotationOffset = Vector3.zero;

		[Header("Variants")]
		public Mesh[] meshVariants = (Mesh[])(object)new Mesh[0];

		public Material[] materialVariants = (Material[])(object)new Material[0];

		[Header("Spawn rate")]
		public bool useGlobalSpawnWeight = true;

		[Range(0f, 100f)]
		public int globalSpawnWeight = 10;

		[SerializeField]
		private ScrapSpawnChancePerScene[] _perPlanetSpawnWeight = new ScrapSpawnChancePerScene[9]
		{
			new ScrapSpawnChancePerScene("41 Experimentation", 10),
			new ScrapSpawnChancePerScene("220 Assurance", 10),
			new ScrapSpawnChancePerScene("56 Vow", 10),
			new ScrapSpawnChancePerScene("21 Offense", 10),
			new ScrapSpawnChancePerScene("61 March", 10),
			new ScrapSpawnChancePerScene("85 Rend", 10),
			new ScrapSpawnChancePerScene("7 Dine", 10),
			new ScrapSpawnChancePerScene("8 Titan", 10),
			new ScrapSpawnChancePerScene("Others", 10)
		};

		[Header("Shovel")]
		public int shovelHitForce = 1;

		public AudioSource shovelAudio;

		public string reelUp = "ShovelReelUp";

		public string swing = "ShovelSwing";

		public string[] hitSFX = new string[2] { "ShovelHitDefault", "ShovelHitDefault2" };

		[Header("Flashlight")]
		public bool usingPlayerHelmetLight = false;

		public int flashlightInterferenceLevel = 0;

		public Light flashlightBulb;

		public Light flashlightBulbGlow;

		public AudioSource flashlightAudio;

		public string[] flashlightClips = new string[1] { "FlashlightClick" };

		public string outOfBatteriesClip = "FlashlightOutOfBatteries";

		public string flashlightFlicker = "FlashlightFlicker";

		public Material bulbLight;

		public Material bulbDark;

		public MeshRenderer flashlightMesh;

		public int flashlightTypeID = 0;

		public bool changeMaterial = true;

		[Header("Noisemaker")]
		public AudioSource noiseAudio;

		public AudioSource noiseAudioFar;

		public string[] noiseSFX = new string[1] { "ClownHorn1" };

		public string[] noiseSFXFar = new string[1] { "ClownHornFar" };

		public float noiseRange = 60f;

		public float maxLoudness = 1f;

		public float minLoudness = 0.6f;

		public float minPitch = 0.93f;

		public float maxPitch = 1f;

		public Animator triggerAnimator;

		[Header("WhoopieCushion")]
		public AudioSource whoopieCushionAudio;

		public string[] fartAudios = new string[4] { "Fart1", "Fart2", "Fart3", "Fart5" };

		[HideInInspector]
		public string serializedData;

		private void OnValidate()
		{
			RequiredBundles = RequiredBundles.RemoveNonAlphanumeric(1);
			IncompatibleBundles = IncompatibleBundles.RemoveNonAlphanumeric(1);
			itemName = itemName.RemoveNonAlphanumeric(1);
			grabSFX = grabSFX.RemoveNonAlphanumeric(1);
			dropSFX = dropSFX.RemoveNonAlphanumeric(1);
			for (int i = 0; i < _perPlanetSpawnWeight.Length; i++)
			{
				_perPlanetSpawnWeight[i].SceneName = _perPlanetSpawnWeight[i].SceneName.RemoveNonAlphanumeric(1);
			}
			serializedData = string.Join(";", _perPlanetSpawnWeight.Select((ScrapSpawnChancePerScene p) => $"{p.SceneName},{p.SpawnWeight}"));
		}

		public ScrapSpawnChancePerScene[] perPlanetSpawnWeight()
		{
			return (from s in serializedData.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new ScrapSpawnChancePerScene(split[0], int.Parse(split[1]))).ToArray();
		}
	}
	public enum ScrapType
	{
		Normal,
		Shovel,
		Flashlight,
		Noisemaker,
		WhoopieCushion
	}
	public enum GrabAnim
	{
		OneHanded,
		TwoHanded,
		Shotgun,
		Jetpack,
		Clipboard
	}
}
namespace LethalSDK.Utils
{
	public static class AssetGatherDialog
	{
		public static Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>();

		public static Dictionary<string, (AudioMixer, AudioMixerGroup[])> audioMixers = new Dictionary<string, (AudioMixer, AudioMixerGroup[])>();

		public static Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();
	}
	[Serializable]
	public class SerializableVersion
	{
		public int Major = 1;

		public int Minor = 0;

		public int Build = 0;

		public int Revision = 0;

		public SerializableVersion(int major, int minor, int build, int revision)
		{
			Major = major;
			Minor = minor;
			Build = build;
			Revision = revision;
		}

		public Version ToVersion()
		{
			return new Version(Major, Minor, Build, Revision);
		}

		public override string ToString()
		{
			return $"{Major}.{Minor}.{Build}.{Revision}";
		}
	}
	[Serializable]
	public class CurveContainer
	{
		public AnimationCurve curve;

		public static string SerializeCurve(AnimationCurve curve)
		{
			CurveContainer curveContainer = new CurveContainer
			{
				curve = curve
			};
			return JsonUtility.ToJson((object)curveContainer);
		}

		public static AnimationCurve DeserializeCurve(string json)
		{
			CurveContainer curveContainer = JsonUtility.FromJson<CurveContainer>(json);
			return curveContainer.curve;
		}
	}
	[Serializable]
	public struct StringIntPair
	{
		public string _string;

		public int _int;

		public StringIntPair(string _string, int _int)
		{
			this._string = _string.RemoveNonAlphanumeric(1);
			this._int = Mathf.Clamp(_int, 0, 100);
		}
	}
	[Serializable]
	public struct StringStringPair
	{
		public string _string1;

		public string _string2;

		public StringStringPair(string _string1, string _string2)
		{
			this._string1 = _string1.RemoveNonAlphanumeric(1);
			this._string2 = _string2.RemoveNonAlphanumeric(1);
		}
	}
	[Serializable]
	public struct IntIntPair
	{
		public int _int1;

		public int _int2;

		public IntIntPair(int _int1, int _int2)
		{
			this._int1 = _int1;
			this._int2 = _int2;
		}
	}
	[Serializable]
	public struct DungeonFlowPair
	{
		public int ID;

		[Range(0f, 300f)]
		public int Rarity;

		public DungeonFlowPair(int id, int rarity)
		{
			ID = id;
			Rarity = Mathf.Clamp(rarity, 0, 300);
		}
	}
	[Serializable]
	public struct SpawnableScrapPair
	{
		public string ObjectName;

		[Range(0f, 100f)]
		public int SpawnWeight;

		public SpawnableScrapPair(string objectName, int spawnWeight)
		{
			ObjectName = objectName.RemoveNonAlphanumeric(1);
			SpawnWeight = Mathf.Clamp(spawnWeight, 0, 100);
		}
	}
	[Serializable]
	public struct SpawnableMapObjectPair
	{
		public string ObjectName;

		public bool SpawnFacingAwayFromWall;

		public AnimationCurve SpawnRate;

		public SpawnableMapObjectPair(string objectName, bool spawnFacingAwayFromWall, AnimationCurve spawnRate)
		{
			ObjectName = objectName.RemoveNonAlphanumeric(1);
			SpawnFacingAwayFromWall = spawnFacingAwayFromWall;
			SpawnRate = spawnRate;
		}
	}
	[Serializable]
	public struct SpawnableOutsideObjectPair
	{
		public string ObjectName;

		public AnimationCurve SpawnRate;

		public SpawnableOutsideObjectPair(string objectName, AnimationCurve spawnRate)
		{
			ObjectName = objectName.RemoveNonAlphanumeric(1);
			SpawnRate = spawnRate;
		}
	}
	[Serializable]
	public struct SpawnableEnemiesPair
	{
		public string EnemyName;

		[Range(0f, 100f)]
		public int SpawnWeight;

		public SpawnableEnemiesPair(string enemyName, int spawnWeight)
		{
			EnemyName = enemyName.RemoveNonAlphanumeric(1);
			SpawnWeight = Mathf.Clamp(spawnWeight, 0, 100);
		}
	}
	[Serializable]
	public struct ScrapSpawnChancePerScene
	{
		public string SceneName;

		[Range(0f, 100f)]
		public int SpawnWeight;

		public ScrapSpawnChancePerScene(string sceneName, int spawnWeight)
		{
			SceneName = sceneName.RemoveNonAlphanumeric(1);
			SpawnWeight = Mathf.Clamp(spawnWeight, 0, 100);
		}
	}
	[Serializable]
	public struct ScrapInfoPair
	{
		public string ScrapPath;

		public Scrap Scrap;

		public ScrapInfoPair(string scrapPath, Scrap scrap)
		{
			ScrapPath = scrapPath.RemoveNonAlphanumeric(4);
			Scrap = scrap;
		}
	}
	[Serializable]
	public struct AudioClipInfoPair
	{
		public string AudioClipName;

		[HideInInspector]
		public string AudioClipPath;

		[SerializeField]
		public AudioClip AudioClip;

		public AudioClipInfoPair(string audioClipName, string audioClipPath)
		{
			AudioClipName = audioClipName.RemoveNonAlphanumeric(1);
			AudioClipPath = audioClipPath.RemoveNonAlphanumeric(4);
			AudioClip = null;
		}
	}
	[Serializable]
	public struct PlanetPrefabInfoPair
	{
		public string PlanetPrefabName;

		[HideInInspector]
		public string PlanetPrefabPath;

		[SerializeField]
		public GameObject PlanetPrefab;

		public PlanetPrefabInfoPair(string planetPrefabName, string planetPrefabPath)
		{
			PlanetPrefabName = planetPrefabName.RemoveNonAlphanumeric(1);
			PlanetPrefabPath = planetPrefabPath.RemoveNonAlphanumeric(4);
			PlanetPrefab = null;
		}
	}
	[Serializable]
	public struct PrefabInfoPair
	{
		public string PrefabName;

		[HideInInspector]
		public string PrefabPath;

		[SerializeField]
		public GameObject Prefab;

		public PrefabInfoPair(string prefabName, string prefabPath)
		{
			PrefabName = prefabName.RemoveNonAlphanumeric(1);
			PrefabPath = prefabPath.RemoveNonAlphanumeric(4);
			Prefab = null;
		}
	}
	[Serializable]
	public struct RandomWeatherPair
	{
		public LevelWeatherType Weather;

		[Tooltip("Thunder Frequency, Flooding speed or minimum initial enemies in eclipses")]
		public int WeatherVariable1;

		[Tooltip("Flooding offset when Weather is Flooded")]
		public int WeatherVariable2;

		public RandomWeatherPair(LevelWeatherType weather, int weatherVariable1, int weatherVariable2)
		{
			Weather = weather;
			WeatherVariable1 = weatherVariable1;
			WeatherVariable2 = weatherVariable2;
		}
	}
	public enum LevelWeatherType
	{
		None = -1,
		DustClouds,
		Rainy,
		Stormy,
		Foggy,
		Flooded,
		Eclipsed
	}
	public class SpawnPrefab
	{
		private static SpawnPrefab _instance;

		public GameObject waterSurface;

		public static SpawnPrefab Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new SpawnPrefab();
				}
				return _instance;
			}
		}
	}
	public static class TypeExtensions
	{
		public enum removeType
		{
			Normal,
			Serializable,
			Keyword,
			Path,
			SerializablePath
		}

		public static readonly Dictionary<removeType, string> regexes = new Dictionary<removeType, string>
		{
			{
				removeType.Normal,
				"[^a-zA-Z0-9 ,.!?_-]"
			},
			{
				removeType.Serializable,
				"[^a-zA-Z0-9 .!_-]"
			},
			{
				removeType.Keyword,
				"[^a-zA-Z0-9._-]"
			},
			{
				removeType.Path,
				"[^a-zA-Z0-9 ,.!_/-]"
			},
			{
				removeType.SerializablePath,
				"[^a-zA-Z0-9 .!_/-]"
			}
		};

		public static string RemoveNonAlphanumeric(this string input)
		{
			if (input != null)
			{
				return Regex.Replace(input, regexes[removeType.Normal], string.Empty);
			}
			return string.Empty;
		}

		public static string[] RemoveNonAlphanumeric(this string[] input)
		{
			if (input != null)
			{
				for (int i = 0; i < input.Length; i++)
				{
					input[i] = Regex.Replace(input[i], regexes[removeType.Normal], string.Empty);
				}
				return input;
			}
			return new string[0];
		}

		public static string RemoveNonAlphanumeric(this string input, removeType removeType = removeType.Normal)
		{
			if (input != null)
			{
				return Regex.Replace(input, regexes[removeType], string.Empty);
			}
			return string.Empty;
		}

		public static string[] RemoveNonAlphanumeric(this string[] input, removeType removeType = removeType.Normal)
		{
			if (input != null)
			{
				for (int i = 0; i < input.Length; i++)
				{
					input[i] = Regex.Replace(input[i], regexes[removeType], string.Empty);
				}
				return input;
			}
			return new string[0];
		}

		public static string RemoveNonAlphanumeric(this string input, int removeType = 0)
		{
			if (input != null)
			{
				return Regex.Replace(input, regexes[(removeType)removeType], string.Empty);
			}
			return string.Empty;
		}

		public static string[] RemoveNonAlphanumeric(this string[] input, int removeType = 0)
		{
			if (input != null)
			{
				for (int i = 0; i < input.Length; i++)
				{
					input[i] = Regex.Replace(input[i], regexes[(removeType)removeType], string.Empty);
				}
				return input;
			}
			return new string[0];
		}
	}
}
namespace LethalSDK.Editor
{
	internal class CopyrightsWindow : EditorWindow
	{
		private Vector2 scrollPosition;

		private readonly Dictionary<string, string> assetAuthorList = new Dictionary<string, string>
		{
			{ "Drop Ship assets, Sun cycle animations, ScrapItem sprite, ScavengerSuit Textures/Arms Mesh and MonitorWall mesh", "Zeekerss" },
			{ "SDK Scripts, Sun Texture, CrossButton Sprite (Inspired of vanilla), OldSeaPort planet prefab texture", "HolographicWings" },
			{ "Old Sea Port asset package", "VIVID Arts" },
			{ "Survival Game Tools asset package", "cookiepopworks.com" }
		};

		[MenuItem("LethalSDK/Copyrights", false, 999)]
		public static void ShowWindow()
		{
			EditorWindow.GetWindow<CopyrightsWindow>("Copyrights");
		}

		private void OnGUI()
		{
			//IL_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("List of Copyrights", EditorStyles.boldLabel, Array.Empty<GUILayoutOption>());
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>());
			EditorGUILayout.Space(5f);
			foreach (KeyValuePair<string, string> assetAuthor in assetAuthorList)
			{
				GUILayout.Label("Asset: " + assetAuthor.Key + " - By: " + assetAuthor.Value, EditorStyles.wordWrappedLabel, Array.Empty<GUILayoutOption>());
				EditorGUILayout.Space(2f);
			}
			EditorGUILayout.Space(5f);
			GUILayout.Label("This SDK do not embed any Vanilla script.", Array.Empty<GUILayoutOption>());
			GUILayout.EndScrollView();
		}
	}
	public class EditorChecker : Editor
	{
		public override void OnInspectorGUI()
		{
			((Editor)this).DrawDefaultInspector();
		}
	}
	[CustomEditor(typeof(ModManifest))]
	public class ModManifestEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			ModManifest modManifest = (ModManifest)(object)((Editor)this).target;
			if (modManifest.serializedVersion == "0.0.0.0")
			{
				EditorGUILayout.HelpBox("Please define a version to your mod and don't forget to increment it at each update.", (MessageType)2);
			}
			if (modManifest.modName == null || modManifest.modName.Length == 0)
			{
				EditorGUILayout.HelpBox("Your mod need a name.", (MessageType)3);
			}
			IEnumerable<string> enumerable = from e in modManifest.scraps.Where((Scrap e) => (Object)(object)e != (Object)null).ToList()
				group e by e.itemName into g
				where g.Count() > 1
				select g.Key;
			if (enumerable.Any())
			{
				string text = string.Empty;
				foreach (string item in enumerable)
				{
					text = text + item + ",";
				}
				text = text.Remove(text.Length - 1);
				EditorGUILayout.HelpBox("You are trying to register two times or more the same Scraps. Duplicated Scraps are: " + text, (MessageType)2);
			}
			IEnumerable<string> enumerable2 = from e in modManifest.moons.Where((Moon e) => (Object)(object)e != (Object)null).ToList()
				group e by e.MoonName into g
				where g.Count() > 1
				select g.Key;
			if (enumerable2.Any())
			{
				string text2 = string.Empty;
				foreach (string item2 in enumerable2)
				{
					text2 = text2 + item2 + ",";
				}
				text2 = text2.Remove(text2.Length - 1);
				EditorGUILayout.HelpBox("You are trying to register two times or more the same Moons. Duplicated Moons are: " + text2, (MessageType)2);
			}
			string text3 = string.Empty;
			Scrap[] scraps = modManifest.scraps;
			foreach (Scrap scrap in scraps)
			{
				if ((Object)(object)scrap != (Object)null && AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)scrap)) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)modManifest)))
				{
					text3 = text3 + ((Object)scrap).name + ",";
				}
			}
			Moon[] moons = modManifest.moons;
			foreach (Moon moon in moons)
			{
				if ((Object)(object)moon != (Object)null && AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)moon)) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)modManifest)))
				{
					text3 = text3 + ((Object)moon).name + ",";
				}
			}
			if (text3 != null && text3.Length > 0)
			{
				text3 = text3.Remove(text3.Length - 1);
				EditorGUILayout.HelpBox("You try to register a Scrap or a Moon from another mod folder. " + text3, (MessageType)2);
			}
			if ((Object)(object)modManifest.assetBank != (Object)null && AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)modManifest.assetBank)) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)modManifest)))
			{
				EditorGUILayout.HelpBox("You try to register an AssetBank from another mod folder.", (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(AssetBank))]
	public class AssetBankEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			AssetBank assetBank = (AssetBank)(object)((Editor)this).target;
			IEnumerable<string> enumerable = from e in (from e in assetBank.AudioClips()
					where e.AudioClipName != null && e.AudioClipName.Length > 0
					select e).ToList()
				group e by e.AudioClipName into g
				where g.Count() > 1
				select g.Key;
			if (enumerable.Any())
			{
				string text = string.Empty;
				foreach (string item in enumerable)
				{
					text = text + item + ",";
				}
				text = text.Remove(text.Length - 1);
				EditorGUILayout.HelpBox("You are trying to register two times or more the same Audio Clip. Duplicated Clips are: " + text, (MessageType)2);
			}
			IEnumerable<string> enumerable2 = from e in (from e in assetBank.PlanetPrefabs()
					where e.PlanetPrefabName != null && e.PlanetPrefabName.Length > 0
					select e).ToList()
				group e by e.PlanetPrefabName into g
				where g.Count() > 1
				select g.Key;
			if (enumerable2.Any())
			{
				string text2 = string.Empty;
				foreach (string item2 in enumerable2)
				{
					text2 = text2 + item2 + ",";
				}
				text2 = text2.Remove(text2.Length - 1);
				EditorGUILayout.HelpBox("You are trying to register two times or more the same Planet Prefabs. Duplicated Planet Prefabs are: " + text2, (MessageType)2);
			}
			string text3 = string.Empty;
			AudioClipInfoPair[] array = assetBank.AudioClips();
			for (int i = 0; i < array.Length; i++)
			{
				AudioClipInfoPair audioClipInfoPair = array[i];
				if (audioClipInfoPair.AudioClipName != null && audioClipInfoPair.AudioClipName.Length > 0 && AssetModificationProcessor.ExtractBundleNameFromPath(audioClipInfoPair.AudioClipPath) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)assetBank)))
				{
					text3 = text3 + audioClipInfoPair.AudioClipName + ",";
				}
			}
			PlanetPrefabInfoPair[] array2 = assetBank.PlanetPrefabs();
			for (int j = 0; j < array2.Length; j++)
			{
				PlanetPrefabInfoPair planetPrefabInfoPair = array2[j];
				if (planetPrefabInfoPair.PlanetPrefabName != null && planetPrefabInfoPair.PlanetPrefabName.Length > 0 && AssetModificationProcessor.ExtractBundleNameFromPath(planetPrefabInfoPair.PlanetPrefabPath) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)assetBank)))
				{
					text3 = text3 + planetPrefabInfoPair.PlanetPrefabName + ",";
				}
			}
			if (text3 != null && text3.Length > 0)
			{
				text3 = text3.Remove(text3.Length - 1);
				EditorGUILayout.HelpBox("You try to register an Audio Clip or a Planet Prefab from another mod folder. " + text3, (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_DungeonGenerator))]
	public class SI_DungeonGeneratorEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_DungeonGenerator sI_DungeonGenerator = (SI_DungeonGenerator)(object)((Editor)this).target;
			string assetPath = AssetDatabase.GetAssetPath((Object)(object)sI_DungeonGenerator.DungeonRoot);
			if (assetPath != null && assetPath.Length > 0)
			{
				EditorGUILayout.HelpBox("Dungeon Root must be in the scene.", (MessageType)3);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_ScanNode))]
	public class SI_ScanNodeEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_ScanNode sI_ScanNode = (SI_ScanNode)(object)((Editor)this).target;
			if (sI_ScanNode.MinRange > sI_ScanNode.MaxRange)
			{
				EditorGUILayout.HelpBox("Min Range must be smaller than Max Ranger.", (MessageType)3);
			}
			if (sI_ScanNode.CreatureScanID < -1)
			{
				EditorGUILayout.HelpBox("Creature Scan ID can't be less than -1.", (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_AnimatedSun))]
	public class SI_AnimatedSunEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_AnimatedSun sI_AnimatedSun = (SI_AnimatedSun)(object)((Editor)this).target;
			if ((Object)(object)sI_AnimatedSun.directLight == (Object)null || (Object)(object)sI_AnimatedSun.indirectLight == (Object)null)
			{
				EditorGUILayout.HelpBox("A direct and an indirect light must be defined.", (MessageType)2);
			}
			if ((Object)(object)((Component)sI_AnimatedSun.directLight).transform.parent != (Object)(object)((Component)sI_AnimatedSun).transform || (Object)(object)((Component)sI_AnimatedSun.indirectLight).transform.parent != (Object)(object)((Component)sI_AnimatedSun).transform)
			{
				EditorGUILayout.HelpBox("Direct and an indirect light must be a child of the AnimatedSun in the hierarchy.", (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_EntranceTeleport))]
	public class SI_EntranceTeleportEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_EntranceTeleport sI_EntranceTeleport = (SI_EntranceTeleport)(object)((Editor)this).target;
			IEnumerable<int> enumerable = from e in Object.FindObjectsOfType<SI_EntranceTeleport>().ToList()
				group e by e.EntranceID into g
				where g.Count() > 1
				select g.Key;
			if (enumerable.Any())
			{
				string text = string.Empty;
				foreach (int item in enumerable)
				{
					text += $"{item},";
				}
				text = text.Remove(text.Length - 1);
				EditorGUILayout.HelpBox("Two entrances or more have same Entrance ID. Duplicated entrances are: " + text, (MessageType)2);
			}
			if ((Object)(object)sI_EntranceTeleport.EntrancePoint == (Object)null)
			{
				EditorGUILayout.HelpBox("An entrance point must be defined.", (MessageType)3);
			}
			if (sI_EntranceTeleport.AudioReverbPreset < 0)
			{
				EditorGUILayout.HelpBox("Audio Reverb Preset can't be negative.", (MessageType)3);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(Scrap))]
	public class ScrapEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			Scrap scrap = (Scrap)(object)((Editor)this).target;
			if ((Object)(object)scrap.prefab == (Object)null)
			{
				EditorGUILayout.HelpBox("You must add a Prefab to your Scrap.", (MessageType)1);
			}
			else
			{
				if ((Object)(object)scrap.prefab.GetComponent<NetworkObject>() == (Object)null)
				{
					EditorGUILayout.HelpBox("The Prefab must have a NetworkObject.", (MessageType)3);
				}
				else
				{
					NetworkObject component = scrap.prefab.GetComponent<NetworkObject>();
					string text = string.Empty;
					if (component.AlwaysReplicateAsRoot)
					{
						text += "\n- AlwaysReplicateAsRoot should be false.";
					}
					if (!component.SynchronizeTransform)
					{
						text += "\n- SynchronizeTransform should be true.";
					}
					if (component.ActiveSceneSynchronization)
					{
						text += "\n- ActiveSceneSynchronization should be false.";
					}
					if (!component.SceneMigrationSynchronization)
					{
						text += "\n- SceneMigrationSynchronization should be true.";
					}
					if (!component.SpawnWithObservers)
					{
						text += "\n- SpawnWithObservers should be true.";
					}
					if (!component.DontDestroyWithOwner)
					{
						text += "\n- DontDestroyWithOwner should be true.";
					}
					if (component.AutoObjectParentSync)
					{
						text += "\n- AutoObjectParentSync should be false.";
					}
					if (text.Length > 0)
					{
						EditorGUILayout.HelpBox("The NetworkObject of the Prefab have incorrect settings: " + text, (MessageType)2);
					}
				}
				if ((Object)(object)scrap.prefab.transform.Find("ScanNode") == (Object)null)
				{
					EditorGUILayout.HelpBox("The Prefab don't have a ScanNode.", (MessageType)2);
				}
				if (AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)scrap.prefab)) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)scrap)))
				{
					EditorGUILayout.HelpBox("The Prefab must come from the same mod folder as your Scrap.", (MessageType)2);
				}
			}
			if (scrap.itemName == null || scrap.itemName.Length == 0)
			{
				EditorGUILayout.HelpBox("Your scrap must have a Name.", (MessageType)3);
			}
			if (!scrap.useGlobalSpawnWeight && !scrap.perPlanetSpawnWeight().Any((ScrapSpawnChancePerScene w) => w.SceneName != null && w.SceneName.Length > 0))
			{
				EditorGUILayout.HelpBox("Your scrap use Per Planet Spawn Weight but no planet are defined.", (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(Moon))]
	public class MoonEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			Moon moon = (Moon)(object)((Editor)this).target;
			if (moon.MoonName == null || moon.MoonName.Length == 0)
			{
				EditorGUILayout.HelpBox("Your moon must have a Name.", (MessageType)3);
			}
			if (moon.PlanetName == null || moon.PlanetName.Length == 0)
			{
				EditorGUILayout.HelpBox("Your moon must have a Planet Name.", (MessageType)3);
			}
			if (moon.RouteWord == null || moon.RouteWord.Length < 3)
			{
				EditorGUILayout.HelpBox("Your moon route word must be at least 3 characters long.", (MessageType)3);
			}
			if ((Object)(object)moon.MainPrefab == (Object)null)
			{
				EditorGUILayout.HelpBox("You must add a Main Prefab to your Scrap.", (MessageType)1);
			}
			else if (AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)moon.MainPrefab)) != AssetModificationProcessor.ExtractBundleNameFromPath(AssetDatabase.GetAssetPath((Object)(object)moon)))
			{
				EditorGUILayout.HelpBox("The Main Prefab must come from the same mod folder as your Moon.", (MessageType)2);
			}
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_DoorLock))]
	public class SI_DoorLockEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_DoorLock sI_DoorLock = (SI_DoorLock)(object)((Editor)this).target;
			EditorGUILayout.HelpBox("DoorLock is not implemented yet.", (MessageType)1);
			base.OnInspectorGUI();
		}
	}
	[CustomEditor(typeof(SI_Ladder))]
	public class SI_LadderEditor : EditorChecker
	{
		public override void OnInspectorGUI()
		{
			SI_Ladder sI_Ladder = (SI_Ladder)(object)((Editor)this).target;
			EditorGUILayout.HelpBox("Ladder is experimental.", (MessageType)1);
			base.OnInspectorGUI();
		}
	}
	internal class OldAssetsRemover
	{
		private static readonly List<string> assetPaths = new List<string>
		{
			"Assets/LethalCompanyAssets", "Assets/Mods/LethalExpansion/Audio", "Assets/Mods/LethalExpansion/AudioMixerController", "Assets/Mods/LethalExpansion/Materials/Default.mat", "Assets/Mods/LethalExpansion/Prefabs/Settings", "Assets/Mods/LethalExpansion/Prefabs/EntranceTeleportA.prefab", "Assets/Mods/LethalExpansion/Prefabs/Prefabs.zip", "Assets/Mods/LethalExpansion/Scenes/ItemPlaceTest", "Assets/Mods/LethalExpansion/Sprites/HandIcon.png", "Assets/Mods/LethalExpansion/Sprites/HandIconPoint.png",
			"Assets/Mods/LethalExpansion/Sprites/HandLadderIcon.png", "Assets/Mods/TemplateMod/Moons/NavMesh-Environment.asset", "Assets/Mods/TemplateMod/Moons/OldSeaPort.asset", "Assets/Mods/TemplateMod/Moons/Sky and Fog Global Volume Profile.asset", "Assets/Mods/TemplateMod/Moons/Sky and Fog Global Volume Profile 1.asset", "Assets/Mods/TemplateMod/AssetBank.asset", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunCompanyLevel.anim", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeB.anim", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeBEclipse.anim", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeBStormy.anim",
			"Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeC.anim", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeCEclipse.anim", "Assets/Mods/LethalExpansion/Animations/Sun/TimeOfDaySunTypeCStormy.anim", "Assets/Mods/LethalExpansion/Skybox", "Assets/Mods/LethalExpansion/Sprites/XButton.png", "Assets/Mods/LethalExpansion/Textures/sunTexture1.png", "Assets/Mods/OldSeaPort/Materials/Maple_bark_1.mat", "Assets/Mods/OldSeaPort/Materials/maple_leaves.mat", "Assets/Mods/TemplateMod/AssetBank.asset", "Assets/Mods/OldSeaPort/EffectExamples/Shared/Scripts",
			"Assets/Mods/OldSeaPort/scenes", "Assets/Mods/OldSeaPort/prefabs/Plane (12).prefab", "Assets/Mods/LethalExpansion/Meshes/labyrinth.fbx", "Assets/Mods/ChristmasVillage/christmas-assets-free/fbx/Materials"
		};

		[InitializeOnLoadMethod]
		public static void CheckOldAssets()
		{
			foreach (string assetPath in assetPaths)
			{
				if (AssetDatabase.IsValidFolder(assetPath))
				{
					DeleteFolder(assetPath);
				}
				else if ((Object)(object)AssetDatabase.LoadAssetAtPath<GameObject>(assetPath) != (Object)null)
				{
					DeleteAsset(assetPath);
				}
			}
		}

		private static void DeleteFolder(string path)
		{
			if (AssetDatabase.DeleteAsset(path))
			{
				Debug.Log((object)("Deleted folder at: " + path));
			}
			else
			{
				Debug.LogError((object)("Failed to delete folder at: " + path));
			}
		}

		private static void DeleteAsset(string path)
		{
			if (AssetDatabase.DeleteAsset(path))
			{
				Debug.Log((object)("Deleted asset at: " + path));
			}
			else
			{
				Debug.LogError((object)("Failed to delete asset at: " + path));
			}
		}
	}
	public class VersionChecker : Editor
	{
		[InitializeOnLoadMethod]
		public static void CheckVersion()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			UnityWebRequest www = UnityWebRequest.Get("https://raw.githubusercontent.com/HolographicWings/LethalSDK-Unity-Project/main/last.txt");
			UnityWebRequestAsyncOperation operation = www.SendWebRequest();
			CallbackFunction callback = null;
			callback = (CallbackFunction)delegate
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				if (((AsyncOperation)operation).isDone)
				{
					EditorApplication.update = (CallbackFunction)Delegate.Remove((Delegate?)(object)EditorApplication.update, (Delegate?)(object)callback);
					OnRequestComplete(www);
				}
			};
			EditorApplication.update = (CallbackFunction)Delegate.Combine((Delegate?)(object)EditorApplication.update, (Delegate?)(object)callback);
		}

		private static void OnRequestComplete(UnityWebRequest www)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			if ((int)www.result == 2 || (int)www.result == 3)
			{
				Debug.LogError((object)("Error when getting last version number: " + www.error));
			}
			else
			{
				CompareVersions(www.downloadHandler.text);
			}
		}

		private static void CompareVersions(string onlineVersion)
		{
			if (Version.Parse(PlayerSettings.bundleVersion) < Version.Parse(onlineVersion) && EditorUtility.DisplayDialogComplex("Warning", "The SDK is not up to date: " + onlineVersion, "Update", "Ignore", "") == 0)
			{
				Application.OpenURL("https://thunderstore.io/c/lethal-company/p/HolographicWings/LethalSDK/");
			}
		}
	}
	internal class LethalSDKCategory : EditorWindow
	{
		[MenuItem("LethalSDK/Lethal SDK v1.3.0", false, 0)]
		public static void ShowWindow()
		{
		}
	}
	public class Lethal_AssetBundleBuilderWindow : EditorWindow
	{
		private enum compressionOption
		{
			NormalCompression,
			FastCompression,
			Uncompressed
		}

		private static string assetBundleDirectoryKey = "LethalSDK_AssetBundleBuilderWindow_assetBundleDirectory";

		private static string compressionModeKey = "LethalSDK_AssetBundleBuilderWindow_compressionMode";

		private static string _64BitsModeKey = "LethalSDK_AssetBundleBuilderWindow_64BitsMode";

		private string assetBundleDirectory = string.Empty;

		private compressionOption compressionMode = compressionOption.NormalCompression;

		private bool _64BitsMode;

		[MenuItem("LethalSDK/AssetBundle Builder", false, 100)]
		public static void ShowWindow()
		{
			//IL_0017: 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)
			Lethal_AssetBundleBuilderWindow window = EditorWindow.GetWindow<Lethal_AssetBundleBuilderWindow>("AssetBundle Builder");
			((EditorWindow)window).minSize = new Vector2(295f, 133f);
			((EditorWindow)window).maxSize = new Vector2(295f, 133f);
			window.LoadPreferences();
		}

		private void OnGUI()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			GUILayout.Label("Base Settings", EditorStyles.boldLabel, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			EditorGUILayout.LabelField(new GUIContent("Output Path", "The directory where the asset bundles will be saved."), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(84f) });
			assetBundleDirectory = EditorGUILayout.TextField(assetBundleDirectory, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
			GUILayout.EndHorizontal();
			EditorGUILayout.Space(5f);
			GUILayout.Label("Options", EditorStyles.boldLabel, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			EditorGUILayout.LabelField(new GUIContent("Compression Mode", "Select the compression option for the asset bundle. Faster the compression is, faster the assets will load and less CPU it will use, but the Bundle will be bigger."), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(145f) });
			compressionMode = (compressionOption)(object)EditorGUILayout.EnumPopup((Enum)compressionMode, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) });
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			EditorGUILayout.LabelField(new GUIContent("64 Bits Asset Bundle (Not recommended)", "Better performances but incompatible with 32 bits computers."), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(270f) });
			_64BitsMode = EditorGUILayout.Toggle(_64BitsMode, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			EditorGUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Build AssetBundles", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) }))
			{
				BuildAssetBundles();
			}
			if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) }))
			{
				ClearPreferences();
			}
			GUILayout.EndHorizontal();
		}

		private void ClearPreferences()
		{
			EditorPrefs.DeleteKey(assetBundleDirectoryKey);
			EditorPrefs.DeleteKey(compressionModeKey);
			EditorPrefs.DeleteKey(_64BitsModeKey);
			LoadPreferences();
		}

		private void BuildAssetBundles()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (!Directory.Exists(assetBundleDirectory))
			{
				Directory.CreateDirectory(assetBundleDirectory);
			}
			BuildAssetBundleOptions val = (BuildAssetBundleOptions)0;
			val = (BuildAssetBundleOptions)(compressionMode switch
			{
				compressionOption.NormalCompression => 0, 
				compressionOption.FastCompression => 256, 
				compressionOption.Uncompressed => 1, 
				_ => 0, 
			});
			BuildTarget val2 = (BuildTarget)(_64BitsMode ? 19 : 5);
			if (assetBundleDirectory != null || assetBundleDirectory.Length != 0 || assetBundleDirectory != string.Empty)
			{
				AssetBundleManifest val3 = null;
				try
				{
					val3 = BuildPipeline.BuildAssetBundles(assetBundleDirectory, val, val2);
				}
				catch (Exception ex)
				{
					Debug.LogError((object)ex.Message);
				}
				if ((Object)(object)val3 != (Object)null)
				{
					Debug.Log((object)"AssetBundles built successfully.");
				}
				else
				{
					Debug.LogError((object)"Cannot build AssetBundles.");
				}
			}
			else
			{
				Debug.LogError((object)"AssetBundles path cannot be blank.");
			}
		}

		private void OnLostFocus()
		{
			SavePreferences();
		}

		private void OnDisable()
		{
			SavePreferences();
		}

		private void LoadPreferences()
		{
			assetBundleDirectory = EditorPrefs.GetString(assetBundleDirectoryKey, "Assets/AssetBundles");
			compressionMode = (compressionOption)EditorPrefs.GetInt(compressionModeKey, 0);
			_64BitsMode = EditorPrefs.GetBool(_64BitsModeKey, false);
		}

		private void SavePreferences()
		{
			EditorPrefs.SetString(assetBundleDirectoryKey, assetBundleDirectory);
			EditorPrefs.SetInt(compressionModeKey, (int)compressionMode);
			EditorPrefs.SetBool(_64BitsModeKey, _64BitsMode);
		}
	}
}
namespace LethalSDK.Component
{
	[AddComponentMenu("LethalSDK/DamagePlayer")]
	public class SI_DamagePlayer : MonoBehaviour
	{
		public bool kill = false;

		public bool dontSpawnBody = false;

		public SI_CauseOfDeath causeOfDeath = SI_CauseOfDeath.Gravity;

		public int damages = 25;

		public int numberIterations = 1;

		public int iterationCooldown = 1000;

		public int warmupCooldown = 0;

		public UnityEvent postEvent = new UnityEvent();

		public void Trigger(object player)
		{
			if (kill)
			{
				((MonoBehaviour)this).StartCoroutine(Kill(player));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(Damage(player));
			}
		}

		public IEnumerator Kill(object player)
		{
			yield return (object)new WaitForSeconds((float)warmupCooldown / 1000f);
			((PlayerControllerB)((player is PlayerControllerB) ? player : null)).KillPlayer(Vector3.zero, !dontSpawnBody, (CauseOfDeath)causeOfDeath, 0);
			postEvent.Invoke();
		}

		public IEnumerator Damage(object player)
		{
			yield return (object)new WaitForSeconds((float)warmupCooldown / 1000f);
			int iteration = 0;
			while (iteration < numberIterations || numberIterations == -1)
			{
				((PlayerControllerB)((player is PlayerControllerB) ? player : null)).DamagePlayer(damages, true, true, (CauseOfDeath)causeOfDeath, 0, false, Vector3.zero);
				postEvent.Invoke();
				iteration++;
				yield return (object)new WaitForSeconds((float)iterationCooldown / 1000f);
			}
		}

		public void StopCounter(object player)
		{
			((MonoBehaviour)this).StopAllCoroutines();
		}
	}
	[AddComponentMenu("LethalSDK/SoundYDistance")]
	public class SI_SoundYDistance : MonoBehaviour
	{
		public AudioSource audioSource;

		public int maxDistance = 50;

		public void Awake()
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
				if ((Object)(object)audioSource == (Object)null)
				{
					audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				}
			}
		}

		public void Update()
		{
			//IL_0032: 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)
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				audioSource.volume = 1f - Mathf.Abs(((Component)this).transform.position.y - ((Component)RoundManager.Instance.playersManager.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[((NetworkBehaviour)StartOfRound.Instance).NetworkManager.LocalClientId]].gameplayCamera).transform.position.y) / (float)maxDistance;
			}
		}
	}
	[AddComponentMenu("LethalSDK/AudioOutputInterface")]
	public class SI_AudioOutputInterface : MonoBehaviour
	{
		public AudioSource audioSource;

		public string mixerName = "Diagetic";

		public string mixerGroupName = "Master";

		public void Awake()
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
				if ((Object)(object)audioSource == (Object)null)
				{
					audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				}
			}
			if (mixerName != null && mixerName.Length > 0 && mixerGroupName != null && mixerGroupName.Length > 0)
			{
				audioSource.outputAudioMixerGroup = AssetGatherDialog.audioMixers[mixerName].Item2.First((AudioMixerGroup g) => ((Object)g).name == mixerGroupName);
			}
			Object.Destroy((Object)(object)this);
		}
	}
	[AddComponentMenu("LethalSDK/NetworkPrefabInstancier")]
	public class SI_NetworkPrefabInstancier : MonoBehaviour
	{
		public GameObject prefab;

		[HideInInspector]
		public GameObject instance;

		public InterfaceType interfaceType = InterfaceType.None;

		public void Awake()
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab != (Object)null)
			{
				NetworkObject component = prefab.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.NetworkManager != (Object)null && component.NetworkManager.IsHost)
				{
					SI_NetworkDataInterfacing component2 = ((Component)this).GetComponent<SI_NetworkDataInterfacing>();
					if ((Object)(object)component2 != (Object)null)
					{
						StringStringPair[] data = component2.getData();
						InterfaceType interfaceType = this.interfaceType;
						InterfaceType interfaceType2 = interfaceType;
						if (interfaceType2 != InterfaceType.Base && interfaceType2 == InterfaceType.Entrance)
						{
							SI_EntranceTeleport componentInChildren = prefab.GetComponentInChildren<SI_EntranceTeleport>();
							if ((Object)(object)componentInChildren != (Object)null)
							{
								if (data.Any((StringStringPair e) => e._string1.ToLower() == "entranceid"))
								{
									int.TryParse(data.First((StringStringPair e) => e._string1.ToLower() == "entranceid")._string2, out componentInChildren.EntranceID);
								}
								if (data.Any((StringStringPair e) => e._string1.ToLower() == "audioreverbpreset"))
								{
									int.TryParse(data.First((StringStringPair e) => e._string1.ToLower() == "audioreverbpreset")._string2, out componentInChildren.AudioReverbPreset);
								}
							}
						}
					}
					instance = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform.parent);
					instance.GetComponent<NetworkObject>().Spawn(false);
				}
			}
			((Component)this).gameObject.SetActive(false);
		}

		public void OnDestroy()
		{
			if ((Object)(object)instance != (Object)null)
			{
				NetworkObject component = prefab.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.NetworkManager != (Object)null && component.NetworkManager.IsHost)
				{
					instance.GetComponent<NetworkObject>().Despawn(true);
					Object.Destroy((Object)(object)instance);
				}
			}
		}
	}
	public enum InterfaceType
	{
		None,
		Base,
		Entrance
	}
	[AddComponentMenu("LethalSDK/NetworkDataInterfacing")]
	public class SI_NetworkDataInterfacing : MonoBehaviour
	{
		public StringStringPair[] data;

		[HideInInspector]
		public string serializedData;

		private void OnValidate()
		{
			serializedData = string.Join(";", data.Select((StringStringPair p) => p._string1 + "," + p._string2));
		}

		public virtual StringStringPair[] getData()
		{
			return (from s in serializedData.Split(new char[1] { ';' })
				select s.Split(new char[1] { ',' }) into split
				where split.Length == 2
				select new StringStringPair(split[0], split[1])).ToArray();
		}
	}
	public class ScriptImporter : MonoBehaviour
	{
		public virtual void Awake()
		{
			Object.Destroy((Object)(object)this);
		}
	}
	[AddComponentMenu("LethalSDK/MatchLocalPlayerPosition")]
	public class SI_MatchLocalPlayerPosition : ScriptImporter
	{
		public override void Awake()
		{
			((Component)this).gameObject.AddComponent<MatchLocalPlayerPosition>();
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/AnimatedSun")]
	public class SI_AnimatedSun : ScriptImporter
	{
		public Light indirectLight;

		public Light directLight;

		public override void Awake()
		{
			animatedSun val = ((Component)this).gameObject.AddComponent<animatedSun>();
			val.indirectLight = indirectLight;
			val.directLight = directLight;
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/ScanNode")]
	public class SI_ScanNode : ScriptImporter
	{
		public int MaxRange;

		public int MinRange;

		public bool RequiresLineOfSight;

		public string HeaderText;

		public string SubText;

		public int ScrapValue;

		public int CreatureScanID;

		public NodeType NodeType;

		public override void Awake()
		{
			ScanNodeProperties val = ((Component)this).gameObject.AddComponent<ScanNodeProperties>();
			val.minRange = MinRange;
			val.maxRange = MaxRange;
			val.requiresLineOfSight = RequiresLineOfSight;
			val.headerText = HeaderText;
			val.subText = SubText;
			val.scrapValue = ScrapValue;
			val.creatureScanID = CreatureScanID;
			val.nodeType = (int)NodeType;
			base.Awake();
		}
	}
	public enum NodeType
	{
		Information = 0,
		Danger = 0,
		Ressource = 0
	}
	[AddComponentMenu("LethalSDK/AudioReverbPresets")]
	public class SI_AudioReverbPresets : ScriptImporter
	{
		public GameObject[] presets;

		public override void Awake()
		{
		}

		public void Update()
		{
			int num = 0;
			GameObject[] array = presets;
			foreach (GameObject val in array)
			{
				if ((Object)(object)val.GetComponent<SI_AudioReverbTrigger>() != (Object)null)
				{
					num++;
				}
			}
			if (num != 0)
			{
				return;
			}
			List<AudioReverbTrigger> list = new List<AudioReverbTrigger>();
			GameObject[] array2 = presets;
			foreach (GameObject val2 in array2)
			{
				if ((Object)(object)val2.GetComponent<AudioReverbTrigger>() != (Object)null)
				{
					list.Add(val2.GetComponent<AudioReverbTrigger>());
				}
			}
			AudioReverbPresets val3 = ((Component)this).gameObject.AddComponent<AudioReverbPresets>();
			val3.audioPresets = list.ToArray();
			Object.Destroy((Object)(object)this);
		}
	}
	[AddComponentMenu("LethalSDK/AudioReverbTrigger")]
	public class SI_AudioReverbTrigger : ScriptImporter
	{
		[Header("Reverb Preset")]
		public bool ChangeDryLevel = false;

		[Range(-10000f, 0f)]
		public float DryLevel = 0f;

		public bool ChangeHighFreq = false;

		[Range(-10000f, 0f)]
		public float HighFreq = -270f;

		public bool ChangeLowFreq = false;

		[Range(-10000f, 0f)]
		public float LowFreq = -244f;

		public bool ChangeDecayTime = false;

		[Range(0f, 35f)]
		public float DecayTime = 1.4f;

		public bool ChangeRoom = false;

		[Range(-10000f, 0f)]
		public float Room = -600f;

		[Header("MISC")]
		public bool ElevatorTriggerForProps = false;

		public bool SetInElevatorTrigger = false;

		public bool IsShipRoom = false;

		public bool ToggleLocalFog = false;

		public float FogEnabledAmount = 10f;

		[Header("Weather and effects")]
		public bool SetInsideAtmosphere = false;

		public bool InsideLighting = false;

		public int WeatherEffect = -1;

		public bool EffectEnabled = true;

		public bool DisableAllWeather = false;

		public bool EnableCurrentLevelWeather = true;

		public override void Awake()
		{
			AudioReverbTrigger val = ((Component)this).gameObject.AddComponent<AudioReverbTrigger>();
			ReverbPreset val2 = ScriptableObject.CreateInstance<ReverbPreset>();
			val2.changeDryLevel = ChangeDryLevel;
			val2.dryLevel = DryLevel;
			val2.changeHighFreq = ChangeHighFreq;
			val2.highFreq = HighFreq;
			val2.changeLowFreq = ChangeLowFreq;
			val2.lowFreq = LowFreq;
			val2.changeDecayTime = ChangeDecayTime;
			val2.decayTime = DecayTime;
			val2.changeRoom = ChangeRoom;
			val2.room = Room;
			val.reverbPreset = val2;
			val.usePreset = -1;
			val.audioChanges = (switchToAudio[])(object)new switchToAudio[0];
			val.elevatorTriggerForProps = ElevatorTriggerForProps;
			val.setInElevatorTrigger = SetInElevatorTrigger;
			val.isShipRoom = IsShipRoom;
			val.toggleLocalFog = ToggleLocalFog;
			val.fogEnabledAmount = FogEnabledAmount;
			val.setInsideAtmosphere = SetInsideAtmosphere;
			val.insideLighting = InsideLighting;
			val.weatherEffect = WeatherEffect;
			val.effectEnabled = EffectEnabled;
			val.disableAllWeather = DisableAllWeather;
			val.enableCurrentLevelWeather = EnableCurrentLevelWeather;
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/DungeonGenerator")]
	public class SI_DungeonGenerator : ScriptImporter
	{
		public GameObject DungeonRoot;

		public override void Awake()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).tag != "DungeonGenerator")
			{
				((Component)this).tag = "DungeonGenerator";
			}
			RuntimeDungeon val = ((Component)this).gameObject.AddComponent<RuntimeDungeon>();
			val.Generator.DungeonFlow = RoundManager.Instance.dungeonFlowTypes[0];
			val.Generator.LengthMultiplier = 0.8f;
			val.Generator.PauseBetweenRooms = 0.2f;
			val.GenerateOnStart = false;
			if ((Object)(object)DungeonRoot != (Object)null)
			{
				_ = DungeonRoot.scene;
				if (false)
				{
					DungeonRoot = new GameObject();
					((Object)DungeonRoot).name = "DungeonRoot";
					DungeonRoot.transform.position = new Vector3(0f, -200f, 0f);
				}
			}
			val.Root = DungeonRoot;
			val.Generator.DungeonFlow = RoundManager.Instance.dungeonFlowTypes[0];
			UnityNavMeshAdapter val2 = ((Component)this).gameObject.AddComponent<UnityNavMeshAdapter>();
			val2.BakeMode = (RuntimeNavMeshBakeMode)3;
			val2.LayerMask = LayerMask.op_Implicit(35072);
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/EntranceTeleport")]
	public class SI_EntranceTeleport : ScriptImporter
	{
		public int EntranceID = 0;

		public Transform EntrancePoint;

		public int AudioReverbPreset = 2;

		public AudioClip[] DoorAudios = (AudioClip[])(object)new AudioClip[0];

		public override void Awake()
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>();
			val.outputAudioMixerGroup = AssetGatherDialog.audioMixers["Diagetic"].Item2.First((AudioMixerGroup g) => ((Object)g).name == "Master");
			val.playOnAwake = false;
			val.spatialBlend = 1f;
			EntranceTeleport entranceTeleport = ((Component)this).gameObject.AddComponent<EntranceTeleport>();
			entranceTeleport.isEntranceToBuilding = true;
			entranceTeleport.entrancePoint = EntrancePoint;
			entranceTeleport.entranceId = EntranceID;
			entranceTeleport.audioReverbPreset = AudioReverbPreset;
			entranceTeleport.entrancePointAudio = val;
			entranceTeleport.doorAudios = DoorAudios;
			InteractTrigger val2 = ((Component)this).gameObject.AddComponent<InteractTrigger>();
			val2.hoverIcon = (AssetGatherDialog.sprites.ContainsKey("HandIcon") ? AssetGatherDialog.sprites["HandIcon"] : AssetGatherDialog.sprites.First().Value);
			val2.hoverTip = "Enter : [LMB]";
			val2.disabledHoverTip = string.Empty;
			val2.holdTip = string.Empty;
			val2.animationString = string.Empty;
			val2.interactable = true;
			val2.oneHandedItemAllowed = true;
			val2.twoHandedItemAllowed = true;
			val2.holdInteraction = true;
			val2.timeToHold = 1.5f;
			val2.timeToHoldSpeedMultiplier = 1f;
			val2.holdingInteractEvent = new InteractEventFloat();
			val2.onInteract = new InteractEvent();
			val2.onInteractEarly = new InteractEvent();
			val2.onStopInteract = new InteractEvent();
			val2.onCancelAnimation = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)val2.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate
			{
				entranceTeleport.TeleportPlayer();
			});
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/DoorLock")]
	public class SI_DoorLock : ScriptImporter
	{
		public override void Awake()
		{
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/WaterSurface")]
	public class SI_WaterSurface : ScriptImporter
	{
		private GameObject obj;

		public int soundMaxDistance = 50;

		public override void Awake()
		{
			//IL_0022: 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_008e: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			obj = Object.Instantiate<GameObject>(SpawnPrefab.Instance.waterSurface);
			SceneManager.MoveGameObjectToScene(obj, ((Component)this).gameObject.scene);
			obj.transform.parent = ((Component)this).transform;
			obj.transform.localPosition = Vector3.zero;
			Transform val = obj.transform.Find("Water");
			((Component)val).GetComponent<MeshFilter>().sharedMesh = ((Component)this).GetComponent<MeshFilter>().sharedMesh;
			val.position = ((Component)this).transform.position;
			val.rotation = ((Component)this).transform.rotation;
			val.localScale = ((Component)this).transform.localScale;
			SI_SoundYDistance sI_SoundYDistance = ((Component)val).gameObject.AddComponent<SI_SoundYDistance>();
			sI_SoundYDistance.audioSource = ((Component)obj.transform.Find("WaterAudio")).GetComponent<AudioSource>();
			sI_SoundYDistance.maxDistance = soundMaxDistance;
			obj.SetActive(true);
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/Ladder")]
	public class SI_Ladder : ScriptImporter
	{
		public Transform BottomPosition;

		public Transform TopPosition;

		public Transform HorizontalPosition;

		public Transform PlayerNodePosition;

		public bool UseRaycastToGetTopPosition = false;

		public override void Awake()
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			InteractTrigger val = ((Component)this).gameObject.AddComponent<InteractTrigger>();
			val.hoverIcon = (AssetGatherDialog.sprites.ContainsKey("HandLadderIcon") ? AssetGatherDialog.sprites["HandLadderIcon"] : AssetGatherDialog.sprites.First().Value);
			val.hoverTip = "Climb : [LMB]";
			val.disabledHoverTip = string.Empty;
			val.holdTip = string.Empty;
			val.animationString = string.Empty;
			val.specialCharacterAnimation = true;
			val.animationWaitTime = 0.5f;
			val.animationString = "SA_PullLever";
			val.isLadder = true;
			val.lockPlayerPosition = true;
			val.playerPositionNode = BottomPosition;
			val.bottomOfLadderPosition = BottomPosition;
			val.bottomOfLadderPosition = BottomPosition;
			val.topOfLadderPosition = TopPosition;
			val.ladderHorizontalPosition = HorizontalPosition;
			val.ladderPlayerPositionNode = PlayerNodePosition;
			val.useRaycastToGetTopPosition = UseRaycastToGetTopPosition;
			val.holdingInteractEvent = new InteractEventFloat();
			val.onCancelAnimation = new InteractEvent();
			val.onInteract = new InteractEvent();
			val.onInteractEarly = new InteractEvent();
			val.onStopInteract = new InteractEvent();
			base.Awake();
		}
	}
	[AddComponentMenu("LethalSDK/ItemDropship")]
	public class SI_ItemDropship : ScriptImporter
	{
		public Animator ShipAnimator;

		public Transform[] ItemSpawnPositions;

		public GameObject OpenTriggerObject;

		public GameObject KillTriggerObject;

		public AudioClip ShipThrusterCloseSound;

		public AudioClip ShipLandSound;

		public AudioClip ShipOpenDoorsSound;

		public override void Awake()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			ItemDropship ItemDropship = ((Component)this).gameObject.AddComponent<ItemDropship>();
			ItemDropship.shipAnimator = ShipAnimator;
			ItemDropship.itemSpawnPositions = ItemSpawnPositions;
			PlayAudioAnimationEvent val = ((Component)this).gameObject.AddComponent<PlayAudioAnimationEvent>();
			val.audioToPlay = ((Component)this).GetComponent<AudioSource>();
			val.audioClip = ShipLandSound;
			val.audioClip2 = ShipOpenDoorsSound;
			InteractTrigger val2 = OpenTriggerObject.AddComponent<InteractTrigger>();
			val2.hoverIcon = (AssetGatherDialog.sprites.ContainsKey("HandIcon") ? AssetGatherDialog.sprites["HandIcon"] : AssetGatherDialog.sprites.First().Value);
			val2.hoverTip = "Open : [LMB]";
			val2.disabledHoverTip = string.Empt