Decompiled source of LunarConfig v0.1.9

plugins/LunarConfig/Crafty.LunarConfig.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeRebirthLib;
using CodeRebirthLib.ContentManagement.MapObjects;
using DunGen.Graph;
using HarmonyLib;
using LethalLevelLoader;
using LethalLib.Modules;
using LunarConfig.Objects.Config;
using LunarConfig.Patches;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WeatherRegistry;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Crafty.LunarConfig")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+da524653c4ea9a277c16fa2d29321946042af415")]
[assembly: AssemblyProduct("LunarConfig")]
[assembly: AssemblyTitle("Crafty.LunarConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LunarConfig
{
	[BepInPlugin("Crafty.LunarConfig", "LunarConfig", "1.0.0")]
	public class LunarConfig : BaseUnityPlugin
	{
		internal static readonly string EXPORT_DIRECTORY = Path.Combine(Paths.ConfigPath, "LunarConfig");

		internal static readonly string ITEM_FILE_NAME = "LunarConfigItems.cfg";

		internal static readonly string ITEM_FILE = Path.Combine(EXPORT_DIRECTORY, ITEM_FILE_NAME);

		internal static readonly string ENEMY_FILE_NAME = "LunarConfigEnemies.cfg";

		internal static readonly string ENEMY_FILE = Path.Combine(EXPORT_DIRECTORY, ENEMY_FILE_NAME);

		internal static readonly string MOON_FILE_NAME = "LunarConfigMoons.cfg";

		internal static readonly string MOON_FILE = Path.Combine(EXPORT_DIRECTORY, MOON_FILE_NAME);

		internal static readonly string MAP_OBJECT_FILE_NAME = "LunarConfigMapObjects.cfg";

		internal static readonly string MAP_OBJECT_FILE = Path.Combine(EXPORT_DIRECTORY, MAP_OBJECT_FILE_NAME);

		internal static readonly string OUTSIDE_MAP_OBJECT_FILE_NAME = "LunarConfigOutsideMapObjects.cfg";

		internal static readonly string OUTSIDE_MAP_OBJECT_FILE = Path.Combine(EXPORT_DIRECTORY, OUTSIDE_MAP_OBJECT_FILE_NAME);

		internal static readonly string DUNGEON_FILE_NAME = "LunarConfigDungeons.cfg";

		internal static readonly string DUNGEON_FILE = Path.Combine(EXPORT_DIRECTORY, DUNGEON_FILE_NAME);

		internal static readonly string CENTRAL_FILE_NAME = "LunarConfigCentral.cfg";

		internal static readonly string CENTRAL_FILE = Path.Combine(Paths.ConfigPath, CENTRAL_FILE_NAME);

		public static LunarConfig Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		public static LunarCentral central { get; set; } = new LunarCentral();


		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"Crafty.LunarConfig v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Crafty.LunarConfig");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(RoundManagerPatch));
			Harmony.PatchAll(typeof(StartOfRoundPatch));
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MiniLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("LunarConfig");

		public static void LogInfo(string message)
		{
			logger.LogDebug((object)message);
		}

		public static void LogWarning(string message)
		{
			logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			logger.LogError((object)message);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Crafty.LunarConfig";

		public const string PLUGIN_NAME = "LunarConfig";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LunarConfig.Patches
{
	internal class RoundManagerPatch
	{
		public static string lastLevel = "";

		public static bool shouldIncrement = false;

		public static Dictionary<string, List<string>> registeredOverrides = new Dictionary<string, List<string>>();

		public static Dictionary<string, SpawnableMapObject> configuredMapObjects = new Dictionary<string, SpawnableMapObject>();

		public static Dictionary<string, CRMapObjectDefinition> configuredCROutsideObjects = new Dictionary<string, CRMapObjectDefinition>();

		public static Dictionary<string, SpawnableOutsideObjectWithRarity> configuredOutsideObjects = new Dictionary<string, SpawnableOutsideObjectWithRarity>();

		public static bool runLate = false;

		public static void startMod()
		{
			//IL_1cc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cce: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cf1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d08: Unknown result type (might be due to invalid IL or missing references)
			LunarCentral central = LunarConfig.central;
			central.InitConfig();
			registeredOverrides["Item"] = new List<string>();
			registeredOverrides["Enemy"] = new List<string>();
			registeredOverrides["Moon"] = new List<string>();
			LunarConfigFile lunarConfigFile = central.files[LunarConfig.CENTRAL_FILE_NAME];
			LunarConfigEntry lunarConfigEntry = lunarConfigFile.entries["Configuration"];
			if (lunarConfigEntry.GetValue<bool>("Configure Items"))
			{
				LunarConfigFile lunarConfigFile2 = central.files[LunarConfig.ITEM_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = lunarConfigFile.entries["Enabled Item Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				List<string> list = new List<string>();
				foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
				{
					try
					{
						Item item = extendedItem.Item;
						LunarConfigEntry lunarConfigEntry3 = lunarConfigFile2.entries[central.UUIDify("LLL - " + item.itemName + " (" + ((ExtendedContent)extendedItem).UniqueIdentificationName + ")")];
						if (lunarConfigEntry3.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val = null;
							if ((Object)(object)item.spawnPrefab != (Object)null)
							{
								val = item.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry3.SetValue("Display Name", ref item.itemName, list.Contains("Display Name"));
							}
							if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Name"))
							{
								lunarConfigEntry3.SetValue("Scan Name", ref val.headerText);
							}
							if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Subtext"))
							{
								lunarConfigEntry3.SetValue("Scan Subtext", ref val.subText);
							}
							if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Min Range"))
							{
								lunarConfigEntry3.SetValue("Scan Min Range", ref val.minRange);
							}
							if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Max Range"))
							{
								lunarConfigEntry3.SetValue("Scan Max Range", ref val.maxRange);
							}
							if (hashSet.Contains("Minimum Value"))
							{
								lunarConfigEntry3.SetValue("Minimum Value", ref item.minValue, list.Contains("Minimum Value"));
							}
							if (hashSet.Contains("Maximum Value"))
							{
								lunarConfigEntry3.SetValue("Maximum Value", ref item.maxValue, list.Contains("Maximum Value"));
							}
							if (hashSet.Contains("Credits Worth"))
							{
								lunarConfigEntry3.SetValue("Credits Worth", ref item.creditsWorth, list.Contains("Credits Worth"));
							}
							if (hashSet.Contains("Weight"))
							{
								lunarConfigEntry3.SetValue("Weight", ref item.weight, list.Contains("Weight"));
							}
							if (hashSet.Contains("Conductivity"))
							{
								lunarConfigEntry3.SetValue("Conductivity", ref item.isConductiveMetal, list.Contains("Conductivity"));
							}
							if (hashSet.Contains("Two-Handed"))
							{
								lunarConfigEntry3.SetValue("Two-Handed", ref item.twoHanded, list.Contains("Two-Handed"));
							}
							if (hashSet.Contains("Is Scrap?"))
							{
								lunarConfigEntry3.SetValue("Is Scrap?", ref item.isScrap, list.Contains("Is Scrap?"));
							}
						}
					}
					catch (Exception arg)
					{
						MiniLogger.LogError($"An error occured while setting item values, please report this!\n{arg}");
					}
				}
				foreach (ScrapItem scrapItem in Items.scrapItems)
				{
					try
					{
						Item item2 = scrapItem.item;
						LunarConfigEntry lunarConfigEntry4 = lunarConfigFile2.entries[central.UUIDify("LL - " + item2.itemName + " (" + scrapItem.modName + "." + ((Object)item2).name + ")")];
						if (lunarConfigEntry4.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val2 = null;
							if ((Object)(object)item2.spawnPrefab != (Object)null)
							{
								val2 = item2.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry4.SetValue("Display Name", ref item2.itemName, list.Contains("Display Name"));
							}
							if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Name"))
							{
								lunarConfigEntry4.SetValue("Scan Name", ref val2.headerText);
							}
							if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Subtext"))
							{
								lunarConfigEntry4.SetValue("Scan Subtext", ref val2.subText);
							}
							if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Min Range"))
							{
								lunarConfigEntry4.SetValue("Scan Min Range", ref val2.minRange);
							}
							if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Max Range"))
							{
								lunarConfigEntry4.SetValue("Scan Max Range", ref val2.maxRange);
							}
							if (hashSet.Contains("Minimum Value"))
							{
								lunarConfigEntry4.SetValue("Minimum Value", ref item2.minValue, list.Contains("Minimum Value"));
							}
							if (hashSet.Contains("Maximum Value"))
							{
								lunarConfigEntry4.SetValue("Maximum Value", ref item2.maxValue, list.Contains("Maximum Value"));
							}
							if (hashSet.Contains("Credits Worth"))
							{
								lunarConfigEntry4.SetValue("Credits Worth", ref item2.creditsWorth, list.Contains("Credits Worth"));
							}
							if (hashSet.Contains("Weight"))
							{
								lunarConfigEntry4.SetValue("Weight", ref item2.weight, list.Contains("Weight"));
							}
							if (hashSet.Contains("Conductivity"))
							{
								lunarConfigEntry4.SetValue("Conductivity", ref item2.isConductiveMetal, list.Contains("Conductivity"));
							}
							if (hashSet.Contains("Two-Handed"))
							{
								lunarConfigEntry4.SetValue("Two-Handed", ref item2.twoHanded, list.Contains("Two-Handed"));
							}
							if (hashSet.Contains("Is Scrap?"))
							{
								lunarConfigEntry4.SetValue("Is Scrap?", ref item2.isScrap, list.Contains("Is Scrap?"));
							}
						}
					}
					catch (Exception arg2)
					{
						MiniLogger.LogError($"An error occured while setting item values, please report this!\n{arg2}");
					}
				}
				foreach (ShopItem shopItem in Items.shopItems)
				{
					try
					{
						Item item3 = shopItem.item;
						LunarConfigEntry lunarConfigEntry5 = lunarConfigFile2.entries[central.UUIDify("LL - " + item3.itemName + " (" + shopItem.modName + "." + ((Object)item3).name + ")")];
						if (lunarConfigEntry5.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val3 = null;
							if ((Object)(object)item3.spawnPrefab != (Object)null)
							{
								val3 = item3.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry5.SetValue("Display Name", ref item3.itemName, list.Contains("Display Name"));
							}
							if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Name"))
							{
								lunarConfigEntry5.SetValue("Scan Name", ref val3.headerText);
							}
							if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Subtext"))
							{
								lunarConfigEntry5.SetValue("Scan Subtext", ref val3.subText);
							}
							if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Min Range"))
							{
								lunarConfigEntry5.SetValue("Scan Min Range", ref val3.minRange);
							}
							if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Max Range"))
							{
								lunarConfigEntry5.SetValue("Scan Max Range", ref val3.maxRange);
							}
							if (hashSet.Contains("Minimum Value"))
							{
								lunarConfigEntry5.SetValue("Minimum Value", ref item3.minValue, list.Contains("Minimum Value"));
							}
							if (hashSet.Contains("Maximum Value"))
							{
								lunarConfigEntry5.SetValue("Maximum Value", ref item3.maxValue, list.Contains("Maximum Value"));
							}
							if (hashSet.Contains("Credits Worth"))
							{
								lunarConfigEntry5.SetValue("Credits Worth", ref item3.creditsWorth, list.Contains("Credits Worth"));
							}
							if (hashSet.Contains("Weight"))
							{
								lunarConfigEntry5.SetValue("Weight", ref item3.weight, list.Contains("Weight"));
							}
							if (hashSet.Contains("Conductivity"))
							{
								lunarConfigEntry5.SetValue("Conductivity", ref item3.isConductiveMetal, list.Contains("Conductivity"));
							}
							if (hashSet.Contains("Two-Handed"))
							{
								lunarConfigEntry5.SetValue("Two-Handed", ref item3.twoHanded, list.Contains("Two-Handed"));
							}
							if (hashSet.Contains("Is Scrap?"))
							{
								lunarConfigEntry5.SetValue("Is Scrap?", ref item3.isScrap, list.Contains("Is Scrap?"));
							}
						}
					}
					catch (Exception arg3)
					{
						MiniLogger.LogError($"An error occured while setting item values, please report this!\n{arg3}");
					}
				}
				foreach (PlainItem plainItem in Items.plainItems)
				{
					try
					{
						Item item4 = plainItem.item;
						LunarConfigEntry lunarConfigEntry6 = lunarConfigFile2.entries[central.UUIDify("LL - " + item4.itemName + " (" + plainItem.modName + "." + ((Object)item4).name + ")")];
						if (lunarConfigEntry6.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val4 = null;
							if ((Object)(object)item4.spawnPrefab != (Object)null)
							{
								val4 = item4.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry6.SetValue("Display Name", ref item4.itemName, list.Contains("Display Name"));
							}
							if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Name"))
							{
								lunarConfigEntry6.SetValue("Scan Name", ref val4.headerText);
							}
							if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Subtext"))
							{
								lunarConfigEntry6.SetValue("Scan Subtext", ref val4.subText);
							}
							if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Min Range"))
							{
								lunarConfigEntry6.SetValue("Scan Min Range", ref val4.minRange);
							}
							if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Max Range"))
							{
								lunarConfigEntry6.SetValue("Scan Max Range", ref val4.maxRange);
							}
							if (hashSet.Contains("Minimum Value"))
							{
								lunarConfigEntry6.SetValue("Minimum Value", ref item4.minValue, list.Contains("Minimum Value"));
							}
							if (hashSet.Contains("Maximum Value"))
							{
								lunarConfigEntry6.SetValue("Maximum Value", ref item4.maxValue, list.Contains("Maximum Value"));
							}
							if (hashSet.Contains("Credits Worth"))
							{
								lunarConfigEntry6.SetValue("Credits Worth", ref item4.creditsWorth, list.Contains("Credits Worth"));
							}
							if (hashSet.Contains("Weight"))
							{
								lunarConfigEntry6.SetValue("Weight", ref item4.weight, list.Contains("Weight"));
							}
							if (hashSet.Contains("Conductivity"))
							{
								lunarConfigEntry6.SetValue("Conductivity", ref item4.isConductiveMetal, list.Contains("Conductivity"));
							}
							if (hashSet.Contains("Two-Handed"))
							{
								lunarConfigEntry6.SetValue("Two-Handed", ref item4.twoHanded, list.Contains("Two-Handed"));
							}
							if (hashSet.Contains("Is Scrap?"))
							{
								lunarConfigEntry6.SetValue("Is Scrap?", ref item4.isScrap, list.Contains("Is Scrap?"));
							}
						}
					}
					catch (Exception arg4)
					{
						MiniLogger.LogError($"An error occured while setting item values, please report this!\n{arg4}");
					}
				}
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Enemies"))
			{
				LunarConfigFile lunarConfigFile3 = central.files[LunarConfig.ENEMY_FILE_NAME];
				LunarConfigEntry lunarConfigEntry7 = lunarConfigFile.entries["Enabled Enemy Settings"];
				HashSet<string> hashSet2 = new HashSet<string>();
				foreach (string key2 in lunarConfigEntry7.fields.Keys)
				{
					if (lunarConfigEntry7.GetValue<bool>(key2))
					{
						hashSet2.Add(key2);
					}
				}
				List<string> list2 = new List<string>();
				foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes)
				{
					try
					{
						EnemyType enemyType = extendedEnemyType.EnemyType;
						LunarConfigEntry lunarConfigEntry8 = lunarConfigFile3.entries[central.UUIDify("LLL - " + enemyType.enemyName + " (" + ((ExtendedContent)extendedEnemyType).UniqueIdentificationName + ")")];
						if (lunarConfigEntry8.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val5 = null;
							if ((Object)(object)enemyType.enemyPrefab != (Object)null)
							{
								val5 = enemyType.enemyPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet2.Contains("Display Name"))
							{
								extendedEnemyType.EnemyDisplayName = lunarConfigEntry8.GetValue<string>("Display Name");
							}
							if ((Object)(object)val5 != (Object)null && hashSet2.Contains("Scan Name"))
							{
								lunarConfigEntry8.SetValue("Scan Name", ref val5.headerText);
							}
							if ((Object)(object)val5 != (Object)null && hashSet2.Contains("Scan Subtext"))
							{
								lunarConfigEntry8.SetValue("Scan Subtext", ref val5.subText);
							}
							if ((Object)(object)val5 != (Object)null && hashSet2.Contains("Scan Min Range"))
							{
								lunarConfigEntry8.SetValue("Scan Min Range", ref val5.minRange);
							}
							if ((Object)(object)val5 != (Object)null && hashSet2.Contains("Scan Max Range"))
							{
								lunarConfigEntry8.SetValue("Scan Max Range", ref val5.maxRange);
							}
							if (hashSet2.Contains("Can See Through Fog?"))
							{
								lunarConfigEntry8.SetValue("Can See Through Fog?", ref enemyType.canSeeThroughFog, list2.Contains("Can See Through Fog?"));
							}
							if (hashSet2.Contains("Door Speed Multiplier"))
							{
								lunarConfigEntry8.SetValue("Door Speed Multiplier", ref enemyType.doorSpeedMultiplier, list2.Contains("Door Speed Multiplier"));
							}
							if (hashSet2.Contains("Is Daytime Enemy?"))
							{
								lunarConfigEntry8.SetValue("Is Daytime Enemy?", ref enemyType.isDaytimeEnemy, list2.Contains("Is Daytime Enemy?"));
							}
							if (hashSet2.Contains("Is Outdoor Enemy?"))
							{
								lunarConfigEntry8.SetValue("Is Outdoor Enemy?", ref enemyType.isOutsideEnemy, list2.Contains("Is Outdoor Enemy?"));
							}
							if (hashSet2.Contains("Loudness Multiplier"))
							{
								lunarConfigEntry8.SetValue("Loudness Multiplier", ref enemyType.loudnessMultiplier, list2.Contains("Loudness Multiplier"));
							}
							if (hashSet2.Contains("Max Count"))
							{
								lunarConfigEntry8.SetValue("Max Count", ref enemyType.MaxCount, list2.Contains("Max Count"));
							}
							if (hashSet2.Contains("Power Level"))
							{
								lunarConfigEntry8.SetValue("Power Level", ref enemyType.PowerLevel, list2.Contains("Power Level"));
							}
							if (hashSet2.Contains("Probability Curve"))
							{
								lunarConfigEntry8.SetCurve("Probability Curve", ref enemyType.probabilityCurve, list2.Contains("Probability Curve"));
							}
							if (hashSet2.Contains("Use Falloff?"))
							{
								lunarConfigEntry8.SetValue("Use Falloff?", ref enemyType.useNumberSpawnedFalloff, list2.Contains("Use Falloff?"));
							}
							if (hashSet2.Contains("Falloff Curve"))
							{
								lunarConfigEntry8.SetCurve("Falloff Curve", ref enemyType.numberSpawnedFalloff, list2.Contains("Falloff Curve"));
							}
							if (hashSet2.Contains("Group Spawn Count"))
							{
								lunarConfigEntry8.SetValue("Group Spawn Count", ref enemyType.spawnInGroupsOf, list2.Contains("Group Spawn Count"));
							}
							if (hashSet2.Contains("Normalized Time To Leave"))
							{
								lunarConfigEntry8.SetValue("Normalized Time To Leave", ref enemyType.normalizedTimeInDayToLeave, list2.Contains("Normalized Time To Leave"));
							}
							if (lunarConfigEntry8.fields.Keys.Contains("Enemy HP") && hashSet2.Contains("Enemy HP"))
							{
								lunarConfigEntry8.SetValue("Enemy HP", ref enemyType.enemyPrefab.GetComponent<EnemyAI>().enemyHP, list2.Contains("Enemy HP"));
							}
							if (hashSet2.Contains("Can Die?"))
							{
								lunarConfigEntry8.SetValue("Can Die?", ref enemyType.canDie, list2.Contains("Can Die?"));
							}
							if (hashSet2.Contains("Destroy On Death?"))
							{
								lunarConfigEntry8.SetValue("Destroy On Death?", ref enemyType.destroyOnDeath, list2.Contains("Destroy On Death?"));
							}
							if (hashSet2.Contains("Can Destroy?"))
							{
								lunarConfigEntry8.SetValue("Can Destroy?", ref enemyType.canBeDestroyed, list2.Contains("Can Destroy?"));
							}
							if (hashSet2.Contains("Can Stun?"))
							{
								lunarConfigEntry8.SetValue("Can Stun?", ref enemyType.canBeStunned, list2.Contains("Can Stun?"));
							}
							if (hashSet2.Contains("Stun Difficulty"))
							{
								lunarConfigEntry8.SetValue("Stun Difficulty", ref enemyType.stunGameDifficultyMultiplier, list2.Contains("Stun Difficulty"));
							}
							if (hashSet2.Contains("Stun Time"))
							{
								lunarConfigEntry8.SetValue("Stun Time", ref enemyType.stunTimeMultiplier, list2.Contains("Stun Time"));
							}
						}
					}
					catch (Exception arg5)
					{
						MiniLogger.LogError($"An error occured while setting enemy values, please report this!\n{arg5}");
					}
				}
				foreach (SpawnableEnemy spawnableEnemy in Enemies.spawnableEnemies)
				{
					try
					{
						EnemyType enemy = spawnableEnemy.enemy;
						LunarConfigEntry lunarConfigEntry9 = lunarConfigFile3.entries[central.UUIDify("LL - " + enemy.enemyName + " (" + spawnableEnemy.modName + "." + ((Object)enemy).name + ")")];
						if (lunarConfigEntry9.GetValue<bool>("Configure Content"))
						{
							ScanNodeProperties val6 = null;
							if ((Object)(object)enemy.enemyPrefab != (Object)null)
							{
								val6 = enemy.enemyPrefab.GetComponentInChildren<ScanNodeProperties>();
							}
							if (hashSet2.Contains("Display Name"))
							{
								enemy.enemyName = lunarConfigEntry9.GetValue<string>("Display Name");
							}
							if ((Object)(object)val6 != (Object)null && hashSet2.Contains("Scan Name"))
							{
								lunarConfigEntry9.SetValue("Scan Name", ref val6.headerText);
							}
							if ((Object)(object)val6 != (Object)null && hashSet2.Contains("Scan Subtext"))
							{
								lunarConfigEntry9.SetValue("Scan Subtext", ref val6.subText);
							}
							if ((Object)(object)val6 != (Object)null && hashSet2.Contains("Scan Min Range"))
							{
								lunarConfigEntry9.SetValue("Scan Min Range", ref val6.minRange);
							}
							if ((Object)(object)val6 != (Object)null && hashSet2.Contains("Scan Max Range"))
							{
								lunarConfigEntry9.SetValue("Scan Max Range", ref val6.maxRange);
							}
							if (hashSet2.Contains("Can See Through Fog?"))
							{
								lunarConfigEntry9.SetValue("Can See Through Fog?", ref enemy.canSeeThroughFog, list2.Contains("Can See Through Fog?"));
							}
							if (hashSet2.Contains("Door Speed Multiplier"))
							{
								lunarConfigEntry9.SetValue("Door Speed Multiplier", ref enemy.doorSpeedMultiplier, list2.Contains("Door Speed Multiplier"));
							}
							if (hashSet2.Contains("Is Daytime Enemy?"))
							{
								lunarConfigEntry9.SetValue("Is Daytime Enemy?", ref enemy.isDaytimeEnemy, list2.Contains("Is Daytime Enemy?"));
							}
							if (hashSet2.Contains("Is Outdoor Enemy?"))
							{
								lunarConfigEntry9.SetValue("Is Outdoor Enemy?", ref enemy.isOutsideEnemy, list2.Contains("Is Outdoor Enemy?"));
							}
							if (hashSet2.Contains("Loudness Multiplier"))
							{
								lunarConfigEntry9.SetValue("Loudness Multiplier", ref enemy.loudnessMultiplier, list2.Contains("Loudness Multiplier"));
							}
							if (hashSet2.Contains("Max Count"))
							{
								lunarConfigEntry9.SetValue("Max Count", ref enemy.MaxCount, list2.Contains("Max Count"));
							}
							if (hashSet2.Contains("Power Level"))
							{
								lunarConfigEntry9.SetValue("Power Level", ref enemy.PowerLevel, list2.Contains("Power Level"));
							}
							if (hashSet2.Contains("Probability Curve"))
							{
								lunarConfigEntry9.SetCurve("Probability Curve", ref enemy.probabilityCurve, list2.Contains("Probability Curve"));
							}
							if (hashSet2.Contains("Use Falloff?"))
							{
								lunarConfigEntry9.SetValue("Use Falloff?", ref enemy.useNumberSpawnedFalloff, list2.Contains("Use Falloff?"));
							}
							if (hashSet2.Contains("Falloff Curve"))
							{
								lunarConfigEntry9.SetCurve("Falloff Curve", ref enemy.numberSpawnedFalloff, list2.Contains("Falloff Curve"));
							}
							if (hashSet2.Contains("Group Spawn Count"))
							{
								lunarConfigEntry9.SetValue("Group Spawn Count", ref enemy.spawnInGroupsOf, list2.Contains("Group Spawn Count"));
							}
							if (hashSet2.Contains("Normalized Time To Leave"))
							{
								lunarConfigEntry9.SetValue("Normalized Time To Leave", ref enemy.normalizedTimeInDayToLeave, list2.Contains("Normalized Time To Leave"));
							}
							if (lunarConfigEntry9.fields.Keys.Contains("Enemy HP") && hashSet2.Contains("Enemy HP"))
							{
								lunarConfigEntry9.SetValue("Enemy HP", ref enemy.enemyPrefab.GetComponent<EnemyAI>().enemyHP, list2.Contains("Enemy HP"));
							}
							if (hashSet2.Contains("Can Die?"))
							{
								lunarConfigEntry9.SetValue("Can Die?", ref enemy.canDie, list2.Contains("Can Die?"));
							}
							if (hashSet2.Contains("Destroy On Death?"))
							{
								lunarConfigEntry9.SetValue("Destroy On Death?", ref enemy.destroyOnDeath, list2.Contains("Destroy On Death?"));
							}
							if (hashSet2.Contains("Can Destroy?"))
							{
								lunarConfigEntry9.SetValue("Can Destroy?", ref enemy.canBeDestroyed, list2.Contains("Can Destroy?"));
							}
							if (hashSet2.Contains("Can Stun?"))
							{
								lunarConfigEntry9.SetValue("Can Stun?", ref enemy.canBeStunned, list2.Contains("Can Stun?"));
							}
							if (hashSet2.Contains("Stun Difficulty"))
							{
								lunarConfigEntry9.SetValue("Stun Difficulty", ref enemy.stunGameDifficultyMultiplier, list2.Contains("Stun Difficulty"));
							}
							if (hashSet2.Contains("Stun Time"))
							{
								lunarConfigEntry9.SetValue("Stun Time", ref enemy.stunTimeMultiplier, list2.Contains("Stun Time"));
							}
						}
					}
					catch (Exception arg6)
					{
						MiniLogger.LogError($"An error occured while setting enemy values, please report this!\n{arg6}");
					}
				}
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Dungeons"))
			{
				LunarConfigFile lunarConfigFile4 = central.files[LunarConfig.DUNGEON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry10 = lunarConfigFile.entries["Enabled Dungeon Settings"];
				HashSet<string> hashSet3 = new HashSet<string>();
				foreach (string key3 in lunarConfigEntry10.fields.Keys)
				{
					if (lunarConfigEntry10.GetValue<bool>(key3))
					{
						hashSet3.Add(key3);
					}
				}
				foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows)
				{
					try
					{
						LunarConfigEntry lunarConfigEntry11 = lunarConfigFile4.entries[central.UUIDify("LLL - " + extendedDungeonFlow.DungeonName + " (" + ((ExtendedContent)extendedDungeonFlow).UniqueIdentificationName + ")")];
						if (lunarConfigEntry11.GetValue<bool>("Configure Content"))
						{
							if (hashSet3.Contains("Enable Dynamic Restriction"))
							{
								extendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled = lunarConfigEntry11.GetValue<bool>("Enable Dynamic Restriction");
							}
							if (hashSet3.Contains("Dynamic Dungeon Size Lerp Rate"))
							{
								extendedDungeonFlow.DynamicDungeonSizeLerpRate = lunarConfigEntry11.GetValue<float>("Dungeon Size Lerp Rate");
							}
							if (hashSet3.Contains("Dynamic Dungeon Size Min"))
							{
								extendedDungeonFlow.DynamicDungeonSizeMinMax = new Vector2((float)lunarConfigEntry11.GetValue<int>("Dungeon Size Min"), extendedDungeonFlow.DynamicDungeonSizeMinMax.y);
							}
							if (hashSet3.Contains("Dynamic Dungeon Size Max"))
							{
								extendedDungeonFlow.DynamicDungeonSizeMinMax = new Vector2(extendedDungeonFlow.DynamicDungeonSizeMinMax.x, (float)lunarConfigEntry11.GetValue<int>("Dungeon Size Max"));
							}
							if (hashSet3.Contains("Random Size Min"))
							{
								lunarConfigEntry11.SetValue("Dungeon Size Min", ref extendedDungeonFlow.DungeonFlow.Length.Min);
							}
							if (hashSet3.Contains("Random Size Max"))
							{
								lunarConfigEntry11.SetValue("Dungeon Size Max", ref extendedDungeonFlow.DungeonFlow.Length.Max);
							}
							if (hashSet3.Contains("Map Tile Size"))
							{
								extendedDungeonFlow.MapTileSize = lunarConfigEntry11.GetValue<float>("Map Tile Size");
							}
						}
					}
					catch (Exception arg7)
					{
						MiniLogger.LogError($"An error occured while setting dungeon values, please report this!\n{arg7}");
					}
				}
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Map Objects"))
			{
				LunarConfigFile lunarConfigFile5 = central.files[LunarConfig.MAP_OBJECT_FILE_NAME];
				LunarConfigEntry lunarConfigEntry12 = lunarConfigFile.entries["Enabled Map Object Settings"];
				HashSet<string> hashSet4 = new HashSet<string>();
				foreach (string key4 in lunarConfigEntry12.fields.Keys)
				{
					if (lunarConfigEntry12.GetValue<bool>(key4))
					{
						hashSet4.Add(key4);
					}
				}
				HashSet<string> hashSet5 = new HashSet<string>();
				foreach (RegisteredMapObject mapObject2 in MapObjects.mapObjects)
				{
					try
					{
						if (mapObject2.mapObject == null)
						{
							continue;
						}
						SpawnableMapObject mapObject = mapObject2.mapObject;
						LunarConfigEntry lunarConfigEntry13 = lunarConfigFile5.entries[central.UUIDify("LL - " + ((Object)mapObject.prefabToSpawn).name)];
						if (lunarConfigEntry13.GetValue<bool>("Configure Content"))
						{
							if (hashSet4.Contains("Face Away From Wall?"))
							{
								lunarConfigEntry13.SetValue("Face Away From Wall?", ref mapObject.spawnFacingAwayFromWall);
							}
							if (hashSet4.Contains("Face Towards Wall?"))
							{
								lunarConfigEntry13.SetValue("Face Towards Wall?", ref mapObject.spawnFacingWall);
							}
							if (hashSet4.Contains("Disallow Near Entrance?"))
							{
								lunarConfigEntry13.SetValue("Disallow Near Entrance?", ref mapObject.disallowSpawningNearEntrances);
							}
							if (hashSet4.Contains("Require Distance Between Spawns?"))
							{
								lunarConfigEntry13.SetValue("Require Distance Between Spawns?", ref mapObject.requireDistanceBetweenSpawns);
							}
							if (hashSet4.Contains("Flush Against Wall?"))
							{
								lunarConfigEntry13.SetValue("Flush Against Wall?", ref mapObject.spawnWithBackFlushAgainstWall);
							}
							if (hashSet4.Contains("Spawn Against Wall?"))
							{
								lunarConfigEntry13.SetValue("Spawn Against Wall?", ref mapObject.spawnWithBackToWall);
							}
							configuredMapObjects[central.UUIDify("LL - " + ((Object)mapObject.prefabToSpawn).name)] = mapObject;
						}
						hashSet5.Add(((Object)mapObject.prefabToSpawn).name);
					}
					catch (Exception arg8)
					{
						MiniLogger.LogError($"An error occured while setting map object values, please report this!\n{arg8}");
					}
				}
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					SpawnableMapObject[] spawnableMapObjects = extendedLevel.SelectableLevel.spawnableMapObjects;
					foreach (SpawnableMapObject val7 in spawnableMapObjects)
					{
						if (hashSet5.Contains(((Object)val7.prefabToSpawn).name))
						{
							continue;
						}
						try
						{
							LunarConfigEntry lunarConfigEntry14 = lunarConfigFile5.entries[central.UUIDify("Vanilla - " + ((Object)val7.prefabToSpawn).name)];
							if (lunarConfigEntry14.GetValue<bool>("Configure Content"))
							{
								if (hashSet4.Contains("Face Away From Wall?"))
								{
									lunarConfigEntry14.SetValue("Face Away From Wall?", ref val7.spawnFacingAwayFromWall);
								}
								if (hashSet4.Contains("Face Towards Wall?"))
								{
									lunarConfigEntry14.SetValue("Face Towards Wall?", ref val7.spawnFacingWall);
								}
								if (hashSet4.Contains("Disallow Near Entrance?"))
								{
									lunarConfigEntry14.SetValue("Disallow Near Entrance?", ref val7.disallowSpawningNearEntrances);
								}
								if (hashSet4.Contains("Require Distance Between Spawns?"))
								{
									lunarConfigEntry14.SetValue("Require Distance Between Spawns?", ref val7.requireDistanceBetweenSpawns);
								}
								if (hashSet4.Contains("Flush Against Wall?"))
								{
									lunarConfigEntry14.SetValue("Flush Against Wall?", ref val7.spawnWithBackFlushAgainstWall);
								}
								if (hashSet4.Contains("Spawn Against Wall?"))
								{
									lunarConfigEntry14.SetValue("Spawn Against Wall?", ref val7.spawnWithBackToWall);
								}
								configuredMapObjects[central.UUIDify("Vanilla - " + ((Object)val7.prefabToSpawn).name)] = val7;
							}
							hashSet5.Add(((Object)val7.prefabToSpawn).name);
						}
						catch (Exception arg9)
						{
							MiniLogger.LogError($"An error occured while setting map object values, please report this!\n{arg9}");
						}
					}
				}
			}
			if (!lunarConfigEntry.GetValue<bool>("Configure Outside Map Objects"))
			{
				return;
			}
			LunarConfigFile lunarConfigFile6 = central.files[LunarConfig.OUTSIDE_MAP_OBJECT_FILE_NAME];
			HashSet<string> hashSet6 = new HashSet<string>();
			foreach (CRMapObjectDefinition item5 in CRMod.AllMapObjects())
			{
				try
				{
					if (item5.OutsideSpawnMechanics != null)
					{
						LunarConfigEntry lunarConfigEntry15 = lunarConfigFile6.entries[central.UUIDify("CRLib - " + ((Object)item5.GameObject).name)];
						if (lunarConfigEntry15.GetValue<bool>("Configure Content"))
						{
							configuredCROutsideObjects[central.UUIDify("CRLib - " + ((Object)item5.GameObject).name)] = item5;
						}
						hashSet6.Add(((Object)item5.GameObject).name);
					}
				}
				catch (Exception arg10)
				{
					MiniLogger.LogError($"An error occured while setting outside object values, please report this!\n{arg10}");
				}
			}
			foreach (ExtendedLevel extendedLevel2 in PatchedContent.ExtendedLevels)
			{
				SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = extendedLevel2.SelectableLevel.spawnableOutsideObjects;
				foreach (SpawnableOutsideObjectWithRarity val8 in spawnableOutsideObjects)
				{
					if (hashSet6.Contains(((Object)val8.spawnableObject).name))
					{
						continue;
					}
					try
					{
						LunarConfigEntry lunarConfigEntry16 = lunarConfigFile6.entries[central.UUIDify("Vanilla - " + ((Object)val8.spawnableObject).name)];
						if (lunarConfigEntry16.GetValue<bool>("Configure Content"))
						{
							configuredOutsideObjects[central.UUIDify("Vanilla - " + ((Object)val8.spawnableObject).name)] = val8;
						}
						hashSet6.Add(((Object)val8.spawnableObject).name);
					}
					catch (Exception arg11)
					{
						MiniLogger.LogError($"An error occured while setting outside object values, please report this!\n{arg11}");
					}
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Awake")]
		[HarmonyPriority(400)]
		[HarmonyPostfix]
		private static void onAwakePostfix(RoundManager __instance)
		{
			try
			{
				LunarCentral central = LunarConfig.central;
				central.InitCentral();
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.CENTRAL_FILE_NAME];
				LunarConfigEntry lunarConfigEntry = lunarConfigFile.entries["Configuration"];
				if (!lunarConfigEntry.GetValue<bool>("Run Late (CentralConfig Port)"))
				{
					startMod();
				}
				else
				{
					runLate = true;
				}
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured while initializing LunarConfig, please report this! {arg}");
			}
		}

		[HarmonyPatch(typeof(HangarShipDoor), "Start")]
		[HarmonyPriority(200)]
		[HarmonyPostfix]
		private static void onStartPostfix(RoundManager __instance)
		{
			try
			{
				if (runLate)
				{
					startMod();
				}
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured, please report this!\n{arg}");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyPriority(800)]
		[HarmonyPrefix]
		private static void onGenerateNewLevelPrefix(RoundManager __instance)
		{
			try
			{
				LunarCentral central = LunarConfig.central;
				LunarConfigEntry lunarConfigEntry = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
				if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					return;
				}
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.MOON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Moon Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				List<string> list = new List<string>();
				ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
				SelectableLevel selectableLevel = currentExtendedLevel.SelectableLevel;
				LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.entries[central.UUIDify("LLL - " + currentExtendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)currentExtendedLevel).UniqueIdentificationName + ")")];
				if (!lunarConfigEntry3.GetValue<bool>("Configure Content"))
				{
					return;
				}
				if (hashSet.Contains("Tags"))
				{
					((ExtendedContent)currentExtendedLevel).ContentTags.Clear();
					string[] array = lunarConfigEntry3.GetValue<string>("Tags").Split(',');
					foreach (string uuid in array)
					{
						string text = Extensions.RemoveWhitespace(central.UUIDify(uuid));
						((ExtendedContent)currentExtendedLevel).ContentTags.Add(ContentTag.Create(text));
					}
				}
				LunarCentral.RefreshMatchers();
				if (hashSet.Contains("Interior Multiplier"))
				{
					lunarConfigEntry3.SetValue("Interior Multiplier", ref selectableLevel.factorySizeMultiplier, list.Contains("Interior Multiplier"));
				}
				if (hashSet.Contains("Possible Interiors"))
				{
					lunarConfigEntry3.SetDungeons("Possible Interiors", central, currentExtendedLevel, list.Contains("Possible Interiors"));
				}
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured while setting interior values, please report this!\n{arg}");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void onGenerateNewFloorPostfix(RoundManager __instance)
		{
			//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a86: Invalid comparison between Unknown and I4
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LunarCentral central = LunarConfig.central;
				LunarConfigEntry lunarConfigEntry = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
				HashSet<string> hashSet = new HashSet<string>();
				LunarConfigEntry lunarConfigEntry2;
				if (lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					LunarConfigFile lunarConfigFile = central.files[LunarConfig.MOON_FILE_NAME];
					lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Moon Settings"];
					hashSet = new HashSet<string>();
					foreach (string key in lunarConfigEntry2.fields.Keys)
					{
						if (lunarConfigEntry2.GetValue<bool>(key))
						{
							hashSet.Add(key);
						}
					}
					List<string> list = new List<string>();
					try
					{
						ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
						SelectableLevel selectableLevel = currentExtendedLevel.SelectableLevel;
						LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.entries[central.UUIDify("LLL - " + currentExtendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)currentExtendedLevel).UniqueIdentificationName + ")")];
						if (lunarConfigEntry3.GetValue<bool>("Configure Content"))
						{
							if (hashSet.Contains("Tags"))
							{
								((ExtendedContent)currentExtendedLevel).ContentTags.Clear();
								string[] array = lunarConfigEntry3.GetValue<string>("Tags").Split(',');
								foreach (string uuid in array)
								{
									string text = Extensions.RemoveWhitespace(central.UUIDify(uuid));
									((ExtendedContent)currentExtendedLevel).ContentTags.Add(ContentTag.Create(text));
								}
							}
							LunarCentral.RefreshMatchers();
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry3.SetValue("Display Name", ref selectableLevel.PlanetName);
							}
							if (hashSet.Contains("Risk Level"))
							{
								lunarConfigEntry3.SetValue("Risk Level", ref selectableLevel.riskLevel);
							}
							if (hashSet.Contains("Description"))
							{
								selectableLevel.LevelDescription = lunarConfigEntry3.GetValue<string>("Description").Replace(";", "\n");
							}
							if (hashSet.Contains("Has Time?"))
							{
								lunarConfigEntry3.SetValue("Has Time?", ref selectableLevel.planetHasTime, list.Contains("Has Time?"));
							}
							if (hashSet.Contains("Time Multiplier"))
							{
								lunarConfigEntry3.SetValue("Time Multiplier", ref selectableLevel.DaySpeedMultiplier, list.Contains("Time Multiplier"));
							}
							if (hashSet.Contains("Daytime Probability Range"))
							{
								lunarConfigEntry3.SetValue("Daytime Probability Range", ref selectableLevel.daytimeEnemiesProbabilityRange, list.Contains("Daytime Probability Range"));
							}
							if (hashSet.Contains("Daytime Curve"))
							{
								lunarConfigEntry3.SetCurve("Daytime Curve", ref selectableLevel.daytimeEnemySpawnChanceThroughDay, list.Contains("Daytime Curve"));
							}
							if (hashSet.Contains("Max Daytime Power"))
							{
								lunarConfigEntry3.SetValue("Max Daytime Power", ref selectableLevel.maxDaytimeEnemyPowerCount, list.Contains("Max Daytime Power"));
							}
							if (hashSet.Contains("Spawnable Daytime Enemies"))
							{
								lunarConfigEntry3.SetEnemies("Spawnable Daytime Enemies", central, ref selectableLevel.DaytimeEnemies, list.Contains("Spawnable Daytime Enemies"));
							}
							if (hashSet.Contains("Interior Probability Range"))
							{
								lunarConfigEntry3.SetValue("Interior Probability Range", ref selectableLevel.spawnProbabilityRange, list.Contains("Interior Probability Range"));
							}
							if (hashSet.Contains("Interior Curve"))
							{
								lunarConfigEntry3.SetCurve("Interior Curve", ref selectableLevel.enemySpawnChanceThroughoutDay, list.Contains("Interior Curve"));
							}
							if (hashSet.Contains("Max Interior Power"))
							{
								lunarConfigEntry3.SetValue("Max Interior Power", ref selectableLevel.maxEnemyPowerCount, list.Contains("Max Interior Power"));
							}
							if (hashSet.Contains("Spawnable Interior Enemies"))
							{
								lunarConfigEntry3.SetEnemies("Spawnable Interior Enemies", central, ref selectableLevel.Enemies, list.Contains("Spawnable Interior Enemies"));
							}
							if (hashSet.Contains("Outside Curve"))
							{
								lunarConfigEntry3.SetCurve("Outside Curve", ref selectableLevel.outsideEnemySpawnChanceThroughDay, list.Contains("Outside Curve"));
							}
							if (hashSet.Contains("Max Outside Power"))
							{
								lunarConfigEntry3.SetValue("Max Outside Power", ref selectableLevel.maxOutsideEnemyPowerCount, list.Contains("Max Outside Power"));
							}
							if (hashSet.Contains("Spawnable Outside Enemies"))
							{
								lunarConfigEntry3.SetEnemies("Spawnable Outside Enemies", central, ref selectableLevel.OutsideEnemies, list.Contains("Spawnable Outside Enemies"));
							}
							if (hashSet.Contains("Min Scrap"))
							{
								lunarConfigEntry3.SetValue("Min Scrap", ref selectableLevel.minScrap, list.Contains("Min Scrap"));
							}
							if (hashSet.Contains("Max Scrap"))
							{
								lunarConfigEntry3.SetValue("Max Scrap", ref selectableLevel.maxScrap, list.Contains("Max Scrap"));
							}
							if (hashSet.Contains("Spawnable Scrap"))
							{
								lunarConfigEntry3.SetItems("Spawnable Scrap", central, ref selectableLevel.spawnableScrap, list.Contains("Spawnable Scrap"));
							}
						}
					}
					catch (Exception arg)
					{
						MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg}");
					}
				}
				LunarCentral.RefreshMatchers();
				ExtendedLevel currentExtendedLevel2 = LevelManager.CurrentExtendedLevel;
				hashSet.Clear();
				if (lunarConfigEntry.GetValue<bool>("Configure Map Objects"))
				{
					LunarConfigFile lunarConfigFile2 = central.files[LunarConfig.MAP_OBJECT_FILE_NAME];
					lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Map Object Settings"];
					hashSet = new HashSet<string>();
					foreach (string key2 in lunarConfigEntry2.fields.Keys)
					{
						if (lunarConfigEntry2.GetValue<bool>(key2))
						{
							hashSet.Add(key2);
						}
					}
					if (hashSet.Contains("Level Curve - " + central.UUIDify(currentExtendedLevel2.NumberlessPlanetName)) && configuredMapObjects.Count > 0 && (Object)(object)currentExtendedLevel2 != (Object)null)
					{
						foreach (KeyValuePair<string, SpawnableMapObject> mapObject2 in configuredMapObjects)
						{
							List<SpawnableMapObject> list2 = currentExtendedLevel2.SelectableLevel.spawnableMapObjects.ToList();
							list2.RemoveAll((SpawnableMapObject obj) => ((Object)obj.prefabToSpawn).name == ((Object)mapObject2.Value.prefabToSpawn).name);
							SpawnableMapObject value = mapObject2.Value;
							LunarConfigEntry lunarConfigEntry4 = lunarConfigFile2.entries[mapObject2.Key];
							string value2 = lunarConfigEntry4.GetValue<string>("Level Curve - " + central.UUIDify(currentExtendedLevel2.NumberlessPlanetName));
							if (value2.Trim() != "")
							{
								value.numberToSpawn = LunarCentral.StringToCurve(value2);
							}
							else
							{
								value.numberToSpawn = LunarCentral.StringToCurve(lunarConfigEntry4.GetValue<string>("Base Curve"));
							}
							list2.Add(value);
							currentExtendedLevel2.SelectableLevel.spawnableMapObjects = list2.ToArray();
						}
					}
				}
				hashSet.Clear();
				if (!lunarConfigEntry.GetValue<bool>("Configure Outside Map Objects"))
				{
					return;
				}
				LunarConfigFile lunarConfigFile3 = central.files[LunarConfig.OUTSIDE_MAP_OBJECT_FILE_NAME];
				lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Outside Map Object Settings"];
				foreach (string key3 in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key3))
					{
						hashSet.Add(key3);
					}
				}
				if (!hashSet.Contains("Level Curve - " + central.UUIDify(currentExtendedLevel2.NumberlessPlanetName)))
				{
					return;
				}
				if (configuredOutsideObjects.Count > 0 && (Object)(object)currentExtendedLevel2 != (Object)null)
				{
					foreach (KeyValuePair<string, SpawnableOutsideObjectWithRarity> mapObject in configuredOutsideObjects)
					{
						List<SpawnableOutsideObjectWithRarity> list3 = currentExtendedLevel2.SelectableLevel.spawnableOutsideObjects.ToList();
						list3.RemoveAll((SpawnableOutsideObjectWithRarity obj) => ((Object)obj.spawnableObject).name == ((Object)mapObject.Value.spawnableObject).name);
						SpawnableOutsideObjectWithRarity value3 = mapObject.Value;
						LunarConfigEntry lunarConfigEntry5 = lunarConfigFile3.entries[mapObject.Key];
						string value4 = lunarConfigEntry5.GetValue<string>("Level Curve - " + central.UUIDify(currentExtendedLevel2.NumberlessPlanetName));
						if (value4.Trim() != "")
						{
							value3.randomAmount = LunarCentral.StringToCurve(value4);
						}
						else
						{
							value3.randomAmount = LunarCentral.StringToCurve(lunarConfigEntry5.GetValue<string>("Base Curve"));
						}
						list3.Add(value3);
						currentExtendedLevel2.SelectableLevel.spawnableOutsideObjects = list3.ToArray();
					}
				}
				if (configuredCROutsideObjects.Count <= 0 || !((Object)(object)currentExtendedLevel2 != (Object)null))
				{
					return;
				}
				foreach (KeyValuePair<string, CRMapObjectDefinition> configuredCROutsideObject in configuredCROutsideObjects)
				{
					MiniLogger.LogInfo("Configuring " + configuredCROutsideObject.Key);
					Enum.TryParse<LevelTypes>(((Object)currentExtendedLevel2.SelectableLevel).name, ignoreCase: true, out LevelTypes result);
					LunarConfigEntry lunarConfigEntry6 = lunarConfigFile3.entries[configuredCROutsideObject.Key];
					string value5 = lunarConfigEntry6.GetValue<string>("Level Curve - " + central.UUIDify(currentExtendedLevel2.NumberlessPlanetName));
					if (value5.Trim() == "")
					{
						value5 = lunarConfigEntry6.GetValue<string>("Base Curve");
					}
					AnimationCurve val = LunarCentral.StringToCurve(value5);
					if ((int)result == 1024)
					{
						AnimationCurve val2 = configuredCROutsideObject.Value.OutsideSpawnMechanics.CurveFunction(currentExtendedLevel2.SelectableLevel);
						if (val2 != val)
						{
							configuredCROutsideObject.Value.OutsideSpawnMechanics.CurvesByCustomLevelType[((Object)currentExtendedLevel2).name] = val;
						}
					}
					else
					{
						AnimationCurve val3 = configuredCROutsideObject.Value.OutsideSpawnMechanics.CurveFunction(currentExtendedLevel2.SelectableLevel);
						if (val3 != val)
						{
							configuredCROutsideObject.Value.OutsideSpawnMechanics.CurvesByLevelType[result] = val;
						}
					}
				}
			}
			catch (Exception arg2)
			{
				MiniLogger.LogError($"An issue occured when modifying spawn pools, please report this!\n{arg2}");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPriority(400)]
		[HarmonyBefore(new string[] { "mrov.WeatherRegistry" })]
		[HarmonyPrefix]
		private static void resetScrapMultipliers(RoundManager __instance)
		{
			try
			{
				__instance.scrapAmountMultiplier = 1f;
				__instance.scrapValueMultiplier = 0.4f;
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg}");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "mrov.WeatherRegistry" })]
		[HarmonyPrefix]
		private static void onScrapSpawnPrefix(RoundManager __instance)
		{
			LunarCentral central = LunarConfig.central;
			LunarConfigEntry lunarConfigEntry = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
			LunarConfigEntry lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Moon Settings"];
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string key in lunarConfigEntry2.fields.Keys)
			{
				if (lunarConfigEntry2.GetValue<bool>(key))
				{
					hashSet.Add(key);
				}
			}
			if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
			{
				return;
			}
			LunarConfigFile lunarConfigFile = central.files[LunarConfig.MOON_FILE_NAME];
			List<string> list = new List<string>();
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				try
				{
					if (!extendedLevel.IsCurrentLevel)
					{
						continue;
					}
					SelectableLevel selectableLevel = extendedLevel.SelectableLevel;
					LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.entries[central.UUIDify("LLL - " + extendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)extendedLevel).UniqueIdentificationName + ")")];
					if (lunarConfigEntry3.GetValue<bool>("Configure Content"))
					{
						if (hashSet.Contains("Amount Multiplier"))
						{
							__instance.scrapAmountMultiplier *= lunarConfigEntry3.GetValue<float>("Amount Multiplier");
						}
						if (hashSet.Contains("Value Multiplier"))
						{
							__instance.scrapValueMultiplier *= lunarConfigEntry3.GetValue<float>("Value Multiplier");
						}
					}
					break;
				}
				catch (Exception arg)
				{
					MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg}");
				}
			}
		}
	}
	internal class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void terminalPostfix()
		{
			try
			{
				MiniLogger.LogInfo("Load Patch");
				LunarCentral central = LunarConfig.central;
				if (!central.files.Keys.Contains(LunarConfig.CENTRAL_FILE_NAME) || !central.files.Keys.Contains(LunarConfig.MOON_FILE_NAME))
				{
					return;
				}
				LunarConfigEntry lunarConfigEntry = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
				LunarCentral.RefreshMatchers();
				if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					return;
				}
				MiniLogger.LogInfo("Changing Moons");
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.MOON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Moon Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				List<string> list = new List<string>();
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					try
					{
						LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.entries[central.UUIDify("LLL - " + extendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)extendedLevel).UniqueIdentificationName + ")")];
						SelectableLevel selectableLevel = extendedLevel.SelectableLevel;
						if (lunarConfigEntry3.GetValue<bool>("Configure Content"))
						{
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry3.SetValue("Display Name", ref selectableLevel.PlanetName);
							}
							if (hashSet.Contains("Risk Level"))
							{
								lunarConfigEntry3.SetValue("Risk Level", ref selectableLevel.riskLevel);
							}
							if (hashSet.Contains("Description"))
							{
								selectableLevel.LevelDescription = lunarConfigEntry3.GetValue<string>("Description").Replace(";", "\n");
							}
							if (hashSet.Contains("Route Price"))
							{
								extendedLevel.RoutePrice = lunarConfigEntry3.GetValue<int>("Route Price");
							}
							if (hashSet.Contains("Is Hidden?"))
							{
								extendedLevel.IsRouteHidden = lunarConfigEntry3.GetValue<bool>("Is Hidden?");
							}
							if (hashSet.Contains("Is Locked?"))
							{
								extendedLevel.IsRouteLocked = lunarConfigEntry3.GetValue<bool>("Is Locked?");
							}
						}
					}
					catch (Exception arg)
					{
						MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg}");
					}
				}
			}
			catch (Exception arg2)
			{
				MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg2}");
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ChangeLevel")]
		[HarmonyPriority(400)]
		[HarmonyPostfix]
		private static void onLoadLevel()
		{
			try
			{
				MiniLogger.LogInfo("Load Patch");
				LunarCentral central = LunarConfig.central;
				if (!central.files.Keys.Contains(LunarConfig.CENTRAL_FILE_NAME) || !central.files.Keys.Contains(LunarConfig.MOON_FILE_NAME))
				{
					return;
				}
				LunarConfigEntry lunarConfigEntry = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
				LunarCentral.RefreshMatchers();
				if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					return;
				}
				MiniLogger.LogInfo("Changing Moons");
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.MOON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = central.files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Moon Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				List<string> list = new List<string>();
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					try
					{
						LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.entries[central.UUIDify("LLL - " + extendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)extendedLevel).UniqueIdentificationName + ")")];
						SelectableLevel selectableLevel = extendedLevel.SelectableLevel;
						if (lunarConfigEntry3.GetValue<bool>("Configure Content"))
						{
							if (hashSet.Contains("Display Name"))
							{
								lunarConfigEntry3.SetValue("Display Name", ref selectableLevel.PlanetName);
							}
							if (hashSet.Contains("Risk Level"))
							{
								lunarConfigEntry3.SetValue("Risk Level", ref selectableLevel.riskLevel);
							}
							if (hashSet.Contains("Description"))
							{
								selectableLevel.LevelDescription = lunarConfigEntry3.GetValue<string>("Description").Replace(";", "\n");
							}
							if (hashSet.Contains("Route Price"))
							{
								extendedLevel.RoutePrice = lunarConfigEntry3.GetValue<int>("Route Price");
							}
							if (hashSet.Contains("Is Hidden?"))
							{
								extendedLevel.IsRouteHidden = lunarConfigEntry3.GetValue<bool>("Is Hidden?");
							}
							if (hashSet.Contains("Is Locked?"))
							{
								extendedLevel.IsRouteLocked = lunarConfigEntry3.GetValue<bool>("Is Locked?");
							}
						}
					}
					catch (Exception arg)
					{
						MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg}");
					}
				}
			}
			catch (Exception arg2)
			{
				MiniLogger.LogError($"An error occured while setting moon values, please report this!\n{arg2}");
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SetTimeAndPlanetToSavedSettings")]
		[HarmonyPriority(-2000)]
		[HarmonyPrefix]
		private static void challengePrefix()
		{
			try
			{
				StartOfRound instance = StartOfRound.Instance;
				LunarCentral central = LunarConfig.central;
				if (!central.files.Keys.Contains(LunarConfig.CENTRAL_FILE_NAME) || !central.files.Keys.Contains(LunarConfig.MOON_FILE_NAME))
				{
					return;
				}
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.CENTRAL_FILE_NAME];
				LunarConfigEntry lunarConfigEntry = lunarConfigFile.entries["Configuration"];
				if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					return;
				}
				LunarConfigFile lunarConfigFile2 = central.files[LunarConfig.MOON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = lunarConfigFile.entries["Enabled Moon Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					SelectableLevel selectableLevel = extendedLevel.SelectableLevel;
					LunarConfigEntry lunarConfigEntry3 = lunarConfigFile2.entries[central.UUIDify("LLL - " + extendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)extendedLevel).UniqueIdentificationName + ")")];
					if (lunarConfigEntry3.GetValue<bool>("Configure Content") && hashSet.Contains("Can Be Challenge Moon?"))
					{
						lunarConfigEntry3.SetValue("Can Be Challenge Moon?", ref selectableLevel.planetHasTime);
					}
				}
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured while setting challenge moons, please report this!{arg}");
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SetTimeAndPlanetToSavedSettings")]
		[HarmonyPriority(-2000)]
		[HarmonyPostfix]
		private static void challengePostfix()
		{
			try
			{
				StartOfRound instance = StartOfRound.Instance;
				LunarCentral central = LunarConfig.central;
				if (!central.files.Keys.Contains(LunarConfig.CENTRAL_FILE_NAME) || !central.files.Keys.Contains(LunarConfig.MOON_FILE_NAME))
				{
					return;
				}
				LunarConfigFile lunarConfigFile = central.files[LunarConfig.CENTRAL_FILE_NAME];
				LunarConfigEntry lunarConfigEntry = lunarConfigFile.entries["Configuration"];
				if (!lunarConfigEntry.GetValue<bool>("Configure Moons"))
				{
					return;
				}
				LunarConfigFile lunarConfigFile2 = central.files[LunarConfig.MOON_FILE_NAME];
				LunarConfigEntry lunarConfigEntry2 = lunarConfigFile.entries["Enabled Moon Settings"];
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string key in lunarConfigEntry2.fields.Keys)
				{
					if (lunarConfigEntry2.GetValue<bool>(key))
					{
						hashSet.Add(key);
					}
				}
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					SelectableLevel selectableLevel = extendedLevel.SelectableLevel;
					LunarConfigEntry lunarConfigEntry3 = lunarConfigFile2.entries[central.UUIDify("LLL - " + extendedLevel.NumberlessPlanetName + " (" + ((ExtendedContent)extendedLevel).UniqueIdentificationName + ")")];
					if (lunarConfigEntry3.GetValue<bool>("Configure Content") && hashSet.Contains("Has Time?"))
					{
						lunarConfigEntry3.SetValue("Has Time?", ref selectableLevel.planetHasTime);
					}
				}
			}
			catch (Exception arg)
			{
				MiniLogger.LogError($"An error occured while setting challenge moons, please report this!{arg}");
			}
		}
	}
}
namespace LunarConfig.Objects.Config
{
	public class LunarCentral
	{
		public Dictionary<string, LunarConfigFile> files = new Dictionary<string, LunarConfigFile>();

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

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

