Decompiled source of DensityMod v2.0.4

DensityMod.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DensityMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod by Nova to allow you to set the range of density allowed when generating a city")]
[assembly: AssemblyFileVersion("2.0.3.0")]
[assembly: AssemblyInformationalVersion("2.0.3+c488e693a6eabe3a107c89ef2386c0caadf15ac2")]
[assembly: AssemblyProduct("DensityMod")]
[assembly: AssemblyTitle("DensityMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DensityMod
{
	internal class AnyCitySizeHooks
	{
		public class MainMenuController_Start
		{
			public static int selectedX;

			public static int selectedY;

			private static TextMeshProUGUI newSizeTMPButtonLabel;

			private static LeftButton popupLeftCallbackCache;

			private static RightButton popupRightCallbackCache;

			public static void Postfix()
			{
				if ((Object)(object)newSizeTMPButtonLabel != (Object)null)
				{
					return;
				}
				selectedX = RestartSafeController.Instance.cityX;
				selectedY = RestartSafeController.Instance.cityY;
				GameObject gameObject = ((Component)GameObject.Find("MenuCanvas").transform.Find("MainMenu/GenerateCityPanel/GenerateNewCityComponents/CityNameInput")).gameObject;
				GameObject popupMessageObject = ((Component)GameObject.Find("TooltipCanvas").transform.Find("PopupMessage")).gameObject;
				if ((Object)(object)gameObject != (Object)null)
				{
					GameObject obj = Object.Instantiate<GameObject>(gameObject.gameObject);
					((Object)obj).name = "CitySizeInput";
					obj.SetActive(true);
					((TMP_Text)((Component)obj.transform.Find("LabelText")).GetComponent<TextMeshProUGUI>()).SetText("Size", true);
					((Component)obj.transform.Find("ButtonArea")).gameObject.SetActive(false);
					Button componentInChildren = obj.GetComponentInChildren<Button>();
					((UnityEventBase)componentInChildren.onClick).RemoveAllListeners();
					((UnityEvent)componentInChildren.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
					{
						popupLeftCallbackCache = PopupMessageController.Instance.OnLeftButton;
						popupRightCallbackCache = PopupMessageController.Instance.OnRightButton;
						PopupMessageController.Instance.inputField.SetText($"{RestartSafeController.Instance.cityX - 2}x{RestartSafeController.Instance.cityY - 2}", true);
						PopupMessageController.Instance.OnLeftButton = LeftButton.op_Implicit((Action)HandlePopupCancel);
						PopupMessageController.Instance.OnRightButton = RightButton.op_Implicit((Action)HandlePopupSubmit);
						PopupMessageController.Instance.PopupMessage("Enter city width.", true, true, "Cancel", "Confirm", true, (AffectPauseState)0, true, "", false, false, false, false, "", "", false, "", false, "", "");
						((TMP_Text)((Component)popupMessageObject.transform.Find("Header/PanelTitle")).gameObject.GetComponent<TextMeshProUGUI>()).text = "Enter City Size";
					}));
					newSizeTMPButtonLabel = ((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>();
					UpdateMenuText();
					((Component)gameObject.transform.parent.GetChild(1)).gameObject.SetActive(false);
					obj.transform.SetParent(gameObject.transform.parent, true);
					obj.transform.SetSiblingIndex(1);
				}
			}

			public static void HandlePopupSubmit()
			{
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Expected O, but got Unknown
				PopupMessageController instance = PopupMessageController.Instance;
				instance.OnLeftButton -= LeftButton.op_Implicit((Action)HandlePopupCancel);
				PopupMessageController instance2 = PopupMessageController.Instance;
				instance2.OnRightButton -= RightButton.op_Implicit((Action)HandlePopupSubmit);
				PopupMessageController.Instance.OnLeftButton = popupLeftCallbackCache;
				PopupMessageController.Instance.OnRightButton = popupRightCallbackCache;
				string text = PopupMessageController.Instance.inputField.text;
				if (new Regex("^\\d+x\\d+$").Match(text).Length != 0)
				{
					List<int> list = (from value in text.Split("x")
						select int.Parse(value)).ToList();
					RestartSafeController.Instance.cityX = 2 + list[0];
					RestartSafeController.Instance.cityY = 2 + list[1];
					ManualLogSource logger = DensityMod.Logger;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(16, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Width: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(RestartSafeController.Instance.cityX - 2);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Height: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(RestartSafeController.Instance.cityY - 2);
					}
					logger.LogDebug(val);
					UpdateMenuText();
				}
			}

			public static void HandlePopupCancel()
			{
				PopupMessageController instance = PopupMessageController.Instance;
				instance.OnLeftButton -= LeftButton.op_Implicit((Action)HandlePopupCancel);
				PopupMessageController instance2 = PopupMessageController.Instance;
				instance2.OnRightButton -= RightButton.op_Implicit((Action)HandlePopupSubmit);
				PopupMessageController.Instance.OnLeftButton = popupLeftCallbackCache;
				PopupMessageController.Instance.OnRightButton = popupRightCallbackCache;
			}

			public static void UpdateMenuText()
			{
				if ((Object)(object)newSizeTMPButtonLabel != (Object)null)
				{
					selectedX = RestartSafeController.Instance.cityX;
					selectedY = RestartSafeController.Instance.cityY;
					((TMP_Text)newSizeTMPButtonLabel).SetText($"Width: {RestartSafeController.Instance.cityX - 2} Height: {RestartSafeController.Instance.cityY - 2}", true);
				}
			}

			public static bool IsInitialised()
			{
				return (Object)(object)newSizeTMPButtonLabel != (Object)null;
			}
		}

		[HarmonyPatch(typeof(MainMenuController), "Update")]
		public class MainMenuController_Update
		{
			public static void Postfix(MainMenuController __instance)
			{
				if (__instance.mainMenuActive && (RestartSafeController.Instance.cityX != MainMenuController_Start.selectedX || RestartSafeController.Instance.cityY != MainMenuController_Start.selectedY))
				{
					MainMenuController_Start.UpdateMenuText();
				}
			}
		}

		[HarmonyPatch(typeof(MainMenuController), "OnChangeCityGenerationOption")]
		public class MainMenuController_OnChangeCityGenerationOption
		{
			public static void Postfix(MainMenuController __instance)
			{
				if (MainMenuController_Start.IsInitialised() && (RestartSafeController.Instance.cityX != MainMenuController_Start.selectedX || RestartSafeController.Instance.cityY != MainMenuController_Start.selectedY))
				{
					RestartSafeController.Instance.cityX = MainMenuController_Start.selectedX;
					RestartSafeController.Instance.cityY = MainMenuController_Start.selectedY;
					MainMenuController_Start.UpdateMenuText();
				}
			}
		}
	}
	internal class DensityModHook
	{
		[HarmonyPatch(typeof(CityConstructor), "Update")]
		public class Citydata_PopulationMultiplier
		{
			public static void Postfix()
			{
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Expected I4, but got Unknown
				//IL_00da: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Expected I4, but got Unknown
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Expected O, but got Unknown
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Expected O, but got Unknown
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: Unknown result type (might be due to invalid IL or missing references)
				CityTile[] array = Il2CppArrayBase<CityTile>.op_Implicit(Resources.FindObjectsOfTypeAll<CityTile>());
				CityConstructor obj = Resources.FindObjectsOfTypeAll<CityConstructor>()[0];
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)(int)Enum.Parse(typeof(Density), DensityMod.DensityMinConfig.Value), (float)(int)Enum.Parse(typeof(Density), DensityMod.DensityMaxConfig.Value));
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor((float)(int)Enum.Parse(typeof(LandValue), DensityMod.LandValueMinConfig.Value), (float)(int)Enum.Parse(typeof(LandValue), DensityMod.LandValueMaxConfig.Value));
				if (!obj.generateNew)
				{
					return;
				}
				CityTile[] array2 = array;
				bool flag = default(bool);
				foreach (CityTile val3 in array2)
				{
					if (((Object)val3).name == "CityTile")
					{
						break;
					}
					int num = (int)val3.density;
					num = (int)Math.Clamp(num, val.x, val.y);
					int num2 = (int)val3.landValue;
					num2 = (int)Math.Clamp(num2, val2.x, val2.y);
					val3.density = (Density)num;
					ManualLogSource logger = DensityMod.Logger;
					BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(11, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val3).name);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" density = ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Density>(val3.density);
					}
					logger.LogDebug(val4);
					val3.landValue = (LandValue)num2;
					ManualLogSource logger2 = DensityMod.Logger;
					val4 = new BepInExDebugLogInterpolatedStringHandler(13, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val3).name);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" landValue = ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<LandValue>(val3.landValue);
					}
					logger2.LogDebug(val4);
				}
			}
		}

		[HarmonyPatch(typeof(MainMenuController), "Start")]
		public class MainMenuController_Start
		{
			public static void Postfix()
			{
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cf: 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_035d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
				GameObject gameObject = ((Component)GameObject.Find("MenuCanvas").transform.Find("MainMenu/GenerateCityPanel/GenerateNewCityComponents/SizeDropdown")).gameObject;
				GenerateCityMenu = ((Component)GameObject.Find("MenuCanvas").transform.Find("MainMenu/GenerateCityPanel/")).gameObject;
				List<string> val = new List<string>();
				val.Add("Low");
				val.Add("Medium");
				val.Add("High");
				val.Add("Very High");
				List<string> val2 = new List<string>();
				val2.Add("Very Low");
				val2.Add("Low");
				val2.Add("Medium");
				val2.Add("High");
				val2.Add("Very High");
				if ((Object)(object)GenerateCityMenu != (Object)null)
				{
					densityMenu = Object.Instantiate<GameObject>(GenerateCityMenu.gameObject);
					((Object)densityMenu).name = "Density Menu";
					densityMenu.transform.parent = GenerateCityMenu.transform.parent;
					densityMenu.transform.localPosition = new Vector3(0f, -42f, 0f);
					menuContainer = ((Component)densityMenu.transform.FindChild("GenerateNewCityComponents")).gameObject;
					((Object)menuContainer).name = "DensitySettingsComponents";
					for (int i = 0; i < menuContainer.transform.GetChildCount(); i++)
					{
						Object.Destroy((Object)(object)((Component)menuContainer.transform.GetChild(i)).gameObject);
					}
					Object.Destroy((Object)(object)((Component)densityMenu.transform.FindChild("ButtonArea").GetChild(0)).gameObject);
					GameObject gameObject2 = ((Component)densityMenu.transform.FindChild("ButtonArea").GetChild(1)).gameObject;
					gameObject2.transform.parent = ((Component)densityMenu.transform.FindChild("ButtonArea")).transform;
					((UnityEvent)gameObject2.GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)CloseDensityMenu));
					Transform child = GenerateCityMenu.transform.Find("ButtonArea").GetChild(1);
					DensityModBtn = Object.Instantiate<GameObject>(((Component)child).gameObject);
					DensityModBtn.transform.parent = ((Component)child).transform.parent;
					DensityModBtn.transform.SetSiblingIndex(1);
					((UnityEvent)DensityModBtn.GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)OpenDensityMenu));
				}
				if ((Object)(object)gameObject != (Object)null)
				{
					string selectedOption = DensityModHook.EnumToString<Density>((Density)Enum.Parse(typeof(Density), DensityMod.DensityMinConfig.Value));
					dropdownDenLow = createDropdown(gameObject.gameObject, "Lowest Density", menuContainer.transform, val, selectedOption);
					string selectedOption2 = DensityModHook.EnumToString<Density>((Density)Enum.Parse(typeof(Density), DensityMod.DensityMaxConfig.Value));
					dropdownDenHigh = createDropdown(gameObject.gameObject, "Highest Density", menuContainer.transform, val, selectedOption2);
					string selectedOption3 = DensityModHook.EnumToString<LandValue>((LandValue)Enum.Parse(typeof(LandValue), DensityMod.LandValueMinConfig.Value));
					dropdownValueLow = createDropdown(gameObject.gameObject, "Lowest Land Value", menuContainer.transform, val2, selectedOption3);
					string selectedOption4 = DensityModHook.EnumToString<LandValue>((LandValue)Enum.Parse(typeof(LandValue), DensityMod.LandValueMaxConfig.Value));
					dropdownValueHigh = createDropdown(gameObject.gameObject, "Highest Land Value", menuContainer.transform, val2, selectedOption4);
				}
				AnyCitySizeHooks.MainMenuController_Start.Postfix();
			}
		}

		[HarmonyPatch(typeof(MainMenuController), "Update")]
		public class MainMenuController_Update
		{
			public static void Postfix()
			{
				if ((Object)(object)dropdownDenLow != (Object)null)
				{
					if (((TMP_Text)((Component)densityMenu.transform.FindChild("Header").FindChild("PanelTitle")).GetComponent<TextMeshProUGUI>()).text != "Density Settings")
					{
						((TMP_Text)((Component)densityMenu.transform.FindChild("Header").FindChild("PanelTitle")).GetComponent<TextMeshProUGUI>()).text = "Density Settings";
					}
					if (((TMP_Text)((Component)densityMenu.transform.FindChild("ButtonArea/Continue/Text")).GetComponent<TextMeshProUGUI>()).text != "Done")
					{
						((TMP_Text)((Component)densityMenu.transform.FindChild("ButtonArea/Continue/Text")).GetComponent<TextMeshProUGUI>()).text = "Done";
					}
					if (((TMP_Text)((Component)DensityModBtn.transform.FindChild("Text")).GetComponent<TextMeshProUGUI>()).text != "Density Settings")
					{
						((TMP_Text)((Component)DensityModBtn.transform.FindChild("Text")).GetComponent<TextMeshProUGUI>()).text = "Density Settings";
					}
				}
			}
		}

		[HarmonyPatch(typeof(DropdownController), "OnValueChange")]
		public class Dropdown_Update
		{
			public static void Postfix()
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: 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_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_010c: Expected O, but got Unknown
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Expected O, but got Unknown
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c0: Expected O, but got Unknown
				Density val = DensityModHook.StringToEnum<Density>(dropdownDenLow.GetComponent<DropdownController>().GetCurrentSelectedStaticOption());
				Density val2 = DensityModHook.StringToEnum<Density>(dropdownDenHigh.GetComponent<DropdownController>().GetCurrentSelectedStaticOption());
				LandValue val3 = DensityModHook.StringToEnum<LandValue>(dropdownValueLow.GetComponent<DropdownController>().GetCurrentSelectedStaticOption());
				LandValue val4 = DensityModHook.StringToEnum<LandValue>(dropdownValueHigh.GetComponent<DropdownController>().GetCurrentSelectedStaticOption());
				if (val > val2)
				{
					val2 = val;
					dropdownDenHigh.GetComponent<DropdownController>().SelectFromStaticOption(DensityModHook.EnumToString<Density>(val2));
				}
				if (val3 > val4)
				{
					val4 = val3;
					dropdownDenHigh.GetComponent<DropdownController>().SelectFromStaticOption(DensityModHook.EnumToString<LandValue>(val4));
				}
				((ConfigEntryBase)DensityMod.DensityMinConfig).BoxedValue = ((object)(Density)(ref val)).ToString();
				ManualLogSource logger = DensityMod.Logger;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val5 = new BepInExDebugLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Density Low Choice is: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(dropdownDenLow.GetComponent<DropdownController>().GetCurrentSelectedStaticOption().ToString());
				}
				logger.LogDebug(val5);
				((ConfigEntryBase)DensityMod.DensityMaxConfig).BoxedValue = ((object)(Density)(ref val2)).ToString();
				ManualLogSource logger2 = DensityMod.Logger;
				val5 = new BepInExDebugLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Density High Choice is: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(dropdownDenHigh.GetComponent<DropdownController>().GetCurrentSelectedStaticOption().ToString());
				}
				logger2.LogDebug(val5);
				((ConfigEntryBase)DensityMod.LandValueMinConfig).BoxedValue = ((object)(LandValue)(ref val3)).ToString();
				ManualLogSource logger3 = DensityMod.Logger;
				val5 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Land Value Low Choice is: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(dropdownValueLow.GetComponent<DropdownController>().GetCurrentSelectedStaticOption().ToString());
				}
				logger3.LogDebug(val5);
				((ConfigEntryBase)DensityMod.LandValueMaxConfig).BoxedValue = ((object)(LandValue)(ref val4)).ToString();
				ManualLogSource logger4 = DensityMod.Logger;
				val5 = new BepInExDebugLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Land Value High Choice is: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(dropdownValueHigh.GetComponent<DropdownController>().GetCurrentSelectedStaticOption().ToString());
				}
				logger4.LogDebug(val5);
			}
		}

		public static GameObject dropdownDenLow;

		public static GameObject dropdownDenHigh;

		public static GameObject dropdownValueLow;

		public static GameObject dropdownValueHigh;

		public static GameObject densityMenu;

		public static GameObject menuContainer;

		public static GameObject GenerateCityMenu;

		public static GameObject DensityModBtn;

		public static string EnumToString<T>(T e) where T : Enum
		{
			string input = e.ToString();
			input = Regex.Replace(input, "(\\B[A-Z])", " $1");
			return new CultureInfo("en-US", useUserOverride: false).TextInfo.ToTitleCase(input);
		}

		public static T StringToEnum<T>(string s) where T : Enum
		{
			s = s.Substring(0, 1).ToLower() + s.Substring(1).Replace(" ", "");
			return (T)Enum.Parse(typeof(T), s);
		}

		private static void CloseDensityMenu()
		{
			densityMenu.SetActive(false);
			GenerateCityMenu.SetActive(true);
		}

		private static void OpenDensityMenu()
		{
			densityMenu.SetActive(true);
			GenerateCityMenu.SetActive(false);
		}

		public static GameObject createDropdown(GameObject _template, string _name, Transform _container, List<string> _options, string _selectedOption)
		{
			GameObject obj = Object.Instantiate<GameObject>(_template);
			((Object)obj.gameObject).name = _name.Trim() + "Dropdown";
			obj.transform.parent = _container;
			obj.GetComponent<DropdownController>().AddOptions(_options, false, (List<string>)null);
			obj.GetComponent<DropdownController>().SelectFromStaticOption(_selectedOption);
			((Behaviour)obj.GetComponentInChildren<MenuAutoTextController>()).enabled = false;
			((TMP_Text)((Component)obj.transform.FindChild("LabelText")).GetComponent<TextMeshProUGUI>()).text = _name;
			return obj;
		}
	}
	[BepInPlugin("DensityMod", "DensityMod", "2.0.3")]
	[BepInProcess("Shadows of Doubt.exe")]
	public class DensityMod : BasePlugin
	{
		public static ConfigEntry<string> DensityMinConfig;

		public static ConfigEntry<string> DensityMaxConfig;

		private static AcceptableValueList<string> allowedDensity = new AcceptableValueList<string>(new string[4] { "low", "medium", "high", "veryHigh" });

		public static ConfigEntry<string> LandValueMinConfig;

		public static ConfigEntry<string> LandValueMaxConfig;

		private static AcceptableValueList<string> allowedLandValue = new AcceptableValueList<string>(new string[5] { "veryLow", "low", "medium", "high", "veryHigh" });

		public static ManualLogSource Logger;

		public override void Load()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Expected O, but got Unknown
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Expected O, but got Unknown
			DensityMinConfig = ((BasePlugin)this).Config.Bind<string>("Settings", "Minimum Density Size", "low", "This sets what the smallest density is allowed. Options are: low, medium, high, veryHigh.");
			DensityMaxConfig = ((BasePlugin)this).Config.Bind<string>("Settings", "Maximum Density Size", "veryHigh", "This sets what the largest density is allowed. Options are: low, medium, high, veryHigh.");
			LandValueMinConfig = ((BasePlugin)this).Config.Bind<string>("Settings", "Minimum Land Value", "veryLow", "This sets what the lowest land value is allowed. Options are: veryLow, low, medium, high, veryHigh.");
			LandValueMaxConfig = ((BasePlugin)this).Config.Bind<string>("Settings", "Maximum Land Value", "veryHigh", "This sets what the highest land value is allowed. Options are: veryLow, low, medium, high, veryHigh.");
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (!((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, (ConfigDescription)null).Value)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DensityMod");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is disabled.");
				}
				log.LogInfo(val);
				return;
			}
			Logger = ((BasePlugin)this).Log;
			((AcceptableValueBase)allowedDensity).Clamp(((ConfigEntryBase)DensityMinConfig).BoxedValue);
			((AcceptableValueBase)allowedDensity).Clamp(((ConfigEntryBase)DensityMaxConfig).BoxedValue);
			((AcceptableValueBase)allowedLandValue).Clamp(((ConfigEntryBase)LandValueMinConfig).BoxedValue);
			((AcceptableValueBase)allowedLandValue).Clamp(((ConfigEntryBase)LandValueMaxConfig).BoxedValue);
			if (!((AcceptableValueBase)allowedDensity).IsValid((object)DensityMinConfig.Value))
			{
				ManualLogSource logger = Logger;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Minimum Density not valid, changing value to default: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(((ConfigEntryBase)DensityMinConfig).DefaultValue);
				}
				logger.LogWarning(val2);
				((ConfigEntryBase)DensityMinConfig).BoxedValue = ((ConfigEntryBase)DensityMinConfig).DefaultValue;
			}
			if (!((AcceptableValueBase)allowedDensity).IsValid((object)DensityMaxConfig.Value))
			{
				ManualLogSource logger2 = Logger;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Maximum Density not valid, changing value to default: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(((ConfigEntryBase)DensityMaxConfig).DefaultValue);
				}
				logger2.LogWarning(val2);
				((ConfigEntryBase)DensityMaxConfig).BoxedValue = ((ConfigEntryBase)DensityMaxConfig).DefaultValue;
			}
			if (!((AcceptableValueBase)allowedLandValue).IsValid((object)LandValueMinConfig.Value))
			{
				ManualLogSource logger3 = Logger;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(56, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Lowest Land Value not valid, changing value to default: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(((ConfigEntryBase)LandValueMinConfig).DefaultValue);
				}
				logger3.LogWarning(val2);
				((ConfigEntryBase)LandValueMinConfig).BoxedValue = ((ConfigEntryBase)LandValueMinConfig).DefaultValue;
			}
			if (!((AcceptableValueBase)allowedLandValue).IsValid((object)LandValueMaxConfig.Value))
			{
				ManualLogSource logger4 = Logger;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(57, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Highest Land Value not valid, changing value to default: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(((ConfigEntryBase)LandValueMaxConfig).DefaultValue);
				}
				logger4.LogWarning(val2);
				((ConfigEntryBase)LandValueMaxConfig).BoxedValue = ((ConfigEntryBase)LandValueMaxConfig).DefaultValue;
			}
			if ((int)Enum.Parse(typeof(Density), DensityMinConfig.Value) > (int)Enum.Parse(typeof(Density), DensityMaxConfig.Value))
			{
				Logger.LogFatal((object)"Maximum Density Size cannot be less then the Minimum Density Size. Restoring default values now...");
				((ConfigEntryBase)DensityMinConfig).BoxedValue = ((ConfigEntryBase)DensityMinConfig).DefaultValue;
				((ConfigEntryBase)DensityMaxConfig).BoxedValue = ((ConfigEntryBase)DensityMaxConfig).DefaultValue;
			}
			if ((int)Enum.Parse(typeof(LandValue), LandValueMinConfig.Value) > (int)Enum.Parse(typeof(LandValue), LandValueMaxConfig.Value))
			{
				Logger.LogFatal((object)"Highest Land Value cannot be less then Lowest Land Value. Restoring default values now...");
				((ConfigEntryBase)LandValueMinConfig).BoxedValue = ((ConfigEntryBase)LandValueMinConfig).DefaultValue;
				((ConfigEntryBase)LandValueMaxConfig).BoxedValue = ((ConfigEntryBase)LandValueMaxConfig).DefaultValue;
			}
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DensityMod");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log2.LogInfo(val);
			new Harmony("DensityMod").PatchAll();
			ManualLogSource log3 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DensityMod");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
			}
			log3.LogInfo(val);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DensityMod";

		public const string PLUGIN_NAME = "DensityMod";

		public const string PLUGIN_VERSION = "2.0.3";
	}
}