Decompiled source of OverworkedUIBeta v1.2.1

OverworkedUI.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OverworkedUI.Core;
using OverworkedUI.Core.Data;
using OverworkedUI.Core.Menu;
using OverworkedUI.Core.Menu.Categories;
using OverworkedUI.Core.Menu.Scripts;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OverworkedUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4973816b401de7433a4224f7b54c08644e240ce5")]
[assembly: AssemblyProduct("OverworkedUI")]
[assembly: AssemblyTitle("OverworkedUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 OverworkedUI
{
	[BepInPlugin("dev.timmywastor.overworkedUI", "OverworkedUI", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "dev.timmywastor.overworkedUI";

		public const string ModName = "OverworkedUI";

		public const string ModVersion = "1.2.0";

		public static Harmony Harmony = new Harmony("dev.timmywastor.overworkedUI");

		public static ManualLogSource OwLogger;

		public static string OwFolder;

		private void Awake()
		{
			OwFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			OwLogger = ((BaseUnityPlugin)this).Logger;
			OwUiCore.Start();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OverworkedUI";

		public const string PLUGIN_NAME = "OverworkedUI";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace OverworkedUI.Core
{
	internal class OwUiCore
	{
		private static AssetBundle? _owUiBundle;

		internal static AssetBundle GetBundle()
		{
			if ((Object)(object)_owUiBundle == (Object)null)
			{
				_owUiBundle = AssetBundle.LoadFromFile(Plugin.OwFolder + "/Assets/owui");
			}
			return _owUiBundle;
		}

		public static void Start()
		{
			Plugin.Harmony.PatchAll(typeof(OwUiMenuManager));
			Plugin.Harmony.PatchAll(typeof(ScrollFix));
		}
	}
}
namespace OverworkedUI.Core.Menu
{
	[HarmonyPatch(typeof(MenuManager))]
	internal class OwUiMenuManager
	{
		public static GameObject CurrentUi;

		public static OwUiView CurrentView;

		public static OwUiController CurrentController;

		public static MenuManager ActualMenuManager { get; private set; }

		public static int GameVersion { get; private set; }

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void CreateUi(MenuManager __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			if (!__instance.isInitScene)
			{
				ActualMenuManager = __instance;
				GameVersion = GameNetworkManager.Instance.gameVersionNum;
				VanillaData.PopulateAvailableItems();
				CurrentUi = Object.Instantiate<GameObject>((GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Host.prefab"));
				((Object)CurrentUi).name = "OverworkedUi";
				CurrentView = CurrentUi.AddComponent<OwUiView>();
				CurrentController = CurrentUi.AddComponent<OwUiController>();
				CurrentController.TargetView = CurrentView;
				CurrentController.TargetManager = ActualMenuManager;
				CurrentController.Initialize();
				DefaultCategories.Inject(CurrentView, GameVersion);
				if (GameVersion < 80)
				{
					CurrentView.HideRerollButton();
				}
			}
		}

		[HarmonyPatch("ClickHostButton")]
		[HarmonyPostfix]
		private static void ClickHostButton_PostFix(MenuManager __instance)
		{
			__instance.HostSettingsScreen.SetActive(false);
		}
	}
	[HarmonyPatch(typeof(ScrollRect))]
	internal class ScrollFix
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnEnable")]
		private static void ChangeScrollSpeed(ScrollRect __instance)
		{
			__instance.scrollSensitivity = 0.15f;
		}
	}
}
namespace OverworkedUI.Core.Menu.Scripts
{
	internal class OwUiController : MonoBehaviour
	{
		public OwUiView TargetView;

		public MenuManager TargetManager;

		public bool UsingHQoL = false;

		public object HQolItemReference;

		public bool UsingOverworked = false;

		public void Initialize()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			LookForHQoLOrOverworked();
			TargetView.Initialize();
			ReloadSaves();
			HideUi();
			TargetView.BindRefresh(ReloadSaves);
			TargetView.BindClose(HideUi);
			TargetView.BindRenameFile(RenameFile);
			TargetView.BindDeleteFile(DeleteFile);
			TargetView.BindConfirmButton(StartHosting);
			TargetView.BindCreateFile(CreateSaveFile);
			Button component = GameObject.Find("Canvas/MenuContainer/MainButtons/HostButton").GetComponent<Button>();
			((UnityEvent)component.onClick).AddListener(new UnityAction(ShowUi));
			TargetView.PassValues(ES3.Load<string>("OwUi_LastName", "LCGeneralSaveData", "My Lobby"), ES3.Load<int>("OwUi_LastSelect", "LCGeneralSaveData", -1), ES3.Load<bool>("OwUi_LastLobbyVis", "LCGeneralSaveData", true));
		}

		private void LookForHQoLOrOverworked()
		{
			Type type = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes()).FirstOrDefault((Type t) => t.FullName == "HQoL.Util.ItemReference");
			if (type != null)
			{
				UsingHQoL = true;
				HQolItemReference = Activator.CreateInstance(typeof(List<>).MakeGenericType(type));
				Plugin.OwLogger.LogInfo((object)"HQoL Found");
				return;
			}
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "Overworked");
			if (assembly != null)
			{
				UsingOverworked = true;
				Plugin.OwLogger.LogInfo((object)"Overworked Found");
			}
		}

		public void StartHosting()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			if (!string.IsNullOrEmpty(TargetView.LobbyName) && TargetView.SelectedSaveFileIndex > 0)
			{
				GameNetworkManager instance = GameNetworkManager.Instance;
				instance.currentSaveFileName = $"LCSaveFile{TargetView.SelectedSaveFileIndex}";
				instance.saveFileNum = TargetView.SelectedSaveFileIndex;
				instance.lobbyHostSettings = new HostSettings(TargetView.LobbyName, TargetView.IsPublic, "");
				ES3.Save<string>("OwUi_LastName", TargetView.LobbyName, "LCGeneralSaveData");
				ES3.Save<int>("OwUi_LastSelect", TargetView.SelectedSaveFileIndex, "LCGeneralSaveData");
				ES3.Save<bool>("OwUi_LastLobbyVis", TargetView.IsPublic, "LCGeneralSaveData");
				instance.StartHost();
				HideUi();
			}
		}

		public void DeleteFile(int index)
		{
			if (ES3.FileExists($"LCSavefile{index}") && Regex.IsMatch($"LCSaveFile{index}", "^LCSaveFile\\d+$"))
			{
				ES3.Save<int>("OwUi_LastSelect", -1, "LCGeneralSaveData");
				ES3.DeleteFile($"LCSavefile{index}");
				ReloadSaves();
			}
		}

		public void RenameFile(int index, string name)
		{
			ES3.Save<string>("Alias_BetterSaves", name, $"LCSaveFile{index}");
			ReloadSaves();
		}

		public void ShowUi()
		{
			((Component)this).gameObject.SetActive(true);
		}

		public void HideUi()
		{
			((Component)this).gameObject.SetActive(false);
		}

		public void CreateSaveFile(int seed, string fileName, int credits, Dictionary<string, object> extraData)
		{
			ES3.Save<string>("CreationDate", DateTime.Now.ToString("d/M/yyyy:H:mm"), "LCSaveFile964298");
			ES3.Save<int>("RandomSeed", seed, "LCSaveFile964298");
			ES3.Save<string>("Alias_BetterSaves", fileName, "LCSaveFile964298");
			ES3.Save<int>("FileGameVers", OwUiMenuManager.GameVersion, "LCSaveFile964298");
			ES3.Save<int>("GroupCredits", credits, "LCSaveFile964298");
			foreach (var (text2, obj2) in extraData)
			{
				ES3.Save(text2, obj2, "LCSaveFile964298");
			}
			ReloadSaves();
		}

		public void ReloadSaves()
		{
			TargetView.ClearSaveView();
			string[] array = (from f in ES3.GetFiles()
				where ES3.FileExists(f) && Regex.IsMatch(f, "^LCSaveFile\\d+$")
				select f).OrderBy(delegate(string f)
			{
				string s = new string(f.Where(char.IsDigit).ToArray());
				int result;
				return int.TryParse(s, out result) ? result : int.MaxValue;
			}).ToArray();
			int num = 1;
			string[] array2 = array;
			foreach (string text in array2)
			{
				string text2 = $"LCSaveFile{num}";
				if (text != text2)
				{
					ES3.RenameFile(text, text2);
				}
				string text3 = ES3.Load<string>("Alias_BetterSaves", text2, "");
				string saveName = ((!string.IsNullOrEmpty(text3)) ? text3 : $"Save File {num}");
				int count = ES3.Load<int>("CurrentPlanetID", text2, 0);
				KeyValuePair<string, (string[], bool, bool, int)> keyValuePair = VanillaData.MoonData.Where((KeyValuePair<string, (string[] Weathers, bool IsPaid, bool IsAccessible, int VersionAdded)> e) => e.Value.VersionAdded < OwUiMenuManager.GameVersion).Skip(count).FirstOrDefault();
				int storageSystem = -1;
				int num3 = 0;
				if (UsingHQoL)
				{
					object obj = ES3.Load("HQoL.ScrapList", text2, HQolItemReference);
					if (obj is IEnumerable enumerable)
					{
						foreach (object item in enumerable)
						{
							int num4 = (int)item.GetType().GetField("value").GetValue(item);
							num3 += num4;
						}
					}
					storageSystem = 1;
				}
				if (UsingOverworked)
				{
					storageSystem = 2;
					num3 = ES3.Load<int>("Ow_money", text2, 0);
				}
				Plugin.OwLogger.LogInfo((object)num3);
				string moon = keyValuePair.Key ?? "Modded moon";
				TargetView.AddSaveView(num, text2, saveName, ES3.Load<int>("GroupCredits", text2, 60), ES3.Load<int>("Stats_DaysSpent", text2, 0), moon, ES3.Load<string>("CreationDate", text2, "???"), ES3.Load<int>("RandomSeed", text2, 0), storageSystem, num3);
				num++;
			}
		}
	}
	internal class OwUiView : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__28_0;

			internal void <InitBindings>b__28_0()
			{
				Application.OpenURL("file://" + Application.persistentDataPath);
			}
		}

		private Button _folderButton;

		private TMP_InputField _lobbyName;

		private GameObject _saveHolder;

		private Button _confirmButton;

		private Button _backButton;

		private Button _refreshButton;

		private Button _createSaveButton;

		private Button _publicBtn;

		private Button _privateBtn;

		private GameObject _confirmMenu;

		private GameObject _saveFileConfig;

		private Button _saveBackButton;

		public GameObject SavePrefab = (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Save.prefab");

		private Button _rerollSeed;

		private TextMeshProUGUI _currentSeed;

		private GameObject _categoriesHolder;

		private GameObject _categoriesDataHolder;

		private Button _createSaveFile;

		private TMP_InputField _saveFileConfigName;

		private readonly Color32 _visColorSelectBckg = new Color32((byte)221, (byte)66, (byte)42, byte.MaxValue);

		private readonly Color32 _visColorSelectTxt = new Color32((byte)99, (byte)28, (byte)28, byte.MaxValue);

		public bool IsPublic = true;

		public string LobbyName = "My Lobby";

		public int SelectedSaveFileIndex = -1;

		private Action<int, string, int, Dictionary<string, object>> _createFileCallback;

		private Action _refreshCallback;

		private Action _closeCallback;

		private Action<int, string> _renameFileCallback;

		private Action<int> _deleteFileCallback;

		private Action _confirmButtonCallback;

		public int Seed = 0;

		public int Credits = 60;

		private List<ListableCategory> _categories = new List<ListableCategory>();

		public ListableCategory SelectedCategory;

		public void Initialize()
		{
			Plugin.OwLogger.LogInfo((object)"Initialized called");
			_folderButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/OpenFolder")).GetComponent<Button>();
			_lobbyName = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/LobbyName")).GetComponent<TMP_InputField>();
			_saveHolder = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/SaveList/Viewport/Content")).gameObject;
			_confirmButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/Confirm")).GetComponent<Button>();
			_backButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/Back")).GetComponent<Button>();
			_refreshButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/Refresh")).GetComponent<Button>();
			_createSaveButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/SaveList/Viewport/Content/OwUi_NewSave/Background")).GetComponent<Button>();
			_publicBtn = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/Public")).GetComponent<Button>();
			_privateBtn = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/Private")).GetComponent<Button>();
			_confirmMenu = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileSelect/ConfirmDeletion")).gameObject;
			_saveFileConfig = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig")).gameObject;
			_saveBackButton = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Topbar/Back")).GetComponent<Button>();
			_rerollSeed = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Topbar1/Reroll")).GetComponent<Button>();
			_currentSeed = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Topbar/CurrentSeed")).GetComponent<TextMeshProUGUI>();
			_categoriesHolder = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Categories/Viewport/Content")).gameObject;
			_categoriesDataHolder = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Content/Viewport/Content")).gameObject;
			_createSaveFile = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Topbar/Create")).GetComponent<Button>();
			_saveFileConfigName = ((Component)((Component)this).gameObject.transform.Find("Background/SaveFileConfig/Topbar1/SaveName")).GetComponent<TMP_InputField>();
			_saveFileConfig.SetActive(false);
			InitBindings();
		}

		public void PassValues(string lastLobbyName, int lastSave, bool wasPublic)
		{
			SetVisibility(wasPublic);
			SetSelectedFile(lastSave);
			LobbyName = lastLobbyName;
			_lobbyName.text = lastLobbyName;
		}

		public void SetVisibility(bool vis)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00ef: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			IsPublic = vis;
			if (vis)
			{
				((Graphic)((Component)_publicBtn).gameObject.GetComponent<Image>()).color = Color32.op_Implicit(_visColorSelectBckg);
				((Graphic)((Component)_publicBtn).gameObject.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectTxt);
				((Graphic)((Component)_privateBtn).gameObject.GetComponent<Image>()).color = Color32.op_Implicit(_visColorSelectTxt);
				((Graphic)((Component)_privateBtn).gameObject.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectBckg);
			}
			else
			{
				((Graphic)((Component)_privateBtn).gameObject.GetComponent<Image>()).color = Color32.op_Implicit(_visColorSelectBckg);
				((Graphic)((Component)_privateBtn).gameObject.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectTxt);
				((Graphic)((Component)_publicBtn).gameObject.GetComponent<Image>()).color = Color32.op_Implicit(_visColorSelectTxt);
				((Graphic)((Component)_publicBtn).gameObject.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectBckg);
			}
		}

		public void HideRerollButton()
		{
			((Component)_currentSeed).gameObject.SetActive(false);
			((Component)_rerollSeed).gameObject.SetActive(false);
		}

		private void InitBindings()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0020: 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_002b: Expected O, but got Unknown
			ButtonClickedEvent onClick = _folderButton.onClick;
			object obj = <>c.<>9__28_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					Application.OpenURL("file://" + Application.persistentDataPath);
				};
				<>c.<>9__28_0 = val;
				obj = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			((UnityEvent)_createSaveButton.onClick).AddListener((UnityAction)delegate
			{
				_saveFileConfig.SetActive(true);
			});
			((UnityEvent)_createSaveFile.onClick).AddListener((UnityAction)delegate
			{
				_saveFileConfig.SetActive(false);
				Dictionary<string, object> dictionary = new Dictionary<string, object>();
				foreach (ListableCategory category in _categories)
				{
					Dictionary<string, object> dictionary2 = category.OnExport?.Invoke();
					if (dictionary2 != null)
					{
						foreach (KeyValuePair<string, object> item in dictionary2)
						{
							item.Deconstruct(out var key, out var value);
							string key2 = key;
							object value2 = value;
							dictionary[key2] = value2;
						}
					}
				}
				_createFileCallback?.Invoke(Seed, _saveFileConfigName.text, Credits, dictionary);
			});
			((UnityEvent)_saveBackButton.onClick).AddListener((UnityAction)delegate
			{
				_saveFileConfig.SetActive(false);
			});
			((UnityEvent<string>)(object)_lobbyName.onEndEdit).AddListener((UnityAction<string>)delegate(string value)
			{
				LobbyName = value;
			});
			((UnityEvent)_backButton.onClick).AddListener((UnityAction)delegate
			{
				_closeCallback?.Invoke();
			});
			((UnityEvent)_refreshButton.onClick).AddListener((UnityAction)delegate
			{
				_refreshCallback?.Invoke();
			});
			((UnityEvent)_publicBtn.onClick).AddListener((UnityAction)delegate
			{
				SetVisibility(vis: true);
			});
			((UnityEvent)_privateBtn.onClick).AddListener((UnityAction)delegate
			{
				SetVisibility(vis: false);
			});
			((UnityEvent)_confirmButton.onClick).AddListener((UnityAction)delegate
			{
				if (SelectedSaveFileIndex != -1)
				{
					_confirmButtonCallback?.Invoke();
				}
			});
			((UnityEvent)_rerollSeed.onClick).AddListener((UnityAction)delegate
			{
				UpdateSeedView(Random.Range(1, 100000000));
			});
		}

		public void BindClose(Action closeCallback)
		{
			_closeCallback = closeCallback;
		}

		public void BindRefresh(Action refreshCallback)
		{
			_refreshCallback = refreshCallback;
		}

		public void BindCreateFile(Action<int, string, int, Dictionary<string, object>> createFileCallback)
		{
			_createFileCallback = createFileCallback;
		}

		public void BindRenameFile(Action<int, string> renameFileCallback)
		{
			_renameFileCallback = renameFileCallback;
		}

		public void BindDeleteFile(Action<int> deleteFileCallback)
		{
			_deleteFileCallback = deleteFileCallback;
		}

		public void BindConfirmButton(Action confirmButtonCallback)
		{
			_confirmButtonCallback = confirmButtonCallback;
		}

		public void SetSelectedFile(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			SelectedSaveFileIndex = index;
			int num = 0;
			foreach (Transform item in _saveHolder.transform)
			{
				Transform val = item;
				if (((Object)val).name != "OwUi_NewSave")
				{
					Outline componentInChildren = ((Component)val).GetComponentInChildren<Outline>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						((Behaviour)componentInChildren).enabled = num == index - 1;
					}
					num++;
				}
			}
			if (index != -1)
			{
				((Graphic)((Component)_confirmButton).GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectBckg);
			}
			else
			{
				((Graphic)((Component)_confirmButton).GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(_visColorSelectTxt);
			}
		}

		public void ClearSaveView()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			SelectedSaveFileIndex = -1;
			SetSelectedFile(-1);
			foreach (Transform item in _saveHolder.transform)
			{
				Transform val = item;
				if (((Object)((Component)val).gameObject).name != "OwUi_NewSave")
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		public void AddSaveView(int index, string internalName, string? saveName, int? money, int? days, string? moon, string? creationDate, long? seed, int storageSystem, int storedMoney)
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(SavePrefab);
			val.transform.SetParent(_saveHolder.transform, false);
			((TMP_Text)((Component)val.transform.Find("Background/Name")).GetComponent<TextMeshProUGUI>()).text = saveName;
			((TMP_Text)((Component)val.transform.Find("Background/Money")).GetComponent<TextMeshProUGUI>()).text = $"${money}";
			((TMP_Text)((Component)val.transform.Find("Background/Day")).GetComponent<TextMeshProUGUI>()).text = "Day " + days;
			((TMP_Text)((Component)val.transform.Find("Background/Planet")).GetComponent<TextMeshProUGUI>()).text = moon;
			((TMP_Text)((Component)val.transform.Find("Background/Date")).GetComponent<TextMeshProUGUI>()).text = creationDate;
			((TMP_Text)((Component)val.transform.Find("Background/Seed")).GetComponent<TextMeshProUGUI>()).text = seed.ToString();
			TextMeshProUGUI component = ((Component)val.transform.Find("Background/StoredMoney")).GetComponent<TextMeshProUGUI>();
			switch (storageSystem)
			{
			case -1:
				((Component)component).gameObject.SetActive(false);
				break;
			case 1:
				((Graphic)component).color = Color32.op_Implicit(new Color32((byte)0, (byte)93, (byte)202, byte.MaxValue));
				break;
			case 2:
				((Graphic)component).color = Color32.op_Implicit(new Color32((byte)0, (byte)120, (byte)34, byte.MaxValue));
				break;
			}
			if (storedMoney == 0)
			{
				((Component)component).gameObject.SetActive(false);
			}
			((TMP_Text)component).text = $"${storedMoney}";
			UnityAction val2 = default(UnityAction);
			UnityAction val5 = default(UnityAction);
			((UnityEvent)((Component)val.transform.Find("Background/Delete")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				//IL_0049: 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_0050: Expected O, but got Unknown
				//IL_0055: Expected O, but got Unknown
				//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_0099: Expected O, but got Unknown
				//IL_009e: Expected O, but got Unknown
				_confirmMenu.SetActive(true);
				ButtonClickedEvent onClick = ((Component)_confirmMenu.transform.Find("Foreground/Confirm")).GetComponent<Button>().onClick;
				UnityAction obj = val2;
				if (obj == null)
				{
					UnityAction val3 = delegate
					{
						_deleteFileCallback?.Invoke(index);
						_confirmMenu.SetActive(false);
						((UnityEventBase)((Component)_confirmMenu.transform.Find("Foreground/Confirm")).GetComponent<Button>().onClick).RemoveAllListeners();
						((UnityEventBase)((Component)_confirmMenu.transform.Find("Foreground/Cancel")).GetComponent<Button>().onClick).RemoveAllListeners();
					};
					UnityAction val4 = val3;
					val2 = val3;
					obj = val4;
				}
				((UnityEvent)onClick).AddListener(obj);
				ButtonClickedEvent onClick2 = ((Component)_confirmMenu.transform.Find("Foreground/Cancel")).GetComponent<Button>().onClick;
				UnityAction obj2 = val5;
				if (obj2 == null)
				{
					UnityAction val6 = delegate
					{
						_confirmMenu.SetActive(false);
						((UnityEventBase)((Component)_confirmMenu.transform.Find("Foreground/Confirm")).GetComponent<Button>().onClick).RemoveAllListeners();
						((UnityEventBase)((Component)_confirmMenu.transform.Find("Foreground/Cancel")).GetComponent<Button>().onClick).RemoveAllListeners();
					};
					UnityAction val4 = val6;
					val5 = val6;
					obj2 = val4;
				}
				((UnityEvent)onClick2).AddListener(obj2);
			});
			((UnityEvent)((Component)val.transform.Find("Background/Rename")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				_renameFileCallback?.Invoke(index, LobbyName);
			});
			((UnityEvent)((Component)val.transform.Find("Background")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				SetSelectedFile(index);
			});
		}

		public void ClearChildren(Transform parent)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}

		public void UpdateSeedView(int seed)
		{
			Seed = seed;
			((TMP_Text)_currentSeed).text = $"Current seed: {seed}";
			VanillaData.SeedData seedData = VanillaData.GetSeedData(seed);
			foreach (ListableCategory category in _categories)
			{
				category.OnSeedRoll?.Invoke(seedData);
			}
			RebuildCategoryView();
		}

		public void AddCategory(ListableCategory newCategory)
		{
			_categories.Add(newCategory);
			RebuildCategoriesList();
		}

		public void RebuildCategoriesList()
		{
			ClearChildren(_categoriesHolder.transform);
			foreach (ListableCategory category in _categories)
			{
				GameObject prefab = Object.Instantiate<GameObject>(category.Prefab, _categoriesHolder.transform);
				category.OnPrefab(prefab, this);
			}
		}

		public void SelectCategory(ListableCategory target)
		{
			SelectedCategory = target;
			RebuildCategoryView();
		}

		public void RebuildCategoryView()
		{
			if (SelectedCategory == null)
			{
				return;
			}
			ClearChildren(_categoriesDataHolder.transform);
			foreach (ListableElement element in SelectedCategory.Elements)
			{
				GameObject prefab = Object.Instantiate<GameObject>(element.Prefab, _categoriesDataHolder.transform);
				element.OnPrefab(prefab, this);
			}
		}
	}
}
namespace OverworkedUI.Core.Menu.Categories
{
	internal class DefaultCategories
	{
		internal class ListableTitle : ListableElement
		{
			public override GameObject Prefab => (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Cat_Title.prefab");

			public ListableTitle(string id)
				: base(id)
			{
			}

			public void SetText(string text)
			{
				Set("text", text);
			}

			public override void OnPrefab(GameObject prefab, OwUiView view)
			{
				string text = GetAs<string>("text");
				((TMP_Text)prefab.GetComponentInChildren<TextMeshProUGUI>()).text = text;
			}
		}