		public Dictionary<string, ExtendedDungeonFlow> dungeons = new Dictionary<string, ExtendedDungeonFlow>();

		public HashSet<string> foundTags = new HashSet<string>();

		public bool useLLLTags = false;

		public static bool clearOrphans = false;

		public static HashSet<string> currentStrings = new HashSet<string>();

		public static HashSet<string> currentTags = new HashSet<string>();

		public string UUIDify(string uuid)
		{
			return uuid.Replace("=", "").Replace("\n", "").Replace("\t", "")
				.Replace("\\", "")
				.Replace("\"", "")
				.Replace("'", "")
				.Replace("[", "")
				.Replace("]", "");
		}

		public string CurveToString(AnimationCurve curve)
		{
			return string.Join(" ; ", curve.keys.Select((Keyframe kf) => $"{((Keyframe)(ref kf)).time},{((Keyframe)(ref kf)).value}"));
		}

		public static void ClearOrphanedEntries(ConfigFile cfg)
		{
			if (clearOrphans)
			{
				PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
				dictionary.Clear();
			}
		}

		public static AnimationCurve StringToCurve(string data)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			AnimationCurve val = new AnimationCurve();
			if (string.IsNullOrWhiteSpace(data))
			{
				return val;
			}
			string[] array = data.Split(';');
			foreach (string text in array)
			{
				string[] array2 = text.Split(',');
				if (array2.Length == 2)
				{
					string s = array2[0].Trim();
					string s2 = array2[1].Trim();
					if (float.TryParse(s, out var result) && float.TryParse(s2, out var result2))
					{
						val.AddKey(result, result2);
					}
				}
			}
			return val;
		}

