Decompiled source of LLLEditor v0.2.0

LLLEditor.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LLLEditor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("LLLEditor")]
[assembly: AssemblyTitle("LLLEditor")]
[assembly: AssemblyVersion("0.2.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LLLEditor
{
	[Serializable]
	internal class Category
	{
		public string name = "";

		public int color;

		public int weight = 100;

		public List<string> moons = new List<string>();

		public List<string> interiors = new List<string>();

		public bool HasMoon(LevelData l)
		{
			return moons.Contains(l.Id);
		}

		public bool HasInterior(DungeonData d)
		{
			return interiors.Contains(d.Id);
		}

		public void SetMoon(LevelData l, bool on)
		{
			moons.Remove(l.Id);
			if (on)
			{
				moons.Add(l.Id);
			}
		}

		public void SetInterior(DungeonData d, bool on)
		{
			interiors.Remove(d.Id);
			if (on)
			{
				interiors.Add(d.Id);
			}
		}
	}
	[Serializable]
	internal class CategoryFile
	{
		public List<Category> categories = new List<Category>();
	}
	internal static class CategoryStore
	{
		public static readonly string FilePath = Path.Combine(Paths.ConfigPath, "LLLEditor.categories.json");

		public static readonly string[] Palette = new string[8] { "#ff8a3d", "#4fb3ff", "#7bd88f", "#e06cdb", "#ffd166", "#ef5b5b", "#5ee0d0", "#b39ddb" };

		private static CategoryFile data;

		public static List<Category> All
		{
			get
			{
				if (data == null)
				{
					Load();
				}
				return data.categories;
			}
		}

		public static string ColorOf(Category c)
		{
			return Palette[Mathf.Abs(c.color) % Palette.Length];
		}

		public static string Chip(Category c)
		{
			return "<color=" + ColorOf(c) + ">■</color> " + c.name;
		}

		private static void Load()
		{
			data = new CategoryFile();
			try
			{
				if (File.Exists(FilePath))
				{
					data = JsonUtility.FromJson<CategoryFile>(File.ReadAllText(FilePath)) ?? new CategoryFile();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Could not read " + FilePath + " (a copy was saved as .bak): " + ex.Message));
				try
				{
					File.Copy(FilePath, FilePath + ".bak", overwrite: true);
				}
				catch
				{
				}
				data = new CategoryFile();
			}
		}

		public static void Save()
		{
			try
			{
				File.WriteAllText(FilePath, JsonUtility.ToJson((object)(data ?? new CategoryFile()), true));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Could not save " + FilePath + ": " + ex.Message));
			}
		}

		public static Category Create(string name)
		{
			name = (name ?? "").Trim();
			if (name.Length == 0 || All.Any((Category c) => c.name.Equals(name, StringComparison.OrdinalIgnoreCase)))
			{
				return null;
			}
			int color = (from i in Enumerable.Range(0, Palette.Length)
				orderby All.Count((Category c) => c.color == i)
				select i).First();
			Category category = new Category
			{
				name = name,
				color = color
			};
			All.Add(category);
			Save();
			return category;
		}

		public static void Delete(Category c)
		{
			All.Remove(c);
			Save();
		}

		public static IEnumerable<Category> Of(LevelData l)
		{
			return All.Where((Category c) => c.HasMoon(l));
		}

		public static IEnumerable<Category> Of(DungeonData d)
		{
			return All.Where((Category c) => c.HasInterior(d));
		}
	}
	internal struct ApplyResult
	{
		public int Added;

		public int Removed;

		public int Skipped;

		public override string ToString()
		{
			List<string> list = new List<string> { L.T($"+{Added} enabled", $"+{Added} ligado(s)") };
			if (Removed > 0)
			{
				list.Add(L.T($"-{Removed} disabled", $"-{Removed} desligado(s)"));
			}
			if (Skipped > 0)
			{
				list.Add(L.T($"{Skipped} locked skipped", $"{Skipped} bloqueado(s) ignorado(s)"));
			}
			return string.Join(", ", list);
		}
	}
	internal class EditorWindow : MonoBehaviour
	{
		private enum Mode
		{
			Moons,
			Categories
		}

		private enum Tab
		{
			Interiors,
			Inside,
			Daytime,
			Nighttime,
			Scrap,
			General
		}

		private Mode mode;

		private Category selectedCategory;

		private string newCategoryName = "";

		private string categoryNameBuffer;

		private string catMoonSearch = "";

		private string catInteriorSearch = "";

		private Vector2 catListScroll;

		private Vector2 catMoonScroll;

		private Vector2 catInteriorScroll;

		private bool confirmDeleteCategory;

		private bool editingMoonCategories;

		private const int MainWindowId = 1280068609;

		private const int PopupWindowId = 1280068610;

		private bool open;

		private Model model;

		private Rect windowRect;

		private Vector2 moonScroll;

		private Vector2 contentScroll;

		private Vector2 popupScroll;

		private string moonSearch = "";

		private string popupSearch = "";

		private string interiorSearch = "";

		private bool hideLockedMoons;

		private bool hideLockedInteriors;

		private LevelData selected;

		private Tab tab;

		private bool popupOpen;

		private LevelList popupList;

		private Rect popupRect;

		private string status = "";

		private float statusUntil;

		private bool confirmDiscard;

		private PlayerControllerB controlledPlayer;

		private bool savedLook;

		private bool savedMove;

		private bool savedMenu;

		private readonly Dictionary<string, string> fieldBuffers = new Dictionary<string, string>();

		private bool stylesReady;

		private GUIStyle sWindow;

		private GUIStyle sPanel;

		private GUIStyle sRow;

		private GUIStyle sRowAlt;

		private GUIStyle sTitle;

		private GUIStyle sHeader;

		private GUIStyle sLabel;

		private GUIStyle sDim;

		private GUIStyle sWarn;

		private GUIStyle sOk;

		private GUIStyle sButton;

		private GUIStyle sAccentButton;

		private GUIStyle sMoonButton;

		private GUIStyle sMoonSelected;

		private GUIStyle sTab;

		private GUIStyle sTabSelected;

		private GUIStyle sField;

		private GUIStyle sToggle;

		private GUIStyle sSmallButton;

		private GUIStyle sCheck;

		private GUIStyle sLockBanner;

		private GUIStyle sWarnBold;

		private GUIStyle sIcon;

		private GUIStyle sToast;

		private GUIStyle sCheckRow;

		private GUIStyle sLockBannerNeutral;

		private GUIStyle sStatusBar;

		private Texture2D searchIcon;

		private static readonly Color Accent = new Color(1f, 0.42f, 0.08f);

		private string toast = "";

		private float toastUntil;

		private static string[] TabNames => new string[6]
		{
			L.T("Interiors", "Interiores"),
			L.T("Inside enemies", "Inimigos (dentro)"),
			L.T("Outside (day)", "Fora (dia)"),
			L.T("Outside (night)", "Fora (noite)"),
			L.T("Scrap", "Sucata"),
			L.T("General", "Geral")
		};

		private static bool InMatch => (Object)(object)StartOfRound.Instance != (Object)null;

		private void DrawModeTabs()
		{
			GUILayout.Space(16f);
			if (GUILayout.Button(L.T("Moons", "Luas"), (mode == Mode.Moons) ? sTabSelected : sTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				SwitchMode(Mode.Moons);
			}
			if (GUILayout.Button(L.T("Categories", "Categorias"), (mode == Mode.Categories) ? sTabSelected : sTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }))
			{
				SwitchMode(Mode.Categories);
			}
		}

		private void SwitchMode(Mode m)
		{
			mode = m;
			confirmDeleteCategory = false;
			GUIUtility.keyboardControl = 0;
		}

		private void DrawCategories()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Invalid comparison between Unknown and I4
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Invalid comparison between Unknown and I4
			List<Category> all = CategoryStore.All;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(sPanel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(250f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label(L.T("Categories", "Categorias"), sHeader, Array.Empty<GUILayoutOption>());
			GUILayout.Label(L.T("Group moons and interiors (e.g. \"Industrial\") to enable several interiors on a moon at once.", "Agrupe luas e interiores (ex.: \"Industrial\") para ligar vários interiores numa lua de uma vez."), sDim, Array.Empty<GUILayoutOption>());
			catListScroll = GUILayout.BeginScrollView(catListScroll, Array.Empty<GUILayoutOption>());
			if (all.Count == 0)
			{
				GUILayout.Label(L.T("No categories yet.", "Nenhuma categoria ainda."), sDim, Array.Empty<GUILayoutOption>());
			}
			foreach (Category item in all)
			{
				string text = L.T($"{item.moons.Count} moon(s)  •  {item.interiors.Count} interior(s)", $"{item.moons.Count} lua(s)  •  {item.interiors.Count} interior(es)");
				if (GUILayout.Button(((item == selectedCategory) ? item.name : CategoryStore.Chip(item)) + "\n<size=11>" + text + "</size>", (item == selectedCategory) ? sMoonSelected : sMoonButton, Array.Empty<GUILayoutOption>()))
				{
					SelectCategory(item);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Label(L.T("New category", "Nova categoria"), sDim, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.SetNextControlName("newCategory");
			newCategoryName = GUILayout.TextField(newCategoryName, 30, sField, Array.Empty<GUILayoutOption>());
			bool flag = (int)Event.current.type == 4 && (int)Event.current.keyCode == 13 && GUI.GetNameOfFocusedControl() == "newCategory";
			if (GUILayout.Button(L.T("Create", "Criar"), sAccentButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) }) || flag)
			{
				Category category = CategoryStore.Create(newCategoryName);
				if (category != null)
				{
					SelectCategory(category);
					newCategoryName = "";
					SetStatus(L.T("Category \"" + category.name + "\" created.", "Categoria \"" + category.name + "\" criada."));
				}
				else
				{
					SetStatus(string.IsNullOrWhiteSpace(newCategoryName) ? L.T("Type a name for the category.", "Digite um nome para a categoria.") : L.T("A category with that name already exists.", "Já existe uma categoria com esse nome."));
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUILayout.Space(6f);
			GUILayout.BeginVertical(sPanel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			if (selectedCategory == null || !all.Contains(selectedCategory))
			{
				selectedCategory = null;
				GUILayout.FlexibleSpace();
				GUILayout.Label(L.T("Select or create a category on the left.", "Selecione ou crie uma categoria à esquerda."), sHeader, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
			}
			else
			{
				DrawCategoryDetail(selectedCategory);
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void SelectCategory(Category c)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			selectedCategory = c;
			categoryNameBuffer = c?.name;
			confirmDeleteCategory = false;
			catMoonScroll = (catInteriorScroll = Vector2.zero);
			GUIUtility.keyboardControl = 0;
		}

		private void DrawCategoryDetail(Category cat)
		{
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(L.T("Name", "Nome"), sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			categoryNameBuffer = GUILayout.TextField(categoryNameBuffer ?? cat.name, 30, sField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			string trimmed = categoryNameBuffer.Trim();
			bool flag = CategoryStore.All.Any((Category c) => c != cat && c.name.Equals(trimmed, StringComparison.OrdinalIgnoreCase));
			if (trimmed.Length > 0 && !flag && trimmed != cat.name)
			{
				cat.name = trimmed;
				CategoryStore.Save();
			}
			GUILayout.Space(16f);
			GUILayout.Label(L.T("Default weight", "Peso padrão"), sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
			int num = IntField($"catw_{CategoryStore.All.IndexOf(cat)}", cat.weight, 70f, 1, 999999);
			if (num != cat.weight)
			{
				cat.weight = num;
				CategoryStore.Save();
			}
			GUILayout.FlexibleSpace();
			if (confirmDeleteCategory)
			{
				GUILayout.Label(L.T("Delete category?", "Excluir categoria?"), sWarn, Array.Empty<GUILayoutOption>());
				if (GUILayout.Button(L.T("Yes", "Sim"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
				{
					CategoryStore.Delete(cat);
					SetStatus(L.T("Category \"" + cat.name + "\" deleted (weights already applied to moons don't change).", "Categoria \"" + cat.name + "\" excluída (os pesos já aplicados nas luas não mudam)."));
					SelectCategory(null);
					return;
				}
				if (GUILayout.Button(L.T("No", "Não"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
				{
					confirmDeleteCategory = false;
				}
			}
			else if (GUILayout.Button(L.T("Delete", "Excluir"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
			{
				confirmDeleteCategory = true;
			}
			GUILayout.EndHorizontal();
			if (trimmed.Length == 0)
			{
				GUILayout.Label(L.T("The name can't be empty.", "O nome não pode ficar vazio."), sWarn, Array.Empty<GUILayoutOption>());
			}
			else if (flag)
			{
				GUILayout.Label(L.T("Another category already has that name.", "Já existe outra categoria com esse nome."), sWarn, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Label(L.T("When applied, the category's interiors are enabled on the moon with the default weight. Interiors that were already enabled keep their weight.", "Ao aplicar, os interiores da categoria são ligados na lua com o peso padrão. Interiores que já estavam ligados mantêm o peso."), sDim, Array.Empty<GUILayoutOption>());
			List<LevelData> list = model.Levels.Where(cat.HasMoon).ToList();
			GUILayout.BeginHorizontal(sLockBannerNeutral, Array.Empty<GUILayoutOption>());
			GUILayout.Label(L.T($"Apply to the {list.Count} moon(s) in this category:", $"Aplicar nas {list.Count} lua(s) desta categoria:"), sLabel, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUI.enabled = list.Count > 0 && cat.interiors.Count > 0;
			if (GUILayout.Button(L.T("Add interiors", "Adicionar interiores"), sButton, Array.Empty<GUILayoutOption>()))
			{
				ApplyToMoons(cat, list, replace: false);
			}
			if (GUILayout.Button(L.T("Replace interiors", "Substituir interiores"), sButton, Array.Empty<GUILayoutOption>()))
			{
				ApplyToMoons(cat, list, replace: true);
			}
			GUI.enabled = true;
			GUILayout.EndHorizontal();
			GUILayout.Label(L.T("\"Replace\" also disables, on those moons, the interiors that aren't in the category.", "\"Substituir\" também desliga, nessas luas, os interiores que não estão na categoria."), sDim, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			int num2 = cat.moons.Count((string id) => model.Levels.Any((LevelData l) => l.Id == id));
			GUILayout.Label(L.T($"Moons ({num2})", $"Luas ({num2})"), sHeader, Array.Empty<GUILayoutOption>());
			catMoonSearch = SearchField("catMoonSearch", catMoonSearch);
			catMoonScroll = GUILayout.BeginScrollView(catMoonScroll, Array.Empty<GUILayoutOption>());
			int num3 = 0;
			foreach (LevelData level in model.Levels)
			{
				if (Contains(level.Name, catMoonSearch) || Contains(level.Mod, catMoonSearch))
				{
					GUILayout.BeginHorizontal((num3++ % 2 == 0) ? sRow : sRowAlt, Array.Empty<GUILayoutOption>());
					bool flag2 = cat.HasMoon(level);
					bool flag3 = GUILayout.Toggle(flag2, " " + level.Name + "  <size=11><color=#8a8a8a>" + level.Mod + "</color></size>", sCheckRow, Array.Empty<GUILayoutOption>());
					if (flag3 != flag2)
					{
						cat.SetMoon(level, flag3);
						CategoryStore.Save();
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			GUILayout.Space(6f);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			int num4 = cat.interiors.Count((string id) => model.Dungeons.Any((DungeonData d) => d.Id == id));
			GUILayout.Label(L.T($"Interiors ({num4})", $"Interiores ({num4})"), sHeader, Array.Empty<GUILayoutOption>());
			catInteriorSearch = SearchField("catInteriorSearch", catInteriorSearch);
			catInteriorScroll = GUILayout.BeginScrollView(catInteriorScroll, Array.Empty<GUILayoutOption>());
			num3 = 0;
			foreach (DungeonData dungeon in model.Dungeons)
			{
				if (Contains(dungeon.Name, catInteriorSearch) || Contains(dungeon.Mod, catInteriorSearch))
				{
					GUILayout.BeginHorizontal((num3++ % 2 == 0) ? sRow : sRowAlt, Array.Empty<GUILayoutOption>());
					bool flag4 = cat.HasInterior(dungeon);
					string text = (dungeon.Editable ? "" : ("  •  <color=#c98a3a>" + L.T("LOCKED", "BLOQUEADO") + "</color>"));
					bool flag5 = GUILayout.Toggle(flag4, " " + dungeon.Name + "  <size=11><color=#8a8a8a>" + dungeon.Mod + "</color>" + text + "</size>", sCheckRow, Array.Empty<GUILayoutOption>());
					if (flag5 != flag4)
					{
						cat.SetInterior(dungeon, flag5);
						CategoryStore.Save();
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void ApplyToMoons(Category cat, List<LevelData> moons, bool replace)
		{
			ApplyResult applyResult = default(ApplyResult);
			foreach (LevelData moon in moons)
			{
				ApplyResult applyResult2 = model.ApplyCategories(moon, new Category[1] { cat }, replace);
				applyResult.Added += applyResult2.Added;
				applyResult.Removed += applyResult2.Removed;
				applyResult.Skipped += applyResult2.Skipped;
			}
			SetStatus(L.T($"{cat.name} on {moons.Count} moon(s): {applyResult}. Click Save to keep the changes.", $"{cat.name} em {moons.Count} lua(s): {applyResult}. Clique em Salvar para gravar."));
		}

		private void DrawMoonCategoryBar(LevelData ld)
		{
			List<Category> list = CategoryStore.Of(ld).ToList();
			GUILayout.BeginVertical(sLockBannerNeutral, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(L.T("Categories:", "Categorias:"), sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			if (list.Count == 0)
			{
				GUILayout.Label(L.T("none", "nenhuma"), sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			}
			foreach (Category item in list)
			{
				GUILayout.Label(CategoryStore.Chip(item), sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			}
			GUILayout.FlexibleSpace();
			if (list.Count > 0)
			{
				if (GUILayout.Button(L.T("Add interiors", "Adicionar interiores"), sSmallButton, Array.Empty<GUILayoutOption>()))
				{
					ApplyToMoon(ld, list, replace: false);
				}
				if (GUILayout.Button(L.T("Replace interiors", "Substituir interiores"), sSmallButton, Array.Empty<GUILayoutOption>()))
				{
					ApplyToMoon(ld, list, replace: true);
				}
			}
			if (GUILayout.Button(editingMoonCategories ? L.T("Close", "Fechar") : L.T("Edit categories", "Editar categorias"), sSmallButton, Array.Empty<GUILayoutOption>()))
			{
				editingMoonCategories = !editingMoonCategories;
			}
			GUILayout.EndHorizontal();
			if (editingMoonCategories)
			{
				if (CategoryStore.All.Count == 0)
				{
					GUILayout.Label(L.T("No categories yet. Create them in the \"Categories\" screen (button at the top).", "Nenhuma categoria criada ainda. Crie na tela \"Categorias\" (botão no topo)."), sDim, Array.Empty<GUILayoutOption>());
				}
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				int num = 0;
				foreach (Category item2 in CategoryStore.All)
				{
					if (num > 0 && num % 5 == 0)
					{
						GUILayout.FlexibleSpace();
						GUILayout.EndHorizontal();
						GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					}
					num++;
					bool flag = item2.HasMoon(ld);
					bool flag2 = GUILayout.Toggle(flag, " " + CategoryStore.Chip(item2), sCheckRow, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
					if (flag2 != flag)
					{
						item2.SetMoon(ld, flag2);
						CategoryStore.Save();
					}
					GUILayout.Space(12f);
				}
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			GUILayout.Space(4f);
		}

		private void ApplyToMoon(LevelData ld, List<Category> cats, bool replace)
		{
			ApplyResult applyResult = model.ApplyCategories(ld, cats, replace);
			SetStatus(L.T($"{ld.Name}: {applyResult}. Click Save to keep the changes.", $"{ld.Name}: {applyResult}. Clique em Salvar para gravar."));
		}

		private static string InteriorChips(DungeonData d)
		{
			List<Category> list = CategoryStore.Of(d).ToList();
			if (list.Count != 0)
			{
				return "  " + string.Join("  ", list.Select(CategoryStore.Chip));
			}
			return "";
		}

		private void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (open && !InMatch)
			{
				Close();
			}
			if (((ButtonControl)current[Plugin.ToggleKey.Value]).wasPressedThisFrame)
			{
				if (open)
				{
					Close();
				}
				else if (InMatch)
				{
					Open();
				}
				else
				{
					ShowToast(L.T("The Moon Editor only opens inside a match (host or join a lobby).", "O Editor de Luas só abre dentro de uma partida (hospede ou entre em um lobby)."));
				}
			}
			else if (open && ((ButtonControl)current.escapeKey).wasPressedThisFrame)
			{
				if (popupOpen)
				{
					popupOpen = false;
				}
				else
				{
					Close();
				}
			}
			if (open)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		private void Open()
		{
			open = true;
			if (Model.ContentReady && (model == null || model.Levels.Count != PatchedContent.ExtendedLevels.Count((ExtendedLevel l) => (Object)(object)((l != null) ? l.SelectableLevel : null) != (Object)null)))
			{
				RebuildModel();
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val != (Object)null)
			{
				controlledPlayer = val;
				savedLook = val.disableLookInput;
				savedMove = val.disableMoveInput;
				val.disableLookInput = true;
				val.disableMoveInput = true;
				if ((Object)(object)val.quickMenuManager != (Object)null)
				{
					savedMenu = val.quickMenuManager.isMenuOpen;
					val.quickMenuManager.isMenuOpen = true;
				}
			}
		}

		private void Close()
		{
			open = false;
			popupOpen = false;
			GUIUtility.keyboardControl = 0;
			PlayerControllerB val = controlledPlayer;
			controlledPlayer = null;
			if (!((Object)(object)val == (Object)null))
			{
				val.disableLookInput = savedLook;
				val.disableMoveInput = savedMove;
				if ((Object)(object)val.quickMenuManager != (Object)null)
				{
					val.quickMenuManager.isMenuOpen = savedMenu;
				}
				if (!savedMenu && !val.inTerminalMenu && !val.isPlayerDead)
				{
					Cursor.lockState = (CursorLockMode)1;
					Cursor.visible = false;
				}
			}
		}

		private void RebuildModel()
		{
			try
			{
				model = Model.Build();
				selected = ((selected != null) ? model.Levels.FirstOrDefault((LevelData l) => (Object)(object)l.Level == (Object)(object)selected.Level) : null);
				if (selected == null)
				{
					selected = model.Levels.FirstOrDefault();
				}
			}
			catch (Exception ex)
			{
				model = null;
				Plugin.Log.LogError((object)("Failed to read LethalLevelLoader content: " + ex));
				SetStatus(L.T("Error reading LLL, see LogOutput.log", "Erro ao ler o LLL, veja o LogOutput.log"));
			}
		}

		private void ShowToast(string s)
		{
			toast = s;
			toastUntil = Time.realtimeSinceStartup + 3.5f;
		}

		private void SetStatus(string s)
		{
			status = s;
			statusUntil = Time.realtimeSinceStartup + 5f;
		}

		private void OnGUI()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			if (!open)
			{
				if (Time.realtimeSinceStartup < toastUntil)
				{
					DrawToast();
				}
				return;
			}
			EnsureStyles();
			float num = Mathf.Clamp(Plugin.UiScale.Value, 0.5f, 3f);
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			float num2 = (float)Screen.width / num;
			float num3 = (float)Screen.height / num;
			if (((Rect)(ref windowRect)).width < 1f)
			{
				float num4 = Mathf.Min(1150f, num2 - 40f);
				float num5 = Mathf.Min(720f, num3 - 40f);
				windowRect = new Rect((num2 - num4) / 2f, (num3 - num5) / 2f, num4, num5);
			}
			GUI.depth = -1000;
			windowRect = GUI.Window(1280068609, windowRect, new WindowFunction(DrawMain), GUIContent.none, sWindow);
			((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f - ((Rect)(ref windowRect)).width + 100f, num2 - 100f);
			((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, num3 - 40f);
			if (popupOpen)
			{
				popupRect = new Rect(((Rect)(ref windowRect)).x + ((Rect)(ref windowRect)).width / 2f - 260f, ((Rect)(ref windowRect)).y + 80f, 520f, Mathf.Min(560f, ((Rect)(ref windowRect)).height - 100f));
				GUI.ModalWindow(1280068610, popupRect, new WindowFunction(DrawPopup), GUIContent.none, sWindow);
			}
			GUI.matrix = matrix;
		}

		private void DrawToast()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			EnsureStyles();
			float num = Mathf.Clamp(Plugin.UiScale.Value, 0.5f, 3f);
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			float num2 = (float)Screen.width / num;
			float num3 = (float)Screen.height / num;
			GUIContent val = new GUIContent(toast);
			Vector2 val2 = sToast.CalcSize(val);
			Rect val3 = new Rect((num2 - val2.x) / 2f, num3 - val2.y - 60f, val2.x, val2.y);
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01((toastUntil - Time.realtimeSinceStartup) / 0.5f));
			GUI.Label(val3, val, sToast);
			GUI.color = color;
			GUI.matrix = matrix;
		}

		private void DrawMain(int id)
		{
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(L.T("MOON EDITOR", "EDITOR DE LUAS") + "  <size=12><color=#999>LethalLevelLoader</color></size>", sTitle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			if (model != null)
			{
				DrawModeTabs();
			}
			GUILayout.FlexibleSpace();
			if (model != null)
			{
				int dirtyCount = model.DirtyCount;
				GUI.enabled = dirtyCount > 0;
				if (confirmDiscard)
				{
					GUILayout.Label(L.T("Discard everything?", "Descartar tudo?"), sWarn, Array.Empty<GUILayoutOption>());
					if (GUILayout.Button(L.T("Yes", "Sim"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
					{
						confirmDiscard = false;
						RebuildModel();
						SetStatus(L.T("Changes discarded.", "Alterações descartadas."));
					}
					if (GUILayout.Button(L.T("No", "Não"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
					{
						confirmDiscard = false;
					}
				}
				else if (GUILayout.Button(L.T("Discard", "Descartar"), sButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
				{
					confirmDiscard = true;
				}
				if (GUILayout.Button((dirtyCount > 0) ? L.T($"Save ({dirtyCount})", $"Salvar ({dirtyCount})") : L.T("Saved", "Salvo"), sAccentButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }))
				{
					try
					{
						int num = model.SaveAll();
						SetStatus(L.T($"{num} change(s) saved to LethalLevelLoader.cfg and applied.", $"{num} alteração(ões) salvas no LethalLevelLoader.cfg e aplicadas."));
					}
					catch (Exception ex)
					{
						Plugin.Log.LogError((object)("Error while saving: " + ex));
						SetStatus(L.T("Error while saving, see LogOutput.log", "Erro ao salvar, veja o LogOutput.log"));
					}
				}
				GUI.enabled = true;
			}
			GUILayout.Space(8f);
			if (GUILayout.Button("EN", L.Pt ? sTab : sTabSelected, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(38f) }))
			{
				L.Set(portuguese: false);
			}
			if (GUILayout.Button("PT", L.Pt ? sTabSelected : sTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(38f) }))
			{
				L.Set(portuguese: true);
			}
			GUILayout.Space(8f);
			if (GUILayout.Button("X", sButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
			{
				Close();
			}
			GUILayout.EndHorizontal();
			if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsHost)
			{
				GUILayout.Label(L.T("You are not the host: changes are saved to your config, but they only apply in matches you host.", "Você não é o host: as mudanças são salvas no seu config, mas só valem nas partidas que você hospedar."), sWarn, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(4f);
			if (!Model.ContentReady)
			{
				GUILayout.FlexibleSpace();
				GUILayout.Label(L.T("LethalLevelLoader is still loading the moons. Close and reopen the editor in a few seconds.", "O LethalLevelLoader ainda está carregando as luas. Feche e abra o editor de novo em alguns segundos."), sHeader, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				GUI.DragWindow();
				return;
			}
			if (model == null)
			{
				RebuildModel();
				if (model == null)
				{
					GUI.DragWindow();
					return;
				}
			}
			if (mode == Mode.Categories)
			{
				DrawCategories();
			}
			else
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				DrawMoonList();
				GUILayout.Space(6f);
				GUILayout.BeginVertical(sPanel, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.ExpandWidth(true),
					GUILayout.ExpandHeight(true)
				});
				if (selected != null)
				{
					DrawMoon(selected);
				}
				GUILayout.EndVertical();
				GUILayout.EndHorizontal();
			}
			GUILayout.Label((Time.realtimeSinceStartup < statusUntil) ? status : "", sStatusBar, Array.Empty<GUILayoutOption>());
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 30f));
		}

		private void DrawMoonList()
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(sPanel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(250f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label(L.T("Moons", "Luas"), sHeader, Array.Empty<GUILayoutOption>());
			int num = model.Levels.Count((LevelData l) => l.Editable);
			GUILayout.Label(L.T($"{num} of {model.Levels.Count} editable", $"{num} de {model.Levels.Count} editáveis"), sDim, Array.Empty<GUILayoutOption>());
			moonSearch = SearchField("moonSearch", moonSearch);
			hideLockedMoons = GUILayout.Toggle(hideLockedMoons, L.T(" Hide locked", " Ocultar bloqueadas"), sCheck, Array.Empty<GUILayoutOption>());
			moonScroll = GUILayout.BeginScrollView(moonScroll, Array.Empty<GUILayoutOption>());
			foreach (LevelData level in model.Levels)
			{
				if ((Contains(level.Name, moonSearch) || Contains(level.Mod, moonSearch)) && (!hideLockedMoons || level.Editable || level == selected))
				{
					bool flag = level == selected;
					string text = ((level.Editable || flag) ? level.Name : ("<color=#777>" + level.Name + "</color>"));
					string text2 = L.T("LOCKED", "BLOQUEADA");
					string arg = (level.Editable ? "" : (flag ? ("  •  " + text2) : ("  •  <color=#c98a3a>" + text2 + "</color>")));
					if (GUILayout.Button((level.Dirty ? "<color=#ff8a3d>• </color>" : "") + text + $"\n<size=11><color=#8a8a8a>{level.Mod}  •  ${level.Level.RoutePrice}</color>{arg}</size>", (level == selected) ? sMoonSelected : sMoonButton, Array.Empty<GUILayoutOption>()))
					{
						selected = level;
						contentScroll = Vector2.zero;
						GUIUtility.keyboardControl = 0;
					}
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private void DrawMoon(LevelData ld)
		{
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(ld.Name + "  <size=13><color=#8a8a8a>" + ld.Mod + "</color></size>", sTitle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (ld.Dirty && GUILayout.Button(L.T("Undo this moon", "Desfazer nesta lua"), sSmallButton, Array.Empty<GUILayoutOption>()))
			{
				model.LoadDraft(ld);
				SetStatus(L.T("Changes to " + ld.Name + " undone.", "Alterações de " + ld.Name + " desfeitas."));
			}
			GUILayout.EndHorizontal();
			if (!ld.Editable)
			{
				GUILayout.BeginVertical(sLockBanner, Array.Empty<GUILayoutOption>());
				GUILayout.Label(L.T("LOCKED  <size=12>: enemies, scrap and general settings are shown read-only.</size>", "BLOQUEADA  <size=12>: inimigos, sucata e configurações gerais aparecem só para consulta.</size>"), sWarnBold, Array.Empty<GUILayoutOption>());
				GUILayout.Label((string)ld.LockReason, sDim, Array.Empty<GUILayoutOption>());
				GUILayout.Label(L.T("This moon's interiors can still be edited, because LLL stores that choice in each interior's config.", "Os interiores desta lua continuam editáveis, porque o LLL guarda essa escolha no config de cada interior."), sDim, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				GUILayout.Space(4f);
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			string[] tabNames = TabNames;
			for (int i = 0; i < tabNames.Length; i++)
			{
				if (GUILayout.Button((!ld.Editable && i != 0) ? (tabNames[i] + L.T(" (read-only)", " (leitura)")) : tabNames[i], (tab == (Tab)i) ? sTabSelected : sTab, Array.Empty<GUILayoutOption>()))
				{
					tab = (Tab)i;
					contentScroll = Vector2.zero;
					GUIUtility.keyboardControl = 0;
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			switch (tab)
			{
			case Tab.Interiors:
				DrawInteriors(ld);
				break;
			case Tab.Inside:
				DrawWeightedList(ld, LevelList.Inside, L.T("Enemies that spawn inside the interior.", "Inimigos que nascem dentro do interior."), ld.DPowerInside, L.T("Max power", "Poder máx."));
				break;
			case Tab.Daytime:
				DrawWeightedList(ld, LevelList.Daytime, L.T("Outside enemies that spawn during the day (bees, birds...).", "Inimigos de fora que nascem durante o dia (abelhas, pássaros...)."), ld.DPowerDay, L.T("Max power", "Poder máx."));
				break;
			case Tab.Nighttime:
				DrawWeightedList(ld, LevelList.Nighttime, L.T("Outside enemies that spawn at night (Eyeless Dog, Giant...).", "Inimigos de fora que nascem à noite (Eyeless Dog, Giant...)."), ld.DPowerNight, L.T("Max power", "Poder máx."));
				break;
			case Tab.Scrap:
				DrawWeightedList(ld, LevelList.Scrap, L.T("Scrap items that can appear inside the interior.", "Itens de sucata que podem aparecer no interior."), -1, null);
				break;
			case Tab.General:
				DrawGeneral(ld);
				break;
			}
		}

		private void DrawInteriors(LevelData ld)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label(L.T("Check which interiors can generate on this moon. The weight sets their relative chance.", "Marque quais interiores podem ser gerados nesta lua. O peso define a chance relativa entre eles."), sDim, Array.Empty<GUILayoutOption>());
			DrawMoonCategoryBar(ld);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			interiorSearch = SearchField("interiorSearch", interiorSearch);
			hideLockedInteriors = GUILayout.Toggle(hideLockedInteriors, L.T(" Hide locked", " Ocultar bloqueados"), sCheck, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
			GUILayout.EndHorizontal();
			int num = model.Dungeons.Sum((DungeonData d) => d.EffectiveWeight(ld));
			contentScroll = GUILayout.BeginScrollView(contentScroll, Array.Empty<GUILayoutOption>());
			int num2 = 0;
			foreach (DungeonData dungeon in model.Dungeons)
			{
				if ((!Contains(dungeon.Name, interiorSearch) && !Contains(dungeon.Mod, interiorSearch)) || (hideLockedInteriors && !dungeon.Editable))
				{
					continue;
				}
				int num3 = dungeon.ManualWeight(ld);
				int num4 = dungeon.OtherRuleWeight(ld);
				int num5 = Math.Max(num3, num4);
				GUILayout.BeginVertical((num2++ % 2 == 0) ? sRow : sRowAlt, Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUI.enabled = dungeon.Editable;
				bool flag = GUILayout.Toggle(num3 > 0, "", sToggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) });
				if (flag != num3 > 0)
				{
					dungeon.SetManualWeight(ld, flag ? 100 : 0);
				}
				GUILayout.Label(dungeon.Editable ? (dungeon.Name + "\n<size=11><color=#8a8a8a>" + dungeon.Mod + "</color>" + InteriorChips(dungeon) + "</size>") : ("<color=#777>" + dungeon.Name + "</color>\n<size=11><color=#8a8a8a>" + dungeon.Mod + "</color>  •  <color=#c98a3a>" + L.T("LOCKED", "BLOQUEADO") + "</color>" + InteriorChips(dungeon) + "</size>"), sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) });
				float num6 = Mathf.Max(1000f, (float)num3);
				int num7 = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)num3, 0f, num6, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }));
				if (num7 != num3)
				{
					dungeon.SetManualWeight(ld, num7);
					num3 = num7;
				}
				int num8 = IntField($"dw_{((Object)dungeon.Flow).GetInstanceID()}_{((Object)ld.Level).GetInstanceID()}", num3, 70f, 0, 999999);
				if (num8 != num3)
				{
					dungeon.SetManualWeight(ld, num8);
				}
				GUILayout.Label((num > 0 && num5 > 0) ? $"{100f * (float)num5 / (float)num:0.#}%" : "—", sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
				GUI.enabled = true;
				GUILayout.EndHorizontal();
				int num9;
				string text;
				if (!dungeon.Editable)
				{
					GUILayout.Label(string.Concat(dungeon.LockReason, (num5 > 0) ? L.T($" It currently appears on this moon with weight {num5}.", $" Hoje ele aparece nesta lua com peso {num5}.") : ""), sDim, Array.Empty<GUILayoutOption>());
				}
				else if (num4 > num3)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					if (dungeon.LockedRuleWeight(ld) > num3)
					{
						num9 = ((dungeon.ConfigurableRuleWeight(ld) <= num3) ? 1 : 0);
						if (num9 != 0)
						{
							text = L.T($"(!) Appears with weight {num4} due to an author rule (author/weather) that LLL doesn't let you edit.", $"(!) Aparece com peso {num4} por regra do autor (autor/clima) que o LLL não deixa editar.");
							goto IL_048c;
						}
					}
					else
					{
						num9 = 0;
					}
					text = L.T($"(!) Also appears with weight {num4} due to an automatic rule (tag, route price or mod name).", $"(!) Também aparece com peso {num4} por regra automática (tag, preço da rota ou nome do mod).");
					goto IL_048c;
				}
				goto IL_050c;
				IL_048c:
				GUILayout.Label(text, sWarn, Array.Empty<GUILayoutOption>());
				if (num9 == 0 && GUILayout.Button(L.T("Convert rules to per-moon weights", "Converter regras em pesos por lua"), sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) }))
				{
					model.ConvertRulesToManual(dungeon);
					SetStatus(L.T(dungeon.Name + ": automatic rules converted to manual per-moon weights.", dungeon.Name + ": regras automáticas convertidas em pesos manuais por lua."));
				}
				GUILayout.EndHorizontal();
				goto IL_050c;
				IL_050c:
				GUILayout.EndVertical();
			}
			GUILayout.EndScrollView();
		}

		private void DrawWeightedList(LevelData ld, LevelList which, string help, int power, string powerLabel)
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			List<Weighted> list = ld.GetList(which);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(help, sDim, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUI.enabled = ld.Editable;
			if (powerLabel != null)
			{
				GUILayout.Label(powerLabel, sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
				int num = IntField($"pw_{which}_{((Object)ld.Level).GetInstanceID()}", power, 60f, 0, 9999);
				if (num != power)
				{
					switch (which)
					{
					case LevelList.Inside:
						ld.DPowerInside = num;
						break;
					case LevelList.Daytime:
						ld.DPowerDay = num;
						break;
					default:
						ld.DPowerNight = num;
						break;
					}
					ld.Dirty = true;
				}
			}
			string text = ((which == LevelList.Scrap) ? L.T("+ Add item", "+ Adicionar item") : L.T("+ Add enemy", "+ Adicionar inimigo"));
			if (ld.Editable && GUILayout.Button(text, sAccentButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }))
			{
				popupOpen = true;
				popupList = which;
				popupSearch = "";
				popupScroll = Vector2.zero;
			}
			GUI.enabled = true;
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			int num2 = list.Sum((Weighted w) => w.Rarity);
			contentScroll = GUILayout.BeginScrollView(contentScroll, Array.Empty<GUILayoutOption>());
			GUI.enabled = ld.Editable;
			if (list.Count == 0)
			{
				GUILayout.Label(L.T("Empty list: nothing will spawn here.", "Lista vazia: nada vai nascer aqui."), sDim, Array.Empty<GUILayoutOption>());
			}
			Weighted weighted = null;
			for (int num3 = 0; num3 < list.Count; num3++)
			{
				Weighted weighted2 = list[num3];
				GUILayout.BeginHorizontal((num3 % 2 == 0) ? sRow : sRowAlt, Array.Empty<GUILayoutOption>());
				GUILayout.Label(weighted2.Name + "\n<size=11><color=#8a8a8a>" + weighted2.Mod + "</color></size>", sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) });
				int num4 = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)weighted2.Rarity, 0f, 100f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }));
				if (num4 != weighted2.Rarity)
				{
					weighted2.Rarity = num4;
					ld.Dirty = true;
				}
				int num5 = IntField($"wl_{which}_{((Object)ld.Level).GetInstanceID()}_{num3}", weighted2.Rarity, 50f, 0, 100);
				if (num5 != weighted2.Rarity)
				{
					weighted2.Rarity = num5;
					ld.Dirty = true;
				}
				GUILayout.Label((num2 > 0 && weighted2.Rarity > 0) ? $"{100f * (float)weighted2.Rarity / (float)num2:0.#}%" : "—", sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
				if (GUILayout.Button("X", sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
				{
					weighted = weighted2;
				}
				GUILayout.EndHorizontal();
			}
			if (weighted != null)
			{
				list.Remove(weighted);
				ld.Dirty = true;
				fieldBuffers.Clear();
			}
			GUI.enabled = true;
			GUILayout.EndScrollView();
		}

		private void DrawPopup(int id)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			LevelData levelData = selected;
			if (levelData == null)
			{
				popupOpen = false;
				return;
			}
			List<Weighted> list = levelData.GetList(popupList);
			bool flag = popupList == LevelList.Scrap;
			List<Candidate> list2 = (flag ? model.ScrapItems : model.Enemies);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(flag ? L.T("Add scrap item", "Adicionar item de sucata") : L.T("Add enemy", "Adicionar inimigo"), sTitle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("X", sButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
			{
				popupOpen = false;
			}
			GUILayout.EndHorizontal();
			popupSearch = SearchField("popupSearch", popupSearch);
			popupScroll = GUILayout.BeginScrollView(popupScroll, Array.Empty<GUILayoutOption>());
			int num = 0;
			foreach (Candidate c in list2)
			{
				if (!list.Any((Weighted w) => w.Name.Equals(c.Name, StringComparison.OrdinalIgnoreCase)) && (Contains(c.Name, popupSearch) || Contains(c.Mod, popupSearch)) && GUILayout.Button($"{c.Name}   <size=11><color=#8a8a8a>{c.Mod}  •  {c.Hint}</color></size>", (num++ % 2 == 0) ? sMoonButton : sMoonButton, Array.Empty<GUILayoutOption>()))
				{
					list.Add(new Weighted(c.Name, flag ? 20 : 25, c.Mod));
					levelData.Dirty = true;
					SetStatus(L.T(c.Name + " added to " + levelData.Name + ".", c.Name + " adicionado a " + levelData.Name + "."));
				}
			}
			if (num == 0)
			{
				GUILayout.Label(L.T("Nothing found.", "Nada encontrado."), sDim, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.Label(L.T("Click to add (you can add several). ESC closes.", "Clique para adicionar (pode adicionar vários). ESC fecha."), sDim, Array.Empty<GUILayoutOption>());
		}

		private void DrawGeneral(LevelData ld)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			contentScroll = GUILayout.BeginScrollView(contentScroll, Array.Empty<GUILayoutOption>());
			GUI.enabled = ld.Editable;
			int instanceID = ((Object)ld.Level).GetInstanceID();
			ld.DRoutePrice = LabeledInt(L.T("Route price (credits)", "Preço da rota (créditos)"), $"g_rp_{instanceID}", ld.DRoutePrice, 0, 99999, ld);
			GUILayout.Space(8f);
			GUILayout.Label(L.T("Scrap", "Sucata"), sHeader, Array.Empty<GUILayoutOption>());
			ld.DMinScrap = LabeledInt(L.T("Minimum item count", "Quantidade mínima de itens"), $"g_mins_{instanceID}", ld.DMinScrap, 0, 999, ld);
			ld.DMaxScrap = LabeledInt(L.T("Maximum item count", "Quantidade máxima de itens"), $"g_maxs_{instanceID}", ld.DMaxScrap, 0, 999, ld);
			ld.DMinValue = LabeledInt(L.T("Minimum total value", "Valor total mínimo"), $"g_minv_{instanceID}", ld.DMinValue, 0, 99999, ld);
			ld.DMaxValue = LabeledInt(L.T("Maximum total value", "Valor total máximo"), $"g_maxv_{instanceID}", ld.DMaxValue, 0, 99999, ld);
			if (ld.DMinScrap > ld.DMaxScrap || ld.DMinValue > ld.DMaxValue)
			{
				GUILayout.Label(L.T("(!) The minimum is greater than the maximum.", "(!) O mínimo está maior que o máximo."), sWarn, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(8f);
			GUILayout.Label(L.T("Maximum enemy power", "Poder máximo de inimigos"), sHeader, Array.Empty<GUILayoutOption>());
			ld.DPowerInside = LabeledInt(L.T("Inside", "Dentro"), $"g_pi_{instanceID}", ld.DPowerInside, 0, 9999, ld);
			ld.DPowerDay = LabeledInt(L.T("Outside, daytime", "Fora, de dia"), $"g_pd_{instanceID}", ld.DPowerDay, 0, 9999, ld);
			ld.DPowerNight = LabeledInt(L.T("Outside, nighttime", "Fora, à noite"), $"g_pn_{instanceID}", ld.DPowerNight, 0, 9999, ld);
			GUI.enabled = true;
			GUILayout.EndScrollView();
		}

		private int LabeledInt(string label, string key, int value, int min, int max, LevelData ld)
		{
			GUILayout.BeginHorizontal(sRow, Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) });
			int num = IntField(key, value, 90f, min, max);
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			if (num != value)
			{
				ld.Dirty = true;
			}
			return num;
		}

		private int IntField(string key, int value, float width, int min, int max)
		{
			string value2;
			string obj = (fieldBuffers.TryGetValue(key, out value2) ? value2 : value.ToString());
			GUI.SetNextControlName(key);
			string text = GUILayout.TextField(obj, 7, sField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			if (GUI.GetNameOfFocusedControl() == key)
			{
				fieldBuffers[key] = text;
				if (!int.TryParse(text, out var result))
				{
					return value;
				}
				return Mathf.Clamp(result, min, max);
			}
			fieldBuffers.Remove(key);
			return value;
		}

		private string SearchField(string key, string value)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label((Texture)(object)searchIcon, sIcon, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(22f),
				GUILayout.Height(26f)
			});
			GUI.SetNextControlName(key);
			value = GUILayout.TextField(value ?? "", 40, sField, Array.Empty<GUILayoutOption>());
			if (value.Length > 0 && GUILayout.Button("X", sSmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
			{
				value = "";
			}
			GUILayout.EndHorizontal();
			return value;
		}

		private static bool Contains(string text, string search)
		{
			if (!string.IsNullOrEmpty(search))
			{
				if (text != null)
				{
					return text.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
				}
				return false;
			}
			return true;
		}

		private static Texture2D MagnifierIcon(Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)1
			};
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(13f, 19f);
			Vector2 val3 = val2;
			Vector2 val4 = new Vector2(1f, -1f);
			Vector2 a = val3 + ((Vector2)(ref val4)).normalized * 9.6f;
			Vector2 b = default(Vector2);
			((Vector2)(ref b))..ctor(27f, 5f);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					Vector2 val5 = new Vector2((float)j + 0.5f, (float)i + 0.5f);
					float num = Mathf.Abs(Vector2.Distance(val5, val2) - 8f) - 1.6f;
					float num2 = DistanceToSegment(val5, a, b) - 2.2f;
					float num3 = Mathf.Clamp01(0.5f - Mathf.Min(num, num2));
					val.SetPixel(j, i, new Color(color.r, color.g, color.b, color.a * num3));
				}
			}
			val.Apply();
			return val;
		}

		private static float DistanceToSegment(Vector2 p, Vector2 a, Vector2 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = b - a;
			float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude);
			return Vector2.Distance(p, a + val * num);
		}

		private static Texture2D Tex(Color c)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, c);
			val.Apply();
			return val;
		}

		private void EnsureStyles()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_0170: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Expected O, but got Unknown
			//IL_01c9: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0203: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Expected O, but got Unknown
			//IL_03a4: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Expected O, but got Unknown
			//IL_043e: Expected O, but got Unknown
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Expected O, but got Unknown
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Expected O, but got Unknown
			//IL_04cb: Expected O, but got Unknown
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Expected O, but got Unknown
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Expected O, but got Unknown
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Expected O, but got Unknown
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Expected O, but got Unknown
			//IL_05ec: Expected O, but got Unknown
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Expected O, but got Unknown
			//IL_0688: Expected O, but got Unknown
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0726: Expected O, but got Unknown
			//IL_072b: Expected O, but got Unknown
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0760: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_076d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Expected O, but got Unknown
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ad: Expected O, but got Unknown
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b9: Expected O, but got Unknown
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Expected O, but got Unknown
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_080c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Unknown result type (might be due to invalid IL or missing references)
			//IL_0815: Unknown result type (might be due to invalid IL or missing references)
			//IL_0816: Unknown result type (might be due to invalid IL or missing references)
			//IL_081d: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_0827: Unknown result type (might be due to invalid IL or missing references)
			//IL_0835: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Expected O, but got Unknown
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0874: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Expected O, but got Unknown
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a0: Expected O, but got Unknown
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Expected O, but got Unknown
			//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_0907: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0913: Unknown result type (might be due to invalid IL or missing references)
			//IL_091d: Expected O, but got Unknown
			//IL_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0922: Unknown result type (might be due to invalid IL or missing references)
			//IL_092c: Expected O, but got Unknown
			//IL_0931: Expected O, but got Unknown
			if (stylesReady)
			{
				GUIStyle obj = sWindow;
				if ((Object)(object)((obj != null) ? obj.normal.background : null) != (Object)null)
				{
					return;
				}
			}
			stylesReady = true;
			Texture2D val = Tex(new Color(0.07f, 0.07f, 0.08f, 0.97f));
			Texture2D background = Tex(new Color(0.11f, 0.11f, 0.13f, 1f));
			Texture2D background2 = Tex(new Color(0.14f, 0.14f, 0.16f, 1f));
			Texture2D background3 = Tex(new Color(0.12f, 0.12f, 0.14f, 1f));
			Texture2D background4 = Tex(new Color(0.19f, 0.19f, 0.22f, 1f));
			Texture2D background5 = Tex(new Color(0.26f, 0.26f, 0.3f, 1f));
			Texture2D val2 = Tex(Accent);
			Texture2D background6 = Tex(new Color(1f, 0.55f, 0.25f));
			Texture2D val3 = Tex(new Color(0.05f, 0.05f, 0.06f, 1f));
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0.92f, 0.92f, 0.92f);
			sWindow = new GUIStyle(GUI.skin.window)
			{
				padding = new RectOffset(12, 12, 10, 12)
			};
			GUIStyleState normal = sWindow.normal;
			Texture2D background7 = (sWindow.onNormal.background = val);
			normal.background = background7;
			sPanel = new GUIStyle(GUI.skin.box)
			{
				padding = new RectOffset(8, 8, 8, 8),
				margin = new RectOffset(0, 0, 0, 0)
			};
			sPanel.normal.background = background;
			sRow = new GUIStyle
			{
				padding = new RectOffset(6, 6, 4, 4),
				margin = new RectOffset(0, 0, 1, 1)
			};
			sRow.normal.background = background2;
			sRowAlt = new GUIStyle(sRow);
			sRowAlt.normal.background = background3;
			sLabel = new GUIStyle(GUI.skin.label)
			{
				richText = true,
				fontSize = 14,
				alignment = (TextAnchor)3,
				wordWrap = false
			};
			sLabel.normal.textColor = val4;
			sTitle = new GUIStyle(sLabel)
			{
				fontSize = 18,
				fontStyle = (FontStyle)1
			};
			sHeader = new GUIStyle(sLabel)
			{
				fontSize = 15,
				fontStyle = (FontStyle)1,
				wordWrap = true
			};
			sDim = new GUIStyle(sLabel)
			{
				fontSize = 12,
				wordWrap = true
			};
			sDim.normal.textColor = new Color(0.6f, 0.6f, 0.6f);
			sWarn = new GUIStyle(sDim);
			sWarn.normal.textColor = new Color(1f, 0.75f, 0.3f);
			sOk = new GUIStyle(sDim);
			sOk.normal.textColor = new Color(0.5f, 0.9f, 0.5f);
			sButton = new GUIStyle(GUI.skin.button)
			{
				richText = true,
				fontSize = 14,
				padding = new RectOffset(10, 10, 6, 6)
			};
			sButton.normal.background = background4;
			sButton.hover.background = background5;
			sButton.active.background = val2;
			GUIStyleState normal2 = sButton.normal;
			GUIStyleState hover = sButton.hover;
			Color val6 = (sButton.active.textColor = val4);
			Color textColor = (hover.textColor = val6);
			normal2.textColor = textColor;
			sSmallButton = new GUIStyle(sButton)
			{
				fontSize = 12,
				padding = new RectOffset(6, 6, 3, 3)
			};
			sAccentButton = new GUIStyle(sButton)
			{
				fontStyle = (FontStyle)1
			};
			sAccentButton.normal.background = val2;
			sAccentButton.hover.background = background6;
			GUIStyleState normal3 = sAccentButton.normal;
			textColor = (sAccentButton.hover.textColor = Color.black);
			normal3.textColor = textColor;
			sMoonButton = new GUIStyle(sButton)
			{
				alignment = (TextAnchor)3,
				margin = new RectOffset(0, 0, 1, 1)
			};
			sMoonButton.normal.background = background2;
			sMoonSelected = new GUIStyle(sMoonButton);
			GUIStyleState normal4 = sMoonSelected.normal;
			background7 = (sMoonSelected.hover.background = val2);
			normal4.background = background7;
			GUIStyleState normal5 = sMoonSelected.normal;
			textColor = (sMoonSelected.hover.textColor = Color.black);
			normal5.textColor = textColor;
			sTab = new GUIStyle(sButton)
			{
				fontSize = 13
			};
			sTabSelected = new GUIStyle(sTab)
			{
				fontStyle = (FontStyle)1
			};
			GUIStyleState normal6 = sTabSelected.normal;
			background7 = (sTabSelected.hover.background = val2);
			normal6.background = background7;
			GUIStyleState normal7 = sTabSelected.normal;
			textColor = (sTabSelected.hover.textColor = Color.black);
			normal7.textColor = textColor;
			sField = new GUIStyle(GUI.skin.textField)
			{
				fontSize = 14,
				padding = new RectOffset(6, 6, 4, 4)
			};
			GUIStyleState normal8 = sField.normal;
			GUIStyleState focused = sField.focused;
			Texture2D val11 = (sField.hover.background = val3);
			background7 = (focused.background = val11);
			normal8.background = background7;
			GUIStyleState normal9 = sField.normal;
			GUIStyleState focused2 = sField.focused;
			val6 = (sField.hover.textColor = val4);
			textColor = (focused2.textColor = val6);
			normal9.textColor = textColor;
			sToggle = new GUIStyle(GUI.skin.toggle)
			{
				margin = new RectOffset(4, 4, 8, 4)
			};
			sCheck = new GUIStyle(GUI.skin.toggle)
			{
				fontSize = 12
			};
			GUIStyleState normal10 = sCheck.normal;
			GUIStyleState onNormal = sCheck.onNormal;
			GUIStyleState hover2 = sCheck.hover;
			GUIStyleState onHover = sCheck.onHover;
			Color val16 = default(Color);
			((Color)(ref val16))..ctor(0.75f, 0.75f, 0.75f);
			onHover.textColor = val16;
			val6 = (hover2.textColor = val16);
			textColor = (onNormal.textColor = val6);
			normal10.textColor = textColor;
			sLockBanner = new GUIStyle(sRow)
			{
				padding = new RectOffset(10, 10, 6, 6)
			};
			sLockBanner.normal.background = Tex(new Color(0.25f, 0.16f, 0.06f, 1f));
			sWarnBold = new GUIStyle(sWarn)
			{
				fontSize = 14,
				fontStyle = (FontStyle)1
			};
			sStatusBar = new GUIStyle(sOk)
			{
				wordWrap = false,
				clipping = (TextClipping)1,
				fixedHeight = 22f,
				margin = new RectOffset(4, 4, 6, 0),
				alignment = (TextAnchor)3
			};
			sCheckRow = new GUIStyle(GUI.skin.toggle)
			{
				fontSize = 14,
				richText = true
			};
			GUIStyleState normal11 = sCheckRow.normal;
			GUIStyleState onNormal2 = sCheckRow.onNormal;
			GUIStyleState hover3 = sCheckRow.hover;
			val16 = (sCheckRow.onHover.textColor = val4);
			val6 = (hover3.textColor = val16);
			textColor = (onNormal2.textColor = val6);
			normal11.textColor = textColor;
			sLockBannerNeutral = new GUIStyle(sLockBanner);
			sLockBannerNeutral.normal.background = Tex(new Color(0.16f, 0.16f, 0.19f, 1f));
			sToast = new GUIStyle(sLabel)
			{
				fontSize = 15,
				padding = new RectOffset(18, 18, 10, 10),
				alignment = (TextAnchor)4
			};
			sToast.normal.background = Tex(new Color(0.07f, 0.07f, 0.08f, 0.95f));
			sToast.border = new RectOffset(0, 0, 0, 0);
			searchIcon = MagnifierIcon(new Color(0.65f, 0.65f, 0.65f));
			sIcon = new GUIStyle
			{
				alignment = (TextAnchor)4,
				padding = new RectOffset(2, 2, 3, 3),
				margin = new RectOffset(0, 2, 4, 4)
			};
		}
	}
	public enum Language
	{
		Auto,
		English,
		Portuguese
	}
	internal static class L
	{
		public static bool Pt
		{
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Invalid comparison between Unknown and I4
				Language language = Plugin.LanguageSetting?.Value ?? Language.Auto;
				if (language == Language.Auto)
				{
					return (int)Application.systemLanguage == 28;
				}
				return language == Language.Portuguese;
			}
		}

		public static string T(string en, string pt)
		{
			if (!Pt)
			{
				return en;
			}
			return pt;
		}

		public static void Set(bool portuguese)
		{
			Plugin.LanguageSetting.Value = ((!portuguese) ? Language.English : Language.Portuguese);
		}
	}
	internal sealed class Txt
	{
		private readonly string en;

		private readonly string pt;

		public Txt(string en, string pt)
		{
			this.en = en;
			this.pt = pt;
		}

		public override string ToString()
		{
			return L.T(en, pt);
		}

		public static implicit operator string(Txt t)
		{
			return t?.ToString();
		}
	}
	internal class Weighted
	{
		public string Name;

		public int Rarity;

		public string Mod;

		public Weighted(string name, int rarity, string mod = "")
		{
			Name = name;
			Rarity = rarity;
			Mod = mod;
		}
	}
	internal class PriceRange
	{
		public int Min;

		public int Max;

		public int Rarity;
	}
	internal class Candidate
	{
		public string Name;

		public string Mod;

		public Txt Hint;
	}
	internal enum LevelList
	{
		Inside,
		Daytime,
		Nighttime,
		Scrap
	}
	internal class LevelData
	{
		public ExtendedLevel Level;

		public Txt LockReason;

		public string Mod;

		public ConfigEntry<bool> Enable;

		public ConfigEntry<int> RoutePrice;

		public ConfigEntry<int> MinScrap;

		public ConfigEntry<int> MaxScrap;

		public ConfigEntry<int> MinValue;

		public ConfigEntry<int> MaxValue;

		public ConfigEntry<int> PowerInside;

		public ConfigEntry<int> PowerDay;

		public ConfigEntry<int> PowerNight;

		public ConfigEntry<string> Scrap;

		public ConfigEntry<string> Inside;

		public ConfigEntry<string> Day;

		public ConfigEntry<string> Night;

		public List<Weighted> DInside;

		public List<Weighted> DDay;

		public List<Weighted> DNight;

		public List<Weighted> DScrap;

		public int DRoutePrice;

		public int DMinScrap;

		public int DMaxScrap;

		public int DMinValue;

		public int DMaxValue;

		public int DPowerInside;

		public int DPowerDay;

		public int DPowerNight;

		public bool Dirty;

		public string Section;

		public bool Editable => LockReason == null;

		public string Name => Level.SelectableLevel.PlanetName;

		public string Id => ((ExtendedContent)Level).UniqueIdentificationName;

		public string ShortName => Level.NumberlessPlanetName;

		public List<Weighted> GetList(LevelList which)
		{
			return which switch
			{
				LevelList.Inside => DInside, 
				LevelList.Daytime => DDay, 
				LevelList.Nighttime => DNight, 
				_ => DScrap, 
			};
		}

		public bool Matches(string name)
		{
			if (!Extensions.EqualsSanitized(name, Level.NumberlessPlanetName))
			{
				return Extensions.EqualsSanitized(name, Level.SelectableLevel.PlanetName);
			}
			return true;
		}
	}
	internal class DungeonData
	{
		public ExtendedDungeonFlow Flow;

		public Txt LockReason;

		public string Mod;

		public ConfigEntry<bool> Enable;

		public ConfigEntry<string> LevelNames;

		public ConfigEntry<string> ModNames;

		public ConfigEntry<string> LevelTags;

		public ConfigEntry<string> RoutePrices;

		public List<Weighted> DPlanets;

		public List<Weighted> DMods;

		public List<Weighted> DTags;

		public List<PriceRange> DPrices;

		public bool Dirty;

		public string Section;

		public bool Editable => LockReason == null;

		public string Name => Flow.DungeonName;

		public string Id => ((ExtendedContent)Flow).UniqueIdentificationName;

		public int ManualWeight(LevelData level)
		{
			int num = 0;
			foreach (Weighted dPlanet in DPlanets)
			{
				if (level.Matches(dPlanet.Name))
				{
					num = Math.Max(num, dPlanet.Rarity);
				}
			}
			return num;
		}

		public void SetManualWeight(LevelData level, int weight)
		{
			DPlanets.RemoveAll((Weighted p) => level.Matches(p.Name));
			if (weight > 0)
			{
				DPlanets.Add(new Weighted(level.ShortName, weight));
			}
			Dirty = true;
		}

		public int ConfigurableRuleWeight(LevelData level)
		{
			ExtendedLevel level2 = level.Level;
			int num = 0;
			foreach (Weighted m in DMods)
			{
				if ((Object)(object)((ExtendedContent)level2).ExtendedMod != (Object)null && ((ExtendedContent)level2).ExtendedMod.ModNameAliases.Any((string a) => Extensions.EqualsSanitized(m.Name, a)))
				{
					num = Math.Max(num, m.Rarity);
				}
			}
			foreach (Weighted t in DTags)
			{
				if (((ExtendedContent)level2).ContentTags.Any((ContentTag ct) => (Object)(object)ct != (Object)null && Extensions.EqualsSanitized(t.Name, ct.contentTagName)))
				{
					num = Math.Max(num, t.Rarity);
				}
			}
			foreach (PriceRange dPrice in DPrices)
			{
				if (level2.RoutePrice >= dPrice.Min && level2.RoutePrice <= dPrice.Max)
				{
					num = Math.Max(num, dPrice.Rarity);
				}
			}
			return num;
		}

		public int LockedRuleWeight(LevelData level)
		{
			LevelMatchingProperties levelMatchingProperties = Flow.LevelMatchingProperties;
			if ((Object)(object)levelMatchingProperties == (Object)null)
			{
				return 0;
			}
			ExtendedLevel level2 = level.Level;
			int num = 0;
			foreach (StringWithRarity authorName in ((MatchingProperties)levelMatchingProperties).authorNames)
			{
				if (Extensions.EqualsSanitized(authorName.Name, ((ExtendedContent)level2).AuthorName))
				{
					num = Math.Max(num, authorName.Rarity);
				}
			}
			string text = ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref level2.SelectableLevel.currentWeather)/*cast due to .constrained prefix*/).ToString();
			foreach (StringWithRarity item in levelMatchingProperties.currentWeather)
			{
				if (Extensions.EqualsSanitized(item.Name, text))
				{
					num = Math.Max(num, item.Rarity);
				}
			}
			return num;
		}

		public int OtherRuleWeight(LevelData level)
		{
			return Math.Max(ConfigurableRuleWeight(level), LockedRuleWeight(level));
		}

		public int EffectiveWeight(LevelData level)
		{
			return Math.Max(ManualWeight(level), OtherRuleWeight(level));
		}
	}
	internal class Model
	{
		public readonly List<LevelData> Levels = new List<LevelData>();

		public readonly List<DungeonData> Dungeons = new List<DungeonData>();

		public readonly List<Candidate> Enemies = new List<Candidate>();

		public readonly List<Candidate> ScrapItems = new List<Candidate>();

		private readonly Dictionary<string, string> enemyMods = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<string, string> itemMods = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private static ConfigFile cachedConfig;

		public static ConfigFile LLLConfig
		{
			get
			{
				if (cachedConfig == null)
				{
					object? obj = (typeof(PatchedContent).Assembly.GetType("LethalLevelLoader.Tools.ConfigLoader")?.GetField("configFile", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null);
					cachedConfig = (ConfigFile)((obj is ConfigFile) ? obj : null);
				}
				return cachedConfig;
			}
		}

		public static bool ContentReady
		{
			get
			{
				if (Plugin.IsSetupComplete && LLLConfig != null)
				{
					return PatchedContent.ExtendedLevels.Count > 0;
				}
				return false;
			}
		}

		public int DirtyCount => Levels.Count((LevelData l) => l.Dirty) + Dungeons.Count((DungeonData d) => d.Dirty);

		public static Model Build()
		{
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			Model model = new Model();
			ConfigFile lLLConfig = LLLConfig;
			foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes)
			{
				if ((Object)(object)extendedEnemyType == (Object)null || (Object)(object)extendedEnemyType.EnemyType == (Object)null || string.IsNullOrEmpty(extendedEnemyType.EnemyType.enemyName))
				{
					continue;
				}
				string enemyName = extendedEnemyType.EnemyType.enemyName;
				if (!model.enemyMods.ContainsKey(enemyName))
				{
					string text = SafeModName((ExtendedContent)(object)extendedEnemyType);
					model.enemyMods[enemyName] = text;
					List<string> list = new List<string>();
					List<string> list2 = new List<string>();
					if (extendedEnemyType.EnemyType.isOutsideEnemy)
					{
						list.Add("outside");
						list2.Add("fora");
					}
					if (extendedEnemyType.EnemyType.isDaytimeEnemy)
					{
						list.Add("daytime");
						list2.Add("dia");
					}
					if (!extendedEnemyType.EnemyType.isOutsideEnemy && !extendedEnemyType.EnemyType.isDaytimeEnemy)
					{
						list.Add("inside");
						list2.Add("dentro");
					}
					model.Enemies.Add(new Candidate
					{
						Name = enemyName,
						Mod = text,
						Hint = new Txt(string.Join(", ", list), string.Join(", ", list2))
					});
				}
			}
			model.Enemies.Sort((Candidate a, Candidate b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				if ((Object)(object)extendedItem == (Object)null || (Object)(object)extendedItem.Item == (Object)null || string.IsNullOrEmpty(extendedItem.Item.itemName))
				{
					continue;
				}
				string itemName = extendedItem.Item.itemName;
				if (!model.itemMods.ContainsKey(itemName))
				{
					string text2 = SafeModName((ExtendedContent)(object)extendedItem);
					model.itemMods[itemName] = text2;
					if (extendedItem.Item.isScrap)
					{
						string text3 = $"${(float)extendedItem.Item.minValue / 2.5f:0}-{(float)extendedItem.Item.maxValue / 2.5f:0}";
						model.ScrapItems.Add(new Candidate
						{
							Name = itemName,
							Mod = text2,
							Hint = new Txt(text3, text3)
						});
					}
				}
			}
			model.ScrapItems.Sort((Candidate a, Candidate b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				if (!((Object)(object)extendedLevel == (Object)null) && !((Object)(object)extendedLevel.SelectableLevel == (Object)null))
				{
					LevelData levelData = new LevelData
					{
						Level = extendedLevel,
						Mod = SafeModName((ExtendedContent)(object)extendedLevel)
					};
					string section = (((int)((ExtendedContent)extendedLevel).ContentType == 0) ? "Vanilla Level:  " : "Custom Level:  ") + Extensions.StripSpecialCharacters(extendedLevel.SelectableLevel.PlanetName).Trim();
					levelData.Enable = Find<bool>(lLLConfig, section, "Enable Content Configuration");
					levelData.RoutePrice = Find<int>(lLLConfig, section, "General Settings - Planet Route Price");
					levelData.MinScrap = Find<int>(lLLConfig, section, "Scrap Settings - Minimum Scrap Item Spawns");
					levelData.MaxScrap = Find<int>(lLLConfig, section, "Scrap Settings - Maximum Scrap Item Spawns");
					levelData.MinValue = Find<int>(lLLConfig, section, "Scrap Settings - Minimum Total Scrap Value");
					levelData.MaxValue = Find<int>(lLLConfig, section, "Scrap Settings - Maximum Total Scrap Value");
					levelData.Scrap = Find<string>(lLLConfig, section, "Scrap Settings - Scrap Spawning List");
					levelData.PowerInside = Find<int>(lLLConfig, section, "Enemy Settings - Maximum Inside Enemy Power Count");
					levelData.PowerDay = Find<int>(lLLConfig, section, "Enemy Settings - Maximum Outside, Daytime Enemy Power Count");
					levelData.PowerNight = Find<int>(lLLConfig, section, "Enemy Settings - Maximum Outside, Nighttime Enemy Power Count");
					levelData.Inside = Find<string>(lLLConfig, section, "Enemy Settings - Inside Enemies Spawning List");
					levelData.Day = Find<string>(lLLConfig, section, "Enemy Settings - Outside Daytime Enemies Spawning List");
					levelData.Night = Find<string>(lLLConfig, section, "Enemy Settings - Outside Nighttime Enemies Spawning List");
					levelData.LockReason = LockReasonFor((ExtendedContent)(object)extendedLevel, extendedLevel.GenerateAutomaticConfigurationOptions, levelData.Enable != null && levelData.Inside != null && levelData.Scrap != null && levelData.RoutePrice != null, isMoon: true);
					levelData.Section = section;
					model.LoadDraft(levelData);
					model.Levels.Add(levelData);
				}
			}
			foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows)
			{
				if (!((Object)(object)extendedDungeonFlow == (Object)null) && !((Object)(object)extendedDungeonFlow.DungeonFlow == (Object)null))
				{
					DungeonData dungeonData = new DungeonData
					{
						Flow = extendedDungeonFlow,
						Mod = SafeModName((ExtendedContent)(object)extendedDungeonFlow)
					};
					string section2 = (((int)((ExtendedContent)extendedDungeonFlow).ContentType == 0) ? ("Vanilla Dungeon:  " + Extensions.StripSpecialCharacters(extendedDungeonFlow.DungeonName).Trim() + " (" + ((Object)extendedDungeonFlow.DungeonFlow).name + ")") : ("Custom Dungeon:  " + Extensions.StripSpecialCharacters(extendedDungeonFlow.DungeonName).Trim()));
					dungeonData.Enable = Find<bool>(lLLConfig, section2, "Enable Content Configuration");
					dungeonData.ModNames = Find<string>(lLLConfig, section2, "Dungeon Injection Settings - Manual Mod Names List");
					dungeonData.LevelNames = Find<string>(lLLConfig, section2, "Dungeon Injection Settings - Manual Level Names List");
					dungeonData.LevelTags = Find<string>(lLLConfig, section2, "Dungeon Injection Settings - Dynamic Level Tags List");
					dungeonData.RoutePrices = Find<string>(lLLConfig, section2, "Dungeon Injection Settings - Dynamic Route Price List");
					dungeonData.LockReason = (((Object)(object)extendedDungeonFlow.LevelMatchingProperties == (Object)null) ? new Txt("This interior has no selection rules (LevelMatchingProperties) in LLL.", "Este interior não tem regras de seleção (LevelMatchingProperties) no LLL.") : LockReasonFor((ExtendedContent)(object)extendedDungeonFlow, extendedDungeonFlow.GenerateAutomaticConfigurationOptions, dungeonData.Enable != null && dungeonData.LevelNames != null && dungeonData.ModNames != null && dungeonData.LevelTags != null && dungeonData.RoutePrices != null, isMoon: false));
					dungeonData.Section = section2;
					LoadDraft(dungeonData);
					model.Dungeons.Add(dungeonData);
				}
			}
			foreach (IGrouping<string, LevelData> item in from l in model.Levels
				where l.LockReason == null
				group l by l.Section into g
				where g.Count() > 1
				select g)
			{
				string text4 = string.Join(", ", item.Select((LevelData x) => x.Mod));
				foreach (LevelData item2 in item)
				{
					item2.LockReason = new Txt("There is more than one moon called \"" + item2.Name + "\" (" + text4 + "). They share the same section in LLL's config, so editing one would change the other.", "Existe mais de uma lua chamada \"" + item2.Name + "\" (" + text4 + "). Elas dividem a mesma seção no config do LLL, então editar uma mudaria a outra.");
				}
			}
			foreach (IGrouping<string, DungeonData> item3 in from d in model.Dungeons
				where d.LockReason == null
				group d by d.Section into g
				where g.Count() > 1
				select g)
			{
				string text5 = string.Join(", ", item3.Select((DungeonData x) => x.Mod));
				foreach (DungeonData item4 in item3)
				{
					item4.LockReason = new Txt("There is more than one interior called \"" + item4.Name + "\" (" + text5 + "). They share the same section in LLL's config, so editing one would change the other.", "Existe mais de um interior chamado \"" + item4.Name + "\" (" + text5 + "). Eles dividem a mesma seção no config do LLL, então editar um mudaria o outro.");
				}
			}
			return model;
		}

		private static Txt LockReasonFor(ExtendedContent content, bool autoConfig, bool entriesFound, bool isMoon)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			string text = (isMoon ? "moon" : "interior");
			if (!autoConfig)
			{
				if ((int)content.ContentType == 3)
				{
					return new Txt("This " + text + " comes from DawnLib, which doesn't use LLL's config. Configure it through DawnLib or the mod's own config.", isMoon ? "Esta lua vem do DawnLib, que não usa o config do LLL. Configure pelo config do próprio mod/DawnLib." : "Este interior vem do DawnLib, que não usa o config do LLL. Configure pelo config do próprio mod/DawnLib.");
				}
				return new Txt("The author of this " + text + " disabled LLL's automatic config (it probably has its own config).", isMoon ? "O autor desta lua desativou a configuração automática do LLL (provavelmente ela tem um config próprio)." : "O autor deste interior desativou a configuração automática do LLL (provavelmente ele tem um config próprio).");
			}
			if (!entriesFound)
			{
				return new Txt("LLL didn't create a section for this " + text + " in LethalLevelLoader.cfg (it may have been registered after LLL read the config). Restart the game and join a lobby.", isMoon ? "O LLL não criou a seção desta lua no LethalLevelLoader.cfg (ela pode ter sido registrada depois que o LLL leu o config). Reinicie o jogo e entre num lobby." : "O LLL não criou a seção deste interior no LethalLevelLoader.cfg (ele pode ter sido registrado depois que o LLL leu o config). Reinicie o jogo e entre num lobby.");
			}
			return null;
		}

		private static string SafeModName(ExtendedContent c)
		{
			try
			{
				return ((Object)(object)c.ExtendedMod != (Object)null) ? c.ExtendedMod.ModName : "?";
			}
			catch
			{
				return "?";
			}
		}

		private static ConfigEntry<T> Find<T>(ConfigFile cfg, string section, string key)
		{
			foreach (ConfigDefinition key2 in cfg.Keys)
			{
				if (key2.Key == key && Clean(key2.Section) == section)
				{
					return cfg[key2] as ConfigEntry<T>;
				}
			}
			return null;
		}

		private static string Clean(string s)
		{
			return s.Replace("\u200b", "").Trim();
		}

		public void LoadDraft(LevelData ld)
		{
			SelectableLevel selectableLevel = ld.Level.SelectableLevel;
			ld.DInside = (from e in selectableLevel.Enemies
				where (Object)(object)e?.enemyType != (Object)null
				select new Weighted(e.enemyType.enemyName, e.rarity, EnemyMod(e.enemyType.enemyName))).ToList();
			ld.DDay = (from e in selectableLevel.DaytimeEnemies
				where (Object)(object)e?.enemyType != (Object)null
				select new Weighted(e.enemyType.enemyName, e.rarity, EnemyMod(e.enemyType.enemyName))).ToList();
			ld.DNight = (from e in selectableLevel.OutsideEnemies
				where (Object)(object)e?.enemyType != (Object)null
				select new Weighted(e.enemyType.enemyName, e.rarity, EnemyMod(e.enemyType.enemyName))).ToList();
			ld.DScrap = (from s in selectableLevel.spawnableScrap
				where (Object)(object)s?.spawnableItem != (Object)null
				select new Weighted(s.spawnableItem.itemName, s.rarity, ItemMod(s.spawnableItem.itemName))).ToList();
			ld.DRoutePrice = ld.Level.RoutePrice;
			ld.DMinScrap = selectableLevel.minScrap;
			ld.DMaxScrap = selectableLevel.maxScrap;
			ld.DMinValue = selectableLevel.minTotalScrapValue;
			ld.DMaxValue = selectableLevel.maxTotalScrapValue;
			ld.DPowerInside = selectableLevel.maxEnemyPowerCount;
			ld.DPowerDay = selectableLevel.maxDaytimeEnemyPowerCount;
			ld.DPowerNight = selectableLevel.maxOutsideEnemyPowerCount;
			ld.Dirty = false;
		}

		public static void LoadDraft(DungeonData dd)
		{
			LevelMatchingProperties levelMatchingProperties = dd.Flow.LevelMatchingProperties;
			dd.DPlanets = (((Object)(object)levelMatchingProperties != (Object)null) ? levelMatchingProperties.planetNames.Select((StringWithRarity s) => new Weighted(s.Name, s.Rarity)).ToList() : new List<Weighted>());
			dd.DMods = (((Object)(object)levelMatchingProperties != (Object)null) ? ((MatchingProperties)levelMatchingProperties).modNames.Select((StringWithRarity s) => new Weighted(s.Name, s.Rarity)).ToList() : new List<Weighted>());
			dd.DTags = (((Object)(object)levelMatchingProperties != (Object)null) ? levelMatchingProperties.levelTags.Select((StringWithRarity s) => new Weighted(s.Name, s.Rarity)).ToList() : new List<Weighted>());
			dd.DPrices = (((Object)(object)levelMatchingProperties != (Object)null) ? levelMatchingProperties.currentRoutePrice.Select((Vector2WithRarity v) => new PriceRange
			{
				Min = Mathf.RoundToInt(v.Min),
				Max = Mathf.RoundToInt(v.Max),
				Rarity = v.Rarity
			}).ToList() : new List<PriceRange>());
			dd.Dirty = false;
		}

		public string EnemyMod(string name)
		{
			if (!enemyMods.TryGetValue(name, out var value))
			{
				return "?";
			}
			return value;
		}

		public string ItemMod(string name)
		{
			if (!itemMods.TryGetValue(name, out var value))
			{
				return "?";
			}
			return value;
		}

		public void ConvertRulesToManual(DungeonData dd)
		{
			List<(LevelData l, int w)> list = Levels.Select((LevelData l) => (l: l, w: Math.Max(dd.ManualWeight(l), dd.ConfigurableRuleWeight(l)))).ToList();
			dd.DMods.Clear();
			dd.DTags.Clear();
			dd.DPrices.Clear();
			dd.DPlanets.Clear();
			foreach (var (levelData, num) in list)
			{
				if (num > 0)
				{
					dd.DPlan