Decompiled source of SpawnPanel v0.3.0

plugins/SpawnPanel.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;

[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("SpawnPanel")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+87711078433e7dbe8004349d45feae143538e9b4")]
[assembly: AssemblyProduct("SpawnPanel")]
[assembly: AssemblyTitle("SpawnPanel")]
[assembly: AssemblyVersion("1.0.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 SpawnPanel
{
	internal static class Icons
	{
		internal static Color? AverageColor(GameObject prefab)
		{
			//IL_0013: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			Vector4 val = Vector4.zero;
			float num = 0f;
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				if (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))
				{
					continue;
				}
				Bounds bounds = val2.bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				float num2 = ((Vector3)(ref size)).sqrMagnitude + 0.01f;
				Material[] sharedMaterials = val2.sharedMaterials;
				foreach (Material val3 in sharedMaterials)
				{
					if (!((Object)(object)val3 == (Object)null))
					{
						Color val4 = (val3.HasProperty("_BaseColor") ? val3.GetColor("_BaseColor") : (val3.HasProperty("_Color") ? val3.color : Color.white));
						Texture val5 = (val3.HasProperty("_BaseColorMap") ? val3.GetTexture("_BaseColorMap") : val3.mainTexture);
						val += Color.op_Implicit(val4 * (((Object)(object)val5 != (Object)null) ? AverageTexture(val5) : Color.white)) * num2;
						num += num2;
					}
				}
			}
			if (num <= 0f)
			{
				return null;
			}
			return Color.op_Implicit(val / num);
		}

		private static Color AverageTexture(Texture tex)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture temporary = RenderTexture.GetTemporary(16, 16, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			Graphics.Blit(tex, temporary);
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, 16f, 16f), 0, 0);
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			Color[] pixels = val.GetPixels();
			Object.Destroy((Object)val);
			Vector4 val2 = pixels.Aggregate(Vector4.zero, (Vector4 a, Color c) => a + Color.op_Implicit(c)) / (float)pixels.Length;
			return new Color(val2.x, val2.y, val2.z, 1f);
		}

		internal static Color FromName(string name)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			return Color.HSVToRGB((float)(name.Aggregate(7, (int h, char c) => h * 31 + c) & 0xFFFF) / 65535f, 0.6f, 0.85f);
		}
	}
	internal class PanelUI : MonoBehaviour
	{
		private enum View
		{
			Planets,
			Enemies,
			Interiors
		}

		internal static MenuManager mainMenu;

		internal static QuickMenuManager quickMenu;

		internal static PanelUI Instance;

		private static readonly string[] weathers = Enum.GetNames(typeof(LevelWeatherType));

		private static readonly Dictionary<string, string> weatherFr = new Dictionary<string, string>
		{
			["None"] = "CLAIR",
			["DustClouds"] = "POUSSIÈRE",
			["Rainy"] = "PLUIE",
			["Stormy"] = "ORAGE",
			["Foggy"] = "BROUILLARD",
			["Flooded"] = "INONDÉ",
			["Eclipsed"] = "ÉCLIPSE"
		};

		private static readonly (View view, string icon, string title)[] sideButtons = new(View, string, string)[3]
		{
			(View.Planets, "planet", "PLANÈTES"),
			(View.Enemies, "monster", "MONSTRES"),
			(View.Interiors, "interior", "INTÉRIEURS")
		};

		private bool open;

		private View view = View.Enemies;

		private int weather = Array.IndexOf(Enum.GetNames(typeof(LevelWeatherType)), "None");

		private string planet = "*";

		private Vector2 scroll;

		private EventSystem pausedEvents;

		private Texture2D circle;

		private Texture2D grid;

		private readonly Rect win = new Rect(150f, 70f, 1620f, 940f);

		private readonly HashSet<string> expanded = new HashSet<string>();

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

		private float slide = -1f;

		private Settings S => Plugin.S;

		private bool InGame => (Object)(object)quickMenu != (Object)null;

		private bool CanOpen
		{
			get
			{
				if (!InGame)
				{
					return AtMainMenu;
				}
				return quickMenu.isMenuOpen;
			}
		}

		private bool AtMainMenu
		{
			get
			{
				if ((Object)(object)mainMenu != (Object)null)
				{
					return !mainMenu.isInitScene;
				}
				return false;
			}
		}

		private string PlanetLabel
		{
			get
			{
				if (!(planet == "*"))
				{
					return planet.ToUpper();
				}
				return "TOUTES LES PLANÈTES";
			}
		}

		private static string Fr(string w)
		{
			if (!weatherFr.TryGetValue(w, out var value))
			{
				return w.ToUpper();
			}
			return value;
		}

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			if (open)
			{
				if (InGame && !quickMenu.isMenuOpen)
				{
					SetOpen(value: false);
					return;
				}
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		private void OnGUI()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			Theme.Init();
			GUI.skin = Theme.Skin;
			GUI.matrix = Matrix4x4.Scale(Vector3.one * (float)Screen.height / 1080f);
			if (!open)
			{
				if (CanOpen)
				{
					DrawOpenButton();
				}
			}
			else
			{
				DrawPanel();
			}
		}

		private void DrawOpenButton()
		{
			//IL_0080: 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)
			float num = (float)Screen.width * 1080f / (float)Screen.height;
			float num2 = (S.ButtonFolded ? 1 : 0);
			slide = ((slide < 0f) ? num2 : Mathf.MoveTowards(slide, num2, Time.unscaledDeltaTime * 4f));
			float num3 = num - 20f - 300f + slide * 320f;
			if (GUI.Button(new Rect(num3 - 45f, 20f, 40f, 50f), S.ButtonFolded ? "<" : ">", Theme.Button))
			{
				S.ButtonFolded = !S.ButtonFolded;
				S.Save();
			}
			if (slide < 1f && GUI.Button(new Rect(num3, 20f, 300f, 50f), "PANNEAU DE SPAWNS", Theme.Button))
			{
				SetOpen(value: true);
			}
		}

		private void SetOpen(bool value)
		{
			open = value;
			if (value)
			{
				Plugin.RememberCatalog();
				pausedEvents = EventSystem.current;
				if ((Object)(object)pausedEvents != (Object)null)
				{
					((Behaviour)pausedEvents).enabled = false;
				}
			}
			else
			{
				S.Save();
				if ((Object)(object)pausedEvents != (Object)null)
				{
					((Behaviour)pausedEvents).enabled = true;
				}
			}
		}

		private void DrawPanel()
		{
			//IL_0001: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: 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_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: 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_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			GUI.Box(win, GUIContent.none, Theme.Frame);
			if ((Object)(object)grid == (Object)null)
			{
				grid = MakeGrid();
			}
			Rect val = win;
			float num = ((Rect)(ref val)).x + 8f;
			val = win;
			float num2 = ((Rect)(ref val)).y + 8f;
			val = win;
			float num3 = ((Rect)(ref val)).width - 16f;
			val = win;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(num, num2, num3, ((Rect)(ref val)).height - 16f);
			GUI.DrawTextureWithTexCoords(val2, (Texture)(object)grid, new Rect(0f, 0f, ((Rect)(ref val2)).width / (float)((Texture)grid).width, ((Rect)(ref val2)).height / (float)((Texture)grid).height));
			Rect val3 = default(Rect);
			for (int i = 0; i < sideButtons.Length; i++)
			{
				(View, string, string) tuple = sideButtons[i];
				val = win;
				float num4 = ((Rect)(ref val)).x + 40f;
				val = win;
				((Rect)(ref val3))..ctor(num4, ((Rect)(ref val)).y + 50f + (float)(i * 210), 180f, 180f);
				bool flag = view == tuple.Item1;
				if (GUI.Button(val3, GUIContent.none, flag ? Theme.PanelOn : Theme.Panel))
				{
					view = tuple.Item1;
					scroll = Vector2.zero;
				}
				GUI.DrawTexture(new Rect(((Rect)(ref val3)).x + 35f, ((Rect)(ref val3)).y + 30f, 110f, 110f), (Texture)(object)Theme.Icon(tuple.Item2));
				GUI.Label(new Rect(((Rect)(ref val3)).x, ((Rect)(ref val3)).y + 140f, ((Rect)(ref val3)).width, 30f), tuple.Item3, Theme.Center(Theme.Small));
				if (flag)
				{
					GUI.DrawTexture(new Rect(((Rect)(ref val3)).xMax - 4f, ((Rect)(ref val3)).y + 72f, 30f, 36f), (Texture)(object)Theme.Icon("chevron"));
				}
			}
			val = win;
			float num5 = ((Rect)(ref val)).x + 40f;
			val = win;
			if (GUI.Button(new Rect(num5, ((Rect)(ref val)).yMax - 160f, 180f, 50f), "ENREGISTRER", Theme.Button))
			{
				S.Save();
			}
			val = win;
			float num6 = ((Rect)(ref val)).x + 40f;
			val = win;
			if (GUI.Button(new Rect(num6, ((Rect)(ref val)).yMax - 95f, 180f, 50f), "RÉINITIALISER", Theme.Button))
			{
				ResetView();
			}
			val = win;
			float num7 = ((Rect)(ref val)).x + 260f;
			val = win;
			float num8 = ((Rect)(ref val)).y + 30f;
			val = win;
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(num7, num8, ((Rect)(ref val)).width - 400f, 110f);
			GUI.Box(val4, GUIContent.none, Theme.PanelOn);
			GUI.DrawTexture(new Rect(((Rect)(ref val4)).x + 25f, ((Rect)(ref val4)).y + 15f, 80f, 80f), (Texture)(object)Theme.Icon(sideButtons[(int)view].icon));
			string text = ((view == View.Planets) ? "PLANÈTES" : ((view == View.Enemies) ? "MONSTRES" : "INTÉRIEURS"));
			GUI.Label(new Rect(((Rect)(ref val4)).x + 125f, ((Rect)(ref val4)).y + 10f, 700f, 60f), text, Theme.Title);
			GUI.Label(new Rect(((Rect)(ref val4)).x + 128f, ((Rect)(ref val4)).y + 66f, 700f, 30f), (view == View.Planets) ? "CHOISIS UNE PLANÈTE OU LE RÉGLAGE GLOBAL" : PlanetLabel, Theme.Heading);
			for (int j = 0; j < 5; j++)
			{
				GUI.DrawTexture(new Rect(((Rect)(ref val4)).xMax - 330f + (float)(j * 42), ((Rect)(ref val4)).y + 30f, 50f, 50f), (Texture)(object)Theme.Icon("stripe"));
			}
			val = win;
			float num9 = ((Rect)(ref val)).xMax - 125f;
			val = win;
			if (GUI.Button(new Rect(num9, ((Rect)(ref val)).y + 35f, 100f, 100f), GUIContent.none, Theme.Octo))
			{
				SetOpen(value: false);
			}
			val = win;
			float num10 = ((Rect)(ref val)).xMax - 105f;
			val = win;
			GUI.DrawTexture(new Rect(num10, ((Rect)(ref val)).y + 55f, 60f, 60f), (Texture)(object)Theme.Icon("close"));
			if (InGame && !GameNetworkManager.Instance.isHostingGame)
			{
				GUI.Label(new Rect(((Rect)(ref val4)).x + 700f, ((Rect)(ref val4)).y + 66f, 500f, 30f), "TU N'ES PAS L'HÔTE : SANS EFFET", Theme.Heading);
			}
			val = win;
			float num11 = ((Rect)(ref val)).x + 260f;
			val = win;
			float num12 = ((Rect)(ref val)).y + 160f;
			val = win;
			float num13 = ((Rect)(ref val)).width - 290f;
			val = win;
			GUILayout.BeginArea(new Rect(num11, num12, num13, ((Rect)(ref val)).height - 190f));
			scroll = GUILayout.BeginScrollView(scroll, false, true, Array.Empty<GUILayoutOption>());
			if (S.Planets.Count == 0)
			{
				GUILayout.Label("CATALOGUE VIDE : LANCE UNE PARTIE UNE FOIS, LE MOD RETIENDRA LES PLANÈTES, MONSTRES ET INTÉRIEURS.", Theme.Heading, Array.Empty<GUILayoutOption>());
			}
			if (view == View.Planets)
			{
				DrawPlanets();
			}
			else if (view == View.Enemies)
			{
				if (planet == "*")
				{
					DrawEnemiesGlobal();
				}
				else
				{
					DrawEnemiesPlanet();
				}
			}
			else
			{
				DrawInteriors();
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();
		}

		private void DrawPlanets()
		{
			foreach (string p in new string[1] { "*" }.Concat(S.Planets.Keys))
			{
				Card(delegate
				{
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					//IL_017c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0181: Unknown result type (might be due to invalid IL or missing references)
					Portrait((p == "*") ? "★" : p, IconColor(p));
					GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
					GUILayout.Label((p == "*") ? "TOUTES LES PLANÈTES (GLOBAL)" : p.ToUpper(), Theme.Name, Array.Empty<GUILayoutOption>());
					if (S.Planets.TryGetValue(p, out var value))
					{
						GUILayout.Label($"{value.Enemies.Sum((Dictionary<string, int> l) => l.Count)} MONSTRES POSSIBLES  ·  BUDGET {value.Budget[0]} / {value.Budget[1]} / {value.Budget[2]}", Theme.Small, Array.Empty<GUILayoutOption>());
					}
					else
					{
						GUILayout.Label("UN % PAR MONSTRE OU INTÉRIEUR, APPLIQUÉ PARTOUT", Theme.Small, Array.Empty<GUILayoutOption>());
					}
					GUILayout.EndVertical();
					GUILayout.FlexibleSpace();
					if (Chevron(open: false, planet == p))
					{
						planet = p;
						view = View.Enemies;
						scroll = Vector2.zero;
					}
				}, planet == p);
			}
		}

		private void DrawEnemiesGlobal()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Hint("CHANCE GLOBALE : 100 % = NORMAL, 200 % = DEUX FOIS PLUS SOUVENT, 0 % = JAMAIS. S'APPLIQUE À TOUTES LES PLANÈTES.");
			foreach (KeyValuePair<string, EnemyInfo> kv in S.Enemies)
			{
				string name = kv.Key;
				string key = name + "|*";
				ItemCard(name, EnemyColor(name), key, $"CHANCE GLOBALE {Settings.Pct(S.EnemyGlobalPct, name)} %", delegate
				{
					IntSetting(S.EnemyGlobalPct, name, Settings.Pct(S.EnemyGlobalPct, name), 0, 300, 560f);
				}, delegate
				{
					Labeled("PUISSANCE", delegate
					{
						FloatSetting(S.EnemyPower, key, Plugin.PlanetOrGlobal(S.EnemyPower, name, "", kv.Value.Power), 0f, 10f, 300f);
					});
					Labeled("MAX EN MÊME TEMPS", delegate
					{
						IntSetting(S.EnemyMaxCount, key, Plugin.PlanetOrGlobal(S.EnemyMaxCount, name, "", kv.Value.MaxCount), 0, 20, 300f);
					});
				});
			}
		}

		private void DrawEnemiesPlanet()
		{
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			if (!S.Planets.TryGetValue(planet, out var info))
			{
				return;
			}
			Hint("BUDGET : LA SOMME DES PUISSANCES DES MONSTRES PRÉSENTS NE PEUT PAS LE DÉPASSER. IL SE REMPLIT AU FIL DE LA JOURNÉE.");
			Card(delegate
			{
				int i;
				for (i = 0; i < 3; i++)
				{
					Labeled(Settings.BudgetNames[i].ToUpper(), delegate
					{
						IntSetting(S.PlanetBudget, planet + "|" + i, S.PlanetBudget.TryGetValue(planet + "|" + i, out var value) ? value : info.Budget[i], 0, 50, 250f);
					});
				}
			});
			for (int num = 0; num < 3; num++)
			{
				Dictionary<string, int> dictionary = info.Enemies[num];
				if (dictionary.Count == 0)
				{
					continue;
				}
				int num2 = dictionary.Sum((KeyValuePair<string, int> keyValuePair) => Plugin.FinalEnemyWeight(keyValuePair.Key, planet, keyValuePair.Value));
				GUILayout.Space(10f);
				GUILayout.Label(Settings.ListNames[num].ToUpper() + "   —   CHANCE = POIDS / SOMME DES POIDS DE LA LISTE", Theme.Heading, Array.Empty<GUILayoutOption>());
				foreach (KeyValuePair<string, int> e in dictionary.OrderByDescending((KeyValuePair<string, int> keyValuePair) => Plugin.FinalEnemyWeight(keyValuePair.Key, planet, keyValuePair.Value)))
				{
					string name = e.Key;
					string key = name + "|" + planet;
					int num3 = Plugin.FinalEnemyWeight(name, planet, e.Value);
					S.Enemies.TryGetValue(name, out var st);
					ItemCard(name, EnemyColor(name), key, $"{((num2 > 0) ? (100f * (float)num3 / (float)num2) : 0f):0.#} % DE CHANCE  ·  POIDS DU JEU {e.Value}  ·  FINAL {num3}", delegate
					{
						IntSetting(S.EnemyWeight, key, S.EnemyWeight.TryGetValue(key, out var value) ? value : e.Value, 0, 300, 560f);
					}, delegate
					{
						Labeled("PUISSANCE", delegate
						{
							FloatSetting(S.EnemyPower, key, Plugin.PlanetOrGlobal(S.EnemyPower, name, planet, st?.Power ?? 1f), 0f, 10f, 300f);
						});
						Labeled("MAX EN MÊME TEMPS", delegate
						{
							IntSetting(S.EnemyMaxCount, key, Plugin.PlanetOrGlobal(S.EnemyMaxCount, name, planet, st?.MaxCount ?? 1), 0, 20, 300f);
						});
					});
				}
			}
		}

		private void DrawInteriors()
		{
			//IL_0085: 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)
			if (S.Interiors.Count == 0)
			{
				Hint("AUCUN INTÉRIEUR CONNU : LANCE UNE PARTIE UNE FOIS (LETHALLEVELLOADER NE LES CHARGE QU'EN JEU).");
				return;
			}
			if (planet == "*")
			{
				Hint("% GLOBAL APPLIQUÉ PARTOUT. DÉPLIE (>) POUR LE % PAR MÉTÉO.");
				{
					foreach (string name in S.Interiors)
					{
						ItemCard(name, IconColor(name), name + "|*", $"CHANCE GLOBALE {Settings.Pct(S.InteriorGlobalPct, name)} %", delegate
						{
							IntSetting(S.InteriorGlobalPct, name, Settings.Pct(S.InteriorGlobalPct, name), 0, 300, 560f);
						}, delegate
						{
							GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
							string[] array = weathers;
							foreach (string w in array)
							{
								Labeled("SI " + Fr(w) + " %", delegate
								{
									IntSetting(S.InteriorWeatherPct, name + "|" + w, Settings.Pct(S.InteriorWeatherPct, name + "|" + w), 0, 300, 420f);
								});
							}
							GUILayout.EndVertical();
						});
					}
					return;
				}
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("MÉTÉO :", Theme.Heading, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) });
			for (int num = 0; num < weathers.Length; num++)
			{
				if (GUILayout.Toggle(weather == num, Fr(weathers[num]), Theme.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }))
				{
					weather = num;
				}
			}
			GUILayout.EndHorizontal();
			if (!S.Planets.TryGetValue(planet, out var info))
			{
				return;
			}
			string wName = weathers[weather];
			int num2 = S.Interiors.Sum((string n) => Plugin.FinalInteriorWeight(n, planet, wName, Orig(n)));
			foreach (string name2 in S.Interiors.OrderByDescending((string n) => Plugin.FinalInteriorWeight(n, planet, wName, Orig(n))))
			{
				string key = name2 + "|" + planet;
				int num3 = Plugin.FinalInteriorWeight(name2, planet, wName, Orig(name2));
				ItemCard(name2, IconColor(name2), key, $"{((num2 > 0) ? (100f * (float)num3 / (float)num2) : 0f):0.#} % DE CHANCE ({Fr(wName)})  ·  POIDS DU JEU {Orig(name2)}  ·  FINAL {num3}", delegate
				{
					IntSetting(S.InteriorWeight, key, S.InteriorWeight.TryGetValue(key, out var value) ? value : Orig(name2), 0, 300, 560f);
				}, null);
			}
			int Orig(string n)
			{
				if (!info.Interiors.TryGetValue(n, out var value))
				{
					return 0;
				}
				return value;
			}
		}

		private void ResetView()
		{
			if (view == View.Enemies)
			{
				S.EnemyGlobalPct.Clear();
				S.EnemyWeight.Clear();
				S.EnemyPower.Clear();
				S.EnemyMaxCount.Clear();
				S.PlanetBudget.Clear();
			}
			else
			{
				if (view != View.Interiors)
				{
					return;
				}
				S.InteriorGlobalPct.Clear();
				S.InteriorWeight.Clear();
				S.InteriorWeatherPct.Clear();
			}
			bool enemies = view == View.Enemies;
			S.Disabled.RemoveWhere((string k) => S.Enemies.ContainsKey(k.Split('|')[0]) == enemies);
			buffers.Clear();
		}

		private void ItemCard(string name, Color color, string key, string info, Action mainSetting, Action details)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			bool on = !S.Disabled.Contains(key);
			Card(delegate
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				Portrait(name, color);
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				GUILayout.Label(name.ToUpper(), Theme.Name, Array.Empty<GUILayoutOption>());
				GUILayout.Label(on ? info : "DÉSACTIVÉ (POIDS GARDÉ, COMPTE POUR 0)", Theme.Small, Array.Empty<GUILayoutOption>());
				mainSetting();
				GUILayout.EndVertical();
				GUILayout.FlexibleSpace();
				if (Switch(on))
				{
					if (on)
					{
						S.Disabled.Add(key);
					}
					else
					{
						S.Disabled.Remove(key);
					}
				}
				if (details != null && Chevron(expanded.Contains(key), active: false))
				{
					if (!expanded.Remove(key))
					{
						expanded.Add(key);
					}
				}
				else if (details == null)
				{
					GUILayout.Space(60f);
				}
				GUILayout.EndHorizontal();
				if (details != null && expanded.Contains(key))
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Space(150f);
					details();
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
			});
		}

		private void Card(Action content, bool highlight = false)
		{
			GUILayout.BeginHorizontal(highlight ? Theme.PanelOn : Theme.Row, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinHeight(110f) });
			content();
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
		}

		private void Hint(string text)
		{
			GUILayout.Label(text, Theme.Small, Array.Empty<GUILayoutOption>());
		}

		private void Labeled(string label, Action field)
		{
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(430f) });
			GUILayout.Label(label, Theme.Small, Array.Empty<GUILayoutOption>());
			field();
			GUILayout.EndVertical();
		}

		private void Portrait(string name, Color color)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			Rect rect = GUILayoutUtility.GetRect(130f, 90f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(130f),
				GUILayout.Height(90f)
			});
			GUI.Box(rect, GUIContent.none, Theme.Box);
			if ((Object)(object)circle == (Object)null)
			{
				circle = Theme.Circle();
			}
			Rect val = new Rect(((Rect)(ref rect)).center.x - 34f, ((Rect)(ref rect)).center.y - 34f, 68f, 68f);
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(val, (Texture)(object)circle);
			GUI.color = color2;
			GUIStyle val2 = Theme.Center(Theme.Title);
			val2.fontSize = 36;
			val2.normal.textColor = ((((Color)(ref color)).grayscale > 0.55f) ? Color.black : Color.white);
			string text = name.TrimStart("0123456789 ".ToCharArray()) + name + "?";
			GUI.Label(val, text.Substring(0, 1).ToUpper(), val2);
			GUILayout.Space(16f);
		}

		private bool Switch(bool on)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(100f, 56f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(100f),
				GUILayout.Height(56f)
			});
			GUI.DrawTexture(rect, (Texture)(object)(on ? Theme.ToggleOn : Theme.ToggleOff));
			GUI.DrawTexture(new Rect(on ? (((Rect)(ref rect)).xMax - 50f) : (((Rect)(ref rect)).x + 10f), ((Rect)(ref rect)).y + 8f, 40f, 40f), (Texture)(object)Theme.Knob);
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private bool Chevron(bool open, bool active)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(60f, 60f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(60f),
				GUILayout.Height(60f)
			});
			Color color = GUI.color;
			if (!active && ((Rect)(ref rect)).Contains(Event.current.mousePosition))
			{
				GUI.color = new Color(1.3f, 1.3f, 1.3f);
			}
			GUI.DrawTexture(rect, (Texture)(object)Theme.Icon(open ? "chevron_down" : "chevron"));
			GUI.color = color;
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private Color EnemyColor(string name)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!S.Enemies.TryGetValue(name, out var value) || !ColorUtility.TryParseHtmlString(value.Color, ref result))
			{
				return IconColor(name);
			}
			return result;
		}

		private static Color IconColor(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Icons.FromName(name);
		}

		private void IntSetting(Dictionary<string, int> d, string key, int shown, int min, int max, float width)
		{
			int num = Mathf.RoundToInt(NumberField(d.GetHashCode() + key, shown, min, max, 0, width));
			if (num != shown)
			{
				d[key] = num;
			}
		}

		private void FloatSetting(Dictionary<string, float> d, string key, float shown, float min, float max, float width)
		{
			float num = NumberField(d.GetHashCode() + key, shown, min, max, 1, width);
			if (Math.Abs(num - shown) > 0.001f)
			{
				d[key] = num;
			}
		}

		private float NumberField(string key, float value, float min, float max, int decimals, float width)
		{
			//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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			Rect rect = GUILayoutUtility.GetRect(width, 40f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(width),
				GUILayout.Height(40f)
			});
			float num = Mathf.InverseLerp(min, max, value);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 12f, ((Rect)(ref rect)).width, 16f);
			if ((int)Event.current.type == 7)
			{
				Theme.TrackStyle.Draw(val, false, false, false, false);
				float num2 = ((Rect)(ref rect)).x + num * (((Rect)(ref rect)).width - 26f);
				if (num > 0f)
				{
					Theme.BarStyle.Draw(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, num2 + 13f - ((Rect)(ref val)).x, ((Rect)(ref val)).height), false, false, false, false);
				}
				GUI.DrawTexture(new Rect(num2 - 7f, ((Rect)(ref rect)).y - 2f, 40f, 44f), (Texture)(object)Theme.Thumb);
			}
			float num3 = GUI.HorizontalSlider(rect, value, min, max, GUIStyle.none, Theme.InvisibleThumb);
			if (Math.Abs(num3 - value) > 0.0001f)
			{
				value = (float)Math.Round(num3, decimals);
				buffers[key] = Format(value);
			}
			GUILayout.Space(14f);
			if (!buffers.TryGetValue(key, out var value2))
			{
				value2 = Format(value);
			}
			string text = GUILayout.TextField(value2, Theme.Field, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(80f),
				GUILayout.Height(40f)
			});
			buffers[key] = text;
			if (text != value2 && float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				value = Mathf.Clamp((float)Math.Round(result, decimals), min, max);
			}
			GUILayout.EndHorizontal();
			return value;
			string Format(float f)
			{
				return f.ToString((decimals == 0) ? "0" : "0.#", CultureInfo.InvariantCulture);
			}
		}

		private static Texture2D MakeGrid()
		{
			//IL_0004: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_005b: 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)
			Texture2D val = new Texture2D(48, 48)
			{
				wrapMode = (TextureWrapMode)0,
				hideFlags = (HideFlags)61
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(Theme.Green.r, Theme.Green.g, Theme.Green.b, 0.05f);
			for (int i = 0; i < 48; i++)
			{
				for (int j = 0; j < 48; j++)
				{
					val.SetPixel(i, j, (i == 0 || j == 0) ? val2 : Color.clear);
				}
			}
			val.Apply();
			return val;
		}

		internal IEnumerator AutoScreenshots(string dir)
		{
			Directory.CreateDirectory(dir);
			yield return (object)new WaitForSecondsRealtime(6f);
			bool folded = S.ButtonFolded;
			(bool, string)[] array = new(bool, string)[2]
			{
				(false, "bouton_deplie.png"),
				(true, "bouton_replie.png")
			};
			for (int i = 0; i < array.Length; i++)
			{
				var (buttonFolded, file) = array[i];
				S.ButtonFolded = buttonFolded;
				yield return (object)new WaitForSecondsRealtime(1.5f);
				ScreenCapture.CaptureScreenshot(Path.Combine(dir, file));
				Plugin.Log.LogInfo((object)("Capture : " + file));
				yield return null;
			}
			S.ButtonFolded = folded;
			SetOpen(value: true);
			string item = S.Planets.Keys.FirstOrDefault((string p) => S.Planets[p].Enemies.Any((Dictionary<string, int> l) => l.Count > 0)) ?? "*";
			string text = S.Enemies.Keys.FirstOrDefault();
			if (text != null)
			{
				expanded.Add(text + "|*");
			}
			(View, string, string)[] array2 = new(View, string, string)[4]
			{
				(View.Enemies, "*", "monstres_global.png"),
				(View.Enemies, item, "monstres_planete.png"),
				(View.Planets, item, "planetes.png"),
				(View.Interiors, item, "interieurs_planete.png")
			};
			(View view, string planet, string file)[] array3 = array2;
			for (int i = 0; i < array3.Length; i++)
			{
				(View view, string planet, string file) s = array3[i];
				(view, planet, _) = s;
				yield return (object)new WaitForSecondsRealtime(1.5f);
				ScreenCapture.CaptureScreenshot(Path.Combine(dir, s.file));
				Plugin.Log.LogInfo((object)("Capture : " + s.file));
				yield return null;
				yield return null;
			}
			yield return (object)new WaitForSecondsRealtime(3f);
			SetOpen(value: false);
			Application.Quit();
		}
	}
	[HarmonyPatch(typeof(MenuManager), "Start")]
	internal static class MainMenuPatch
	{
		private static bool shotsDone;

		internal static string ScreenshotDir()
		{
			string[] commandLineArgs = Environment.GetCommandLineArgs();
			int num = Array.IndexOf(commandLineArgs, "--spawnpanel-screenshot");
			if (num < 0 || num + 1 >= commandLineArgs.Length)
			{
				return null;
			}
			return commandLineArgs[num + 1];
		}

		private static void Postfix(MenuManager __instance)
		{
			PanelUI.mainMenu = __instance;
			string text = ScreenshotDir();
			if (text != null && !shotsDone && !__instance.isInitScene)
			{
				shotsDone = true;
				((MonoBehaviour)PanelUI.Instance).StartCoroutine(PanelUI.Instance.AutoScreenshots(text));
			}
		}
	}
	[HarmonyPatch(typeof(PreInitSceneScript), "Start")]
	internal static class LaunchModePatch
	{
		private static void Postfix(PreInitSceneScript __instance)
		{
			if (MainMenuPatch.ScreenshotDir() != null)
			{
				__instance.ChooseLaunchOption(true);
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "Start")]
	internal static class QuickMenuPatch
	{
		private static void Postfix(QuickMenuManager __instance)
		{
			PanelUI.quickMenu = __instance;
		}
	}
	[BepInPlugin("alexis.spawnpanel", "SpawnPanel", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static Settings S;

		internal static string Folder;

		private static readonly Dictionary<SpawnableEnemyWithRarity, (int orig, int applied)> rarities = new Dictionary<SpawnableEnemyWithRarity, (int, int)>();

		private static readonly Dictionary<EnemyType, (float power, int max)> stats = new Dictionary<EnemyType, (float, int)>();

		private static readonly Dictionary<SelectableLevel, int[]> budgets = new Dictionary<SelectableLevel, int[]>();

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			S = Settings.Load();
			new Harmony("alexis.spawnpanel").PatchAll(typeof(Plugin).Assembly);
			GameObject val = new GameObject("SpawnPanelUI")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<PanelUI>();
			Log.LogInfo((object)"SpawnPanel chargé");
		}

		internal static List<SpawnableEnemyWithRarity>[] ListsOf(SelectableLevel level)
		{
			return new List<SpawnableEnemyWithRarity>[3] { level.Enemies, level.OutsideEnemies, level.DaytimeEnemies };
		}

		internal static IEnumerable<SpawnableEnemyWithRarity> EnemiesOf(SelectableLevel level)
		{
			return from e in (from l in ListsOf(level)
					where l != null
					select l).SelectMany((List<SpawnableEnemyWithRarity> l) => l)
				where (Object)(object)e?.enemyType != (Object)null
				select e;
		}

		internal static void RememberCatalog()
		{
			SelectableLevel[] array = Resources.FindObjectsOfTypeAll<SelectableLevel>();
			foreach (SelectableLevel level in array)
			{
				if (string.IsNullOrEmpty(level.PlanetName))
				{
					continue;
				}
				PlanetInfo planetInfo = new PlanetInfo();
				List<SpawnableEnemyWithRarity>[] array2 = ListsOf(level);
				for (int j = 0; j < 3; j++)
				{
					foreach (SpawnableEnemyWithRarity item in array2[j] ?? new List<SpawnableEnemyWithRarity>())
					{
						if (!((Object)(object)item?.enemyType == (Object)null))
						{
							planetInfo.Enemies[j][item.enemyType.enemyName] = OriginalRarity(item);
							RememberEnemy(item.enemyType);
						}
					}
				}
				planetInfo.Budget = OriginalBudget(level);
				ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)level));
				PlanetInfo value;
				if ((Object)(object)val != (Object)null)
				{
					InteriorPatch.bypass = true;
					try
					{
						foreach (ExtendedDungeonFlowWithRarity validExtendedDungeonFlow in DungeonManager.GetValidExtendedDungeonFlows(val, false))
						{
							planetInfo.Interiors[validExtendedDungeonFlow.extendedDungeonFlow.DungeonName] = validExtendedDungeonFlow.rarity;
						}
					}
					finally
					{
						InteriorPatch.bypass = false;
					}
				}
				else if (S.Planets.TryGetValue(level.PlanetName, out value))
				{
					planetInfo.Interiors = value.Interiors;
				}
				S.Planets[level.PlanetName] = planetInfo;
			}
			foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows)
			{
				S.Interiors.Add(extendedDungeonFlow.DungeonName);
			}
		}

		private static void RememberEnemy(EnemyType t)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			(float, int) tuple = OriginalStats(t);
			S.Enemies.TryGetValue(t.enemyName, out var value);
			string text = value?.Color;
			if (string.IsNullOrEmpty(text) || text == "#808080")
			{
				Color? val = Icons.AverageColor(t.enemyPrefab);
				text = (val.HasValue ? ("#" + ColorUtility.ToHtmlStringRGB(val.Value)) : "");
				if (!val.HasValue)
				{
					Log.LogDebug((object)("Couleur de " + t.enemyName + " pas encore disponible (modèle " + (((Object)(object)t.enemyPrefab == (Object)null) ? "non chargé" : "sans rendu") + ")"));
				}
			}
			S.Enemies[t.enemyName] = new EnemyInfo
			{
				Power = tuple.Item1,
				MaxCount = tuple.Item2,
				Color = text
			};
		}

		internal static int OriginalRarity(SpawnableEnemyWithRarity e)
		{
			if (!rarities.TryGetValue(e, out (int, int) value) || value.Item2 != e.rarity)
			{
				return e.rarity;
			}
			return value.Item1;
		}

		internal static (float power, int max) OriginalStats(EnemyType t)
		{
			if (!stats.TryGetValue(t, out (float, int) value))
			{
				return (power: t.PowerLevel, max: t.MaxCount);
			}
			return value;
		}

		internal static int[] OriginalBudget(SelectableLevel l)
		{
			if (!budgets.TryGetValue(l, out var value))
			{
				return new int[3] { l.maxEnemyPowerCount, l.maxOutsideEnemyPowerCount, l.maxDaytimeEnemyPowerCount };
			}
			return value;
		}

		internal static int FinalEnemyWeight(string enemy, string planet, int orig)
		{
			if (S.Disabled.Contains(enemy + "|" + planet) || S.Disabled.Contains(enemy + "|*"))
			{
				return 0;
			}
			int value;
			return Mathf.RoundToInt((float)((S.EnemyWeight.TryGetValue(enemy + "|" + planet, out value) ? value : orig) * Settings.Pct(S.EnemyGlobalPct, enemy)) / 100f);
		}

		internal static T PlanetOrGlobal<T>(Dictionary<string, T> d, string enemy, string planet, T orig)
		{
			if (!d.TryGetValue(enemy + "|" + planet, out var value))
			{
				if (!d.TryGetValue(enemy + "|*", out value))
				{
					return orig;
				}
				return value;
			}
			return value;
		}

		internal static int FinalInteriorWeight(string interior, string planet, string weather, int orig)
		{
			if (S.Disabled.Contains(interior + "|" + planet) || S.Disabled.Contains(interior + "|*"))
			{
				return 0;
			}
			int value;
			return Mathf.RoundToInt((float)((S.InteriorWeight.TryGetValue(interior + "|" + planet, out value) ? value : orig) * Settings.Pct(S.InteriorGlobalPct, interior)) / 100f * (float)Settings.Pct(S.InteriorWeatherPct, interior + "|" + weather) / 100f);
		}

		internal static void Apply(SelectableLevel level)
		{
			string planet = level.PlanetName;
			foreach (SpawnableEnemyWithRarity item in EnemiesOf(level))
			{
				int num = OriginalRarity(item);
				item.rarity = FinalEnemyWeight(item.enemyType.enemyName, planet, num);
				rarities[item] = (num, item.rarity);
				EnemyType enemyType = item.enemyType;
				(float, int) value = OriginalStats(enemyType);
				stats[enemyType] = value;
				enemyType.PowerLevel = PlanetOrGlobal(S.EnemyPower, enemyType.enemyName, planet, value.Item1);
				enemyType.MaxCount = PlanetOrGlobal(S.EnemyMaxCount, enemyType.enemyName, planet, value.Item2);
			}
			int[] b = OriginalBudget(level);
			budgets[level] = b;
			level.maxEnemyPowerCount = Budget(0);
			level.maxOutsideEnemyPowerCount = Budget(1);
			level.maxDaytimeEnemyPowerCount = Budget(2);
			int Budget(int i)
			{
				if (!S.PlanetBudget.TryGetValue(planet + "|" + i, out var value2))
				{
					return b[i];
				}
				return value2;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
	internal static class LoadNewLevelPatch
	{
		[HarmonyPriority(0)]
		private static void Prefix(SelectableLevel newLevel)
		{
			if (GameNetworkManager.Instance.isHostingGame && !((Object)(object)newLevel == (Object)null))
			{
				Plugin.RememberCatalog();
				Plugin.Apply(newLevel);
				Plugin.S.Save();
				Plugin.Log.LogInfo((object)("Réglages des monstres appliqués sur " + newLevel.PlanetName));
			}
		}
	}
	[HarmonyPatch(typeof(DungeonManager), "GetValidExtendedDungeonFlows")]
	internal static class InteriorPatch
	{
		internal static bool bypass;

		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "TheFixer.EqualInteriors" })]
		private static void Postfix(ExtendedLevel extendedLevel, ref List<ExtendedDungeonFlowWithRarity> __result)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			SelectableLevel val = ((extendedLevel != null) ? extendedLevel.SelectableLevel : null);
			if (bypass || (Object)(object)val == (Object)null || __result == null)
			{
				return;
			}
			string planet = val.PlanetName;
			string weather = ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref val.currentWeather)/*cast due to .constrained prefix*/).ToString();
			List<ExtendedDungeonFlowWithRarity> list = __result.ToList();
			foreach (ExtendedDungeonFlow flow in PatchedContent.ExtendedDungeonFlows)
			{
				if (Plugin.S.InteriorWeight.TryGetValue(flow.DungeonName + "|" + planet, out var value) && value > 0 && !list.Any((ExtendedDungeonFlowWithRarity r) => (Object)(object)r.extendedDungeonFlow == (Object)(object)flow))
				{
					list.Add(new ExtendedDungeonFlowWithRarity(flow, 0));
				}
			}
			List<int> list2 = list.Select((ExtendedDungeonFlowWithRarity r) => Plugin.FinalInteriorWeight(r.extendedDungeonFlow.DungeonName, planet, weather, r.rarity)).ToList();
			if (list2.Sum() <= 0)
			{
				Plugin.Log.LogWarning((object)(planet + " (" + weather + ") : tous les intérieurs à 0, réglages ignorés"));
				return;
			}
			for (int num = 0; num < list.Count; num++)
			{
				list[num].rarity = list2[num];
			}
			__result = list;
		}
	}
	internal class PlanetInfo
	{
		public Dictionary<string, int>[] Enemies = new Dictionary<string, int>[3]
		{
			new Dictionary<string, int>(),
			new Dictionary<string, int>(),
			new Dictionary<string, int>()
		};

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

		public int[] Budget = new int[3];
	}
	internal class EnemyInfo
	{
		public float Power;

		public int MaxCount;

		public string Color;
	}
	internal class Settings
	{
		public const string AllPlanets = "*";

		public static readonly string[] ListNames = new string[3] { "Intérieur", "Extérieur (nuit)", "Extérieur (jour)" };

		public static readonly string[] BudgetNames = new string[3] { "Budget intérieur", "Budget extérieur", "Budget jour" };

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

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

		public Dictionary<string, float> EnemyPower = new Dictionary<string, float>();

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

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

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

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

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

		public SortedSet<string> Disabled = new SortedSet<string>();

		public bool ButtonFolded;

		public SortedDictionary<string, PlanetInfo> Planets = new SortedDictionary<string, PlanetInfo>();

		public SortedDictionary<string, EnemyInfo> Enemies = new SortedDictionary<string, EnemyInfo>();

		public SortedSet<string> Interiors = new SortedSet<string>();

		private static string FilePath => Path.Combine(Paths.ConfigPath, "SpawnPanel.json");

		public static Settings Load()
		{
			try
			{
				if (File.Exists(FilePath))
				{
					return JsonConvert.DeserializeObject<Settings>(File.ReadAllText(FilePath)) ?? new Settings();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("SpawnPanel.json illisible (" + ex.Message + "), copie dans SpawnPanel.json.bak"));
				File.Copy(FilePath, FilePath + ".bak", overwrite: true);
			}
			return new Settings();
		}

		public void Save()
		{
			File.WriteAllText(FilePath, JsonConvert.SerializeObject((object)this, (Formatting)1));
		}

		public static int Pct(Dictionary<string, int> d, string key)
		{
			if (!d.TryGetValue(key, out var value))
			{
				return 100;
			}
			return value;
		}
	}
	internal static class Theme
	{
		public static readonly Color Green = new Color(0.22f, 1f, 0.48f);

		public static readonly Color GreenDim = new Color(0.13f, 0.5f, 0.27f);

		public static readonly Color Fill = new Color(0.035f, 0.085f, 0.06f, 0.97f);

		public static readonly Color FillLight = new Color(0.07f, 0.17f, 0.11f, 0.98f);

		public static readonly Color Text = new Color(0.86f, 0.96f, 0.89f);

		public static GUIStyle Frame;

		public static GUIStyle Panel;

		public static GUIStyle PanelOn;

		public static GUIStyle Row;

		public static GUIStyle Button;

		public static GUIStyle Box;

		public static GUIStyle Octo;

		public static GUIStyle Title;

		public static GUIStyle Name;

		public static GUIStyle Small;

		public static GUIStyle Heading;

		public static GUIStyle Field;

		public static GUIStyle InvisibleThumb;

		public static GUIStyle TrackStyle;

		public static GUIStyle BarStyle;

		public static GUISkin Skin;

		public static Texture2D Track;

		public static Texture2D Bar;

		public static Texture2D Thumb;

		public static Texture2D ToggleOn;

		public static Texture2D ToggleOff;

		public static Texture2D Knob;

		private static readonly Dictionary<string, Texture2D> icons = new Dictionary<string, Texture2D>();

		private static Font font;

		public static void Init()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: 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)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Expected O, but got Unknown
			//IL_02a7: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: 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_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: 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_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Expected O, but got Unknown
			//IL_05e6: Expected O, but got Unknown
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Expected O, but got Unknown
			//IL_0611: Expected O, but got Unknown
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: 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)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Expected O, but got Unknown
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Expected O, but got Unknown
			//IL_06be: Expected O, but got Unknown
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Expected O, but got Unknown
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Expected O, but got Unknown
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			if (Frame == null)
			{
				font = Font.CreateDynamicFontFromOSFont(new string[2] { "Segoe UI", "Arial" }, 20);
				((Object)font).hideFlags = (HideFlags)61;
				Frame = Box9("frame", 96, 18f, Fill, Green, 3f, 10f);
				Panel = Box9("panel", 80, 14f, Fill, GreenDim, 2f, 0f);
				PanelOn = Box9("panel_on", 80, 14f, FillLight, Green, 3f, 9f);
				Panel.hover.background = Load("panel_hover") ?? Shape9(80, 14f, Fill, Green, 2f, 4f);
				Octo = Box9("octo", 80, 22f, Fill, Green, 3f, 8f);
				Row = Box9("row", 80, 12f, new Color(0.03f, 0.075f, 0.05f, 0.95f), GreenDim, 2f, 0f);
				Button = Box9("button", 64, 10f, FillLight, GreenDim, 2f, 0f);
				GUIStyleState hover = Button.hover;
				GUIStyleState active = Button.active;
				Texture2D val = (Button.onNormal.background = Load("button_on") ?? Shape9(64, 10f, new Color(0.1f, 0.3f, 0.17f), Green, 2f, 6f));
				Texture2D background = (active.background = val);
				hover.background = background;
				Button.alignment = (TextAnchor)4;
				GUIStyleState normal = Button.normal;
				GUIStyleState hover2 = Button.hover;
				Color val4 = (Button.onNormal.textColor = Text);
				Color textColor = (hover2.textColor = val4);
				normal.textColor = textColor;
				Box = Box9("box", 48, 6f, new Color(0.02f, 0.05f, 0.035f), GreenDim, 2f, 0f);
				Field = new GUIStyle(Box)
				{
					alignment = (TextAnchor)4,
					font = font,
					fontSize = 20,
					padding = new RectOffset(6, 6, 4, 4)
				};
				GUIStyleState normal2 = Field.normal;
				textColor = (Field.focused.textColor = Green);
				normal2.textColor = textColor;
				Field.focused.background = Load("box_on") ?? Shape9(48, 6f, new Color(0.02f, 0.08f, 0.05f), Green, 2f, 4f);
				Title = Label(46, Green, (FontStyle)1);
				Name = Label(24, Text, (FontStyle)1);
				Small = Label(16, new Color(0.55f, 0.8f, 0.62f), (FontStyle)0);
				Heading = Label(20, Green, (FontStyle)1);
				InvisibleThumb = new GUIStyle
				{
					fixedWidth = 26f,
					fixedHeight = 30f
				};
				Track = Load("slider_track") ?? Shape(256, 24, (float x, float y) => RoundBox(x, y, 124f, 8f, 8f), new Color(0.02f, 0.06f, 0.04f), GreenDim, 2f, 0f);
				Bar = Load("slider_fill") ?? Shape(256, 24, (float x, float y) => RoundBox(x, y, 124f, 8f, 8f), Green, Green, 0f, 3f);
				Thumb = Load("slider_thumb") ?? Shape(40, 44, (float x, float y) => RoundBox(x, y, 12f, 14f, 5f), new Color(0.45f, 1f, 0.62f), Green, 2f, 6f);
				ToggleOn = Load("toggle_on") ?? Shape(96, 52, (float x, float y) => RoundBox(x, y, 40f, 20f, 20f), new Color(0.1f, 0.55f, 0.27f), Green, 2f, 5f);
				ToggleOff = Load("toggle_off") ?? Shape(96, 52, (float x, float y) => RoundBox(x, y, 40f, 20f, 20f), new Color(0.04f, 0.1f, 0.07f), GreenDim, 2f, 0f);
				Knob = Load("toggle_knob") ?? Shape(40, 40, (float x, float y) => Mathf.Sqrt(x * x + y * y) - 14f, new Color(0.6f, 1f, 0.72f), Green, 0f, 3f);
				GUIStyle val6 = new GUIStyle();
				val6.normal.background = Track;
				val6.border = new RectOffset(14, 14, 0, 0);
				TrackStyle = val6;
				GUIStyle val7 = new GUIStyle();
				val7.normal.background = Bar;
				val7.border = new RectOffset(14, 14, 0, 0);
				BarStyle = val7;
				Skin = Object.Instantiate<GUISkin>(GUI.skin);
				GUISkin skin = Skin;
				GUIStyle val8 = new GUIStyle();
				val8.normal.background = Load("scroll_track") ?? Shape(24, 64, (float x, float y) => RoundBox(x, y, 7f, 30f, 7f), new Color(0.02f, 0.06f, 0.04f), GreenDim, 2f, 0f);
				val8.border = new RectOffset(0, 0, 12, 12);
				val8.fixedWidth = 18f;
				val8.margin = new RectOffset(8, 2, 0, 0);
				skin.verticalScrollbar = val8;
				GUISkin skin2 = Skin;
				GUIStyle val9 = new GUIStyle();
				val9.normal.background = Load("scroll_thumb") ?? Shape(24, 64, (float x, float y) => RoundBox(x, y, 7f, 30f, 7f), Green, Green, 0f, 2f);
				val9.border = new RectOffset(0, 0, 12, 12);
				val9.fixedWidth = 18f;
				skin2.verticalScrollbarThumb = val9;
				GUISkin skin3 = Skin;
				GUIStyle verticalScrollbarUpButton = (Skin.verticalScrollbarDownButton = GUIStyle.none);
				skin3.verticalScrollbarUpButton = verticalScrollbarUpButton;
				Skin.horizontalScrollbar = GUIStyle.none;
				Skin.scrollView = GUIStyle.none;
				GUIStyle label = Skin.label;
				GUIStyle button = Skin.button;
				Font val10 = (Skin.textField.font = font);
				Font val12 = (button.font = val10);
				label.font = val12;
			}
		}

		public static GUIStyle Center(GUIStyle s)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			return new GUIStyle(s)
			{
				alignment = (TextAnchor)4
			};
		}

		public static Texture2D Circle()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return Shape(64, 64, (float x, float y) => Mathf.Sqrt(x * x + y * y) - 30f, Color.white, Color.white, 0f, 0f);
		}

		private static GUIStyle Label(int size, Color color, FontStyle style)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				font = font,
				fontSize = size,
				fontStyle = style,
				alignment = (TextAnchor)3,
				wordWrap = false
			};
			val.normal.textColor = color;
			return val;
		}

		public static Texture2D Icon(string name)
		{
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			if (icons.TryGetValue(name, out var value))
			{
				return value;
			}
			Func<float, float, float> sdf = name switch
			{
				"planet" => delegate(float x, float y)
				{
					float num = Circle(x, y, 0f, 0f, 30f);
					float num2 = x * 0.94f + y * 0.34f;
					float num3 = ((0f - x) * 0.34f + y * 0.94f) * 3.2f;
					float num4 = Mathf.Abs(Mathf.Sqrt(num2 * num2 + num3 * num3) - 50f) - 7f;
					return Mathf.Min(num, Mathf.Max(num4, 0f - (num - 6f)));
				}, 
				"monster" => delegate(float x, float y)
				{
					float num = Mathf.Min(Circle(x, y, 0f, 10f, 38f), RoundBox(x, y + 28f, 22f, 18f, 6f));
					float num2 = Mathf.Min(Mathf.Min(Circle(x, y, -15f, 8f, 11f), Circle(x, y, 15f, 8f, 11f)), Circle(x, y, 0f, -12f, 5f));
					float num3 = Mathf.Min(Mathf.Min(RoundBox(x + 8f, y + 36f, 2f, 9f, 1f), RoundBox(x, y + 36f, 2f, 9f, 1f)), RoundBox(x - 8f, y + 36f, 2f, 9f, 1f));
					return Mathf.Max(num, 0f - Mathf.Min(num2, num3));
				}, 
				"interior" => delegate(float x, float y)
				{
					float num = RoundBox(x, y, 38f, 46f, 4f);
					for (int i = 0; i < 2; i++)
					{
						for (int j = 0; j < 2; j++)
						{
							num = Mathf.Max(num, 0f - RoundBox(x - (float)((i == 0) ? (-16) : 16), y - (float)((j == 0) ? 26 : 4), 8f, 7f, 1f));
						}
					}
					return Mathf.Max(num, 0f - RoundBox(x, y + 32f, 9f, 15f, 2f));
				}, 
				"stripe" => (float x, float y) => Segment(x, y, -12f, -22f, 12f, 22f) - 7f, 
				"close" => (float x, float y) => Mathf.Min(Segment(x, y, -26f, -26f, 26f, 26f) - 8f, Segment(x, y, -26f, 26f, 26f, -26f) - 8f), 
				"chevron" => (float x, float y) => Mathf.Min(Segment(x, y, -12f, 26f, 14f, 0f) - 6f, Segment(x, y, 14f, 0f, -12f, -26f) - 6f), 
				"chevron_down" => (float x, float y) => Mathf.Min(Segment(x, y, -26f, 12f, 0f, -14f) - 6f, Segment(x, y, 0f, -14f, 26f, 12f) - 6f), 
				_ => (float x, float y) => Mathf.Min(Mathf.Min(Circle(x, y, -22f, -2f, 22f), Circle(x, y, 8f, 10f, 30f)), Mathf.Min(Circle(x, y, 32f, -4f, 18f), RoundBox(x - 4f, y + 12f, 44f, 14f, 14f))), 
			};
			value = Load("icon_" + name) ?? Shape(128, 128, sdf, Green, Green, 0f, 7f);
			icons[name] = value;
			return value;
		}

		private static GUIStyle Box9(string file, int size, float chamfer, Color fill, Color line, float lineW, float glow)
		{
			//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D background = Load(file) ?? Shape9(size, chamfer, fill, line, lineW, glow);
			int num = Mathf.CeilToInt(glow * 1.2f);
			int num2 = num + Mathf.CeilToInt(chamfer) + 4;
			GUIStyle val = new GUIStyle();
			val.normal.background = background;
			val.normal.textColor = Text;
			val.border = new RectOffset(num2, num2, num2, num2);
			val.overflow = new RectOffset(num, num, num, num);
			val.padding = new RectOffset(14, 14, 10, 10);
			val.font = font;
			val.fontSize = 20;
			return val;
		}

		private static Texture2D Shape9(int size, float chamfer, Color fill, Color line, float lineW, float glow)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			float half = (float)size / 2f - Mathf.Ceil(glow * 1.2f);
			return Shape(size, size, (float x, float y) => Chamfer(x, y, half, half, chamfer), fill, line, lineW, glow);
		}

		private static Texture2D Shape(int w, int h, Func<float, float, float> sdf, Color fill, Color line, float lineW, float glow)
		{
			//IL_0004: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_008b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			//IL_00e4: 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)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(w, h, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			Color[] array = (Color[])(object)new Color[w * h];
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					float num = sdf((float)j + 0.5f - (float)w / 2f, (float)i + 0.5f - (float)h / 2f);
					float num2 = Mathf.Clamp01(0.5f - num);
					float num3 = ((lineW > 0f) ? Mathf.Clamp01(lineW + 0.5f + num) : 0f);
					Color val2 = Color.Lerp(fill, line, num3);
					Color val3 = (Color)((glow > 0f && num > 0f) ? new Color(line.r, line.g, line.b, 0.45f * Mathf.Exp(-2.5f * num / glow)) : Color.clear);
					float num4 = num2 * val2.a + val3.a * (1f - num2 * val2.a);
					Color val4 = ((num4 > 0f) ? ((val2 * (num2 * val2.a) + val3 * (val3.a * (1f - num2 * val2.a))) / num4) : Color.clear);
					array[i * w + j] = new Color(val4.r, val4.g, val4.b, num4);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static Texture2D Load(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0042: Expected O, but got Unknown
			string path = Path.Combine(Plugin.Folder, "skin", name + ".png");
			if (!File.Exists(path))
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2)
			{
				hideFlags = (HideFlags)61
			};
			ImageConversion.LoadImage(val, File.ReadAllBytes(path));
			return val;
		}

		private static float Circle(float x, float y, float cx, float cy, float r)
		{
			return Mathf.Sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) - r;
		}

		private static float RoundBox(float x, float y, float hw, float hh, float r)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(x) - hw + r;
			float num2 = Mathf.Abs(y) - hh + r;
			Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f));
			return ((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f) - r;
		}

		private static float Chamfer(float x, float y, float hw, float hh, float c)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(x) - hw;
			float num2 = Mathf.Abs(y) - hh;
			Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f));
			return Mathf.Max(((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f), (num + num2 + c) * 0.7071f);
		}

		private static float Segment(float x, float y, float ax, float ay, float bx, float by)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = new Vector2(x - ax, y - ay);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(bx - ax, by - ay);
			float num = Mathf.Clamp01(Vector2.Dot(val, val2) / ((Vector2)(ref val2)).sqrMagnitude);
			Vector2 val3 = val - val2 * num;
			return ((Vector2)(ref val3)).magnitude;
		}
	}
}