		public static void RefreshMatchers()
		{
			currentStrings.Clear();
			currentTags.Clear();
			ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
			if ((Object)(object)currentExtendedLevel != (Object)null)
			{
				foreach (ContentTag contentTag in ((ExtendedContent)currentExtendedLevel).ContentTags)
				{
					currentTags.Add(ConfigHelper.SanitizeString(contentTag.contentTagName));
				}
				currentStrings.Add(ConfigHelper.SanitizeString(currentExtendedLevel.NumberlessPlanetName));
			}
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			if ((Object)(object)currentExtendedDungeonFlow != (Object)null)
			{
				currentStrings.Add(ConfigHelper.SanitizeString(currentExtendedDungeonFlow.DungeonName));
				currentStrings.Add(ConfigHelper.SanitizeString(((Object)currentExtendedDungeonFlow.DungeonFlow).name));
			}
			Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
			if ((Object)(object)currentLevelWeather != (Object)null)
			{
				currentStrings.Add(ConfigHelper.SanitizeString(currentLevelWeather.Name));
			}
			foreach (string currentString in currentStrings)
			{
				MiniLogger.LogInfo("MATCHER : " + currentString);
			}
			foreach (string currentTag in currentTags)
			{
				MiniLogger.LogInfo("TAG : " + currentTag);
			}
		}

