Decompiled source of DensityMod v2.1.0

DensityMod.dll

Decompiled 4 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DensityMod")]
[assembly: AssemblyConfiguration("Debug")]
[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 val = GameObject.Find("MenuCanvas/MainMenu/GenerateCityPanel/GenerateNewCityComponents/CityNameInput");
				GameObject popupMessageObject = ((Component)GameObject.Find("TooltipCanvas").transform.Find("PopupMessage")).gameObject;
				if ((Object)(object)val != (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(val.gameObject);
					((Object)val2).name = "CitySizeInput";
					val2.SetActive(true);
					((TMP_Text)((Component)val2.transform.Find("LabelText")).GetComponent<TextMeshProUGUI>()).SetText("Size", true);
					((Component)val2.transform.Find("ButtonArea")).gameObject.SetActive(false);
					Button componentInChildren = val2.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, "", "", false);
						GameObject gameObject = ((Component)popupMessageObject.transform.Find("Header/PanelTitle")).gameObject;
						((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).text = "Enter City Size";
					}));
					newSizeTMPButtonLabel = ((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>();
					UpdateMenuText();
					int siblingIndex = val.transform.parent.FindChild("SizeDropdown").GetSiblingIndex();
					((Component)val.transform.parent.FindChild("SizeDropdown")).gameObject.SetActive(false);
					val2.transform.SetParent(val.transform.parent, true);
					val2.transform.SetSiblingIndex(siblingIndex);
				}
			}

			public static void HandlePopupSubmit()
			{
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: 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(CityEditorController), "Start")]
		public class CityEditorController_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))
				{
					selectedX = RestartSafeController.Instance.cityX;
					selectedY = RestartSafeController.Instance.cityY;
					GameObject val = GameObject.Find("PrototypeBuilderCanvas/CityEditorPanel/ButtonComponents/CityNameInput");
					GameObject gameObject = ((Component)GameObject.Find("TooltipCanvas").transform.Find("PopupMessage")).gameObject;
					if ((Object)(object)val != (Object)null)
					{
						UpdateMenuElements(val, gameObject);
					}
				}
			}

			public static void UpdateMenuElements(GameObject inputTemplate, GameObject popupMessageObject)
			{
				GameObject val = Object.Instantiate<GameObject>(inputTemplate.gameObject);
				((Object)val).name = "CitySizeInput";
				val.SetActive(true);
				((TMP_Text)((Component)val.transform.Find("LabelText")).GetComponent<TextMeshProUGUI>()).SetText("Size", true);
				Transform val2 = val.transform.Find("ButtonArea");
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				Button componentInChildren = val.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, "", "", false);
					GameObject gameObject = ((Component)popupMessageObject.transform.Find("Header/PanelTitle")).gameObject;
					((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).text = "Enter City Size";
				}));
				newSizeTMPButtonLabel = ((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>();
				UpdateMenuText();
				int siblingIndex = inputTemplate.transform.parent.FindChild("SizeDropdown").GetSiblingIndex();
				((Component)inputTemplate.transform.parent.FindChild("SizeDropdown")).gameObject.SetActive(false);
				val.transform.SetParent(inputTemplate.transform.parent, true);
				val.transform.SetSiblingIndex(siblingIndex);
			}

			public static void HandlePopupSubmit()
			{
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Expected I4, but got Unknown
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Expected I4, but got Unknown
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Expected O, but got Unknown
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Expected O, but got Unknown
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				CityTile[] array = Il2CppArrayBase<CityTile>.op_Implicit(Resources.FindObjectsOfTypeAll<CityTile>());
				CityConstructor val = Resources.FindObjectsOfTypeAll<CityConstructor>()[0];
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor((float)(int)Enum.Parse(typeof(Density), DensityMod.DensityMinConfig.Value), (float)(int)Enum.Parse(typeof(Density), DensityMod.DensityMaxConfig.Value));
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor((float)(int)Enum.Parse(typeof(LandValue), DensityMod.LandValueMinConfig.Value), (float)(int)Enum.Parse(typeof(LandValue), DensityMod.LandValueMaxConfig.Value));
				if (!val.generateNew)
				{
					return;
				}
				CityTile[] array2 = array;
				bool flag = default(bool);
				foreach (CityTile val4 in array2)
				{
					if (((Object)val4).name == "CityTile")
					{
						break;
					}
					int num = (int)val4.density;
					num = (int)Math.Clamp(num, val2.x, val2.y);
					int num2 = (int)val4.landValue;
					num2 = (int)Math.Clamp(num2, val3.x, val3.y);
					val4.density = (Density)num;
					ManualLogSource logger = DensityMod.Logger;
					BepInExDebugLogInterpolatedStringHandler val5 = new BepInExDebugLogInterpolatedStringHandler(11, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val4).name);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" density = ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Density>(val4.density);
					}
					logger.LogDebug(val5);
					val4.landValue = (LandValue)num2;
					ManualLogSource logger2 = DensityMod.Logger;
					val5 = new BepInExDebugLogInterpolatedStringHandler(13, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val4).name);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" landValue = ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<LandValue>(val4.landValue);
					}
					logger2.LogDebug(val5);
				}
			}
		}

		[HarmonyPatch(typeof(MainMenuController), "Start")]
		public class MainMenuController_Start
		{
			public static void Postfix()
			{
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0324: Unknown result type (might be due to invalid IL or missing references)
				//IL_036b: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f9: 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;
					((UnityEventBase)gameObject2.GetComponent<Button>().onClick).RemoveAllListeners();
					((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);
					((UnityEventBase)DensityModBtn.GetComponent<Button>().onClick).RemoveAllListeners();
					((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_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: 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_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: 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_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Expected O, but got Unknown
				//IL_0084: 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_0090: 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_012a: Expected O, but got Unknown
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Expected O, but got Unknown
				//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ee: 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 val = Object.Instantiate<GameObject>(_template);
			((Object)val.gameObject).name = _name.Trim() + "Dropdown";
			val.transform.parent = _container;
			val.GetComponent<DropdownController>().AddOptions(_options, false, (List<string>)null);
			val.GetComponent<DropdownController>().SelectFromStaticOption(_selectedOption);
			((Behaviour)val.GetComponentInChildren<MenuAutoTextController>()).enabled = false;
			((TMP_Text)((Component)val.transform.FindChild("LabelText")).GetComponent<TextMeshProUGUI>()).text = _name;
			return val;
		}
	}
	[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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Expected O, but got Unknown
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Expected O, but got Unknown
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: 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);
			Harmony val3 = new Harmony("DensityMod");
			val3.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";
	}
}