Decompiled source of OutputRandomizer v1.0.0

BepInEx/plugins/OutputRandomizer/OutputRandomizer.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("OutputRandomizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+15ec46452908e021cd9085358a46476248f8b03a")]
[assembly: AssemblyProduct("OutputRandomizer")]
[assembly: AssemblyTitle("OutputRandomizer")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OutputRandomizer
{
	internal static class ItemFilterPicker
	{
		private sealed class ItemCellHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			private ItemProto _item;

			private UIButtonTip _tip;

			internal void SetItem(ItemProto item)
			{
				_item = item;
			}

			internal void RefreshVisual()
			{
				if (_item != null)
				{
					RefreshCell(((Component)this).gameObject, ((Proto)_item).ID);
				}
			}

			public void OnPointerEnter(PointerEventData eventData)
			{
				//IL_0034: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				if (_item == null || (Object)(object)_tip != (Object)null)
				{
					return;
				}
				_tip = UIButtonTip.Create(true, string.Empty, ((Proto)_item).name, 5, Vector2.zero, 240, ((Component)this).transform, string.Empty, string.Empty);
				if ((Object)(object)_tip != (Object)null)
				{
					((Component)_tip).transform.SetParent(_window.transform, false);
					((Component)_tip).transform.SetAsLastSibling();
					Transform transform = ((Component)_tip).transform;
					RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if ((Object)(object)val != (Object)null)
					{
						val.anchorMin = new Vector2(0.5f, 0.5f);
						val.anchorMax = new Vector2(0.5f, 0.5f);
						val.pivot = new Vector2(0.5f, 0f);
						val.anchoredPosition = new Vector2(0f, 260f);
					}
				}
			}

			public void OnPointerExit(PointerEventData eventData)
			{
				ClearTooltip();
			}

			private void OnDisable()
			{
				ClearTooltip();
			}

			private void ClearTooltip()
			{
				if (!((Object)(object)_tip == (Object)null))
				{
					Object.Destroy((Object)(object)((Component)_tip).gameObject);
					_tip = null;
				}
			}
		}

		private const int Columns = 12;

		private const float CellSize = 46f;

		private static GameObject _window;

		private static RectTransform _content;

		private static Text _bodyTextTemplate;

		private static Text _headingTemplate;

		private static HashSet<int> _selectedIds;

		private static Action<int> _onToggle;

		private static int _activeTab;

		internal static HashSet<int> GetCandidateItemIds()
		{
			return new HashSet<int>(from item in GetCandidateItems()
				select ((Proto)item).ID);
		}

		internal static void Open(RectTransform parent, Text bodyTextTemplate, Text headingTemplate, HashSet<int> selectedIds, Action<int> onToggle)
		{
			ManualLogSource modLogger = Plugin.ModLogger;
			if (modLogger != null)
			{
				modLogger.LogInfo((object)"Opening ItemFilterPicker window.");
			}
			if (!((Object)(object)parent == (Object)null) && !((Object)(object)bodyTextTemplate == (Object)null) && !((Object)(object)headingTemplate == (Object)null) && selectedIds != null && onToggle != null)
			{
				Close();
				_bodyTextTemplate = bodyTextTemplate;
				_headingTemplate = headingTemplate;
				_selectedIds = selectedIds;
				_onToggle = onToggle;
				_activeTab = 0;
				BuildWindow(parent);
				RebuildGrid();
			}
		}

		internal static void Close()
		{
			if ((Object)(object)_window != (Object)null)
			{
				Object.Destroy((Object)(object)_window);
			}
			_window = null;
			_content = null;
			_selectedIds = null;
			_onToggle = null;
		}

		private static void BuildWindow(RectTransform parent)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Expected O, but got Unknown
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Expected O, but got Unknown
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Expected O, but got Unknown
			_window = new GameObject("OutputRandomizer_ItemFilter", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			_window.transform.SetParent((Transform)(object)parent, false);
			_window.transform.SetAsLastSibling();
			RectTransform component = _window.GetComponent<RectTransform>();
			Stretch(component);
			Image component2 = _window.GetComponent<Image>();
			((Graphic)component2).color = new Color(0f, 0f, 0f, 0.55f);
			((Graphic)component2).raycastTarget = true;
			GameObject val = new GameObject("Border", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(_window.transform, false);
			RectTransform component3 = val.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0.5f, 0.5f);
			component3.anchorMax = new Vector2(0.5f, 0.5f);
			component3.pivot = new Vector2(0.5f, 0.5f);
			component3.sizeDelta = new Vector2(652f, 502f);
			((Graphic)val.GetComponent<Image>()).color = new Color(0.15f, 0.2f, 0.28f, 0.8f);
			GameObject val2 = new GameObject("Dialog", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent(_window.transform, false);
			RectTransform component4 = val2.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.5f, 0.5f);
			component4.anchorMax = new Vector2(0.5f, 0.5f);
			component4.pivot = new Vector2(0.5f, 0.5f);
			component4.sizeDelta = new Vector2(650f, 500f);
			((Graphic)val2.GetComponent<Image>()).color = new Color(0.04f, 0.055f, 0.075f, 0.96f);
			CreateText(component4, _headingTemplate, "Random Miner Output Filter", Vector2.zero, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(-24f, 30f), (TextAnchor)4, 18);
			CreateButton(component4, "Close", new Vector2(-8f, 8f), new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(60f, 26f), Close);
			Transform transform = new GameObject("Tabs", new Type[1] { typeof(RectTransform) }).transform;
			transform.SetParent((Transform)(object)component4, false);
			RectTransform val3 = (RectTransform)transform;
			val3.anchorMin = new Vector2(0f, 1f);
			val3.anchorMax = new Vector2(1f, 1f);
			val3.pivot = new Vector2(0.5f, 1f);
			val3.anchoredPosition = new Vector2(0f, -48f);
			val3.sizeDelta = new Vector2(-24f, 34f);
			HorizontalLayoutGroup val4 = ((Component)transform).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val4).spacing = 6f;
			((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = true;
			string[] array = new string[4] { "All", "Items", "Buildings", "Other" };
			for (int i = 0; i < array.Length; i++)
			{
				int capturedIndex = i;
				CreateButton(val3, array[i], Vector2.zero, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 30f), delegate
				{
					SelectTab(capturedIndex);
				});
			}
			UpdateTabColors();
			GameObject val5 = new GameObject("Viewport", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Mask)
			});
			val5.transform.SetParent((Transform)(object)component4, false);
			RectTransform component5 = val5.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0f, 0f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.offsetMin = new Vector2(12f, 40f);
			component5.offsetMax = new Vector2(-12f, -82f);
			Image component6 = val5.GetComponent<Image>();
			((Graphic)component6).color = new Color(0.02f, 0.03f, 0.04f, 0.5f);
			((Graphic)component6).raycastTarget = true;
			val5.GetComponent<Mask>().showMaskGraphic = false;
			GameObject val6 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(GridLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val6.transform.SetParent((Transform)(object)component5, false);
			_content = val6.GetComponent<RectTransform>();
			_content.anchorMin = new Vector2(0.5f, 1f);
			_content.anchorMax = new Vector2(0.5f, 1f);
			_content.pivot = new Vector2(0.5f, 1f);
			_content.anchoredPosition = Vector2.zero;
			_content.sizeDelta = new Vector2(0f, 0f);
			GridLayoutGroup component7 = val6.GetComponent<GridLayoutGroup>();
			component7.cellSize = new Vector2(46f, 46f);
			component7.spacing = new Vector2(4f, 4f);
			component7.constraint = (Constraint)1;
			component7.constraintCount = 12;
			component7.startCorner = (Corner)0;
			component7.startAxis = (Axis)0;
			((LayoutGroup)component7).padding = new RectOffset(15, 15, 6, 6);
			ContentSizeFitter component8 = val6.GetComponent<ContentSizeFitter>();
			component8.horizontalFit = (FitMode)2;
			component8.verticalFit = (FitMode)2;
			ScrollRect val7 = val5.AddComponent<ScrollRect>();
			val7.viewport = component5;
			val7.content = _content;
			val7.horizontal = false;
			val7.vertical = true;
			val7.movementType = (MovementType)2;
			val7.scrollSensitivity = 92f;
		}

		private static void Stretch(RectTransform rectTransform)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
		}

		private static void SelectTab(int tabIndex)
		{
			_activeTab = tabIndex;
			UpdateTabColors();
			RebuildGrid();
		}

		private static void UpdateTabColors()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_window == (Object)null)
			{
				return;
			}
			Transform val = _window.transform.Find("Dialog/Tabs");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			for (int i = 0; i < val.childCount; i++)
			{
				Image component = ((Component)val.GetChild(i)).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).color = ((i == _activeTab) ? new Color(0.22f, 0.28f, 0.38f, 1f) : new Color(0.1f, 0.13f, 0.18f, 0.8f));
				}
			}
		}

		private static void RebuildGrid()
		{
			if ((Object)(object)_content == (Object)null || _selectedIds == null)
			{
				return;
			}
			for (int num = ((Transform)_content).childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)((Transform)_content).GetChild(num)).gameObject);
			}
			IOrderedEnumerable<ItemProto> orderedEnumerable = from item in GetCandidateItems().Where(IsInActiveTab)
				orderby item.GridIndex, ((Proto)item).ID
				select item;
			foreach (ItemProto item in orderedEnumerable)
			{
				CreateItemCell(item);
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(_content);
		}

		private static IEnumerable<ItemProto> GetCandidateItems()
		{
			ItemProto[] array = ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray;
			if (array == null || array.Length == 0)
			{
				return Array.Empty<ItemProto>();
			}
			return array.Where((ItemProto item) => item != null && ((Proto)item).ID > 0);
		}

		private static bool IsInActiveTab(ItemProto item)
		{
			if (_activeTab == 0)
			{
				return true;
			}
			int num = ((item.GridIndex >= 0) ? (item.GridIndex / 1000) : 0);
			if (_activeTab == 1)
			{
				return num == 1;
			}
			if (_activeTab == 2)
			{
				return num == 2;
			}
			return num != 1 && num != 2;
		}

		private static void CreateItemCell(ItemProto item)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			GameObject val = new GameObject("Item_" + ((Proto)item).ID, new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button),
				typeof(ItemCellHover)
			});
			val.transform.SetParent((Transform)(object)_content, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(46f, 46f);
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.08f, 0.1f, 0.14f, 0.7f);
			((Graphic)component2).raycastTarget = true;
			GameObject val2 = new GameObject("Icon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component3 = val2.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = new Vector2(4f, 4f);
			component3.offsetMax = new Vector2(-4f, -4f);
			Image component4 = val2.GetComponent<Image>();
			component4.sprite = item.iconSprite;
			component4.preserveAspect = true;
			((Graphic)component4).raycastTarget = false;
			Button component5 = val.GetComponent<Button>();
			((Selectable)component5).targetGraphic = (Graphic)(object)component2;
			((Selectable)component5).transition = (Transition)1;
			ColorBlock colors = ((Selectable)component5).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.2f, 1.2f, 1.2f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.8f, 0.8f);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)component5).colors = colors;
			((UnityEvent)component5.onClick).AddListener((UnityAction)delegate
			{
				ToggleItem(((Proto)item).ID);
			});
			ItemCellHover component6 = val.GetComponent<ItemCellHover>();
			component6.SetItem(item);
			RefreshCell(val, ((Proto)item).ID);
		}

		private static void ToggleItem(int itemId)
		{
			if (_selectedIds == null || _onToggle == null || (_selectedIds.Contains(itemId) && _selectedIds.Count <= 1))
			{
				return;
			}
			_onToggle(itemId);
			Transform content = (Transform)(object)_content;
			if (!((Object)(object)content == (Object)null))
			{
				for (int i = 0; i < content.childCount; i++)
				{
					((Component)content.GetChild(i)).GetComponent<ItemCellHover>()?.RefreshVisual();
				}
			}
		}

		private static void RefreshCell(GameObject cell, int itemId)
		{
			//IL_0071: 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_00d1: 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)
			if ((Object)(object)cell == (Object)null || _selectedIds == null)
			{
				return;
			}
			bool flag = _selectedIds.Contains(itemId);
			Image component = cell.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = (flag ? new Color(0.12f, 0.16f, 0.22f, 0.9f) : new Color(0.04f, 0.05f, 0.07f, 0.6f));
			}
			Transform val = cell.transform.Find("Icon");
			if ((Object)(object)val != (Object)null)
			{
				Image component2 = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Graphic)component2).color = (Color)(flag ? Color.white : new Color(1f, 1f, 1f, 0.3f));
				}
			}
		}

		private static void CreateButton(RectTransform parent, string labelText, Vector2 position, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, Action onClick)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button_" + labelText, new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button)
			});
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.pivot = anchorMin;
			component.anchoredPosition = position;
			component.sizeDelta = size;
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.1f, 0.13f, 0.18f, 0.9f);
			Button component3 = val.GetComponent<Button>();
			((Selectable)component3).targetGraphic = (Graphic)(object)component2;
			((Selectable)component3).transition = (Transition)1;
			ColorBlock colors = ((Selectable)component3).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.3f, 1.3f, 1.3f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.7f, 0.7f, 0.7f);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)component3).colors = colors;
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
			Transform transform = val.transform;
			Text val2 = CreateText((RectTransform)(object)((transform is RectTransform) ? transform : null), _bodyTextTemplate, labelText, Vector2.zero, Vector2.zero, Vector2.one, Vector2.zero, (TextAnchor)4, 13);
			if ((Object)(object)val2 != (Object)null)
			{
				((Graphic)val2).raycastTarget = false;
				((Graphic)val2).color = new Color(0.85f, 0.88f, 0.92f);
			}
		}

		private static Text CreateText(RectTransform parent, Text template, string value, Vector2 position, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, TextAnchor alignment, int fontSize)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)template == (Object)null || (Object)(object)((Component)template).gameObject == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)parent, false);
			((Object)val).name = "Label_" + value.Replace(' ', '_');
			Text component = val.GetComponent<Text>();
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if ((Object)(object)component == (Object)null || (Object)(object)val2 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			component.text = value;
			component.alignment = alignment;
			component.fontSize = fontSize;
			((Graphic)component).raycastTarget = false;
			((Graphic)component).color = new Color(0.85f, 0.88f, 0.92f);
			val2.anchorMin = anchorMin;
			val2.anchorMax = anchorMax;
			val2.pivot = anchorMin;
			val2.anchoredPosition = position;
			val2.sizeDelta = size;
			return component;
		}
	}
	internal static class NewGameMenuIntegration
	{
		private sealed class HoverDescription : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			private UIButtonTip _tooltip;

			public void OnPointerEnter(PointerEventData eventData)
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_tooltip != (Object)null) && !((Object)(object)UIRoot.instance == (Object)null) && !((Object)(object)UIRoot.instance.buttonTopTipTransform == (Object)null))
				{
					_tooltip = UIButtonTip.Create(true, string.Empty, "Includes Mining Machine, Advanced Mining Machine, Water Pump, and Oil Extractor.", 5, Vector2.zero, 320, ((Component)this).transform, string.Empty, string.Empty);
					PositionTooltipNearPointer(eventData);
				}
			}

			public void OnPointerExit(PointerEventData eventData)
			{
				if (!((Object)(object)_tooltip == (Object)null))
				{
					Object.Destroy((Object)(object)((Component)_tooltip).gameObject);
					_tooltip = null;
				}
			}

			private void PositionTooltipNearPointer(PointerEventData eventData)
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_tooltip == (Object)null)
				{
					return;
				}
				Transform transform = ((Component)_tooltip).transform;
				RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				RectTransform val2 = (RectTransform)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
				{
					return;
				}
				Canvas componentInParent = ((Component)val2).GetComponentInParent<Canvas>();
				Camera val3 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
				Vector2 val4 = default(Vector2);
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val2, eventData.position, val3, ref val4))
				{
					val.anchorMin = new Vector2(0.5f, 0.5f);
					val.anchorMax = new Vector2(0.5f, 0.5f);
					val.pivot = new Vector2(0.5f, 0.5f);
					Rect rect = val2.rect;
					Rect rect2 = val.rect;
					Vector2 val5 = ((Rect)(ref rect2)).size * 0.5f;
					Vector2 val6 = val4 + new Vector2(val5.x + 16f, 0f - val5.y - 12f);
					float num = ((Rect)(ref rect)).xMin + val5.x + 8f;
					float num2 = ((Rect)(ref rect)).xMax - val5.x - 8f;
					float num3 = ((Rect)(ref rect)).yMin + val5.y + 8f;
					float num4 = ((Rect)(ref rect)).yMax - val5.y - 8f;
					if (val6.x > num2)
					{
						val6.x = val4.x - val5.x - 16f;
					}
					val6.x = Mathf.Clamp(val6.x, num, num2);
					val6.y = Mathf.Clamp(val6.y, num3, num4);
					val.anchoredPosition = val6 - ((Rect)(ref rect)).center;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OpenItemPicker;

			public static Action<int> <1>__OnItemFilterChanged;

			public static UnityAction<bool> <2>__OnToggleChanged;
		}

		private const float PanelHeight = 112f;

		private const float PanelGap = 8f;

		private const float RowHeight = 30f;

		private const string HoverDescriptionText = "Includes Mining Machine, Advanced Mining Machine, Water Pump, and Oil Extractor.";

		private static UIGalaxySelect _screen;

		private static object _gameDesc;

		private static GameObject _panel;

		private static GameObject _row;

		private static UIToggle _toggle;

		private static Button _filterButton;

		private static Text _filterLabelText;

		private static Text _filterCountText;

		private static HashSet<int> _pendingItemIds = new HashSet<int>();

		private static int _candidateItemCount;

		internal static bool PendingEnabled { get; set; } = true;

		internal static HashSet<int> PendingItemIds => _pendingItemIds;

		internal static void OnOpen(UIGalaxySelect __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				_screen = __instance;
				object obj = AccessTools.Field(typeof(UIGalaxySelect), "gameDesc")?.GetValue(__instance);
				if (_gameDesc != obj)
				{
					_gameDesc = obj;
					PendingEnabled = Plugin.DefaultEnabled?.Value ?? true;
					_pendingItemIds = ItemFilterPicker.GetCandidateItemIds();
					_candidateItemCount = _pendingItemIds.Count;
				}
				EnsureTable(__instance);
				if ((Object)(object)_toggle != (Object)null)
				{
					_toggle.isOn = PendingEnabled;
				}
			}
		}

		internal static void OnClose(UIGalaxySelect __instance)
		{
			if ((Object)(object)__instance == (Object)(object)_screen)
			{
				ItemFilterPicker.Close();
			}
		}

		private static void EnsureTable(UIGalaxySelect screen)
		{
			//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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_panel != (Object)null || (Object)(object)screen.propertyRect == (Object)null || (Object)(object)screen.propertyMultiplierText == (Object)null || (Object)(object)screen.sandboxToggle == (Object)null)
			{
				return;
			}
			RectTransform propertyRect = screen.propertyRect;
			Transform parent = ((Transform)propertyRect).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Rect rect = propertyRect.rect;
			float num = Mathf.Max(250f, ((Rect)(ref rect)).width);
			_panel = CreatePanel(val, propertyRect, num);
			if (!((Object)(object)_panel == (Object)null))
			{
				RectTransform component = _panel.GetComponent<RectTransform>();
				Text template = FindMetadataHeading(screen) ?? screen.propertyMultiplierText;
				Text val2 = CreateLabel(template, component, "Randomizer", new Vector2(0f, -10f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(-24f, 28f), 0);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.alignment = (TextAnchor)4;
					val2.fontSize = Mathf.Max(val2.fontSize, 16);
					val2.fontStyle = (FontStyle)1;
				}
				_row = new GameObject("OutputRandomizer_OptionRow", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(HoverDescription)
				});
				_row.transform.SetParent((Transform)(object)component, false);
				RectTransform component2 = _row.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0f, 0f);
				component2.anchorMax = new Vector2(1f, 0f);
				component2.pivot = new Vector2(0.5f, 0f);
				component2.offsetMin = new Vector2(8f, 42f);
				component2.offsetMax = new Vector2(-8f, 72f);
				component2.sizeDelta = new Vector2(0f, 30f);
				Image component3 = _row.GetComponent<Image>();
				((Graphic)component3).color = new Color(1f, 1f, 1f, 0f);
				((Graphic)component3).raycastTarget = true;
				CreateLabel(screen.propertyMultiplierText, component2, "Random Miner Outputs", new Vector2(4f, 15f), new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(num - 76f, 30f), 0);
				_toggle = CreateToggle(screen.sandboxToggle, component2, new Vector2(-8f, 15f));
				if ((Object)(object)_toggle == (Object)null)
				{
					Object.Destroy((Object)(object)_panel);
					_panel = null;
					return;
				}
				HoverDescription component4 = _row.GetComponent<HoverDescription>();
				_row.transform.SetAsLastSibling();
				CreateItemFilterRow(screen, component, num);
				_panel.SetActive(true);
			}
		}

		private static void CreateItemFilterRow(UIGalaxySelect screen, RectTransform parent, float panelWidth)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_003f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OutputRandomizer_ItemFilterRow", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.offsetMin = new Vector2(8f, 8f);
			component.offsetMax = new Vector2(-8f, 38f);
			component.sizeDelta = new Vector2(0f, 30f);
			GameObject val2 = new GameObject("FilterBtn", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button)
			});
			val2.transform.SetParent((Transform)(object)component, false);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(0f, 1f);
			component2.pivot = new Vector2(0f, 0.5f);
			component2.anchoredPosition = Vector2.zero;
			component2.sizeDelta = new Vector2(100f, 0f);
			Image component3 = val2.GetComponent<Image>();
			((Graphic)component3).color = new Color(0.1f, 0.13f, 0.18f, 0.9f);
			((Graphic)component3).raycastTarget = true;
			_filterButton = val2.GetComponent<Button>();
			((Selectable)_filterButton).targetGraphic = (Graphic)(object)component3;
			((Selectable)_filterButton).transition = (Transition)1;
			ColorBlock colors = ((Selectable)_filterButton).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.3f, 1.3f, 1.3f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.7f, 0.7f, 0.7f);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)_filterButton).colors = colors;
			ButtonClickedEvent onClick = _filterButton.onClick;
			object obj = <>O.<0>__OpenItemPicker;
			if (obj == null)
			{
				UnityAction val3 = OpenItemPicker;
				<>O.<0>__OpenItemPicker = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			_filterLabelText = CreateLabel(screen.propertyMultiplierText, component2, "Filter", Vector2.zero, Vector2.zero, Vector2.one, Vector2.zero, 0);
			if ((Object)(object)_filterLabelText != (Object)null)
			{
				_filterLabelText.alignment = (TextAnchor)4;
				((Graphic)_filterLabelText).color = new Color(0.85f, 0.88f, 0.92f);
			}
			_filterCountText = CreateLabel(screen.propertyMultiplierText, component, string.Empty, new Vector2(-8f, 0f), new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(80f, 30f), 1);
			if ((Object)(object)_filterCountText != (Object)null)
			{
				_filterCountText.alignment = (TextAnchor)5;
				((Graphic)_filterCountText).color = new Color(0.85f, 0.88f, 0.92f);
			}
			RefreshFilterControl();
		}

		private static void OpenItemPicker()
		{
			if (!PendingEnabled || (Object)(object)_screen == (Object)null)
			{
				return;
			}
			Canvas componentInParent = ((Component)_screen).GetComponentInParent<Canvas>();
			Transform obj = ((componentInParent != null) ? ((Component)componentInParent).transform : null);
			RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource modLogger = Plugin.ModLogger;
				if (modLogger != null)
				{
					modLogger.LogError((object)"[OR] No Canvas found above UIGalaxySelect!");
				}
			}
			else
			{
				ItemFilterPicker.Open(val, _screen.propertyMultiplierText, FindMetadataHeading(_screen) ?? _screen.propertyMultiplierText, _pendingItemIds ?? new HashSet<int>(), OnItemFilterChanged);
			}
		}

		private static void OnItemFilterChanged(int itemId)
		{
			if (_pendingItemIds.Contains(itemId))
			{
				_pendingItemIds.Remove(itemId);
			}
			else
			{
				_pendingItemIds.Add(itemId);
			}
			RefreshFilterControl();
		}

		private static void RefreshFilterControl()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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)
			if ((Object)(object)_filterButton != (Object)null)
			{
				((Selectable)_filterButton).interactable = PendingEnabled;
			}
			if ((Object)(object)_filterCountText != (Object)null)
			{
				_filterCountText.text = _pendingItemIds.Count + "/" + _candidateItemCount;
				((Graphic)_filterCountText).color = (Color)(PendingEnabled ? Color.white : new Color(0.45f, 0.45f, 0.45f, 0.7f));
			}
			if ((Object)(object)_filterLabelText != (Object)null)
			{
				((Graphic)_filterLabelText).color = (Color)(PendingEnabled ? Color.white : new Color(0.45f, 0.45f, 0.45f, 0.7f));
			}
		}

		private static Text FindMetadataHeading(UIGalaxySelect screen)
		{
			RectTransform leftGroupRect = screen.leftGroupRect;
			if ((Object)(object)leftGroupRect == (Object)null)
			{
				return null;
			}
			Text[] componentsInChildren = ((Component)leftGroupRect).GetComponentsInChildren<Text>(true);
			Text[] array = componentsInChildren;
			foreach (Text val in array)
			{
				if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(val.text) && val.text.IndexOf("metadata", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return val;
				}
			}
			return null;
		}

		private static GameObject CreatePanel(RectTransform parent, RectTransform metadataRect, float width)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_003f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OutputRandomizer_OptionsTable", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(width, 112f);
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			metadataRect.GetWorldCorners(array);
			float num = float.PositiveInfinity;
			float num2 = 0f;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val2 = ((Transform)parent).InverseTransformPoint(array[i]);
				num = Mathf.Min(num, val2.y);
				num2 += val2.x * 0.25f;
			}
			component.anchoredPosition = new Vector2(num2, num - 8f - 56f);
			val.transform.SetAsLastSibling();
			return val;
		}

		private static Text CreateLabel(Text template, RectTransform parent, string value, Vector2 position, Vector2 anchorMin, Vector2 anchorMax, Vector2 size, int siblingIndex)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)parent, false);
			((Object)val).name = "OutputRandomizer_Label_" + value.Replace(' ', '_');
			Text component = val.GetComponent<Text>();
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if ((Object)(object)component == (Object)null || (Object)(object)val2 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			component.text = value;
			((Graphic)component).raycastTarget = false;
			val2.anchorMin = anchorMin;
			val2.anchorMax = anchorMax;
			val2.pivot = anchorMin;
			val2.anchoredPosition = position;
			val2.sizeDelta = size;
			((Transform)val2).SetSiblingIndex(siblingIndex);
			return component;
		}

		private static UIToggle CreateToggle(UIToggle template, RectTransform parent, Vector2 position)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)parent, false);
			((Object)val).name = "OutputRandomizer_RandomMinerOutputsToggle";
			UIToggle component = val.GetComponent<UIToggle>();
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if ((Object)(object)component == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)component.toggle == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.anchoredPosition = position;
			component.toggle.onValueChanged = new ToggleEvent();
			((UnityEvent<bool>)(object)component.toggle.onValueChanged).AddListener((UnityAction<bool>)OnToggleChanged);
			component.isOn = PendingEnabled;
			return component;
		}

		private static void OnToggleChanged(bool value)
		{
			PendingEnabled = value;
			RefreshFilterControl();
		}
	}
	[BepInPlugin("com.francisco.dsp.outputrandomizer", "Output Randomizer", "1.0.0")]
	[BepInProcess("DSPGAME.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.francisco.dsp.outputrandomizer";

		public const string PluginName = "Output Randomizer";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		internal static ManualLogSource ModLogger { get; private set; }

		internal static ConfigEntry<bool> DefaultEnabled { get; private set; }

		private void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_0283: Expected O, but got Unknown
			//IL_0283: Expected O, but got Unknown
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Expected O, but got Unknown
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Expected O, but got Unknown
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Expected O, but got Unknown
			ModLogger = ((BaseUnityPlugin)this).Logger;
			DefaultEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Default for newly created saves.");
			NewGameMenuIntegration.PendingEnabled = DefaultEnabled.Value;
			_harmony = new Harmony("com.francisco.dsp.outputrandomizer");
			MethodInfo methodInfo = AccessTools.Method(typeof(UIGalaxySelect), "_OnOpen", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(NewGameMenuIntegration), "OnOpen", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo2 = AccessTools.Method(typeof(UIGalaxySelect), "_OnClose", (Type[])null, (Type[])null);
			if (methodInfo2 != null)
			{
				_harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(NewGameMenuIntegration), "OnClose", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo3 = AccessTools.Method(typeof(GameData), "NewGame", new Type[1] { typeof(GameDesc) }, (Type[])null);
			if (methodInfo3 != null)
			{
				_harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(RandomizerSaveState), "OnNewGame", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo4 = AccessTools.Method(typeof(GameSave), "SaveCurrentGame", new Type[1] { typeof(string) }, (Type[])null);
			if (methodInfo4 != null)
			{
				_harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(RandomizerSaveState), "AfterSave", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo5 = AccessTools.Method(typeof(GameSave), "LoadCurrentGame", new Type[1] { typeof(string) }, (Type[])null);
			if (methodInfo5 != null)
			{
				_harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(typeof(RandomizerSaveState), "BeforeLoad", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo6 = AccessTools.Method(typeof(MinerComponent), "InternalUpdate", (Type[])null, (Type[])null);
			if (methodInfo6 == null)
			{
				ModLogger.LogError((object)"Could not find MinerComponent.InternalUpdate; miner outputs will not be randomized.");
				return;
			}
			_harmony.Patch((MethodBase)methodInfo6, new HarmonyMethod(typeof(MinerOutputPatch), "Prefix", (Type[])null), new HarmonyMethod(typeof(MinerOutputPatch), "Postfix", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MinerOutputPatch), "Finalizer", (Type[])null), (HarmonyMethod)null);
			MethodInfo methodInfo7 = AccessTools.Method(typeof(GameMain), "Begin", (Type[])null, (Type[])null);
			if (methodInfo7 != null)
			{
				_harmony.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(typeof(MinerOutputPatch), "OnGameBegin", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo8 = AccessTools.Method(typeof(FactorySystem), "NewMinerComponent", (Type[])null, (Type[])null);
			if (methodInfo8 != null)
			{
				_harmony.Patch((MethodBase)methodInfo8, (HarmonyMethod)null, new HarmonyMethod(typeof(MinerOutputPatch), "RegisterNewCollector", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo9 = AccessTools.Method(typeof(PlanetFactory), "InsertInto", new Type[6]
			{
				typeof(int),
				typeof(int),
				typeof(int),
				typeof(byte),
				typeof(byte),
				typeof(byte).MakeByRefType()
			}, (Type[])null);
			MethodInfo methodInfo10 = AccessTools.Method(typeof(PlanetFactory), "InsertInto", new Type[6]
			{
				typeof(uint),
				typeof(int),
				typeof(int),
				typeof(byte),
				typeof(byte),
				typeof(byte).MakeByRefType()
			}, (Type[])null);
			if (methodInfo9 != null)
			{
				_harmony.Patch((MethodBase)methodInfo9, new HarmonyMethod(typeof(MinerOutputPatch), "InsertIntoPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			if (methodInfo10 != null)
			{
				_harmony.Patch((MethodBase)methodInfo10, new HarmonyMethod(typeof(MinerOutputPatch), "InsertIntoPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo11 = AccessTools.Method(typeof(StationComponent), "UpdateVeinCollection", (Type[])null, (Type[])null);
			if (methodInfo11 != null)
			{
				_harmony.Patch((MethodBase)methodInfo11, new HarmonyMethod(typeof(MinerOutputPatch), "EnforceDepotPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			ModLogger.LogInfo((object)"Output Randomizer v1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class MinerOutputPatch
	{
		internal sealed class UpdateState
		{
			internal bool PreviousHasActiveMiner;

			internal int PreviousFactoryIndex;

			internal int PreviousEntityId;

			internal int PreviousOutputItemId;

			internal int FactoryIndex;

			internal int EntityId;

			internal int OutputItemId;
		}

		private static readonly object RandomLock = new object();

		private static readonly Random Random = new Random();

		private static readonly object OutputItemsLock = new object();

		private static readonly Dictionary<long, int> OutputItems = new Dictionary<long, int>();

		private static readonly HashSet<long> CollectorMiners = new HashSet<long>();

		private static int[] _itemIds;

		[ThreadStatic]
		private static bool _hasActiveMiner;

		[ThreadStatic]
		private static int _activeFactoryIndex;

		[ThreadStatic]
		private static int _activeEntityId;

		[ThreadStatic]
		private static int _activeOutputItemId;

		internal static void Prefix(ref MinerComponent __instance, PlanetFactory factory, ref bool __runOriginal, out UpdateState __state)
		{
			__state = null;
			if (!RandomizerSaveState.Enabled || factory == null)
			{
				return;
			}
			int index = factory.index;
			int entityId = __instance.entityId;
			long minerKey = GetMinerKey(index, entityId);
			if (__instance.productCount > 0 && CollectorMiners.Contains(minerKey))
			{
				__runOriginal = false;
				return;
			}
			if (__instance.productCount <= 0)
			{
				RemoveOutputItem(index, entityId);
			}
			int outputItemId = GetOutputItemId(index, entityId);
			if (outputItemId > 0)
			{
				__state = new UpdateState
				{
					PreviousHasActiveMiner = _hasActiveMiner,
					PreviousFactoryIndex = _activeFactoryIndex,
					PreviousEntityId = _activeEntityId,
					PreviousOutputItemId = _activeOutputItemId,
					FactoryIndex = index,
					EntityId = entityId,
					OutputItemId = outputItemId
				};
				_hasActiveMiner = true;
				_activeFactoryIndex = index;
				_activeEntityId = entityId;
				_activeOutputItemId = outputItemId;
			}
		}

		internal static void Postfix(ref MinerComponent __instance, UpdateState __state)
		{
			if (__state != null)
			{
				if (__instance.productCount > 0)
				{
					__instance.productId = __state.OutputItemId;
				}
				else
				{
					RemoveOutputItem(__state.FactoryIndex, __state.EntityId);
				}
			}
		}

		internal static Exception Finalizer(Exception __exception, UpdateState __state)
		{
			RestoreThreadContext(__state);
			return __exception;
		}

		internal static void InsertIntoPrefix(PlanetFactory __instance, ref int __2, ref byte __3)
		{
			if (RandomizerSaveState.Enabled && _hasActiveMiner && __instance != null && __instance.index == _activeFactoryIndex)
			{
				__2 = _activeOutputItemId;
				if (__3 > 1)
				{
					__3 = 1;
				}
			}
		}

		internal static void EnforceDepotPrefix(StationComponent __instance, PlanetFactory factory, ref bool __runOriginal)
		{
			if (!RandomizerSaveState.Enabled || __instance == null || !__instance.isVeinCollector || __instance.storage == null || __instance.storage.Length == 0 || __instance.collectionIds == null || __instance.collectionIds.Length == 0 || factory?.factorySystem?.minerPool == null || __instance.minerId <= 0 || __instance.minerId >= factory.factorySystem.minerPool.Length)
			{
				return;
			}
			EnforceDepotMode(__instance, factory);
			ref MinerComponent reference = ref factory.factorySystem.minerPool[__instance.minerId];
			if (reference.id != __instance.minerId || reference.productId <= 0 || reference.productCount <= 0)
			{
				return;
			}
			bool flag;
			lock (__instance.storage)
			{
				ref StationStore reference2 = ref __instance.storage[0];
				flag = reference2.itemId != reference.productId || __instance.collectionIds[0] != reference.productId;
				reference2.max = 1;
				if (flag && (reference2.count > 0 || reference2.localOrder != 0 || reference2.remoteOrder != 0))
				{
					__runOriginal = false;
					return;
				}
				if (flag)
				{
					reference2.itemId = reference.productId;
					__instance.collectionIds[0] = reference.productId;
				}
			}
			if (flag)
			{
				__instance.UpdateNeeds();
				PlanetTransport transport = factory.transport;
				if (transport != null)
				{
					transport.RefreshStationTraffic(__instance.id);
				}
			}
		}

		internal static void OnGameBegin()
		{
			lock (OutputItemsLock)
			{
				OutputItems.Clear();
			}
			_itemIds = null;
			GameData data = GameMain.data;
			if (data?.factories == null)
			{
				return;
			}
			CollectorMiners.Clear();
			for (int i = 0; i < data.factoryCount; i++)
			{
				PlanetFactory val = data.factories[i];
				PlanetTransport val2 = val?.transport;
				MinerComponent[] array = val?.factorySystem?.minerPool;
				if (val2?.stationPool == null || array == null)
				{
					continue;
				}
				for (int j = 1; j < val2.stationCursor; j++)
				{
					StationComponent val3 = val2.stationPool[j];
					if (val3 != null && val3.id == j && val3.isVeinCollector && val3.minerId > 0 && val3.minerId < array.Length)
					{
						ref MinerComponent reference = ref array[val3.minerId];
						if (reference.id == val3.minerId)
						{
							CollectorMiners.Add(GetMinerKey(i, reference.entityId));
							EnforceDepotMode(val3, val);
						}
					}
				}
			}
		}

		internal static void RegisterNewCollector(FactorySystem __instance, int entityId, PrefabDesc desc, int __result)
		{
			if (__result > 0 && desc != null && desc.isVeinCollector && __instance?.factory != null && __instance.minerPool != null && __result < __instance.minerPool.Length)
			{
				ref MinerComponent reference = ref __instance.minerPool[__result];
				if (reference.id == __result)
				{
					CollectorMiners.Add(GetMinerKey(__instance.factory.index, reference.entityId));
				}
			}
		}

		private static void EnforceDepotMode(StationComponent station, PlanetFactory factory)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_0035: 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)
			bool flag = false;
			lock (station.storage)
			{
				ref StationStore reference = ref station.storage[0];
				if ((int)reference.localLogic > 0)
				{
					reference.localLogic = (ELogisticStorage)0;
					flag = true;
				}
				if ((int)reference.remoteLogic > 0)
				{
					reference.remoteLogic = (ELogisticStorage)0;
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			station.UpdateNeeds();
			if (factory != null)
			{
				PlanetTransport transport = factory.transport;
				if (transport != null)
				{
					transport.RefreshStationTraffic(station.id);
				}
			}
		}

		internal static void RestoreThreadContext(UpdateState state)
		{
			if (state != null)
			{
				_hasActiveMiner = state.PreviousHasActiveMiner;
				_activeFactoryIndex = state.PreviousFactoryIndex;
				_activeEntityId = state.PreviousEntityId;
				_activeOutputItemId = state.PreviousOutputItemId;
			}
		}

		private static int GetOutputItemId(int factoryIndex, int entityId)
		{
			long minerKey = GetMinerKey(factoryIndex, entityId);
			lock (OutputItemsLock)
			{
				if (!OutputItems.TryGetValue(minerKey, out var value))
				{
					value = GetRandomItemId();
					if (value > 0)
					{
						OutputItems[minerKey] = value;
					}
				}
				return value;
			}
		}

		private static void RemoveOutputItem(int factoryIndex, int entityId)
		{
			long minerKey = GetMinerKey(factoryIndex, entityId);
			lock (OutputItemsLock)
			{
				OutputItems.Remove(minerKey);
			}
		}

		private static long GetMinerKey(int factoryIndex, int entityId)
		{
			return ((long)factoryIndex << 32) | (uint)entityId;
		}

		private static int GetRandomItemId()
		{
			if (_itemIds == null)
			{
				ItemProto[] array = ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray;
				if (array == null)
				{
					return 0;
				}
				List<int> list = new List<int>(array.Length);
				ItemProto[] array2 = array;
				foreach (ItemProto val in array2)
				{
					if (val != null && ((Proto)val).ID > 0 && RandomizerSaveState.SelectedItemIds.Contains(((Proto)val).ID))
					{
						list.Add(((Proto)val).ID);
					}
				}
				_itemIds = list.ToArray();
			}
			if (_itemIds.Length == 0)
			{
				return 0;
			}
			lock (RandomLock)
			{
				return _itemIds[Random.Next(_itemIds.Length)];
			}
		}
	}
	internal static class RandomizerSaveState
	{
		private const string MetadataSuffix = ".outputrandomizer";

		private const string Header = "OutputRandomizerV1";

		internal static bool Enabled { get; private set; } = true;

		internal static HashSet<int> SelectedItemIds { get; private set; } = new HashSet<int>();

		internal static void OnNewGame(GameDesc __0)
		{
			Enabled = NewGameMenuIntegration.PendingEnabled;
			SelectedItemIds = new HashSet<int>(NewGameMenuIntegration.PendingItemIds);
		}

		internal static void BeforeLoad(string __0)
		{
			Enabled = false;
			SelectedItemIds = ItemFilterPicker.GetCandidateItemIds();
			string metadataPath = GetMetadataPath(__0);
			if (metadataPath == null || !File.Exists(metadataPath))
			{
				return;
			}
			try
			{
				string[] array = File.ReadAllLines(metadataPath);
				if (array.Length < 2 || array[0].Trim() != "OutputRandomizerV1")
				{
					return;
				}
				Enabled = array[1].Trim() == "1";
				HashSet<int> candidateItemIds = ItemFilterPicker.GetCandidateItemIds();
				HashSet<int> hashSet = new HashSet<int>();
				if (!string.IsNullOrWhiteSpace(array[2]))
				{
					string[] array2 = array[2].Split(new char[1] { ',' });
					foreach (string s in array2)
					{
						if (int.TryParse(s, out var result) && candidateItemIds.Contains(result))
						{
							hashSet.Add(result);
						}
					}
				}
				if (hashSet.Count > 0)
				{
					SelectedItemIds = hashSet;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource modLogger = Plugin.ModLogger;
				if (modLogger != null)
				{
					modLogger.LogWarning((object)("[OR] Failed to load save state: " + ex.Message));
				}
			}
		}

		internal static void AfterSave(bool __result, string __0)
		{
			if (!__result)
			{
				return;
			}
			string metadataPath = GetMetadataPath(__0);
			if (metadataPath == null)
			{
				return;
			}
			try
			{
				string text = string.Join(",", SelectedItemIds.OrderBy((int x) => x));
				File.WriteAllText(metadataPath, "OutputRandomizerV1\n" + (Enabled ? "1" : "0") + "\n" + text);
			}
			catch (Exception ex)
			{
				ManualLogSource modLogger = Plugin.ModLogger;
				if (modLogger != null)
				{
					modLogger.LogWarning((object)("[OR] Failed to write save state: " + ex.Message));
				}
			}
		}

		private static string GetMetadataPath(string saveName)
		{
			if (string.IsNullOrEmpty(saveName))
			{
				return null;
			}
			try
			{
				return GameSave.SavePath(saveName) + ".outputrandomizer";
			}
			catch
			{
				return null;
			}
		}
	}
}