Decompiled source of Stellogistics v1.0.0

Stellogistics.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Stellogistics")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Shows combined Interplanetary Logistics (ILS) imports and exports per planet and star system on the Starmap.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a6c6b7111e1e4e7f68747c51c5e17133bb63097b")]
[assembly: AssemblyProduct("Stellogistics")]
[assembly: AssemblyTitle("Stellogistics")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Stellogistics
{
	public static class LogisticsAggregator
	{
		private const double OneLightYearMeters = 2390000.0;

		private const int WarperItemId = 1210;

		public static LogisticsSummary AggregatePlanet(PlanetData planet, StellogisticsConfig config)
		{
			int galaxySeed = ((GameMain.galaxy != null) ? GameMain.galaxy.seed : 0);
			int num = ((planet != null) ? planet.astroId : 0);
			EItemCategoryFilter filterForAstro = config.GetFilterForAstro(galaxySeed, num);
			LogisticsSummary logisticsSummary = new LogisticsSummary
			{
				IsStarSystem = false,
				TargetAstroId = num,
				GalaxySeed = galaxySeed,
				ActiveCategoryFilter = filterForAstro,
				TargetName = ((planet != null) ? planet.displayName : "Unknown Planet")
			};
			if (planet == null || GameMain.data == null)
			{
				return logisticsSummary;
			}
			Dictionary<int, CombinedLogisticsItem> exportsByItem = new Dictionary<int, CombinedLogisticsItem>();
			Dictionary<int, CombinedLogisticsItem> importsByItem = new Dictionary<int, CombinedLogisticsItem>();
			StationComponent[] gStationPool = GameMain.data.galacticTransport?.stationPool;
			int starId = ((planet.star != null) ? planet.star.id : (planet.id / 100));
			AggregatePlanetStations(planet, starId, config.IncludeOrbitalCollectors.Value, EStarFilterMode.AllRemoteSlots, gStationPool, exportsByItem, importsByItem, null, null, ref logisticsSummary.TotalIlsCount, ref logisticsSummary.TotalCollectorCount, ref logisticsSummary.TotalWarperCount, ref logisticsSummary.TotalIdleShips, ref logisticsSummary.TotalWorkShips);
			logisticsSummary.ColonizedPlanetCount = (logisticsSummary.HasAnyStations ? 1 : 0);
			FinalizeSummary(logisticsSummary, exportsByItem, importsByItem, config);
			string arg = ((logisticsSummary.TotalCollectorCount > 0) ? $", {logisticsSummary.TotalCollectorCount} OC" : "");
			logisticsSummary.TargetSubtitle = $"Planet • {logisticsSummary.TotalIlsCount} ILS{arg}";
			return logisticsSummary;
		}

		public static LogisticsSummary AggregateStar(StarData star, StellogisticsConfig config)
		{
			int galaxySeed = ((GameMain.galaxy != null) ? GameMain.galaxy.seed : 0);
			int num = ((star != null) ? star.astroId : 0);
			EItemCategoryFilter filterForAstro = config.GetFilterForAstro(galaxySeed, num);
			LogisticsSummary logisticsSummary = new LogisticsSummary
			{
				IsStarSystem = true,
				TargetAstroId = num,
				GalaxySeed = galaxySeed,
				ActiveCategoryFilter = filterForAstro,
				TargetName = ((star != null) ? (star.displayName + " System") : "Unknown System")
			};
			if (star == null || star.planets == null || GameMain.data == null)
			{
				return logisticsSummary;
			}
			Dictionary<int, CombinedLogisticsItem> exportsByItem = new Dictionary<int, CombinedLogisticsItem>();
			Dictionary<int, CombinedLogisticsItem> importsByItem = new Dictionary<int, CombinedLogisticsItem>();
			Dictionary<int, HashSet<int>> exportPlanetsByItem = new Dictionary<int, HashSet<int>>();
			Dictionary<int, HashSet<int>> importPlanetsByItem = new Dictionary<int, HashSet<int>>();
			StationComponent[] gStationPool = GameMain.data.galacticTransport?.stationPool;
			EStarFilterMode value = config.StarSystemFilterMode.Value;
			bool value2 = config.IncludeOrbitalCollectors.Value;
			for (int i = 0; i < star.planets.Length; i++)
			{
				PlanetData val = star.planets[i];
				if (val != null)
				{
					int totalIlsCount = logisticsSummary.TotalIlsCount;
					int totalCollectorCount = logisticsSummary.TotalCollectorCount;
					AggregatePlanetStations(val, star.id, value2, value, gStationPool, exportsByItem, importsByItem, exportPlanetsByItem, importPlanetsByItem, ref logisticsSummary.TotalIlsCount, ref logisticsSummary.TotalCollectorCount, ref logisticsSummary.TotalWarperCount, ref logisticsSummary.TotalIdleShips, ref logisticsSummary.TotalWorkShips);
					if (logisticsSummary.TotalIlsCount > totalIlsCount || logisticsSummary.TotalCollectorCount > totalCollectorCount)
					{
						logisticsSummary.ColonizedPlanetCount++;
					}
				}
			}
			switch (value)
			{
			case EStarFilterMode.InterstellarSmart:
				ApplyInterstellarSmartFilter(exportsByItem, importsByItem);
				break;
			case EStarFilterMode.NetOutIntraSystem:
				ApplyNetOutIntraSystemFilter(exportsByItem, importsByItem);
				break;
			}
			FinalizeSummary(logisticsSummary, exportsByItem, importsByItem, config);
			string text = value switch
			{
				EStarFilterMode.InterstellarSmart => "Interstellar", 
				EStarFilterMode.NetOutIntraSystem => "Netted", 
				_ => "All Remote", 
			};
			string text2 = ((logisticsSummary.TotalCollectorCount > 0) ? $" +{logisticsSummary.TotalCollectorCount} OC" : "");
			logisticsSummary.TargetSubtitle = $"{text} • {logisticsSummary.ColonizedPlanetCount}/{star.planets.Length} Planets • {logisticsSummary.TotalIlsCount} ILS{text2}";
			return logisticsSummary;
		}

		private static void AggregatePlanetStations(PlanetData planet, int starId, bool includeCollectors, EStarFilterMode filterMode, StationComponent[] gStationPool, Dictionary<int, CombinedLogisticsItem> exportsByItem, Dictionary<int, CombinedLogisticsItem> importsByItem, Dictionary<int, HashSet<int>> exportPlanetsByItem, Dictionary<int, HashSet<int>> importPlanetsByItem, ref int totalIlsCount, ref int totalCollectorCount, ref int totalWarperCount, ref int totalIdleShips, ref int totalWorkShips)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Invalid comparison between Unknown and I4
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Invalid comparison between Unknown and I4
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Invalid comparison between Unknown and I4
			StationComponent[] array = planet.factory?.transport?.stationPool;
			int num = ((planet.factory?.transport != null) ? planet.factory.transport.stationCursor : 0);
			if (array == null || num <= 0)
			{
				return;
			}
			for (int i = 1; i < num; i++)
			{
				StationComponent val = array[i];
				if (val == null || val.id != i || !val.isStellar)
				{
					continue;
				}
				if (val.isCollector)
				{
					if (!includeCollectors)
					{
						continue;
					}
					totalCollectorCount++;
				}
				else
				{
					totalIlsCount++;
					totalWarperCount += val.warperCount;
					totalIdleShips += val.idleShipCount;
					totalWorkShips += val.workShipCount;
				}
				StationStore[] storage = val.storage;
				if (storage == null)
				{
					continue;
				}
				bool flag = val.isCollector || val.tripRangeShips >= 2390000.0;
				bool flag2 = !val.isCollector && val.idleShipCount + val.workShipCount > 0 && flag && (!val.warperNecessary || val.warperCount > 0 || val.warperFree || HasWarperSlot(storage));
				for (int j = 0; j < storage.Length; j++)
				{
					StationStore val2 = storage[j];
					if (val2.itemId <= 0 || (int)val2.remoteLogic == 0)
					{
						continue;
					}
					bool hasExternalPair = false;
					bool hasInternalPair = false;
					if (filterMode == EStarFilterMode.InterstellarSmart && gStationPool != null)
					{
						InspectSlotRemotePairs(val, j, starId, gStationPool, out hasExternalPair, out hasInternalPair);
						if ((hasInternalPair && !hasExternalPair && !flag2) || ((int)val2.remoteLogic == 2 && !flag && !hasExternalPair))
						{
							continue;
						}
					}
					if ((int)val2.remoteLogic == 1)
					{
						AccumulateSlot(exportsByItem, exportPlanetsByItem, planet.id, val2, val.isCollector, hasExternalPair, flag2);
					}
					else if ((int)val2.remoteLogic == 2)
					{
						AccumulateSlot(importsByItem, importPlanetsByItem, planet.id, val2, val.isCollector, hasExternalPair, flag2);
					}
				}
			}
		}

		private static bool HasWarperSlot(StationStore[] storage)
		{
			for (int i = 0; i < storage.Length; i++)
			{
				if (storage[i].itemId == 1210 && storage[i].count > 0)
				{
					return true;
				}
			}
			return false;
		}

		private static void InspectSlotRemotePairs(StationComponent station, int slotIndex, int starId, StationComponent[] gStationPool, out bool hasExternalPair, out bool hasInternalPair)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			hasExternalPair = false;
			hasInternalPair = false;
			SupplyDemandPair[] remotePairs = station.remotePairs;
			if (remotePairs == null)
			{
				return;
			}
			int num = Math.Min(station.remotePairTotalCount, remotePairs.Length);
			int gid = station.gid;
			for (int i = 0; i < num; i++)
			{
				SupplyDemandPair val = remotePairs[i];
				int num2 = -1;
				if (val.supplyId == gid && val.supplyIndex == slotIndex)
				{
					num2 = val.demandId;
				}
				else if (val.demandId == gid && val.demandIndex == slotIndex)
				{
					num2 = val.supplyId;
				}
				if (num2 <= 0 || num2 >= gStationPool.Length)
				{
					continue;
				}
				StationComponent val2 = gStationPool[num2];
				if (val2 != null && val2.gid == num2)
				{
					if (val2.planetId / 100 != starId)
					{
						hasExternalPair = true;
					}
					else
					{
						hasInternalPair = true;
					}
				}
			}
		}

		private static void AccumulateSlot(Dictionary<int, CombinedLogisticsItem> dict, Dictionary<int, HashSet<int>> planetsByItem, int planetId, StationStore store, bool isCollector, bool hasExternalPair, bool hasWarpCapableStation)
		{
			//IL_0001: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0081: 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_0087: 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)
			if (!dict.TryGetValue(store.itemId, out var value))
			{
				ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items)?.Select(store.itemId);
				value = new CombinedLogisticsItem
				{
					ItemId = store.itemId,
					ItemName = ((val != null) ? ((Proto)val).name : $"Item #{store.itemId}"),
					Icon = ((val != null) ? val.iconSprite : null),
					Category = CombinedLogisticsItem.ClassifyItem(val),
					Logic = store.remoteLogic,
					PlanetCount = 1
				};
				dict[store.itemId] = value;
			}
			value.StoredCount += store.count;
			value.MaxCount += store.max;
			value.InTransitOrder += store.remoteOrder;
			value.SlotCount++;
			if (isCollector)
			{
				value.CollectorSlotCount++;
			}
			if (hasExternalPair)
			{
				value.HasExternalStarPair = true;
			}
			if (hasWarpCapableStation)
			{
				value.HasWarpCapableStation = true;
			}
			if (planetsByItem != null)
			{
				if (!planetsByItem.TryGetValue(store.itemId, out var value2))
				{
					value2 = new HashSet<int>();
					planetsByItem[store.itemId] = value2;
				}
				value2.Add(planetId);
				value.PlanetCount = value2.Count;
			}
		}

		private static void ApplyInterstellarSmartFilter(Dictionary<int, CombinedLogisticsItem> exportsByItem, Dictionary<int, CombinedLogisticsItem> importsByItem)
		{
			List<int> list = new List<int>();
			foreach (int key2 in exportsByItem.Keys)
			{
				if (importsByItem.ContainsKey(key2))
				{
					list.Add(key2);
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				int key = list[i];
				CombinedLogisticsItem combinedLogisticsItem = exportsByItem[key];
				CombinedLogisticsItem combinedLogisticsItem2 = importsByItem[key];
				if (combinedLogisticsItem.HasExternalStarPair && !combinedLogisticsItem2.HasExternalStarPair)
				{
					importsByItem.Remove(key);
				}
				else if (combinedLogisticsItem2.HasExternalStarPair && !combinedLogisticsItem.HasExternalStarPair)
				{
					exportsByItem.Remove(key);
				}
				else if (!combinedLogisticsItem.HasExternalStarPair && !combinedLogisticsItem2.HasExternalStarPair)
				{
					exportsByItem.Remove(key);
					importsByItem.Remove(key);
				}
			}
		}

		private static void ApplyNetOutIntraSystemFilter(Dictionary<int, CombinedLogisticsItem> exportsByItem, Dictionary<int, CombinedLogisticsItem> importsByItem)
		{
			List<int> list = new List<int>();
			foreach (int key2 in exportsByItem.Keys)
			{
				if (importsByItem.ContainsKey(key2))
				{
					list.Add(key2);
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				int key = list[i];
				CombinedLogisticsItem combinedLogisticsItem = exportsByItem[key];
				CombinedLogisticsItem combinedLogisticsItem2 = importsByItem[key];
				int num = combinedLogisticsItem.SlotCount - combinedLogisticsItem.CollectorSlotCount;
				if (num <= combinedLogisticsItem2.SlotCount && combinedLogisticsItem.CollectorSlotCount == 0)
				{
					exportsByItem.Remove(key);
					if (combinedLogisticsItem2.SlotCount <= num)
					{
						importsByItem.Remove(key);
					}
				}
				else
				{
					importsByItem.Remove(key);
				}
			}
		}

		private static void FinalizeSummary(LogisticsSummary summary, Dictionary<int, CombinedLogisticsItem> exportsByItem, Dictionary<int, CombinedLogisticsItem> importsByItem, StellogisticsConfig config)
		{
			int critPct = config.CriticalThresholdPercent.Value;
			int warnPct = config.WarningThresholdPercent.Value;
			ESortOrder sortOrder = config.SortOrder.Value;
			foreach (CombinedLogisticsItem value in exportsByItem.Values)
			{
				if (!config.IsItemVisibleForAstro(summary.GalaxySeed, summary.TargetAstroId, value.ItemId, value.Category))
				{
					summary.FilteredOutItemCount++;
					continue;
				}
				summary.Exports.Add(value);
				switch (value.GetHealthStatus(critPct, warnPct))
				{
				case EHealthStatus.Critical:
					summary.CriticalExportCount++;
					break;
				case EHealthStatus.Warning:
					summary.WarningExportCount++;
					break;
				}
			}
			foreach (CombinedLogisticsItem value2 in importsByItem.Values)
			{
				if (!config.IsItemVisibleForAstro(summary.GalaxySeed, summary.TargetAstroId, value2.ItemId, value2.Category))
				{
					summary.FilteredOutItemCount++;
					continue;
				}
				summary.Imports.Add(value2);
				switch (value2.GetHealthStatus(critPct, warnPct))
				{
				case EHealthStatus.Critical:
					summary.CriticalImportCount++;
					break;
				case EHealthStatus.Warning:
					summary.WarningImportCount++;
					break;
				}
			}
			Comparison<CombinedLogisticsItem> comparison = delegate(CombinedLogisticsItem a, CombinedLogisticsItem b)
			{
				if (sortOrder == ESortOrder.ShortageFirst)
				{
					EHealthStatus healthStatus = a.GetHealthStatus(critPct, warnPct);
					EHealthStatus healthStatus2 = b.GetHealthStatus(critPct, warnPct);
					if (healthStatus != healthStatus2)
					{
						return healthStatus.CompareTo(healthStatus2);
					}
					int num = a.FillRatio.CompareTo(b.FillRatio);
					if (num != 0)
					{
						return num;
					}
				}
				else if (sortOrder == ESortOrder.StoredAmountDesc)
				{
					int num2 = b.StoredCount.CompareTo(a.StoredCount);
					if (num2 != 0)
					{
						return num2;
					}
				}
				return a.ItemId.CompareTo(b.ItemId);
			};
			summary.Exports.Sort(comparison);
			summary.Imports.Sort(comparison);
		}

		public static void CollectStoredItemIds(HashSet<int> result)
		{
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			result.Clear();
			GameData data = GameMain.data;
			if (data == null || data.factories == null)
			{
				return;
			}
			int num = Math.Min(data.factoryCount, data.factories.Length);
			for (int i = 0; i < num; i++)
			{
				PlanetFactory val = data.factories[i];
				if (val == null)
				{
					continue;
				}
				PlanetTransport transport = val.transport;
				if (transport != null)
				{
					StationComponent[] stationPool = transport.stationPool;
					if (stationPool != null)
					{
						int num2 = Math.Min(transport.stationCursor, stationPool.Length);
						for (int j = 1; j < num2; j++)
						{
							StationComponent val2 = stationPool[j];
							if (val2 == null || val2.id != j || val2.storage == null)
							{
								continue;
							}
							for (int k = 0; k < val2.storage.Length; k++)
							{
								int itemId = val2.storage[k].itemId;
								if (itemId > 0)
								{
									result.Add(itemId);
								}
							}
						}
					}
					DispenserComponent[] dispenserPool = transport.dispenserPool;
					if (dispenserPool != null)
					{
						int num3 = Math.Min(transport.dispenserCursor, dispenserPool.Length);
						for (int l = 1; l < num3; l++)
						{
							DispenserComponent val3 = dispenserPool[l];
							if (val3 != null && val3.id == l && val3.filter > 0)
							{
								result.Add(val3.filter);
							}
						}
					}
				}
				FactoryStorage factoryStorage = val.factoryStorage;
				if (factoryStorage == null)
				{
					continue;
				}
				StorageComponent[] storagePool = factoryStorage.storagePool;
				if (storagePool != null)
				{
					int num4 = Math.Min(factoryStorage.storageCursor, storagePool.Length);
					for (int m = 1; m < num4; m++)
					{
						StorageComponent val4 = storagePool[m];
						if (val4 == null || val4.id != m || val4.grids == null)
						{
							continue;
						}
						for (int n = 0; n < val4.grids.Length; n++)
						{
							int itemId2 = val4.grids[n].itemId;
							if (itemId2 > 0)
							{
								result.Add(itemId2);
							}
							int filter = val4.grids[n].filter;
							if (filter > 0)
							{
								result.Add(filter);
							}
						}
					}
				}
				TankComponent[] tankPool = factoryStorage.tankPool;
				if (tankPool == null)
				{
					continue;
				}
				int num5 = Math.Min(factoryStorage.tankCursor, tankPool.Length);
				for (int num6 = 1; num6 < num5; num6++)
				{
					TankComponent val5 = tankPool[num6];
					if (val5.id == num6 && val5.fluidId > 0)
					{
						result.Add(val5.fluidId);
					}
				}
			}
		}
	}
	public enum EHealthStatus
	{
		Critical,
		Warning,
		Healthy
	}
	public class CombinedLogisticsItem
	{
		public int ItemId;

		public string ItemName;

		public Sprite Icon;

		public EItemCategoryFilter Category;

		public ELogisticStorage Logic;

		public long StoredCount;

		public long MaxCount;

		public long InTransitOrder;

		public int SlotCount;

		public int CollectorSlotCount;

		public int PlanetCount;

		public bool HasExternalStarPair;

		public bool HasWarpCapableStation;

		public float FillRatio
		{
			get
			{
				if (MaxCount <= 0)
				{
					if (StoredCount <= 0)
					{
						return 0f;
					}
					return 1f;
				}
				return Mathf.Clamp01((float)StoredCount / (float)MaxCount);
			}
		}

		public float EffectiveFillRatio
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Invalid comparison between Unknown and I4
				if (MaxCount <= 0)
				{
					if (StoredCount <= 0)
					{
						return 0f;
					}
					return 1f;
				}
				if ((int)Logic == 1)
				{
					return Mathf.Clamp01((float)Math.Max(0L, StoredCount + InTransitOrder) / (float)MaxCount);
				}
				return Mathf.Clamp01((float)StoredCount / (float)MaxCount);
			}
		}

		public EHealthStatus GetHealthStatus(int criticalThresholdPct, int warningThresholdPct)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			float num = Mathf.Clamp01((float)criticalThresholdPct / 100f);
			float num2 = Mathf.Clamp01((float)warningThresholdPct / 100f);
			if (MaxCount <= 0)
			{
				if (StoredCount <= 0)
				{
					return EHealthStatus.Critical;
				}
				return EHealthStatus.Healthy;
			}
			float fillRatio = FillRatio;
			if ((int)Logic == 1)
			{
				float effectiveFillRatio = EffectiveFillRatio;
				float num3 = Mathf.Min(fillRatio, effectiveFillRatio);
				if (StoredCount == 0L || num3 <= num)
				{
					return EHealthStatus.Critical;
				}
				if (num3 <= num2)
				{
					return EHealthStatus.Warning;
				}
				return EHealthStatus.Healthy;
			}
			if (StoredCount == 0L || fillRatio <= num)
			{
				float num4 = Mathf.Clamp01((float)(StoredCount + Math.Max(0L, InTransitOrder)) / (float)MaxCount);
				if (StoredCount == 0L && InTransitOrder <= 0)
				{
					return EHealthStatus.Critical;
				}
				if (num4 <= num)
				{
					return EHealthStatus.Critical;
				}
				if (fillRatio != 0f)
				{
					return EHealthStatus.Warning;
				}
				return EHealthStatus.Critical;
			}
			if (fillRatio <= num2)
			{
				return EHealthStatus.Warning;
			}
			return EHealthStatus.Healthy;
		}

		public static EItemCategoryFilter ClassifyItem(ItemProto proto)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected I4, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			if (proto == null)
			{
				return EItemCategoryFilter.Materials;
			}
			if ((int)proto.Type == 11)
			{
				return EItemCategoryFilter.Matrices;
			}
			if (proto.CanBuild || (int)proto.Type == 5 || (int)proto.Type == 6 || (int)proto.Type == 7 || (int)proto.Type == 8 || (int)proto.Type == 9)
			{
				return EItemCategoryFilter.Buildings;
			}
			EItemType type = proto.Type;
			switch (type - 1)
			{
			default:
				if ((int)type == 10)
				{
					return EItemCategoryFilter.Materials;
				}
				return EItemCategoryFilter.Materials;
			case 0:
				return EItemCategoryFilter.RawResources;
			case 1:
				return EItemCategoryFilter.Materials;
			case 2:
				return EItemCategoryFilter.Components;
			case 3:
				return EItemCategoryFilter.ConsumablesAndPods;
			}
		}

		public static string FormatAmount(long amount)
		{
			long num = Math.Abs(amount);
			string arg = ((amount < 0) ? "-" : "");
			if (num >= 1000000)
			{
				return $"{arg}{(double)num / 1000000.0:0.#}M";
			}
			if (num >= 10000)
			{
				return $"{arg}{(double)num / 1000.0:0.#}k";
			}
			if (num >= 1000)
			{
				return $"{arg}{(double)num / 1000.0:0.0}k";
			}
			return $"{arg}{num}";
		}
	}
	public class LogisticsSummary
	{
		public string TargetName = "";

		public string TargetSubtitle = "";

		public bool IsStarSystem;

		public int TargetAstroId;

		public int GalaxySeed;

		public EItemCategoryFilter ActiveCategoryFilter = EItemCategoryFilter.All;

		public int FilteredOutItemCount;

		public int TotalIlsCount;

		public int TotalCollectorCount;

		public int TotalWarperCount;

		public int TotalIdleShips;

		public int TotalWorkShips;

		public int ColonizedPlanetCount;

		public List<CombinedLogisticsItem> Exports = new List<CombinedLogisticsItem>();

		public List<CombinedLogisticsItem> Imports = new List<CombinedLogisticsItem>();

		public int CriticalExportCount;

		public int WarningExportCount;

		public int CriticalImportCount;

		public int WarningImportCount;

		public bool HasAnyStations
		{
			get
			{
				if (TotalIlsCount <= 0)
				{
					return TotalCollectorCount > 0;
				}
				return true;
			}
		}

		public bool HasAnySlots
		{
			get
			{
				if (Exports.Count <= 0)
				{
					return Imports.Count > 0;
				}
				return true;
			}
		}
	}
	public static class StarmapPatches
	{
		private static UIStarmapLogisticsPanel _panelInstance;

		private static bool _zoomBlockedThisFrame;

		private static double _savedDistWanted;

		private static float _savedFovWanted;

		public static bool IsPointerOverPanel()
		{
			if ((Object)(object)_panelInstance != (Object)null)
			{
				return _panelInstance.IsPointerOverUI();
			}
			return false;
		}

		public static UIStarmapLogisticsPanel EnsurePanel(UIStarmap starmap)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_panelInstance != (Object)null)
			{
				return _panelInstance;
			}
			UIGame val = UIRoot.instance?.uiGame;
			if ((Object)(object)val == (Object)null || (Object)(object)starmap == (Object)null)
			{
				return null;
			}
			Transform transform = ((Component)starmap).transform;
			GameObject val2 = new GameObject("Stellogistics_StarmapPanel", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(transform, false);
			val2.SetActive(false);
			_panelInstance = val2.AddComponent<UIStarmapLogisticsPanel>();
			_panelInstance.Initialize(val, StellogisticsPlugin.ModConfig);
			ManualLogSource log = StellogisticsPlugin.Log;
			if (log != null)
			{
				log.LogInfo((object)"Initialized Stellogistics Starmap sidebar panel.");
			}
			return _panelInstance;
		}

		public static void DestroyPanel()
		{
			if ((Object)(object)_panelInstance != (Object)null)
			{
				if ((Object)(object)((Component)_panelInstance).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_panelInstance).gameObject);
				}
				_panelInstance = null;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIStarmap), "_OnOpen")]
		public static void UIStarmap_OnOpen_Postfix(UIStarmap __instance)
		{
			UIStarmapLogisticsPanel uIStarmapLogisticsPanel = EnsurePanel(__instance);
			if ((Object)(object)uIStarmapLogisticsPanel != (Object)null)
			{
				uIStarmapLogisticsPanel.RequestImmediateRefresh();
				uIStarmapLogisticsPanel.OnStarmapUpdate(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIStarmap), "_OnUpdate")]
		public static void UIStarmap_OnUpdate_Postfix(UIStarmap __instance)
		{
			UIStarmapLogisticsPanel uIStarmapLogisticsPanel = EnsurePanel(__instance);
			if ((Object)(object)uIStarmapLogisticsPanel != (Object)null)
			{
				uIStarmapLogisticsPanel.OnStarmapUpdate(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIStarmap), "_OnClose")]
		public static void UIStarmap_OnClose_Postfix()
		{
			if ((Object)(object)_panelInstance != (Object)null && ((Component)_panelInstance).gameObject.activeSelf)
			{
				((Component)_panelInstance).gameObject.SetActive(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIStarmap), "_OnDestroy")]
		public static void UIStarmap_OnDestroy_Postfix()
		{
			DestroyPanel();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")]
		public static void UIPlanetDetail_OnPlanetDataSet_Postfix()
		{
			if ((Object)(object)_panelInstance != (Object)null)
			{
				_panelInstance.RequestImmediateRefresh();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIStarDetail), "OnStarDataSet")]
		public static void UIStarDetail_OnStarDataSet_Postfix()
		{
			if ((Object)(object)_panelInstance != (Object)null)
			{
				_panelInstance.RequestImmediateRefresh();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VFInput), "UpdateGameStates")]
		public static void VFInput_UpdateGameStates_Postfix()
		{
			if (IsPointerOverPanel())
			{
				VFInput.inScrollView = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void VFInput_CameraZoomIn_Postfix(ref float __result)
		{
			if (IsPointerOverPanel())
			{
				__result = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void VFInput_CameraZoomOut_Postfix(ref float __result)
		{
			if (IsPointerOverPanel())
			{
				__result = 0f;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StarmapCamera), "CameraControl")]
		public static void StarmapCamera_CameraControl_Prefix(StarmapCamera __instance)
		{
			if (IsPointerOverPanel())
			{
				VFInput.inScrollView = true;
				_zoomBlockedThisFrame = true;
				_savedDistWanted = __instance.distWanted;
				_savedFovWanted = __instance.fovWanted;
			}
			else
			{
				_zoomBlockedThisFrame = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StarmapCamera), "CameraControl")]
		public static void StarmapCamera_CameraControl_Postfix(StarmapCamera __instance)
		{
			if (_zoomBlockedThisFrame)
			{
				__instance.distWanted = _savedDistWanted;
				__instance.fovWanted = _savedFovWanted;
			}
		}
	}
	public enum EStarFilterMode
	{
		InterstellarSmart,
		NetOutIntraSystem,
		AllRemoteSlots
	}
	public enum ESortOrder
	{
		ShortageFirst,
		ItemId,
		StoredAmountDesc
	}
	[Flags]
	public enum EItemCategoryFilter
	{
		None = 0,
		RawResources = 1,
		Materials = 2,
		Components = 4,
		Buildings = 8,
		ConsumablesAndPods = 0x10,
		Matrices = 0x20,
		All = 0x3F
	}
	public class StellogisticsConfig
	{
		private readonly ConfigFile _configFile;

		public const float DefaultPosX = 82f;

		public const float DefaultPosY = -470f;

		public const float DefaultWidth = 310f;

		public const float DefaultMaxHeight = 460f;

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

		private readonly Dictionary<string, HashSet<int>> _astroItemOverridesCache = new Dictionary<string, HashSet<int>>();

		public ConfigEntry<bool> EnableMod { get; }

		public ConfigEntry<bool> IncludeOrbitalCollectors { get; }

		public ConfigEntry<EStarFilterMode> StarSystemFilterMode { get; }

		public ConfigEntry<ESortOrder> SortOrder { get; }

		public ConfigEntry<bool> ShowOnHover { get; }

		public ConfigEntry<int> CriticalThresholdPercent { get; }

		public ConfigEntry<int> WarningThresholdPercent { get; }

		public ConfigEntry<float> PanelWidth { get; }

		public ConfigEntry<float> PanelMaxHeight { get; }

		public ConfigEntry<bool> UseCustomPosition { get; }

		public ConfigEntry<float> CustomPanelPosX { get; }

		public ConfigEntry<float> CustomPanelPosY { get; }

		public ConfigEntry<EItemCategoryFilter> DefaultCategoryFilter { get; }

		public ConfigEntry<string> SavedAstroFilters { get; }

		public ConfigEntry<string> SavedAstroItemOverrides { get; }

		public StellogisticsConfig(ConfigFile config)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			_configFile = config;
			EnableMod = config.Bind<bool>("General", "EnableMod", true, "Enable the Stellogistics import/export panel on the Starmap.");
			IncludeOrbitalCollectors = config.Bind<bool>("Logistics", "IncludeOrbitalCollectors", true, "Include Gas Giant Orbital Collectors (Hydrogen, Deuterium, Fire Ice) in Exports.");
			StarSystemFilterMode = config.Bind<EStarFilterMode>("Logistics", "StarSystemFilterMode", EStarFilterMode.InterstellarSmart, "How to filter intra-system trade when viewing an entire Star System:\nInterstellarSmart: Excludes slots restricted to intra-system range (<1 LY) and internal supply+demand pairs that have no external star routes.\nNetOutIntraSystem: Nets total Supply against total Demand within the same star system.\nAllRemoteSlots: Shows all Remote Supply and Remote Demand slots in the star system.");
			SortOrder = config.Bind<ESortOrder>("Display", "SortOrder", ESortOrder.ShortageFirst, "How combined items are sorted in the Exports and Imports lists:\nShortageFirst: Items running empty (Exports) or starved (Imports) appear at the top.\nItemId: Sorted by DSP item ID.\nStoredAmountDesc: Sorted by highest stored amount first.");
			ShowOnHover = config.Bind<bool>("Display", "ShowOnHover", true, "Show logistics when hovering a planet or star in the Starmap even if not clicked/selected.");
			CriticalThresholdPercent = config.Bind<int>("Thresholds", "CriticalThresholdPercent", 15, new ConfigDescription("Storage fullness percentage at or below which an item is highlighted Red (Critical / Empty).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>()));
			WarningThresholdPercent = config.Bind<int>("Thresholds", "WarningThresholdPercent", 40, new ConfigDescription("Storage fullness percentage at or below which an item is highlighted Orange (Low / Depleting).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 85), Array.Empty<object>()));
			PanelWidth = config.Bind<float>("UI", "PanelWidth", 310f, new ConfigDescription("Width of the Stellogistics panel in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(240f, 700f), Array.Empty<object>()));
			PanelMaxHeight = config.Bind<float>("UI", "PanelMaxHeight", 460f, new ConfigDescription("Maximum height of the scrollable list area in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(120f, 950f), Array.Empty<object>()));
			UseCustomPosition = config.Bind<bool>("UI", "UseCustomPosition", false, "True when the user has dragged the Stellogistics panel to a custom screen position.");
			CustomPanelPosX = config.Bind<float>("UI", "CustomPanelPosX", 82f, "Saved X anchoredPosition (from top-left) of the Stellogistics panel.");
			CustomPanelPosY = config.Bind<float>("UI", "CustomPanelPosY", -470f, "Saved Y anchoredPosition (from top-left) of the Stellogistics panel.");
			DefaultCategoryFilter = config.Bind<EItemCategoryFilter>("Filters", "DefaultCategoryFilter", EItemCategoryFilter.All, "Default item category filter for planets and star systems that do not have a custom per-body filter saved.");
			SavedAstroFilters = config.Bind<string>("Filters", "SavedAstroFilters", "", "Serialized per-star and per-planet item category filters (format: seed_astroId:mask,...).");
			SavedAstroItemOverrides = config.Bind<string>("Filters", "SavedAstroItemOverrides", "", "Serialized per-star and per-planet individual item filter overrides (format: seed_astroId:id1|id2,...).");
			ParseSavedAstroFilters();
			ParseSavedAstroItemOverrides();
		}

		private static string MakeAstroKey(int galaxySeed, int astroId)
		{
			return $"{galaxySeed}_{astroId}";
		}

		private void ParseSavedAstroFilters()
		{
			_astroFilterCache.Clear();
			string value = SavedAstroFilters.Value;
			if (string.IsNullOrEmpty(value))
			{
				return;
			}
			string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				if (array2.Length == 2 && int.TryParse(array2[1], out var result))
				{
					_astroFilterCache[array2[0].Trim()] = (EItemCategoryFilter)(result & 0x3F);
				}
			}
		}

		private void FlushSavedAstroFilters()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, EItemCategoryFilter> item in _astroFilterCache)
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append(',');
				}
				stringBuilder.Append(item.Key).Append(':').Append((int)item.Value);
			}
			SavedAstroFilters.Value = stringBuilder.ToString();
			_configFile.Save();
		}

		private void ParseSavedAstroItemOverrides()
		{
			_astroItemOverridesCache.Clear();
			string value = SavedAstroItemOverrides.Value;
			if (string.IsNullOrEmpty(value))
			{
				return;
			}
			string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				if (array2.Length != 2)
				{
					continue;
				}
				string key = array2[0].Trim();
				string[] array3 = array2[1].Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries);
				HashSet<int> hashSet = new HashSet<int>();
				for (int j = 0; j < array3.Length; j++)
				{
					if (int.TryParse(array3[j], out var result) && result > 0)
					{
						hashSet.Add(result);
					}
				}
				if (hashSet.Count > 0)
				{
					_astroItemOverridesCache[key] = hashSet;
				}
			}
		}

		private void FlushSavedAstroItemOverrides()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, HashSet<int>> item in _astroItemOverridesCache)
			{
				if (item.Value == null || item.Value.Count == 0)
				{
					continue;
				}
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append(',');
				}
				stringBuilder.Append(item.Key).Append(':');
				bool flag = true;
				foreach (int item2 in item.Value)
				{
					if (!flag)
					{
						stringBuilder.Append('|');
					}
					stringBuilder.Append(item2);
					flag = false;
				}
			}
			SavedAstroItemOverrides.Value = stringBuilder.ToString();
			_configFile.Save();
		}

		public EItemCategoryFilter GetFilterForAstro(int galaxySeed, int astroId)
		{
			if (astroId <= 0)
			{
				return DefaultCategoryFilter.Value;
			}
			string key = MakeAstroKey(galaxySeed, astroId);
			if (_astroFilterCache.TryGetValue(key, out var value))
			{
				return value;
			}
			return DefaultCategoryFilter.Value;
		}

		public bool HasCustomFilterForAstro(int galaxySeed, int astroId)
		{
			if (astroId <= 0)
			{
				return false;
			}
			string key = MakeAstroKey(galaxySeed, astroId);
			if (!_astroFilterCache.ContainsKey(key))
			{
				if (_astroItemOverridesCache.TryGetValue(key, out var value))
				{
					return value.Count > 0;
				}
				return false;
			}
			return true;
		}

		private HashSet<int> GetOrInitHiddenItemsSet(int galaxySeed, int astroId)
		{
			string key = MakeAstroKey(galaxySeed, astroId);
			if (!_astroItemOverridesCache.TryGetValue(key, out var value))
			{
				value = new HashSet<int>();
				EItemCategoryFilter filterForAstro = GetFilterForAstro(galaxySeed, astroId);
				if (filterForAstro != EItemCategoryFilter.All && (Object)(object)LDB.items != (Object)null && ((ProtoSet<ItemProto>)(object)LDB.items).dataArray != null)
				{
					ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
					foreach (ItemProto val in dataArray)
					{
						if (val != null && ((Proto)val).ID > 0)
						{
							EItemCategoryFilter eItemCategoryFilter = CombinedLogisticsItem.ClassifyItem(val);
							if ((filterForAstro & eItemCategoryFilter) == 0)
							{
								value.Add(((Proto)val).ID);
							}
						}
					}
				}
				_astroItemOverridesCache[key] = value;
			}
			return value;
		}

		public void SetFilterForAstro(int galaxySeed, int astroId, EItemCategoryFilter mask, EItemCategoryFilter? toggledCategories = null)
		{
			if (astroId <= 0)
			{
				DefaultCategoryFilter.Value = mask;
				_configFile.Save();
				return;
			}
			HashSet<int> orInitHiddenItemsSet = GetOrInitHiddenItemsSet(galaxySeed, astroId);
			string key = MakeAstroKey(galaxySeed, astroId);
			EItemCategoryFilter eItemCategoryFilter = mask & EItemCategoryFilter.All;
			_astroFilterCache[key] = eItemCategoryFilter;
			if (toggledCategories.HasValue && (Object)(object)LDB.items != (Object)null && ((ProtoSet<ItemProto>)(object)LDB.items).dataArray != null)
			{
				EItemCategoryFilter value = toggledCategories.Value;
				ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
				foreach (ItemProto val in dataArray)
				{
					if (val == null || ((Proto)val).ID <= 0)
					{
						continue;
					}
					EItemCategoryFilter eItemCategoryFilter2 = CombinedLogisticsItem.ClassifyItem(val);
					if ((value & eItemCategoryFilter2) != EItemCategoryFilter.None)
					{
						if ((eItemCategoryFilter & eItemCategoryFilter2) != EItemCategoryFilter.None)
						{
							orInitHiddenItemsSet.Remove(((Proto)val).ID);
						}
						else
						{
							orInitHiddenItemsSet.Add(((Proto)val).ID);
						}
					}
				}
			}
			FlushSavedAstroItemOverrides();
			FlushSavedAstroFilters();
		}

		public void SetCustomItemsAllVisible(int galaxySeed, int astroId, bool visible)
		{
			if (astroId <= 0)
			{
				return;
			}
			HashSet<int> orInitHiddenItemsSet = GetOrInitHiddenItemsSet(galaxySeed, astroId);
			if (visible)
			{
				orInitHiddenItemsSet.Clear();
			}
			else if ((Object)(object)LDB.items != (Object)null && ((ProtoSet<ItemProto>)(object)LDB.items).dataArray != null)
			{
				ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
				foreach (ItemProto val in dataArray)
				{
					if (val != null && ((Proto)val).ID > 0)
					{
						orInitHiddenItemsSet.Add(((Proto)val).ID);
					}
				}
			}
			FlushSavedAstroItemOverrides();
		}

		public void ResetFilterForAstro(int galaxySeed, int astroId)
		{
			if (astroId <= 0)
			{
				DefaultCategoryFilter.Value = EItemCategoryFilter.All;
				_configFile.Save();
				return;
			}
			string key = MakeAstroKey(galaxySeed, astroId);
			bool num = _astroFilterCache.Remove(key);
			bool flag = _astroItemOverridesCache.Remove(key);
			if (num)
			{
				FlushSavedAstroFilters();
			}
			if (flag)
			{
				FlushSavedAstroItemOverrides();
			}
		}

		public bool IsItemVisibleForAstro(int galaxySeed, int astroId, int itemId, EItemCategoryFilter itemCategory)
		{
			if (astroId > 0)
			{
				string key = MakeAstroKey(galaxySeed, astroId);
				if (_astroItemOverridesCache.TryGetValue(key, out var value))
				{
					return !value.Contains(itemId);
				}
			}
			return (GetFilterForAstro(galaxySeed, astroId) & itemCategory) != 0;
		}

		public void ToggleItemOverrideForAstro(int galaxySeed, int astroId, int itemId)
		{
			if (astroId > 0 && itemId > 0)
			{
				HashSet<int> orInitHiddenItemsSet = GetOrInitHiddenItemsSet(galaxySeed, astroId);
				if (!orInitHiddenItemsSet.Remove(itemId))
				{
					orInitHiddenItemsSet.Add(itemId);
				}
				FlushSavedAstroItemOverrides();
			}
		}

		public void SaveCustomPanelPosition(float x, float y)
		{
			UseCustomPosition.Value = true;
			CustomPanelPosX.Value = x;
			CustomPanelPosY.Value = y;
			_configFile.Save();
		}

		public void SavePanelSize(float width, float maxHeight)
		{
			PanelWidth.Value = width;
			PanelMaxHeight.Value = maxHeight;
			_configFile.Save();
		}

		public void ResetPanelLayout()
		{
			UseCustomPosition.Value = false;
			CustomPanelPosX.Value = 82f;
			CustomPanelPosY.Value = -470f;
			PanelWidth.Value = 310f;
			PanelMaxHeight.Value = 460f;
			_configFile.Save();
		}
	}
	[BepInPlugin("com.stellogistics.dsp", "Stellogistics", "1.0.0")]
	[BepInProcess("DSPGAME.exe")]
	public class StellogisticsPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.stellogistics.dsp";

		public const string PluginName = "Stellogistics";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		public static ManualLogSource Log { get; private set; }

		public static StellogisticsConfig ModConfig { get; private set; }

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig = new StellogisticsConfig(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("com.stellogistics.dsp");
			_harmony.PatchAll(typeof(StarmapPatches));
			Log.LogInfo((object)"Stellogistics v1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			StarmapPatches.DestroyPanel();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public class PointerHoverTracker : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public bool IsHovered { get; private set; }

		public void OnPointerEnter(PointerEventData eventData)
		{
			IsHovered = true;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			IsHovered = false;
		}

		private void OnDisable()
		{
			IsHovered = false;
		}
	}
	public class ItemCellHoverHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public Action OnHoverEnter;

		public Action OnHoverExit;

		public void OnPointerEnter(PointerEventData eventData)
		{
			OnHoverEnter?.Invoke();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			OnHoverExit?.Invoke();
		}
	}
	public class PanelDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public RectTransform TargetRect;

		public Action OnDragStarted;

		public Action<Vector2> OnDragFinished;

		private Canvas _canvas;

		public void OnBeginDrag(PointerEventData eventData)
		{
			if (!((Object)(object)TargetRect == (Object)null))
			{
				if ((Object)(object)_canvas == (Object)null)
				{
					_canvas = ((Component)TargetRect).GetComponentInParent<Canvas>();
				}
				OnDragStarted?.Invoke();
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)TargetRect == (Object)null))
			{
				float num = (((Object)(object)_canvas != (Object)null && _canvas.scaleFactor > 0.01f) ? _canvas.scaleFactor : 1f);
				RectTransform targetRect = TargetRect;
				targetRect.anchoredPosition += eventData.delta / num;
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)TargetRect != (Object)null)
			{
				OnDragFinished?.Invoke(TargetRect.anchoredPosition);
			}
		}
	}
	public class PanelResizeHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public RectTransform TargetRect;

		public Action OnResizeStarted;

		public Action<float, float> OnResizing;

		public Action<float, float> OnResizeFinished;

		private Vector2 _grabOffset;

		private float _lastWidth = 310f;

		private float _lastTotalHeight = 300f;

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)TargetRect == (Object)null))
			{
				Vector2 val = default(Vector2);
				Rect rect;
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(TargetRect, eventData.position, eventData.pressEventCamera, ref val))
				{
					rect = TargetRect.rect;
					float width = ((Rect)(ref rect)).width;
					rect = TargetRect.rect;
					float height = ((Rect)(ref rect)).height;
					_grabOffset = new Vector2(width - val.x, height - (0f - val.y));
				}
				else
				{
					_grabOffset = Vector2.zero;
				}
				rect = TargetRect.rect;
				_lastWidth = ((Rect)(ref rect)).width;
				rect = TargetRect.rect;
				_lastTotalHeight = ((Rect)(ref rect)).height;
				OnResizeStarted?.Invoke();
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			if (!((Object)(object)TargetRect == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(TargetRect, eventData.position, eventData.pressEventCamera, ref val))
			{
				float num = val.x + _grabOffset.x;
				float num2 = 0f - val.y + _grabOffset.y;
				_lastWidth = Mathf.Clamp(num, 240f, 700f);
				_lastTotalHeight = Mathf.Clamp(num2, 10f, 1020f);
				OnResizing?.Invoke(_lastWidth, _lastTotalHeight);
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			OnResizeFinished?.Invoke(_lastWidth, _lastTotalHeight);
		}
	}
	public class UIStarmapLogisticsPanel : MonoBehaviour
	{
		private class ItemRowView
		{
			public GameObject RootGo;

			public RectTransform RootRect;

			public Image BgImage;

			public RectTransform FillBarRect;

			public Image FillBarImage;

			public Image StatusStripeImage;

			public Image IconImage;

			public Text NameText;

			public Text MetaText;

			public Text AmountText;

			public Text SubStatusText;
		}

		private class FilterToggleRow
		{
			public EItemCategoryFilter Category;

			public Button Btn;

			public Image CheckBoxBg;

			public Text CheckMarkText;

			public Text LabelText;
		}

		private class CustomPickerCell
		{
			public int ItemId;

			public string ItemName;

			public EItemCategoryFilter Category;

			public int TabIndex;

			public GameObject CellGo;

			public Image BgImage;

			public Image IconImage;
		}

		private StellogisticsConfig _config;

		private UIGame _uiGame;

		private Font _gameFont;

		private RectTransform _panelRect;

		private RectTransform _headerRect;

		private Image _panelBg;

		private PointerHoverTracker _panelHoverTracker;

		private PointerHoverTracker _optionsHoverTracker;

		private PointerHoverTracker _customPickerHoverTracker;

		private Button _panelCollapseBtn;

		private Text _panelCollapseBtnText;

		private Text _titleText;

		private Text _subtitleText;

		private Text _fleetInfoText;

		private Button _filterModeBtn;

		private Text _filterModeBtnText;

		private Button _sortModeBtn;

		private Text _sortModeBtnText;

		private Button _optionsBtn;

		private Text _optionsBtnText;

		private RectTransform _scrollViewportRect;

		private RectTransform _scrollContentRect;

		private ScrollRect _scrollRect;

		private GameObject _scrollbarGo;

		private Scrollbar _verticalScrollbar;

		private GameObject _resizeGripGo;

		private GameObject _emptyStateGo;

		private Text _emptyStateText;

		private GameObject _exportsHeaderGo;

		private RectTransform _exportsHeaderRect;

		private Text _exportsHeaderText;

		private Text _exportsAlertText;

		private GameObject _importsHeaderGo;

		private RectTransform _importsHeaderRect;

		private Text _importsHeaderText;

		private Text _importsAlertText;

		private GameObject _optionsMenuGo;

		private RectTransform _optionsMenuRect;

		private Text _optionsTargetLabel;

		private readonly List<FilterToggleRow> _filterToggles = new List<FilterToggleRow>();

		private GameObject _customPickerGo;

		private RectTransform _customPickerRect;

		private Text _customPickerHoveredLabel;

		private Image _customTabItemsBg;

		private Image _customTabBuildingsBg;

		private int _customPickerActiveTab = 1;

		private bool _customPickerOpen;

		private readonly List<CustomPickerCell> _customPickerCells = new List<CustomPickerCell>();

		private readonly HashSet<int> _storedItemsSet = new HashSet<int>();

		private readonly List<ItemRowView> _rowPool = new List<ItemRowView>();

		private int _lastTargetAstroId = -1;

		private int _lastGalaxySeed;

		private string _lastTargetDisplayName = "";

		private PlanetData _lastResolvedPlanet;

		private StarData _lastResolvedStar;

		private float _nextRefreshTime;

		private bool _forceRefresh = true;

		private float _activeContentHeight = 160f;

		private bool _panelCollapsed;

		private bool _exportsCollapsed;

		private bool _importsCollapsed;

		private bool _optionsMenuOpen;

		private bool _isResizing;

		private static readonly Color PanelBgColor = new Color(0.055f, 0.085f, 0.13f, 0.94f);

		private static readonly Color HeaderBgColor = new Color(0.09f, 0.145f, 0.22f, 0.98f);

		private static readonly Color SectionHeaderBgColor = new Color(0.12f, 0.19f, 0.28f, 0.95f);

		private static readonly Color SectionHeaderHoverColor = new Color(0.17f, 0.27f, 0.39f, 0.98f);

		private static readonly Color RowEvenBgColor = new Color(0.08f, 0.12f, 0.18f, 0.78f);

		private static readonly Color RowOddBgColor = new Color(0.065f, 0.1f, 0.15f, 0.78f);

		private static readonly Color CriticalColor = new Color(1f, 0.34f, 0.34f, 1f);

		private static readonly Color CriticalFillColor = new Color(0.85f, 0.18f, 0.18f, 0.24f);

		private static readonly Color WarningColor = new Color(1f, 0.7f, 0.24f, 1f);

		private static readonly Color WarningFillColor = new Color(0.85f, 0.52f, 0.12f, 0.22f);

		private static readonly Color HealthyColor = new Color(0.3f, 0.9f, 0.58f, 1f);

		private static readonly Color HealthyFillColor = new Color(0.18f, 0.68f, 0.42f, 0.18f);

		private const float HeaderHeight = 74f;

		private const float CollapsedTabWidth = 148f;

		private const float CollapsedTabHeight = 32f;

		private const float SectionHeaderHeight = 26f;

		private const float RowHeight = 38f;

		private const float RowSpacing = 2f;

		private const float MinScrollHeight = 56f;

		private const float ScrollbarWidth = 7f;

		public void Initialize(UIGame uiGame, StellogisticsConfig config)
		{
			_uiGame = uiGame;
			_config = config;
			if ((Object)(object)_uiGame.planetDetail != (Object)null && (Object)(object)_uiGame.planetDetail.typeText != (Object)null)
			{
				_gameFont = _uiGame.planetDetail.typeText.font;
			}
			else if ((Object)(object)_uiGame.starmap != (Object)null && (Object)(object)_uiGame.starmap.cursorViewText != (Object)null)
			{
				_gameFont = _uiGame.starmap.cursorViewText.font;
			}
			if ((Object)(object)_gameFont == (Object)null)
			{
				_gameFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			BuildUI();
			BuildOptionsMenu();
			BuildCustomItemPicker();
		}

		public bool IsPointerOverUI()
		{
			if (!((Component)this).gameObject.activeInHierarchy)
			{
				return false;
			}
			if ((Object)(object)_panelHoverTracker != (Object)null && _panelHoverTracker.IsHovered)
			{
				return true;
			}
			if (_optionsMenuOpen && (Object)(object)_optionsHoverTracker != (Object)null && _optionsHoverTracker.IsHovered)
			{
				return true;
			}
			if (_customPickerOpen && (Object)(object)_customPickerHoverTracker != (Object)null && _customPickerHoverTracker.IsHovered)
			{
				return true;
			}
			return false;
		}

		private void BuildUI()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Expected O, but got Unknown
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Expected O, but got Unknown
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Expected O, but got Unknown
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Expected O, but got Unknown
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Expected O, but got Unknown
			//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0806: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_084a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f0: Expected O, but got Unknown
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			//IL_0948: Unknown result type (might be due to invalid IL or missing references)
			//IL_095d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a29: Expected O, but got Unknown
			//IL_0a36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a58: Expected O, but got Unknown
			_panelRect = ((Component)this).gameObject.GetComponent<RectTransform>();
			if ((Object)(object)_panelRect == (Object)null)
			{
				_panelRect = ((Component)this).gameObject.AddComponent<RectTransform>();
			}
			_panelRect.anchorMin = new Vector2(0f, 1f);
			_panelRect.anchorMax = new Vector2(0f, 1f);
			_panelRect.pivot = new Vector2(0f, 1f);
			_panelRect.sizeDelta = new Vector2(_config.PanelWidth.Value, 240f);
			if (_config.UseCustomPosition.Value)
			{
				_panelRect.anchoredPosition = new Vector2(_config.CustomPanelPosX.Value, _config.CustomPanelPosY.Value);
			}
			else
			{
				_panelRect.anchoredPosition = new Vector2(82f, -470f);
			}
			_panelBg = ((Component)this).gameObject.AddComponent<Image>();
			((Graphic)_panelBg).color = PanelBgColor;
			((Graphic)_panelBg).raycastTarget = true;
			_panelHoverTracker = ((Component)this).gameObject.AddComponent<PointerHoverTracker>();
			Outline obj = ((Component)this).gameObject.AddComponent<Outline>();
			((Shadow)obj).effectColor = new Color(0.25f, 0.55f, 0.8f, 0.45f);
			((Shadow)obj).effectDistance = new Vector2(1f, -1f);
			GameObject val = new GameObject("Header", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(PanelDragHandler)
			});
			val.transform.SetParent((Transform)(object)_panelRect, false);
			_headerRect = val.GetComponent<RectTransform>();
			_headerRect.anchorMin = new Vector2(0f, 1f);
			_headerRect.anchorMax = new Vector2(1f, 1f);
			_headerRect.pivot = new Vector2(0.5f, 1f);
			_headerRect.anchoredPosition = Vector2.zero;
			_headerRect.sizeDelta = new Vector2(0f, 74f);
			Image component = val.GetComponent<Image>();
			((Graphic)component).color = HeaderBgColor;
			((Graphic)component).raycastTarget = true;
			PanelDragHandler component2 = val.GetComponent<PanelDragHandler>();
			component2.TargetRect = _panelRect;
			component2.OnDragStarted = delegate
			{
				_config.UseCustomPosition.Value = true;
			};
			component2.OnDragFinished = delegate(Vector2 pos)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				_config.SaveCustomPanelPosition(pos.x, pos.y);
				if (_customPickerOpen)
				{
					PositionCustomPickerBesidePanel();
				}
			};
			_panelCollapseBtn = CreateHeaderButton("CollapsePanelBtn", _headerRect, new Vector2(8f, -6f), new Vector2(22f, 20f), anchorRight: false, out _panelCollapseBtnText);
			_panelCollapseBtnText.text = "▼";
			((UnityEvent)_panelCollapseBtn.onClick).AddListener(new UnityAction(OnTogglePanelCollapseClicked));
			_titleText = CreateText("TitleText", _headerRect, 13, (FontStyle)1, (TextAnchor)3, new Color(0.94f, 0.97f, 1f, 1f));
			((Graphic)_titleText).rectTransform.anchorMin = new Vector2(0f, 1f);
			((Graphic)_titleText).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)_titleText).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)_titleText).rectTransform.anchoredPosition = new Vector2(34f, -6f);
			((Graphic)_titleText).rectTransform.sizeDelta = new Vector2(-190f, 20f);
			_filterModeBtn = CreateHeaderButton("FilterModeBtn", _headerRect, new Vector2(-114f, -6f), new Vector2(52f, 20f), anchorRight: true, out _filterModeBtnText);
			((UnityEvent)_filterModeBtn.onClick).AddListener(new UnityAction(OnFilterModeButtonClicked));
			_sortModeBtn = CreateHeaderButton("SortModeBtn", _headerRect, new Vector2(-58f, -6f), new Vector2(52f, 20f), anchorRight: true, out _sortModeBtnText);
			((UnityEvent)_sortModeBtn.onClick).AddListener(new UnityAction(OnSortModeButtonClicked));
			_optionsBtn = CreateHeaderButton("OptionsBtn", _headerRect, new Vector2(-6f, -6f), new Vector2(48f, 20f), anchorRight: true, out _optionsBtnText);
			_optionsBtnText.text = "Filter ▾";
			((UnityEvent)_optionsBtn.onClick).AddListener(new UnityAction(OnOptionsButtonClicked));
			_subtitleText = CreateText("SubtitleText", _headerRect, 11, (FontStyle)0, (TextAnchor)3, new Color(0.68f, 0.82f, 0.94f, 1f));
			((Graphic)_subtitleText).rectTransform.anchorMin = new Vector2(0f, 1f);
			((Graphic)_subtitleText).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)_subtitleText).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)_subtitleText).rectTransform.anchoredPosition = new Vector2(10f, -31f);
			((Graphic)_subtitleText).rectTransform.sizeDelta = new Vector2(-20f, 18f);
			_fleetInfoText = CreateText("FleetInfoText", _headerRect, 11, (FontStyle)0, (TextAnchor)3, new Color(0.56f, 0.72f, 0.85f, 0.95f));
			((Graphic)_fleetInfoText).rectTransform.anchorMin = new Vector2(0f, 1f);
			((Graphic)_fleetInfoText).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)_fleetInfoText).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)_fleetInfoText).rectTransform.anchoredPosition = new Vector2(10f, -50f);
			((Graphic)_fleetInfoText).rectTransform.sizeDelta = new Vector2(-20f, 18f);
			GameObject val2 = new GameObject("ScrollView", new Type[4]
			{
				typeof(RectTransform),
				typeof(ScrollRect),
				typeof(Image),
				typeof(Mask)
			});
			val2.transform.SetParent((Transform)(object)_panelRect, false);
			_scrollViewportRect = val2.GetComponent<RectTransform>();
			_scrollViewportRect.anchorMin = new Vector2(0f, 1f);
			_scrollViewportRect.anchorMax = new Vector2(1f, 1f);
			_scrollViewportRect.pivot = new Vector2(0.5f, 1f);
			_scrollViewportRect.anchoredPosition = new Vector2(0f, -74f);
			_scrollViewportRect.sizeDelta = new Vector2(0f, 160f);
			Image component3 = val2.GetComponent<Image>();
			((Graphic)component3).color = new Color(0f, 0f, 0f, 0.01f);
			((Graphic)component3).raycastTarget = true;
			val2.GetComponent<Mask>().showMaskGraphic = false;
			GameObject val3 = new GameObject("Content", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent((Transform)(object)_scrollViewportRect, false);
			_scrollContentRect = val3.GetComponent<RectTransform>();
			_scrollContentRect.anchorMin = new Vector2(0f, 1f);
			_scrollContentRect.anchorMax = new Vector2(1f, 1f);
			_scrollContentRect.pivot = new Vector2(0f, 1f);
			_scrollContentRect.anchoredPosition = Vector2.zero;
			_scrollContentRect.sizeDelta = new Vector2(0f, 160f);
			BuildScrollbar();
			_scrollRect = val2.GetComponent<ScrollRect>();
			_scrollRect.viewport = _scrollViewportRect;
			_scrollRect.content = _scrollContentRect;
			_scrollRect.horizontal = false;
			_scrollRect.vertical = true;
			_scrollRect.movementType = (MovementType)2;
			_scrollRect.scrollSensitivity = 32f;
			_scrollRect.verticalScrollbar = _verticalScrollbar;
			_emptyStateGo = new GameObject("EmptyState", new Type[1] { typeof(RectTransform) });
			_emptyStateGo.transform.SetParent((Transform)(object)_scrollContentRect, false);
			RectTransform component4 = _emptyStateGo.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 1f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.pivot = new Vector2(0.5f, 1f);
			component4.anchoredPosition = new Vector2(0f, -8f);
			component4.sizeDelta = new Vector2(-20f, 40f);
			_emptyStateText = CreateText("EmptyText", component4, 12, (FontStyle)2, (TextAnchor)4, new Color(0.6f, 0.72f, 0.82f, 0.95f));
			((Graphic)_emptyStateText).rectTransform.anchorMin = Vector2.zero;
			((Graphic)_emptyStateText).rectTransform.anchorMax = Vector2.one;
			((Graphic)_emptyStateText).rectTransform.sizeDelta = Vector2.zero;
			_emptyStateText.text = "No active Interplanetary Logistics slots.";
			CreateSectionHeader("ExportsHeader", new UnityAction(OnToggleExportsCollapseClicked), out _exportsHeaderGo, out _exportsHeaderRect, out _exportsHeaderText, out _exportsAlertText);
			CreateSectionHeader("ImportsHeader", new UnityAction(OnToggleImportsCollapseClicked), out _importsHeaderGo, out _importsHeaderRect, out _importsHeaderText, out _importsAlertText);
			BuildResizeGrip();
		}

		private void BuildScrollbar()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_006b: 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_0095: 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)
			//IL_00bf: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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)
			_scrollbarGo = new GameObject("VerticalScrollbar", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Scrollbar)
			});
			_scrollbarGo.transform.SetParent((Transform)(object)_scrollViewportRect, false);
			RectTransform component = _scrollbarGo.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 1f);
			component.anchoredPosition = new Vector2(-1f, -2f);
			component.sizeDelta = new Vector2(7f, -14f);
			Image component2 = _scrollbarGo.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.03f, 0.05f, 0.09f, 0.85f);
			((Graphic)component2).raycastTarget = true;
			GameObject val = new GameObject("SlidingArea", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)component, false);
			RectTransform component3 = val.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = new Vector2(1f, 1f);
			component3.offsetMax = new Vector2(-1f, -1f);
			GameObject val2 = new GameObject("Handle", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent((Transform)(object)component3, false);
			RectTransform component4 = val2.GetComponent<RectTransform>();
			component4.anchorMin = Vector2.zero;
			component4.anchorMax = Vector2.one;
			component4.offsetMin = Vector2.zero;
			component4.offsetMax = Vector2.zero;
			Image component5 = val2.GetComponent<Image>();
			((Graphic)component5).color = new Color(0.28f, 0.54f, 0.78f, 0.9f);
			((Graphic)component5).raycastTarget = true;
			_verticalScrollbar = _scrollbarGo.GetComponent<Scrollbar>();
			_verticalScrollbar.direction = (Direction)2;
			_verticalScrollbar.handleRect = component4;
			((Selectable)_verticalScrollbar).targetGraphic = (Graphic)(object)component5;
			ColorBlock colors = ((Selectable)_verticalScrollbar).colors;
			((ColorBlock)(ref colors)).normalColor = new Color(0.28f, 0.54f, 0.78f, 0.9f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.4f, 0.7f, 0.95f, 1f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.2f, 0.42f, 0.64f, 1f);
			((Selectable)_verticalScrollbar).colors = colors;
			_scrollbarGo.SetActive(false);
		}

		private void BuildResizeGrip()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_006b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			_resizeGripGo = new GameObject("ResizeGrip", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(PanelResizeHandler)
			});
			_resizeGripGo.transform.SetParent((Transform)(object)_panelRect, false);
			RectTransform component = _resizeGripGo.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 0f);
			component.anchorMax = new Vector2(1f, 0f);
			component.pivot = new Vector2(1f, 0f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(16f, 16f);
			Image component2 = _resizeGripGo.GetComponent<Image>();
			((Graphic)component2).color = new Color(0f, 0f, 0f, 0.01f);
			((Graphic)component2).raycastTarget = true;
			Text obj = CreateText("GripIcon", component, 11, (FontStyle)1, (TextAnchor)8, new Color(0.55f, 0.82f, 1f, 0.85f));
			((Graphic)obj).rectTransform.anchorMin = Vector2.zero;
			((Graphic)obj).rectTransform.anchorMax = Vector2.one;
			((Graphic)obj).rectTransform.offsetMin = Vector2.zero;
			((Graphic)obj).rectTransform.offsetMax = new Vector2(-1f, 0f);
			obj.text = "◢";
			PanelResizeHandler component3 = _resizeGripGo.GetComponent<PanelResizeHandler>();
			component3.TargetRect = _panelRect;
			component3.OnResizeStarted = delegate
			{
				_isResizing = true;
			};
			component3.OnResizing = delegate(float newW, float newTotalH)
			{
				float num = newTotalH - 74f;
				if (num <= 10f)
				{
					if (!_panelCollapsed)
					{
						_panelCollapsed = true;
						_panelCollapseBtnText.text = "▶";
						if (_optionsMenuOpen)
						{
							_optionsMenuOpen = false;
							_optionsMenuGo.SetActive(false);
							_optionsBtnText.text = "Filter ▾";
						}
						if (_customPickerOpen && (Object)(object)_customPickerGo != (Object)null)
						{
							_customPickerOpen = false;
							_customPickerGo.SetActive(false);
						}
						_forceRefresh = true;
					}
				}
				else if (num <= 68f)
				{
					if (num >= 18f && _panelCollapsed)
					{
						_panelCollapsed = false;
						_panelCollapseBtnText.text = "▼";
						_forceRefresh = true;
					}
					if (!_panelCollapsed && (!_exportsCollapsed || !_importsCollapsed))
					{
						_exportsCollapsed = true;
						_importsCollapsed = true;
						_forceRefresh = true;
					}
					_config.PanelWidth.Value = newW;
					if (!_panelCollapsed)
					{
						ApplyCurrentLayoutSizes(newW, _config.PanelMaxHeight.Value);
					}
				}
				else
				{
					if (num >= 82f)
					{
						if (_panelCollapsed)
						{
							_panelCollapsed = false;
							_panelCollapseBtnText.text = "▼";
							_forceRefresh = true;
						}
						if (_exportsCollapsed && _importsCollapsed)
						{
							_exportsCollapsed = false;
							_importsCollapsed = false;
							_forceRefresh = true;
						}
					}
					_config.PanelWidth.Value = newW;
					float num2 = Mathf.Clamp(num, 82f, 950f);
					_config.PanelMaxHeight.Value = num2;
					ApplyCurrentLayoutSizes(newW, num2);
				}
			};
			component3.OnResizeFinished = delegate
			{
				_isResizing = false;
				float maxHeight = Mathf.Max(120f, _config.PanelMaxHeight.Value);
				_config.SavePanelSize(_config.PanelWidth.Value, maxHeight);
				_forceRefresh = true;
			};
		}

		private void ApplyCurrentLayoutSizes(float panelWidth, float maxScrollHeight)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			if (_panelCollapsed)
			{
				return;
			}
			bool flag = _exportsCollapsed && _importsCollapsed;
			float num = ((_isResizing && !flag) ? Mathf.Max(56f, maxScrollHeight) : Mathf.Min(maxScrollHeight, _activeContentHeight));
			bool flag2 = _activeContentHeight > num + 0.5f;
			if (_scrollbarGo.activeSelf != flag2)
			{
				_scrollbarGo.SetActive(flag2);
			}
			float num2 = (flag2 ? (-9f) : 0f);
			_scrollContentRect.sizeDelta = new Vector2(num2, _activeContentHeight);
			_scrollViewportRect.sizeDelta = new Vector2(0f, num);
			_panelRect.sizeDelta = new Vector2(panelWidth, 74f + num + 6f);
			float num3 = panelWidth + num2;
			for (int i = 0; i < _rowPool.Count; i++)
			{
				ItemRowView itemRowView = _rowPool[i];
				if (itemRowView.RootGo.activeSelf && (Object)(object)itemRowView.FillBarRect != (Object)null)
				{
					Rect rect = itemRowView.RootRect.rect;
					float num4;
					if (!(((Rect)(ref rect)).width > 10f))
					{
						num4 = 0f;
					}
					else
					{
						float x = itemRowView.FillBarRect.sizeDelta.x;
						rect = itemRowView.RootRect.rect;
						num4 = Mathf.Clamp01(x / ((Rect)(ref rect)).width);
					}
					float num5 = num4;
					itemRowView.FillBarRect.sizeDelta = new Vector2(num5 * num3, 0f);
				}
			}
		}

		private void BuildOptionsMenu()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: 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_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Expected O, but got Unknown
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Expected O, but got Unknown
			_optionsMenuGo = new GameObject("OptionsMenu", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Outline),
				typeof(PointerHoverTracker)
			});
			_optionsMenuGo.transform.SetParent((Transform)(object)_panelRect, false);
			_optionsMenuRect = _optionsMenuGo.GetComponent<RectTransform>();
			_optionsMenuRect.anchorMin = new Vector2(1f, 1f);
			_optionsMenuRect.anchorMax = new Vector2(1f, 1f);
			_optionsMenuRect.pivot = new Vector2(1f, 1f);
			_optionsMenuRect.anchoredPosition = new Vector2(-4f, -30f);
			_optionsMenuRect.sizeDelta = new Vector2(236f, 246f);
			_optionsHoverTracker = _optionsMenuGo.GetComponent<PointerHoverTracker>();
			Image component = _optionsMenuGo.GetComponent<Image>();
			((Graphic)component).color = new Color(0.06f, 0.1f, 0.16f, 0.98f);
			((Graphic)component).raycastTarget = true;
			Outline component2 = _optionsMenuGo.GetComponent<Outline>();
			((Shadow)component2).effectColor = new Color(0.32f, 0.68f, 0.95f, 0.65f);
			((Shadow)component2).effectDistance = new Vector2(1f, -1f);
			Text obj = CreateText("MenuTitle", _optionsMenuRect, 12, (FontStyle)1, (TextAnchor)3, new Color(0.92f, 0.97f, 1f, 1f));
			((Graphic)obj).rectTransform.anchorMin = new Vector2(0f, 1f);
			((Graphic)obj).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)obj).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)obj).rectTransform.anchoredPosition = new Vector2(10f, -8f);
			((Graphic)obj).rectTransform.sizeDelta = new Vector2(-20f, 18f);
			obj.text = "OPTIONS — ITEM FILTER";
			_optionsTargetLabel = CreateText("TargetScopeLabel", _optionsMenuRect, 10, (FontStyle)0, (TextAnchor)3, new Color(0.6f, 0.78f, 0.92f, 1f));
			((Graphic)_optionsTargetLabel).rectTransform.anchorMin = new Vector2(0f, 1f);
			((Graphic)_optionsTargetLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)_optionsTargetLabel).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)_optionsTargetLabel).rectTransform.anchoredPosition = new Vector2(10f, -26f);
			((Graphic)_optionsTargetLabel).rectTransform.sizeDelta = new Vector2(-20f, 16f);
			_optionsTargetLabel.text = "Saved for current Star / Planet";
			(EItemCategoryFilter, string)[] array = new(EItemCategoryFilter, string)[6]
			{
				(EItemCategoryFilter.RawResources, "Raw Resources (Ores, Gas)"),
				(EItemCategoryFilter.Materials, "Materials & Ingots"),
				(EItemCategoryFilter.Components, "Components & Parts"),
				(EItemCategoryFilter.Buildings, "Buildings & Structures"),
				(EItemCategoryFilter.ConsumablesAndPods, "Fuel, Warpers & Vessels"),
				(EItemCategoryFilter.Matrices, "Science Matrices")
			};
			float num = -48f;
			for (int i = 0; i < array.Length; i++)
			{
				EItemCategoryFilter item = array[i].Item1;
				FilterToggleRow item2 = CreateFilterToggleRow(_optionsMenuRect, item, array[i].Item2, num);
				_filterToggles.Add(item2);
				num -= 26f;
			}
			Text btnText;
			Button obj2 = CreateHeaderButton("BtnResetFilters", _optionsMenuRect, new Vector2(-150f, num - 6f), new Vector2(78f, 22f), anchorRight: true, out btnText);
			btnText.text = "Reset Filters";
			((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
			{
				_config.ResetFilterForAstro(_lastGalaxySeed, _lastTargetAstroId);
				RefreshOptionsMenuState();
				RefreshCustomPickerCells();
				_forceRefresh = true;
			});
			Text btnText2;
			Button obj3 = CreateHeaderButton("BtnCustom", _optionsMenuRect, new Vector2(-78f, num - 6f), new Vector2(66f, 22f), anchorRight: true, out btnText2);
			btnText2.text = "Custom";
			((UnityEvent)obj3.onClick).AddListener(new UnityAction(ToggleCustomItemPicker));
			Text btnText3;
			Button obj4 = CreateHeaderButton("BtnResetPos", _optionsMenuRect, new Vector2(-6f, num - 6f), new Vector2(66f, 22f), anchorRight: true, out btnText3);
			btnText3.text = "Reset UI";
			((UnityEvent)obj4.onClick).AddListener((UnityAction)delegate
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				_config.ResetPanelLayout();
				_panelRect.anchoredPosition = new Vector2(82f, -470f);
				PositionCustomPickerBesidePanel();
				_forceRefresh = true;
			});
			_optionsMenuGo.SetActive(false);
		}

		private void BuildCustomItemPicker()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Expected O, but got Unknown
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: 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_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Expected O, but got Unknown
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Expected O, but got Unknown
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_0856: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0991: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09da: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd6: Expected O, but got Unknown
			//IL_0bfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4e: Expected O, but got Unknown
			float num = 558f;
			float num2 = 318f;
			float num3 = num + 20f;
			float num4 = 68f + num2 + 10f;
			_customPickerGo = new GameObject("CustomItemPicker", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Outline),
				typeof(PointerHoverTracker)
			});
			_customPickerGo.transform.SetParent((Transform)(object)_panelRect, false);
			_customPickerRect = _customPickerGo.GetCom