		internal class ListableChoice : ListableElement
		{
			public override GameObject Prefab => (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Cat_Choice.prefab");

			public ListableChoice(string id)
				: base(id)
			{
				SetSelected(v: false);
				SetText("Choice");
				Set("selectable", true);
			}

			public void SetSelected(bool v)
			{
				Set("selected", v);
			}

			public void SetText(string t)
			{
				Set("text", t);
			}

			public override void OnPrefab(GameObject prefab, OwUiView view)
			{
				//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_006f: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Expected O, but got Unknown
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				bool flag = GetAs<bool>("selected");
				bool flag2 = GetAs<bool>("selectable");
				string text = GetAs<string>("text");
				if (!flag)
				{
					((Graphic)prefab.GetComponentInChildren<Image>()).color = Color32.op_Implicit(new Color32((byte)0, (byte)0, (byte)0, (byte)0));
					((Graphic)prefab.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(new Color32((byte)17, (byte)101, (byte)10, byte.MaxValue));
				}
				if (!flag2)
				{
					((Graphic)prefab.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(new Color32((byte)101, (byte)39, (byte)10, byte.MaxValue));
				}
				((UnityEvent)prefab.GetComponentInChildren<Button>().onClick).AddListener((UnityAction)delegate
				{
					if (GetAs<bool>("selectable"))
					{
						foreach (ListableElement element in view.SelectedCategory.Elements)
						{
							if (element is ListableChoice)
							{
								((ListableChoice)element).SetSelected(v: false);
							}
						}
						SetSelected(v: true);
						view.RebuildCategoryView();
					}
				});
				((TMP_Text)prefab.GetComponentInChildren<TextMeshProUGUI>()).text = text;
			}
		}

		internal class ListableCounter : ListableElement
		{
			public Action OnAdd;

			public Action OnRemove;

			public int Counter = 0;

			public override GameObject Prefab => (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Cat_Counter.prefab");

			public void SetDisplayVariables(List<string> var)
			{
				Set("display", var);
			}

			public override void OnPrefab(GameObject prefab, OwUiView view)
			{
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Expected O, but got Unknown
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Expected O, but got Unknown
				List<string> list = GetAs<List<string>>("display");
				TextMeshProUGUI component = ((Component)prefab.transform.Find("Background/Text")).GetComponent<TextMeshProUGUI>();
				TextMeshProUGUI component2 = ((Component)prefab.transform.Find("Background/Counter")).GetComponent<TextMeshProUGUI>();
				((TMP_Text)component2).text = "x" + Counter;
				((TMP_Text)component).text = "";
				foreach (string item in list)
				{
					string text = GetAs<string>(item);
					if (text != null)
					{
						((TMP_Text)component).text = ((TMP_Text)component).text + text + " ";
					}
				}
				((UnityEvent)((Component)prefab.transform.Find("Background/Add")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnAdd?.Invoke();
				});
				((UnityEvent)((Component)prefab.transform.Find("Background/Remove")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnRemove?.Invoke();
				});
			}

			public ListableCounter(string id)
				: base(id)
			{
				SetDisplayVariables(new List<string>());
			}
		}

		internal class ListableInput : ListableElement
		{
			public Action<string> OnSubmit;

			public override GameObject Prefab => (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Cat_Box.prefab");

			public ListableInput(string id, string inputText)
				: base(id)
			{
				Set("inputText", inputText);
			}

			public override void OnPrefab(GameObject prefab, OwUiView view)
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Expected O, but got Unknown
				((Component)((Component)prefab.transform.Find("Background/Box")).GetComponent<TMP_InputField>().placeholder).GetComponent<TMP_Text>().text = GetAs<string>("inputText");
				((UnityEvent)((Component)prefab.transform.Find("Background/Add")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnSubmit?.Invoke(((Component)prefab.transform.Find("Background/Box")).GetComponent<TMP_InputField>().text);
				});
			}
		}

		internal class ListableButton : ListableElement
		{
			public Action OnClick;

			public Action OnRemove;

			public override GameObject Prefab => (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Cat_Button.prefab");

			public ListableButton(string id)
				: base(id)
			{
			}

			public override void OnPrefab(GameObject prefab, OwUiView view)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Expected O, but got Unknown
				((UnityEvent)((Component)prefab.transform.Find("Background")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnClick?.Invoke();
				});
				((UnityEvent)((Component)prefab.transform.Find("Background/Add")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnRemove?.Invoke();
				});
				((TMP_Text)((Component)prefab.transform.Find("Background/Text")).GetComponent<TextMeshProUGUI>()).text = GetAs<string>("text");
			}

			public void SetText(string t)
			{
				Set("text", t);
			}
		}

		private static int _version;

		private static OwUiView _targetView;

		private static ListableCategory CreateMoons()
		{
			ListableCategory moonCategory = new ListableCategory("Moons");
			moonCategory.OnSeedRoll = delegate(VanillaData.SeedData data)
			{
				foreach (ListableElement element in moonCategory.Elements)
				{
					if (element is ListableChoice listableChoice2)
					{
						string text = element.GetAs<string>("moonName");
						if (text != null)
						{
							if (data.moonWeathers.ContainsKey(text))
							{
								listableChoice2.SetText("* " + text + " (" + data.moonWeathers[text] + ")");
							}
							else
							{
								listableChoice2.SetText("* " + text);
							}
						}
					}
				}
			};
			moonCategory.OnExport = delegate
			{
				Dictionary<string, object> dictionary = new Dictionary<string, object>();
				ListableElement listableElement = moonCategory.Elements.Find((ListableElement e) => e is ListableChoice && e.GetAs<bool>("selected"));
				if (listableElement != null)
				{
					dictionary["CurrentPlanetID"] = listableElement.GetAs<int>("moonId");
				}
				return dictionary;
			};
			ListableTitle listableTitle = new ListableTitle("main-title");
			listableTitle.SetText("Moons");
			moonCategory.AddElement(listableTitle);
			int num = 0;
			foreach (KeyValuePair<string, (string[], bool, bool, int)> moonDatum in VanillaData.MoonData)
			{
				if (moonDatum.Value.Item3 && _version >= moonDatum.Value.Item4)
				{
					ListableChoice listableChoice = new ListableChoice(moonDatum.Key);
					listableChoice.SetText("* " + moonDatum.Key);
					listableChoice.Set("moonName", moonDatum.Key);
					listableChoice.Set("moonId", num);
					moonCategory.AddElement(listableChoice);
					if (moonDatum.Key == "41 Experimentation")
					{
						listableChoice.SetSelected(v: true);
					}
					if (moonDatum.Value.Item2)
					{
						listableChoice.Set("selectable", false);
					}
					num++;
				}
			}
			return moonCategory;
		}

		private static ListableCategory CreateStore()
		{
			ListableCategory storeCategory = new ListableCategory("Store");
			ListableTitle newTitle = new ListableTitle("main-title");
			newTitle.SetText($"Store (${_targetView.Credits})");
			storeCategory.AddElement(newTitle);
			storeCategory.OnSeedRoll = delegate(VanillaData.SeedData data)
			{
				_targetView.Credits = 60;
				newTitle.SetText($"Store (${_targetView.Credits})");
				foreach (ListableElement element in storeCategory.Elements)
				{
					if (element is ListableCounter listableCounter)
					{
						string key = element.GetAs<string>("id");
						int num = listableCounter.GetAs<int>("itemPrice");
						listableCounter.Counter = 0;
						if (data.storeSales.TryGetValue(key, out var value))
						{
							int num2 = Mathf.RoundToInt((float)num * (1f - (float)value / 100f));
							listableCounter.Set("displaySale", $"({value}% Off)");
							listableCounter.Set("displayPrice", $"{num2}$");
							listableCounter.Set("itemPriceWithSale", num2);
						}
						else
						{
							listableCounter.Set("displaySale", "");
							listableCounter.Set("displayPrice", $"{num}$");
							listableCounter.Set("itemPriceWithSale", num);
						}
					}
				}
			};
			storeCategory.OnExport = delegate
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<string, object> dictionary = new Dictionary<string, object>();
				List<int> list = new List<int>();
				List<Vector3> list2 = new List<Vector3>();
				foreach (ListableElement element2 in storeCategory.Elements)
				{
					if (element2 is ListableCounter listableCounter)
					{
						for (int i = 0; i < listableCounter.Counter; i++)
						{
							list.Add(element2.GetAs<int>("itemId"));
							list2.Add(Vector3.zero);
						}
					}
				}
				dictionary["shipGrabbableItemIDs"] = list.ToArray();
				dictionary["shipGrabbableItemPos"] = list2.ToArray();
				return dictionary;
			};
			foreach (var value2 in VanillaData.AvailableItems.Values)
			{
				ListableCounter counter = new ListableCounter(value2.itemName);
				counter.Set("itemName", value2.itemName + " //");
				counter.Set("itemPrice", value2.creditsWorth);
				counter.Set("itemPriceWithSale", value2.creditsWorth);
				counter.Set("itemId", value2.itemId);
				counter.Set("displayPrice", value2.creditsWorth + "$");
				counter.Set("displaySale", "");
				counter.SetDisplayVariables(new List<string> { "itemName", "displayPrice", "displaySale" });
				counter.OnAdd = delegate
				{
					int num = counter.GetAs<int>("itemPriceWithSale");
					Plugin.OwLogger.LogInfo((object)counter.GetAs<int>("itemId"));
					if (_targetView.Credits >= num)
					{
						counter.Counter++;
						_targetView.Credits -= num;
						newTitle.SetText($"Store (${_targetView.Credits})");
						_targetView.RebuildCategoryView();
					}
				};
				counter.OnRemove = delegate
				{
					if (counter.Counter > 0)
					{
						int num = counter.GetAs<int>("itemPriceWithSale");
						counter.Counter--;
						_targetView.Credits += num;
						newTitle.SetText($"Store (${_targetView.Credits})");
						_targetView.RebuildCategoryView();
					}
				};
				storeCategory.AddElement(counter);
			}
			return storeCategory;
		}

		private static ListableCategory CreateSavedSeeds()
		{
			ListableCategory seedCategory = new ListableCategory("Seeds");
			Dictionary<int, string> seeds = ES3.Load<Dictionary<int, string>>("seeds", "OwUiSavedSeeds", new Dictionary<int, string>());
			ListableTitle listableTitle = new ListableTitle("main-title");
			listableTitle.SetText("Seeds");
			seedCategory.AddElement(listableTitle);
			ListableInput listableInput = new ListableInput("main-title", "Enter seed");
			seedCategory.AddElement(listableInput);
			Action<int, string> CreateButton = delegate(int seed, string text2)
			{
				ListableButton newBtn = new ListableButton("value");
				newBtn.SetText(text2);
				newBtn.OnClick = delegate
				{
					_targetView.UpdateSeedView(seed);
				};
				newBtn.OnRemove = delegate
				{
					seeds.Remove(seed);
					seedCategory.RemoveElement(newBtn);
					_targetView.RebuildCategoryView();
					ES3.Save<Dictionary<int, string>>("seeds", seeds, "OwUiSavedSeeds");
				};
				seedCategory.AddElement(newBtn);
				_targetView.RebuildCategoryView();
			};
			listableInput.OnSubmit = delegate(string s)
			{
				if (int.TryParse(s, out var result))
				{
					VanillaData.SeedData seedData = VanillaData.GetSeedData(result);
					string text2 = "";
					foreach (KeyValuePair<string, int> storeSale in seedData.storeSales)
					{
						storeSale.Deconstruct(out var key, out var value);
						string text3 = key;
						int num2 = value;
						text2 = text2 + text3.Substring(0, 3) + num2 + "%";
					}
					text2.Trim();
					if (text2 == "")
					{
						text2 = "No sales";
					}
					CreateButton(result, text2);
					seeds[result] = text2;
					ES3.Save<Dictionary<int, string>>("seeds", seeds, "OwUiSavedSeeds");
				}
			};
			foreach (var (arg, arg2) in seeds)
			{
				CreateButton(arg, arg2);
			}
			return seedCategory;
		}

		internal static void Inject(OwUiView targetView, int version)
		{
			_version = version;
			_targetView = targetView;
			_targetView.AddCategory(CreateMoons());
			_targetView.AddCategory(CreateStore());
			if (_version >= 81)
			{
				_targetView.AddCategory(CreateSavedSeeds());
				_targetView.UpdateSeedView(Random.Range(1, 100000000));
			}
		}
	}
	internal class ListableCategory
	{
		public GameObject Prefab = (GameObject)OwUiCore.GetBundle().LoadAsset<Object>("assets/overworked/ui/OwUi_Category.prefab");

		public List<ListableElement> Elements = new List<ListableElement>();

		public Action<VanillaData.SeedData> OnSeedRoll;

		public Func<Dictionary<string, object>> OnExport;

		public string Name { get; private set; } = "New Category";

		public void OnPrefab(GameObject prefab, OwUiView view)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			((Object)prefab).name = Name;
			((TMP_Text)((Component)prefab.transform).GetComponentInChildren<TextMeshProUGUI>()).text = Name;
			((UnityEvent)prefab.GetComponentInChildren<Button>().onClick).AddListener((UnityAction)delegate
			{
				view.SelectCategory(this);
			});
		}

		public void AddElement(ListableElement elem)
		{
			Elements.Add(elem);
		}

		public void RemoveElement(ListableElement elem)
		{
			Elements.Remove(elem);
		}

		public ListableElement? GetElementFromId(string id)
		{
			foreach (ListableElement element in Elements)
			{
				if (element.GetAs<string>("id") == id)
				{
					return element;
				}
			}
			return null;
		}

		public ListableCategory(string name, GameObject prefab)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			Name = name;
			Prefab = prefab;
		}