		public void InitConfig()
		{
			InitCollections();
			FixDungeons();
			LunarConfigEntry lunarConfigEntry = files[LunarConfig.CENTRAL_FILE_NAME].entries["Configuration"];
			if (lunarConfigEntry.GetValue<bool>("Configure Items"))
			{
				InitItems();
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Enemies"))
			{
				InitEnemies();
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Moons"))
			{
				InitMoons();
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Dungeons"))
			{
				InitDungeons();
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Map Objects"))
			{
				InitMapObjects();
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Outside Map Objects"))
			{
				InitOutsideMapObjects();
			}
		}

		public void InitCollections()
		{
			CollectItems();
			CollectEnemies();
			CollectDungeons();
			foreach (string key in dungeons.Keys)
			{
				MiniLogger.LogInfo("DUNGEON: " + key);
			}
		}

		public void CollectItems()
		{
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				Item item = extendedItem.Item;
				items[ConfigHelper.SanitizeString(item.itemName)] = item;
				items[ConfigHelper.SanitizeString(((Object)item).name)] = item;
			}
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				Item item2 = scrapItem.item;
				items[ConfigHelper.SanitizeString(item2.itemName)] = item2;
				items[ConfigHelper.SanitizeString(((Object)item2).name)] = item2;
			}
			foreach (ShopItem shopItem in Items.shopItems)
			{
				Item item3 = shopItem.item;
				items[ConfigHelper.SanitizeString(item3.itemName)] = item3;
				items[ConfigHelper.SanitizeString(((Object)item3).name)] = item3;
			}
			foreach (PlainItem plainItem in Items.plainItems)
			{
				Item item4 = plainItem.item;
				items[ConfigHelper.SanitizeString(item4.itemName)] = item4;
				items[ConfigHelper.SanitizeString(((Object)item4).name)] = item4;
			}
		}

		public void CollectEnemies()
		{
			foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes)
			{
				EnemyType enemyType = extendedEnemyType.EnemyType;
				enemies[ConfigHelper.SanitizeString(enemyType.enemyName)] = enemyType;
				if ((Object)(object)enemyType.enemyPrefab != (Object)null)
				{
					ScanNodeProperties componentInChildren = enemyType.enemyPrefab.GetComponentInChildren<ScanNodeProperties>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						enemies[ConfigHelper.SanitizeString(Extensions.RemoveWhitespace(componentInChildren.headerText.ToLower()))] = enemyType;
					}
				}
			}
			foreach (SpawnableEnemy spawnableEnemy in Enemies.spawnableEnemies)
			{
				EnemyType enemy = spawnableEnemy.enemy;
				enemies[ConfigHelper.SanitizeString(enemy.enemyName)] = enemy;
				if ((Object)(object)enemy.enemyPrefab != (Object)null)
				{
					ScanNodeProperties componentInChildren2 = enemy.enemyPrefab.GetComponentInChildren<ScanNodeProperties>();
					if ((Object)(object)componentInChildren2 != (Object)null)
					{
						enemies[ConfigHelper.SanitizeString(Extensions.RemoveWhitespace(componentInChildren2.headerText.ToLower()))] = enemy;
					}
				}
			}
		}

		public void CollectDungeons()
		{
			foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows)
			{
				if (extendedDungeonFlow.DungeonName != "Facility" || ((Object)extendedDungeonFlow.DungeonFlow).name == "Level1Flow")
				{
					dungeons[ConfigHelper.SanitizeString(extendedDungeonFlow.DungeonName)] = extendedDungeonFlow;
				}
				dungeons[ConfigHelper.SanitizeString(((Object)extendedDungeonFlow.DungeonFlow).name)] = extendedDungeonFlow;
			}
		}