		public ListableCategory(string name)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			Name = name;
		}
	}
	internal abstract class ListableElement
	{
		public Dictionary<string, object> Data = new Dictionary<string, object>();

		public virtual GameObject Prefab { get; }

		public virtual void OnPrefab(GameObject prefab, OwUiView view)
		{
		}

		public void Set(string key, object value)
		{
			Data[key] = value;
		}

		public T GetAs<T>(string key)
		{
			if (Data.TryGetValue(key, out var value))
			{
				return (T)value;
			}
			return default(T);
		}

		public ListableElement(string id)
		{
			Set("id", id);
		}
	}
}
namespace OverworkedUI.Core.Data
{
	internal class VanillaData
	{
		public struct SeedData
		{
			public int seed;

			public Dictionary<string, string> moonWeathers;

			public Dictionary<string, int> storeSales;
		}

		public static readonly Dictionary<string, (string[] Weathers, bool IsPaid, bool IsAccessible, int VersionAdded)> MoonData = new Dictionary<string, (string[], bool, bool, int)>
		{
			{
				"41 Experimentation",
				(new string[5] { "Rainy", "Stormy", "Foggy", "Flooded", "Eclipsed" }, false, true, 0)
			},
			{
				"220 Assurance",
				(new string[5] { "Rainy", "Stormy", "Flooded", "Eclipsed", "Foggy" }, false, true, 0)
			},
			{
				"56 Vow",
				(new string[4] { "Flooded", "Stormy", "Foggy", "Eclipsed" }, false, true, 0)
			},
			{
				"71 Gordion",
				(new string[0], false, true, 0)
			},
			{
				"61 March",
				(new string[3] { "Stormy", "Foggy", "Eclipsed" }, false, true, 0)
			},
			{
				"20 Adamance",
				(new string[5] { "Stormy", "Eclipsed", "Rainy", "Flooded", "Foggy" }, false, true, 50)
			},
			{
				"85 Rend",
				(new string[2] { "Stormy", "Eclipsed" }, true, true, 0)
			},
			{
				"7 Dine",
				(new string[3] { "Flooded", "Eclipsed", "Rainy" }, true, true, 0)
			},
			{
				"21 Offense",
				(new string[5] { "Rainy", "Stormy", "Eclipsed", "Flooded", "Foggy" }, false, true, 0)
			},
			{
				"8 Titan",
				(new string[3] { "Stormy", "Foggy", "Eclipsed" }, true, true, 0)
			},
			{
				"68 Artifice",
				(new string[5] { "Stormy", "Eclipsed", "Rainy", "Flooded", "Foggy" }, true, true, 50)
			},
			{
				"44 Liquidation",
				(new string[4] { "Stormy", "Eclipsed", "Rainy", "Flooded" }, true, false, 50)
			},
			{
				"5 Embrion",
				(new string[2] { "Foggy", "Eclipsed" }, true, true, 50)
			}
		};

		public static readonly List<string> BuyableItemList = new List<string>
		{
			"Walkie-talkie", "Flashlight", "Shovel", "Lockpicker", "Pro-flashlight", "Stun grenade", "Boombox", "TZP-Inhalant", "Zap gun", "Jetpack",
			"Extension ladder", "Radar-booster", "Spray paint", "Weed killer", "Belt bag", "Cruiser"
		};

		public static readonly Dictionary<string, int> BuyableItemIds = new Dictionary<string, int>
		{
			{ "Walkie-talkie", 14 },
			{ "Flashlight", 3 },
			{ "Shovel", 10 },
			{ "Lockpicker", 6 },
			{ "Pro-flashlight", 9 },
			{ "Stun grenade", 11 },
			{ "Boombox", 1 },
			{ "TZP-Inhalant", 13 },
			{ "Zap gun", 15 },
			{ "Jetpack", 4 },
			{ "Extension ladder", 12 },
			{ "Radar-booster", 57 },
			{ "Spray paint", 61 },
			{ "Weed killer", 70 },
			{ "Belt bag", 79 }
		};

		public static Dictionary<string, (string itemName, int highestSalePercentage, int creditsWorth, int itemId)> AvailableItems = new Dictionary<string, (string, int, int, int)>();

		public static AnimationCurve GetWeatherCurve()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			Keyframe val = default(Keyframe);
			((Keyframe)(ref val))..ctor(0f, 0f, 3.9991f, 3.9991f);
			((Keyframe)(ref val)).weightedMode = (WeightedMode)3;
			((Keyframe)(ref val)).inWeight = 0f;
			((Keyframe)(ref val)).outWeight = 0.234f;
			Keyframe val2 = val;
			((Keyframe)(ref val))..ctor(0.4983f, 0.4932f, 0.4621f, 0.4621f);
			((Keyframe)(ref val)).weightedMode = (WeightedMode)3;
			((Keyframe)(ref val)).inWeight = 0.8088f;
			((Keyframe)(ref val)).outWeight = 0.6222f;
			Keyframe val3 = val;
			((Keyframe)(ref val))..ctor(1f, 1.0039f, 4.3878f, 4.3878f);
			((Keyframe)(ref val)).weightedMode = (WeightedMode)3;
			((Keyframe)(ref val)).inWeight = 0.1519f;
			((Keyframe)(ref val)).outWeight = 0f;
			Keyframe val4 = val;
			AnimationCurve val5 = new AnimationCurve((Keyframe[])(object)new Keyframe[3] { val2, val3, val4 });
			val5.preWrapMode = (WrapMode)8;
			val5.postWrapMode = (WrapMode)8;
			return val5;
		}