		public void InitCentral()
		{
			LunarConfigFile lunarConfigFile = AddFile(LunarConfig.CENTRAL_FILE, LunarConfig.CENTRAL_FILE_NAME);
			lunarConfigFile.file.SaveOnConfigSet = false;
			LunarConfigEntry lunarConfigEntry = lunarConfigFile.AddEntry("Configuration");
			lunarConfigEntry.AddField("Configure Items", "Check this to generate and use configuration files for items.", defaultValue: true);
			lunarConfigEntry.AddField("Configure Enemies", "Check this to generate and use configuration files for enemies.", defaultValue: true);
			lunarConfigEntry.AddField("Configure Moons", "Check this to generate and use configuration files for moons.", defaultValue: true);
			lunarConfigEntry.AddField("Configure Dungeons", "Check this to generate and use configuration files for dungeons.", defaultValue: true);
			lunarConfigEntry.AddField("Configure Map Objects", "Check this to generate and use configuration files for map objects.", defaultValue: true);
			lunarConfigEntry.AddField("Configure Outside Map Objects", "Check this to generate and use configuration files for outside map objects.", defaultValue: true);
			lunarConfigEntry.AddField("Run Late (CentralConfig Port)", "IMPORTANT: This setting will make LunarConfig initialize later than usual, breaking some of it's functionality.\nThis should only be used if you are trying to port settings from a mod like CentralConfig, and should be turned off after the first use.\nLunar Config isn't perfect at porting, but it can get most things right, also remember to delete all Lunar Config files before trying this for the best result!", defaultValue: false);
			lunarConfigEntry.AddField("Clear Orphaned Entries", "WARNING: Enabling this will delete any config entries that get disabled when the configuration is refreshed!", defaultValue: false);
			clearOrphans = lunarConfigEntry.GetValue<bool>("Clear Orphaned Entries");
			if (lunarConfigEntry.GetValue<bool>("Configure Items"))
			{
				LunarConfigEntry lunarConfigEntry2 = lunarConfigFile.AddEntry("Enabled Item Settings");
				lunarConfigEntry2.AddField("Display Name", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Scan Name", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Scan Subtext", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Scan Min Range", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Scan Max Range", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Minimum Value", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Maximum Value", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Credits Worth", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Weight", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Conductivity", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Two-Handed", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry2.AddField("Is Scrap?", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Enemies"))
			{
				LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.AddEntry("Enabled Enemy Settings");
				lunarConfigEntry3.AddField("Display Name", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Scan Name", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Scan Subtext", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Scan Min Range", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Scan Max Range", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Can See Through Fog?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Door Speed Multiplier", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Is Daytime Enemy?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Is Outdoor Enemy?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Loudness Multiplier", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Max Count", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Power Level", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Probability Curve", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Use Falloff?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Falloff Curve", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Group Spawn Count", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Normalized Time To Leave", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Enemy HP", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Can Die?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Destroy On Death?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Can Destroy?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Can Stun?", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Stun Difficulty", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
				lunarConfigEntry3.AddField("Stun Time", "Disable this to disable configuring this property in enemy config entries.", defaultValue: true);
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Moons"))
			{
				LunarConfigEntry lunarConfigEntry4 = lunarConfigFile.AddEntry("Enabled Moon Settings");
				lunarConfigEntry4.AddField("Display Name", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Risk Level", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Description", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Route Price", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Is Hidden?", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Is Locked?", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Can Be Challenge Moon?", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Has Time?", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Time Multiplier", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Daytime Probability Range", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Daytime Curve", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Max Daytime Power", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Spawnable Daytime Enemies", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Interior Probability Range", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Interior Curve", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Max Interior Power", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Spawnable Interior Enemies", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Outside Curve", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Max Outside Power", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Spawnable Outside Enemies", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Min Scrap", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Max Scrap", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Value Multiplier", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Amount Multiplier", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Spawnable Scrap", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Interior Multiplier", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Possible Interiors", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
				lunarConfigEntry4.AddField("Tags", "Disable this to disable configuring this property in moon config entries.", defaultValue: true);
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Dungeons"))
			{
				LunarConfigEntry lunarConfigEntry5 = lunarConfigFile.AddEntry("Enabled Dungeon Settings");
				lunarConfigEntry5.AddField("Enable Dynamic Restriction", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Dynamic Dungeon Size Lerp Rate", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Dynamic Dungeon Size Min", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Dynamic Dungeon Size Max", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Random Size Min", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Random Size Max", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
				lunarConfigEntry5.AddField("Map Tile Size", "Disable this to disable configuring this property in item config entries.", defaultValue: true);
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Map Objects"))
			{
				LunarConfigEntry lunarConfigEntry6 = lunarConfigFile.AddEntry("Enabled Map Object Settings");
				lunarConfigEntry6.AddField("Face Away From Wall?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				lunarConfigEntry6.AddField("Face Towards Wall?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				lunarConfigEntry6.AddField("Disallow Near Entrance?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				lunarConfigEntry6.AddField("Require Distance Between Spawns?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				lunarConfigEntry6.AddField("Flush Against Wall?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				lunarConfigEntry6.AddField("Spawn Against Wall?", "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
				{
					lunarConfigEntry6.AddField("Level Curve - " + UUIDify(extendedLevel.NumberlessPlanetName), "Disable this to disable configuring this property in map object config entries.", defaultValue: true);
				}
			}
			if (lunarConfigEntry.GetValue<bool>("Configure Outside Map Objects"))
			{
				LunarConfigEntry lunarConfigEntry7 = lunarConfigFile.AddEntry("Enabled Outside Map Object Settings");
				foreach (ExtendedLevel extendedLevel2 in PatchedContent.ExtendedLevels)
				{
					lunarConfigEntry7.AddField("Level Curve - " + UUIDify(extendedLevel2.NumberlessPlanetName), "Disable this to disable configuring this property in outside map object config entries.", defaultValue: true);
				}
			}
			ClearOrphanedEntries(lunarConfigFile.file);
			lunarConfigFile.file.Save();
			lunarConfigFile.file.SaveOnConfigSet = true;
		}

		public void InitItems()
		{
			MiniLogger.LogInfo("Initializing Item Configuration...");
			LunarConfigFile lunarConfigFile = AddFile(LunarConfig.ITEM_FILE, LunarConfig.ITEM_FILE_NAME);
			lunarConfigFile.file.SaveOnConfigSet = false;
			LunarConfigEntry lunarConfigEntry = files[LunarConfig.CENTRAL_FILE_NAME].entries["Enabled Item Settings"];
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string key in lunarConfigEntry.fields.Keys)
			{
				if (lunarConfigEntry.GetValue<bool>(key))
				{
					hashSet.Add(key);
				}
			}
			HashSet<string> hashSet2 = new HashSet<string>();
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				string text = UUIDify("LLL - " + extendedItem.Item.itemName + " (" + ((ExtendedContent)extendedItem).UniqueIdentificationName + ")");
				if (!hashSet2.Contains(text))
				{
					Item item = extendedItem.Item;
					ScanNodeProperties val = null;
					if ((Object)(object)item.spawnPrefab != (Object)null)
					{
						val = item.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
					}
					LunarConfigEntry lunarConfigEntry2 = lunarConfigFile.AddEntry(text);
					MiniLogger.LogInfo("Recording " + ((Object)extendedItem).name + "...");
					lunarConfigEntry2.AddField("Configure Content", "Enable to change any of the settings below.", defaultValue: false);
					lunarConfigEntry2.AddField("Appropriate Aliases", "Changing this setting will do nothing, these are the names which LunarConfig will recognize as this object in other config options.\nThey are case-insensitve and do not regard whitespace.", ConfigHelper.SanitizeString(extendedItem.Item.itemName) + ", " + ConfigHelper.SanitizeString(((Object)extendedItem.Item).name));
					if (hashSet.Contains("Display Name"))
					{
						lunarConfigEntry2.AddField("Display Name", "Specifies the name that appears when scanning the item.", item.itemName);
					}
					if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Name"))
					{
						lunarConfigEntry2.AddField("Scan Name", "Specifies the name of the item that appears on its scan node.", val.headerText);
					}
					if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Subtext"))
					{
						lunarConfigEntry2.AddField("Scan Subtext", "Specifies the subtext that appears on the item's scan node. NOTE: This setting may be overridden if the item has a scrap value.", val.subText);
					}
					if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Min Range"))
					{
						lunarConfigEntry2.AddField("Scan Min Range", "Specifies the minimum distance the scan node can be scanned.", val.minRange);
					}
					if ((Object)(object)val != (Object)null && hashSet.Contains("Scan Max Range"))
					{
						lunarConfigEntry2.AddField("Scan Max Range", "Specifies the maximum distance the scan node can be scanned.", val.maxRange);
					}
					if (hashSet.Contains("Minimum Value"))
					{
						lunarConfigEntry2.AddField("Minimum Value", "The minimum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item.minValue);
					}
					if (hashSet.Contains("Maximum Value"))
					{
						lunarConfigEntry2.AddField("Maximum Value", "The maximum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item.maxValue);
					}
					if (hashSet.Contains("Credits Worth"))
					{
						lunarConfigEntry2.AddField("Credits Worth", "The value of an item if it is sold in the shop.", item.creditsWorth);
					}
					if (hashSet.Contains("Weight"))
					{
						lunarConfigEntry2.AddField("Weight", "Specifies the weight of an item.\nCalculated with: (x - 1) * 105 = weight in pounds.", item.weight);
					}
					if (hashSet.Contains("Conductivity"))
					{
						lunarConfigEntry2.AddField("Conductivity", "Specifies whether an item is conductive.", item.isConductiveMetal);
					}
					if (hashSet.Contains("Two-Handed"))
					{
						lunarConfigEntry2.AddField("Two-Handed", "Specifies whether an item is two-handed.", item.twoHanded);
					}
					if (hashSet.Contains("Is Scrap?"))
					{
						lunarConfigEntry2.AddField("Is Scrap?", "Specifies if an item is scrap or gear.\nThis decides whether an item can be sold to the company for credits.", item.isScrap);
					}
					MiniLogger.LogInfo("Recorded " + ((Object)extendedItem).name);
					hashSet2.Add(text);
				}
			}
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				string text2 = UUIDify("LL - " + scrapItem.item.itemName + " (" + scrapItem.modName + "." + ((Object)scrapItem.item).name + ")");
				if (!hashSet2.Contains(text2))
				{
					Item item2 = scrapItem.item;
					ScanNodeProperties val2 = null;
					if ((Object)(object)item2.spawnPrefab != (Object)null)
					{
						val2 = item2.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
					}
					LunarConfigEntry lunarConfigEntry3 = lunarConfigFile.AddEntry(text2);
					MiniLogger.LogInfo("Recording " + ((Object)item2).name + "...");
					lunarConfigEntry3.AddField("Configure Content", "Enable to change any of the settings below.", defaultValue: false);
					lunarConfigEntry3.AddField("Appropriate Aliases", "Changing this setting will do nothing, these are the names which LunarConfig will recognize as this object in other config options.\nThey are case-insensitve and do not regard whitespace.", ConfigHelper.SanitizeString(scrapItem.item.itemName) + ", " + ConfigHelper.SanitizeString(((Object)scrapItem.item).name));
					if (hashSet.Contains("Display Name"))
					{
						lunarConfigEntry3.AddField("Display Name", "Specifies the name that appears when scanning the item.", item2.itemName);
					}
					if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Name"))
					{
						lunarConfigEntry3.AddField("Scan Name", "Specifies the name of the item that appears on its scan node.", val2.headerText);
					}
					if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Subtext"))
					{
						lunarConfigEntry3.AddField("Scan Subtext", "Specifies the subtext that appears on the item's scan node. NOTE: This setting may be overridden if the item has a scrap value.", val2.subText);
					}
					if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Min Range"))
					{
						lunarConfigEntry3.AddField("Scan Min Range", "Specifies the minimum distance the scan node can be scanned.", val2.minRange);
					}
					if ((Object)(object)val2 != (Object)null && hashSet.Contains("Scan Max Range"))
					{
						lunarConfigEntry3.AddField("Scan Max Range", "Specifies the maximum distance the scan node can be scanned.", val2.maxRange);
					}
					if (hashSet.Contains("Minimum Value"))
					{
						lunarConfigEntry3.AddField("Minimum Value", "The minimum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item2.minValue);
					}
					if (hashSet.Contains("Maximum Value"))
					{
						lunarConfigEntry3.AddField("Maximum Value", "The maximum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item2.maxValue);
					}
					if (hashSet.Contains("Credits Worth"))
					{
						lunarConfigEntry3.AddField("Credits Worth", "The value of an item if it is sold in the shop.", item2.creditsWorth);
					}
					if (hashSet.Contains("Weight"))
					{
						lunarConfigEntry3.AddField("Weight", "Specifies the weight of an item.\nCalculated with: (x - 1) * 105 = weight in pounds.", item2.weight);
					}
					if (hashSet.Contains("Conductivity"))
					{
						lunarConfigEntry3.AddField("Conductivity", "Specifies whether an item is conductive.", item2.isConductiveMetal);
					}
					if (hashSet.Contains("Two-Handed"))
					{
						lunarConfigEntry3.AddField("Two-Handed", "Specifies whether an item is two-handed.", item2.twoHanded);
					}
					if (hashSet.Contains("Is Scrap?"))
					{
						lunarConfigEntry3.AddField("Is Scrap?", "Specifies if an item is scrap or gear.\nThis decides whether an item can be sold to the company for credits.", item2.isScrap);
					}
					MiniLogger.LogInfo("Recorded " + ((Object)item2).name);
					hashSet2.Add(text2);
				}
			}
			foreach (ShopItem shopItem in Items.shopItems)
			{
				string text3 = UUIDify("LL - " + shopItem.item.itemName + " (" + shopItem.modName + "." + ((Object)shopItem.item).name + ")");
				if (!hashSet2.Contains(text3))
				{
					Item item3 = shopItem.item;
					ScanNodeProperties val3 = null;
					if ((Object)(object)item3.spawnPrefab != (Object)null)
					{
						val3 = item3.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
					}
					LunarConfigEntry lunarConfigEntry4 = lunarConfigFile.AddEntry(text3);
					MiniLogger.LogInfo("Recording " + ((Object)item3).name + "...");
					lunarConfigEntry4.AddField("Configure Content", "Enable to change any of the settings below.", defaultValue: false);
					lunarConfigEntry4.AddField("Appropriate Aliases", "Changing this setting will do nothing, these are the names which LunarConfig will recognize as this object in other config options.\nThey are case-insensitve and do not regard whitespace.", ConfigHelper.SanitizeString(shopItem.item.itemName) + ", " + ConfigHelper.SanitizeString(((Object)shopItem.item).name));
					if (hashSet.Contains("Display Name"))
					{
						lunarConfigEntry4.AddField("Display Name", "Specifies the name that appears when scanning the item.", item3.itemName);
					}
					if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Name"))
					{
						lunarConfigEntry4.AddField("Scan Name", "Specifies the name of the item that appears on its scan node.", val3.headerText);
					}
					if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Subtext"))
					{
						lunarConfigEntry4.AddField("Scan Subtext", "Specifies the subtext that appears on the item's scan node. NOTE: This setting may be overridden if the item has a scrap value.", val3.subText);
					}
					if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Min Range"))
					{
						lunarConfigEntry4.AddField("Scan Min Range", "Specifies the minimum distance the scan node can be scanned.", val3.minRange);
					}
					if ((Object)(object)val3 != (Object)null && hashSet.Contains("Scan Max Range"))
					{
						lunarConfigEntry4.AddField("Scan Max Range", "Specifies the maximum distance the scan node can be scanned.", val3.maxRange);
					}
					if (hashSet.Contains("Minimum Value"))
					{
						lunarConfigEntry4.AddField("Minimum Value", "The minimum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item3.minValue);
					}
					if (hashSet.Contains("Maximum Value"))
					{
						lunarConfigEntry4.AddField("Maximum Value", "The maximum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatus and items from enemies (Hives, Double-barrel).", item3.maxValue);
					}
					if (hashSet.Contains("Credits Worth"))
					{
						lunarConfigEntry4.AddField("Credits Worth", "The value of an item if it is sold in the shop.", item3.creditsWorth);
					}
					if (hashSet.Contains("Weight"))
					{
						lunarConfigEntry4.AddField("Weight", "Specifies the weight of an item.\nCalculated with: (x - 1) * 105 = weight in pounds.", item3.weight);
					}
					if (hashSet.Contains("Conductivity"))
					{
						lunarConfigEntry4.AddField("Conductivity", "Specifies whether an item is conductive.", item3.isConductiveMetal);
					}
					if (hashSet.Contains("Two-Handed"))
					{
						lunarConfigEntry4.AddField("Two-Handed", "Specifies whether an item is two-handed.", item3.twoHanded);
					}
					if (hashSet.Contains("Is Scrap?"))
					{
						lunarConfigEntry4.AddField("Is Scrap?", "Specifies if an item is scrap or gear.\nThis decides whether an item can be sold to the company for credits.", item3.isScrap);
					}
					MiniLogger.LogInfo("Recorded " + ((Object)item3).name);
					hashSet2.Add(text3);
				}
			}
			foreach (PlainItem plainItem in Items.plainItems)
			{
				string text4 = UUIDify("LL - " + plainItem.item.itemName + " (" + plainItem.modName + "." + ((Object)plainItem.item).name + ")");
				if (!hashSet2.Contains(text4))
				{
					Item item4 = plainItem.item;
					ScanNodeProperties val4 = null;
					if ((Object)(object)item4.spawnPrefab != (Object)null)
					{
						val4 = item4.spawnPrefab.GetComponentInChildren<ScanNodeProperties>();
					}
					LunarConfigEntry lunarConfigEntry5 = lunarConfigFile.AddEntry(text4);
					MiniLogger.LogInfo("Recording " + ((Object)item4).name + "...");
					lunarConfigEntry5.AddField("Configure Content", "Enable to change any of the settings below.", defaultValue: false);
					lunarConfigEntry5.AddField("Appropriate Aliases", "Changing this setting will do nothing, these are the names which LunarConfig will recognize as this object in other config options.\nThey are case-insensitve and do not regard whitespace.", ConfigHelper.SanitizeString(plainItem.item.itemName) + ", " + ConfigHelper.SanitizeString(((Object)plainItem.item).name));
					if (hashSet.Contains("Display Name"))
					{
						lunarConfigEntry5.AddField("Display Name", "Specifies the name that appears when scanning the item.", item4.itemName);
					}
					if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Name"))
					{
						lunarConfigEntry5.AddField("Scan Name", "Specifies the name of the item that appears on its scan node.", val4.headerText);
					}
					if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Subtext"))
					{
						lunarConfigEntry5.AddField("Scan Subtext", "Specifies the subtext that appears on the item's scan node. NOTE: This setting may be overridden if the item has a scrap value.", val4.subText);
					}
					if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Min Range"))
					{
						lunarConfigEntry5.AddField("Scan Min Range", "Specifies the minimum distance the scan node can be scanned.", val4.minRange);
					}
					if ((Object)(object)val4 != (Object)null && hashSet.Contains("Scan Max Range"))
					{
						lunarConfigEntry5.AddField("Scan Max Range", "Specifies the maximum distance the scan node can be scanned.", val4.maxRange);
					}
					if (hashSet.Contains("Minimum Value"))
					{
						lunarConfigEntry5.AddField("Minimum Value", "The minimum scrap value and item can have.\nTypically multiplied by 0.4, setting not applicable to non-scrap.\nDoes not work on items like Apparatu