		public static void PopulateAvailableItems()
		{
			Item[] array = Resources.FindObjectsOfTypeAll<Item>();
			Item[] array2 = array;
			foreach (Item val in array2)
			{
				if (BuyableItemList.Contains(val.itemName))
				{
					AvailableItems[val.itemName] = (val.itemName, val.highestSalePercentage, val.creditsWorth, BuyableItemIds[val.itemName]);
				}
			}
			if (OwUiMenuManager.GameVersion >= 55)
			{
				AvailableItems["Cruiser"] = ("Cruiser", 80, 370, -1);
			}
		}

		public static SeedData GetSeedData(int seed)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			AnimationCurve weatherCurve = GetWeatherCurve();
			Random random = new Random(seed + 35);
			List<string> list = MoonData.Keys.ToList();
			float num = Mathf.Clamp(weatherCurve.Evaluate((float)random.NextDouble()) * 1f, 0f, 1f);
			int num2 = Mathf.Clamp((int)(num * ((float)MoonData.Keys.Count - 3f)), 0, MoonData.Keys.Count);
			for (int i = 0; i < num2; i++)
			{
				int index = random.Next(0, list.Count);
				string text = list[index];
				string[] item = MoonData[text].Weathers;
				if (text != "41 Experimentation")
				{
					if (item != null && item.Length != 0)
					{
						string value = item[random.Next(0, item.Length)];
						dictionary[text] = value;
					}
					list.Remove(text);
				}
			}
			Random random2 = new Random(seed + 90);
			int num3 = Mathf.Max(random2.Next(-10, 5), 0);
			if (num3 > 0)
			{
				List<int> list2 = new List<int>();
				int[] array = new int[BuyableItemList.Count];
				for (int j = 0; j < BuyableItemList.Count; j++)
				{
					list2.Add(j);
					array[j] = 100;
				}
				for (int k = 0; k < num3; k++)
				{
					if (list2.Count <= 0)
					{
						break;
					}
					int num4 = random2.Next(0, list2.Count);
					int item2 = AvailableItems[BuyableItemList[num4]].highestSalePercentage;
					int maxValue = ((num4 < BuyableItemList.Count) ? Mathf.Clamp(item2, 0, 90) : 80);
					int num5 = 100 - random2.Next(0, maxValue);
					num5 = (int)Math.Round((double)num5 / 10.0) * 10;
					array[num4] = num5;
					list2.RemoveAt(num4);
				}
				for (int l = 0; l < array.Length; l++)
				{
					if (array[l] < 100)
					{
						dictionary2[BuyableItemList.ElementAt(l)] = 100 - array[l];
					}
				}
			}
			return new SeedData
			{
				seed = seed,
				moonWeathers = dictionary,
				storeSales = dictionary2
			};
		}
	}
}