Decompiled source of ParcelBoard v0.1.0

plugins/ParcelBoard.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Configuration;
using CatLib.Config;
using CatLib.Core;
using CatLib.DevTools;
using CatLib.Game;
using CatLib.Game.Events;
using CatLib.Localization;
using CatLib.Logging;
using CatLib.Net;
using CatLib.UI;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ParcelBoard.Logic;
using ParcelBoard.Scene;
using ParcelBoard.Settings;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CatLib contributors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+3d98633339100a90d3315e53ccadb1fe0c3a62b7")]
[assembly: AssemblyProduct("CatLib")]
[assembly: AssemblyTitle("ParcelBoard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ParcelBoard
{
	public sealed class ParcelBoardController
	{
		public const int RefreshFrames = 15;

		private readonly CatLogger _log;

		private readonly TextCatalog _texts;

		private readonly BoardView _view = new BoardView();

		private readonly HashSet<PackageSize> _seenSizes = new HashSet<PackageSize>();

		private readonly Dictionary<PackageSize, ParcelFootprint> _footprints = new Dictionary<PackageSize, ParcelFootprint>();

		private char? _times;

		private int _countdown;

		private bool _hidden;

		private bool? _open;

		private bool _logged;

		public BoardSettings Settings { get; set; }

		public BoardView View => _view;

		public bool IsOpen => _open ?? Settings.StartOpen.Value;

		public bool IsHidden => _hidden;

		public IReadOnlyList<BoardColumn> LastColumns { get; private set; } = Array.Empty<BoardColumn>();

		public ParcelBoardController(CatLogger log, TextCatalog texts)
		{
			_log = log;
			_texts = texts;
		}

		public void OnSettingsChanged()
		{
			_countdown = 0;
		}

		public void Forget()
		{
			_view.Forget();
			_seenSizes.Clear();
			_footprints.Clear();
			_times = null;
			_open = null;
			_logged = false;
			LastColumns = Array.Empty<BoardColumn>();
		}

		public void Update()
		{
			try
			{
				if (HudLayer.IsAvailable && CatParcels.IsAvailable)
				{
					HandleKeys();
					if (--_countdown <= 0)
					{
						_countdown = 15;
						Refresh();
					}
				}
			}
			catch (Exception ex)
			{
				_countdown = 300;
				_log.Error("Updating the parcel board failed", ex);
			}
		}

		public void Refresh()
		{
			//IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.Enabled.Value || _hidden)
			{
				_view.Hide();
				return;
			}
			List<ParcelInfo> list = CatParcels.Read();
			foreach (ParcelInfo item in list)
			{
				_seenSizes.Add(item.Size);
				ParcelFootprint footprint = item.Footprint;
				if (((ParcelFootprint)(ref footprint)).IsKnown && !_footprints.ContainsKey(item.Size))
				{
					_footprints[item.Size] = item.Footprint;
				}
			}
			BoardOptions boardOptions = Settings.Options();
			boardOptions.KnownSizes = _seenSizes;
			LastColumns = BoardCounter.Build(list, boardOptions);
			_view.Show(LastColumns, Look());
			if (!_logged && _view.IsAlive)
			{
				_logged = true;
				_log.Info($"Parcel board shown with {LastColumns.Count} list(s) for {list.Count} parcel(s)");
			}
		}

		public BoardLook Look()
		{
			return new BoardLook
			{
				Open = IsOpen,
				Corner = Settings.Corner.Value,
				Scale = Settings.Scale.Value,
				Opacity = Settings.Opacity.Value,
				RegionNames = Settings.RegionNames.Value,
				Order = Settings.Order.Value,
				Title = Title,
				SizeName = SizeName,
				SizeTag = SizeTag
			};
		}

		public string Title(BoardList list)
		{
			return _texts.Get("list." + list);
		}

		public unsafe string SizeName(PackageSize size)
		{
			return _texts.Get("size." + ((object)(*(PackageSize*)(&size))/*cast due to .constrained prefix*/).ToString());
		}

		public string SizeTag(PackageSize size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!_footprints.TryGetValue(size, out var value))
			{
				return string.Empty;
			}
			return ((ParcelFootprint)(ref value)).Text(Times());
		}

		private char Times()
		{
			if (!_times.HasValue)
			{
				TMP_FontAsset font = HudLayer.Font;
				try
				{
					_times = (((Object)(object)font == (Object)null || font.HasCharacter('×', true, true)) ? '×' : 'x');
				}
				catch (Exception)
				{
					_times = 'x';
				}
			}
			return _times.Value;
		}

		public void ToggleOpen()
		{
			_open = !IsOpen;
			_countdown = 0;
		}

		public void ToggleHidden()
		{
			_hidden = !_hidden;
			_countdown = 0;
		}

		public string Describe()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			List<ParcelInfo> list = CatParcels.Read();
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder3 = stringBuilder2;
			StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(26, 3, stringBuilder2);
			handler.AppendFormatted(list.Count);
			handler.AppendLiteral(" parcel(s), board ");
			handler.AppendFormatted(IsHidden ? "hidden" : "shown");
			handler.AppendLiteral(", lists ");
			handler.AppendFormatted(IsOpen ? "open" : "closed");
			stringBuilder3.Append(ref handler);
			foreach (IGrouping<ParcelPlace, ParcelInfo> item in from parcel in list
				group parcel by parcel.Place into @group
				orderby @group.Key
				select @group)
			{
				stringBuilder2 = stringBuilder;
				StringBuilder stringBuilder4 = stringBuilder2;
				handler = new StringBuilder.AppendInterpolatedStringHandler(4, 2, stringBuilder2);
				handler.AppendLiteral("; ");
				handler.AppendFormatted<ParcelPlace>(item.Key);
				handler.AppendLiteral(": ");
				handler.AppendFormatted(item.Count());
				stringBuilder4.Append(ref handler);
			}
			_log.Info(stringBuilder.ToString());
			foreach (ParcelInfo item2 in list)
			{
				CatLogger log = _log;
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(44, 10);
				defaultInterpolatedStringHandler.AppendLiteral("Parcel ");
				defaultInterpolatedStringHandler.AppendFormatted(item2.NetworkId);
				defaultInterpolatedStringHandler.AppendLiteral(": ");
				defaultInterpolatedStringHandler.AppendFormatted<ParcelRegion>(item2.Region);
				defaultInterpolatedStringHandler.AppendLiteral(", ");
				defaultInterpolatedStringHandler.AppendFormatted<PackageSize>(item2.Size);
				defaultInterpolatedStringHandler.AppendLiteral(" ");
				ParcelFootprint footprint = item2.Footprint;
				defaultInterpolatedStringHandler.AppendFormatted(((ParcelFootprint)(ref footprint)).Text('x'));
				defaultInterpolatedStringHandler.AppendLiteral(", weight ");
				defaultInterpolatedStringHandler.AppendFormatted<ParcelWeightClass>(item2.Weight);
				defaultInterpolatedStringHandler.AppendLiteral(", storage ");
				defaultInterpolatedStringHandler.AppendFormatted<StorageConstraint>(item2.Storage);
				defaultInterpolatedStringHandler.AppendLiteral(", behavior ");
				defaultInterpolatedStringHandler.AppendFormatted<BehaviorConstraint>(item2.Behavior);
				defaultInterpolatedStringHandler.AppendFormatted(item2.IsDamaged ? ", damaged" : string.Empty);
				defaultInterpolatedStringHandler.AppendFormatted(item2.NeedsStamps ? (", missing stamps: " + ((object)item2.MissingStamps/*cast due to .constrained prefix*/).ToString()) : string.Empty);
				defaultInterpolatedStringHandler.AppendLiteral(", ");
				defaultInterpolatedStringHandler.AppendFormatted<ParcelPlace>(item2.Place);
				log.Info(defaultInterpolatedStringHandler.ToStringAndClear());
			}
			foreach (BoardColumn item3 in BoardCounter.Build(list, Settings.Options()))
			{
				_log.Info($"List {item3.List}: {item3.Total} — {string.Join(", ", item3.Rows.Select((BoardRow row) => (row.IsSize ? ((object)row.Size/*cast due to .constrained prefix*/).ToString() : ((object)row.Region/*cast due to .constrained prefix*/).ToString()) + " " + row.Count))}");
			}
			return "see the log";
		}

		public string MeasureSizes()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			if (!CatParcels.IsAvailable)
			{
				return "no parcels here";
			}
			List<EntityParcel> allParcels = Singleton<ParcelManager>.Instance.GetAllParcels();
			Dictionary<PackageSize, int> measured = new Dictionary<PackageSize, int>();
			List<string> list = new List<string>();
			int num = 0;
			while (allParcels != null && num < allParcels.Count)
			{
				EntityParcel val = allParcels[num];
				EntityProperties val2 = (((Object)(object)val == (Object)null || ((Entity)val).IsDisposed) ? null : ((Entity)val).Properties);
				if (!((Object)(object)val2 == (Object)null))
				{
					PackageSize packageSize = val2.PackageSize;
					measured[packageSize] = ((!measured.TryGetValue(packageSize, out var value)) ? 1 : (value + 1));
					if (measured[packageSize] <= 1)
					{
						EntityInteractablePickable val3 = (((Object)(object)((Entity)val).Interactable == (Object)null) ? null : ((Entity)val).Interactable.Pickable);
						Vector2Int val4 = (Vector2Int)(((Object)(object)val3 == (Object)null) ? default(Vector2Int) : val3.Size);
						BoxCollider val5 = (((Object)(object)val3 == (Object)null) ? null : val3.MainCollider);
						Vector3 val6 = (((Object)(object)val5 == (Object)null) ? Vector3.zero : Vector3.Scale(val5.size, ((Component)val5).transform.lossyScale));
						list.Add(string.Format(CultureInfo.InvariantCulture, "Size {0}: footprint {1}x{2} cells, box {3:0.###} x {4:0.###} x {5:0.###} m (width x height x depth), prefab {6}", packageSize, ((Vector2Int)(ref val4)).x, ((Vector2Int)(ref val4)).y, val6.x, val6.y, val6.z, ((Object)val).name));
					}
				}
				num++;
			}
			foreach (string item in list.OrderBy<string, string>((string line) => line, StringComparer.Ordinal))
			{
				_log.Info(item);
			}
			List<PackageSize> list2 = BoardCounter.SizeOrder.Where((PackageSize size) => !measured.ContainsKey(size)).ToList();
			_log.Info($"Measured {list.Count} size(s) from {measured.Values.Sum()} parcel(s){((list2.Count == 0) ? string.Empty : ("; not in this level: " + string.Join(", ", list2)))}");
			return "see the log";
		}

		private void HandleKeys()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!HudLayer.IsGameMenuOpen)
			{
				KeyboardShortcut value = Settings.ShowKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleHidden();
				}
				value = Settings.OpenKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleOpen();
				}
			}
		}
	}
	[BepInPlugin("catlib.parcelboard", "Parcel Board", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class ParcelBoardPlugin : BasePlugin
	{
		public const string LanguageResourcePrefix = "ParcelBoard.Lang.";

		private ParcelBoardController _controller;

		public static ParcelBoardController Controller { get; private set; }

		public override void Load()
		{
			CatLogger val = CatLogger.From(((BasePlugin)this).Log);
			CatSettings val2 = CatSettings.For((BasePlugin)(object)this);
			int count = val2.Texts.Count;
			CatNetwork.Declare((BasePlugin)(object)this, (SessionPolicy)3, (VersionRule)2);
			_controller = new ParcelBoardController(val, val2.Texts);
			_controller.Settings = new BoardSettings(val2, _controller.OnSettingsChanged);
			Controller = _controller;
			FrameLoop.Update += _controller.Update;
			BootstrapEvents.LevelLoadStarted += _controller.Forget;
			BootstrapEvents.GameRestartStarted += _controller.Forget;
			BootstrapEvents.MainMenuLoaded += _controller.Forget;
			DevMenu.Command("Parcel Board", "Parcels in the log", (Func<string>)_controller.Describe, "Writes every parcel of the level with its destination, marks, missing stamps, size and place, and the counts of every list.");
			DevMenu.Command("Parcel Board", "Parcel sizes in the log", (Func<string>)_controller.MeasureSizes, "Writes the shelf footprint in cells and the box size of one parcel of every size in the level, for drawing the size icons.");
			val.Info($"Parcel Board {"0.1.0"} loaded with {count} translated text(s) in {string.Join(", ", val2.Texts.Languages)}");
		}
	}
	public static class PluginMeta
	{
		public const string Guid = "catlib.parcelboard";

		public const string Name = "Parcel Board";

		public const string Version = "0.1.0";
	}
}
namespace ParcelBoard.Settings
{
	public sealed class BoardSettings
	{
		private readonly Dictionary<BoardList, Setting<ListVisibility>> _lists = new Dictionary<BoardList, Setting<ListVisibility>>();

		public Setting<bool> Enabled { get; }

		public Setting<KeyboardShortcut> ShowKey { get; }

		public Setting<KeyboardShortcut> OpenKey { get; }

		public Setting<bool> StartOpen { get; }

		public Setting<BoardCorner> Corner { get; }

		public Setting<float> Scale { get; }

		public Setting<float> Opacity { get; }

		public Setting<bool> RegionNames { get; }

		public Setting<RegionOrder> Order { get; }

		public Setting<bool> HideEmptyRows { get; }

		public Setting<CountScope> Scope { get; }

		public BoardSettings(CatSettings settings, Action changed)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			Enabled = settings.Local<bool>("Board", "Enabled", true, "Shows the parcel board in a level. The key below hides and shows it too.", (AcceptableValueBase)null);
			ShowKey = settings.Local<KeyboardShortcut>("Board", "ShowKey", new KeyboardShortcut((KeyCode)112, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Hides or shows the whole board.", (AcceptableValueBase)null);
			OpenKey = settings.Local<KeyboardShortcut>("Board", "OpenKey", new KeyboardShortcut((KeyCode)111, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Opens or closes the lists: closed, only the totals show; open, every destination with its count.", (AcceptableValueBase)null);
			StartOpen = settings.Local<bool>("Board", "StartOpen", false, "The lists are open when a level starts.", (AcceptableValueBase)null);
			Corner = settings.Local<BoardCorner>("Board", "Corner", BoardCorner.TopLeft, "The corner of the screen for the board.", (AcceptableValueBase)null);
			Scale = settings.Local<float>("Board", "Scale", 0.9f, "Size of the board.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.6f));
			Opacity = settings.Local<float>("Board", "Opacity", 0.15f, "How solid the background of the lists is: 0 is fully clear, 1 is solid.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f));
			RegionNames = settings.Local<bool>("Board", "RegionNames", false, "Writes the name of a destination next to its icon.", (AcceptableValueBase)null);
			Order = settings.Local<RegionOrder>("Board", "Order", RegionOrder.ByCount, "Order of the destinations in an open list: the most parcels first, or the game's order. Cat's Island always comes first.", (AcceptableValueBase)null);
			HideEmptyRows = settings.Local<bool>("Board", "HideEmptyRows", true, "Leaves out destinations and sizes with no parcels; they come back as soon as there is one.", (AcceptableValueBase)null);
			Scope = settings.Local<CountScope>("Board", "Scope", CountScope.Everything, "Which parcels are counted: everything in the level, or without the parcels on the boat and at customers.", (AcceptableValueBase)null);
			foreach (BoardList item in BoardCounter.DefaultOrder)
			{
				Setting<ListVisibility> val = settings.Local<ListVisibility>("Lists", item.ToString(), (item != BoardList.All) ? ListVisibility.WhenNotEmpty : ListVisibility.Always, Describe(item), (AcceptableValueBase)null);
				_lists[item] = val;
				val.Changed += delegate
				{
					changed();
				};
			}
			Enabled.Changed += delegate
			{
				changed();
			};
			Corner.Changed += delegate
			{
				changed();
			};
			Scale.Changed += delegate
			{
				changed();
			};
			Opacity.Changed += delegate
			{
				changed();
			};
			RegionNames.Changed += delegate
			{
				changed();
			};
			Order.Changed += delegate
			{
				changed();
			};
			HideEmptyRows.Changed += delegate
			{
				changed();
			};
			Scope.Changed += delegate
			{
				changed();
			};
		}

		public ListVisibility Visibility(BoardList list)
		{
			if (!_lists.TryGetValue(list, out var value))
			{
				return ListVisibility.WhenNotEmpty;
			}
			return value.Value;
		}

		public BoardOptions Options()
		{
			return new BoardOptions
			{
				Visibility = Visibility,
				HideEmptyRows = HideEmptyRows.Value,
				Order = Order.Value,
				Scope = Scope.Value
			};
		}

		private static string Describe(BoardList list)
		{
			return list switch
			{
				BoardList.All => "Every parcel, by destination.", 
				BoardList.NeedsStamps => "Parcels for other places that still miss a stamp: destination, weight or a mark.", 
				BoardList.Damaged => "Damaged parcels, by destination.", 
				BoardList.Sizes => "Every parcel, by size instead of destination.", 
				_ => "Parcels with this mark, by destination.", 
			};
		}
	}
}
namespace ParcelBoard.Scene
{
	public sealed class BoardLook
	{
		public bool Open { get; set; }

		public BoardCorner Corner { get; set; }

		public float Scale { get; set; } = 0.9f;

		public float Opacity { get; set; } = 0.15f;

		public bool RegionNames { get; set; }

		public RegionOrder Order { get; set; }

		public Func<BoardList, string> Title { get; set; } = (BoardList list) => list.ToString();

		public unsafe Func<PackageSize, string> SizeName { get; set; } = (PackageSize size) => ((object)(*(PackageSize*)(&size))/*cast due to .constrained prefix*/).ToString();

		public Func<PackageSize, string> SizeTag { get; set; } = (PackageSize _) => string.Empty;
	}
	public sealed class BoardView
	{
		public const string RootName = "ParcelBoard_Board";

		public const string IconPrefix = "ParcelBoard.Icons.";

		public const float Margin = 24f;

		public const float TableGap = 8f;

		private GameObject _root;

		private RectTransform _rect;

		private IntPtr _hudPointer;

		private CountTable _main;

		private CountTable _sizes;

		public static readonly string[] OwnListIcons = new string[5] { "all.png", "damaged.png", "stamps.png", "corrupted.png", "nocontact.png" };

		public bool IsAlive
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return !((Il2CppObjectBase)_root).WasCollected;
				}
				return false;
			}
		}

		public RectTransform Rect
		{
			get
			{
				if (!IsAlive)
				{
					return null;
				}
				return _rect;
			}
		}

		public CountTable Main
		{
			get
			{
				if (_main == null || !_main.IsAlive)
				{
					return null;
				}
				return _main;
			}
		}

		public CountTable Sizes
		{
			get
			{
				if (_sizes == null || !_sizes.IsAlive)
				{
					return null;
				}
				return _sizes;
			}
		}

		public void Show(IReadOnlyList<BoardColumn> columns, BoardLook look)
		{
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: 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_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform root = HudLayer.Root;
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			if (!IsAlive || ((Il2CppObjectBase)root).Pointer != _hudPointer)
			{
				Create(root);
			}
			if (!_root.activeSelf)
			{
				_root.SetActive(true);
			}
			bool flag = look.Corner == BoardCorner.BottomLeft || look.Corner == BoardCorner.BottomRight;
			bool flag2 = look.Corner == BoardCorner.TopRight || look.Corner == BoardCorner.BottomRight;
			BoardTableModel boardTableModel = BoardTable.Build(columns, look.Order);
			List<CountTable> list = new List<CountTable>();
			CountTableContent val = ((boardTableModel.Columns.Count > 0) ? MainContent(boardTableModel, look) : null);
			int lines = ((val != null) ? boardTableModel.Lines.Count : 0);
			CountTableContent val2 = ((boardTableModel.Sizes != null) ? SizesContent(boardTableModel.Sizes, look, BoardTable.SizeRowsPerBlock(boardTableModel.Sizes.Rows.Count, lines)) : null);
			if (val != null)
			{
				_main = Ensure(_main, "ParcelBoard_Table", look);
			}
			else
			{
				CountTable main = _main;
				if (main != null)
				{
					main.Destroy();
				}
				_main = null;
			}
			if (val2 != null)
			{
				_sizes = Ensure(_sizes, "ParcelBoard_Sizes", look);
			}
			else
			{
				CountTable sizes = _sizes;
				if (sizes != null)
				{
					sizes.Destroy();
				}
				_sizes = null;
			}
			float num = Mathf.Max((_main == null) ? 0f : _main.HeightOf(val), (_sizes == null) ? 0f : _sizes.HeightOf(val2));
			if (_main != null)
			{
				_main.Show(val, flag, num);
				list.Add(_main);
			}
			if (_sizes != null)
			{
				_sizes.Show(val2, flag, num);
				list.Add(_sizes);
			}
			if (flag2)
			{
				list.Reverse();
			}
			float num2 = 0f;
			num = 0f;
			foreach (CountTable item in list)
			{
				RectTransform rect = item.Rect;
				rect.anchorMin = new Vector2(0f, flag ? 0f : 1f);
				rect.anchorMax = rect.anchorMin;
				rect.pivot = rect.anchorMin;
				rect.anchoredPosition = new Vector2(num2, 0f);
				num2 += item.Size.x + 8f * look.Scale;
				num = Mathf.Max(num, item.Size.y);
			}
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(flag2 ? 1f : 0f, flag ? 0f : 1f);
			_rect.anchorMin = val3;
			_rect.anchorMax = val3;
			_rect.pivot = val3;
			_rect.sizeDelta = new Vector2(Mathf.Max(0f, num2 - 8f * look.Scale), num);
			_rect.anchoredPosition = new Vector2(flag2 ? (-24f) : 24f, flag ? 24f : (-24f));
		}

		public void Hide()
		{
			if (IsAlive && _root.activeSelf)
			{
				_root.SetActive(false);
			}
		}

		public void Forget()
		{
			if (IsAlive)
			{
				Object.Destroy((Object)(object)_root);
			}
			_root = null;
			_main = null;
			_sizes = null;
		}

		public static CountTableContent MainContent(BoardTableModel model, BoardLook look)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			List<TableColumn> list = ((IEnumerable<BoardColumn>)model.Columns).Select((Func<BoardColumn, TableColumn>)delegate(BoardColumn column)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected O, but got Unknown
				Sprite obj = ListIcon(column.List);
				return new TableColumn(obj, ((Object)(object)obj == (Object)null) ? look.Title(column.List) : string.Empty, Number(column.Total), column.Total == 0);
			}).ToList();
			List<TableRow> list2 = ((IEnumerable<TableLine>)model.Lines).Select((Func<TableLine, TableRow>)delegate(TableLine line)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				Sprite obj = CatParcels.RegionIcon(line.Region);
				string text = (((Object)(object)obj == (Object)null || look.RegionNames) ? CatParcels.RegionName(line.Region) : string.Empty);
				return new TableRow(obj, text, (IReadOnlyList<string>)line.Counts.Select((int count) => (count != 0) ? Number(count) : string.Empty).ToList(), line.Separated, false);
			}).ToList();
			return new CountTableContent((IReadOnlyList<TableColumn>)list, (IReadOnlyList<TableRow>)list2, look.Open, 0);
		}

		public static CountTableContent SizesContent(BoardColumn sizes, BoardLook look, int rowsPerBlock = 0)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			Sprite val = SizesIcon();
			TableColumn[] obj = new TableColumn[1]
			{
				new TableColumn(val, ((Object)(object)val == (Object)null) ? look.Title(BoardList.Sizes) : string.Empty, Number(sizes.Total), sizes.Total == 0)
			};
			List<TableRow> list = ((IEnumerable<BoardRow>)sizes.Rows).Select((Func<BoardRow, TableRow>)delegate(BoardRow row)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: 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_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Expected O, but got Unknown
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				Sprite val2 = SizeIcon(row.Size);
				string text = look.SizeTag(row.Size) ?? string.Empty;
				string[] array = new string[1] { (row.Count == 0) ? string.Empty : Number(row.Count) };
				return ((Object)(object)val2 == (Object)null) ? new TableRow((Sprite)null, look.SizeName(row.Size), (IReadOnlyList<string>)array, false, false) : new TableRow(val2, text, (IReadOnlyList<string>)array, false, true);
			}).ToList();
			return new CountTableContent((IReadOnlyList<TableColumn>)(object)obj, (IReadOnlyList<TableRow>)list, look.Open, rowsPerBlock);
		}

		public static Sprite SizesIcon()
		{
			return UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons.sizes.png");
		}

		public unsafe static Sprite SizeIcon(PackageSize size)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if ((int)size != 0)
			{
				return UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons.size_" + ((object)(*(PackageSize*)(&size))/*cast due to .constrained prefix*/).ToString() + ".png");
			}
			return null;
		}

		public static Sprite ListIcon(BoardList list)
		{
			return (Sprite)(list switch
			{
				BoardList.All => UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons.all.png"), 
				BoardList.Damaged => UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons.damaged.png"), 
				BoardList.NeedsStamps => UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons.stamps.png"), 
				BoardList.Heavy => CatParcels.ConstraintIcon((BehaviorConstraint)2), 
				BoardList.Fragile => CatParcels.ConstraintIcon((BehaviorConstraint)1), 
				BoardList.ContactForbidden => GameOrOwn(CatParcels.ConstraintIcon((BehaviorConstraint)4), "nocontact.png"), 
				BoardList.Lover => CatParcels.ConstraintIcon((BehaviorConstraint)8), 
				BoardList.Corrupted => GameOrOwn(CatParcels.ConstraintIcon((BehaviorConstraint)16), "corrupted.png"), 
				BoardList.Dark => CatParcels.ConstraintIcon((StorageConstraint)8), 
				BoardList.Frozen => CatParcels.ConstraintIcon((StorageConstraint)1), 
				BoardList.Hot => CatParcels.ConstraintIcon((StorageConstraint)4), 
				BoardList.Cold => CatParcels.ConstraintIcon((StorageConstraint)2), 
				BoardList.Bright => CatParcels.ConstraintIcon((StorageConstraint)16), 
				_ => null, 
			});
		}

		private static Sprite GameOrOwn(Sprite game, string file)
		{
			if (!((Object)(object)game != (Object)null))
			{
				return UiSprites.FromResource(typeof(BoardView).Assembly, "ParcelBoard.Icons." + file);
			}
			return game;
		}

		private static string Number(int value)
		{
			return value.ToString(CultureInfo.InvariantCulture);
		}

		private CountTable Ensure(CountTable table, string name, BoardLook look)
		{
			if (table == null || !table.IsAlive)
			{
				table = CountTable.Create((Transform)(object)_rect, name, (CountListStyle)null);
			}
			table.Style.Scale = look.Scale;
			if (Math.Abs(table.Style.PlateAlpha - look.Opacity) > 0.001f)
			{
				table.Style.PlateAlpha = look.Opacity;
				table.ApplyPlate();
			}
			return table;
		}

		private void Create(RectTransform hud)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Forget();
			_hudPointer = ((Il2CppObjectBase)hud).Pointer;
			_root = new GameObject("ParcelBoard_Board");
			_root.layer = ((Component)hud).gameObject.layer;
			_rect = _root.AddComponent<RectTransform>();
			((Transform)_rect).SetParent((Transform)(object)hud, false);
		}
	}
}
namespace ParcelBoard.Logic
{
	public sealed record BoardRow(ParcelRegion Region, PackageSize Size, int Count, bool Separated)
	{
		public bool IsSize => (int)Region == 0;

		[CompilerGenerated]
		public void Deconstruct(out ParcelRegion Region, out PackageSize Size, out int Count, out bool Separated)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected I4, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected I4, but got Unknown
			Region = (ParcelRegion)(int)this.Region;
			Size = (PackageSize)(int)this.Size;
			Count = this.Count;
			Separated = this.Separated;
		}
	}
	public sealed record BoardColumn(BoardList List, int Total, IReadOnlyList<BoardRow> Rows);
	public sealed class BoardOptions
	{
		public IReadOnlyList<BoardList> Lists { get; set; } = BoardCounter.DefaultOrder;

		public Func<BoardList, ListVisibility> Visibility { get; set; } = (BoardList _) => ListVisibility.Always;

		public bool HideEmptyRows { get; set; } = true;

		public RegionOrder Order { get; set; }

		public CountScope Scope { get; set; }

		public IReadOnlyCollection<ParcelRegion> KnownRegions { get; set; } = (IReadOnlyCollection<ParcelRegion>)(object)CatParcels.Regions.ToArray();

		public IReadOnlyCollection<PackageSize> KnownSizes { get; set; } = (IReadOnlyCollection<PackageSize>)(object)Array.Empty<PackageSize>();
	}
	public static class BoardCounter
	{
		public static readonly IReadOnlyList<BoardList> DefaultOrder = (BoardList[])Enum.GetValues(typeof(BoardList));

		public static readonly IReadOnlyList<PackageSize> SizeOrder;

		public static bool Matches(BoardList list, ParcelInfo parcel)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			return list switch
			{
				BoardList.All => true, 
				BoardList.Heavy => parcel.Has((BehaviorConstraint)2), 
				BoardList.Fragile => parcel.Has((BehaviorConstraint)1), 
				BoardList.ContactForbidden => parcel.Has((BehaviorConstraint)4), 
				BoardList.Lover => parcel.Has((BehaviorConstraint)8), 
				BoardList.Corrupted => parcel.Has((BehaviorConstraint)16), 
				BoardList.Dark => parcel.Has((StorageConstraint)8), 
				BoardList.Frozen => parcel.Has((StorageConstraint)1), 
				BoardList.Hot => parcel.Has((StorageConstraint)4), 
				BoardList.Cold => parcel.Has((StorageConstraint)2), 
				BoardList.Bright => parcel.Has((StorageConstraint)16), 
				BoardList.Damaged => parcel.IsDamaged, 
				BoardList.NeedsStamps => parcel.NeedsStamps, 
				BoardList.Sizes => (int)parcel.Size > 0, 
				_ => false, 
			};
		}

		public static bool Counted(ParcelInfo parcel, CountScope scope)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			if (scope != CountScope.Everything)
			{
				if ((int)parcel.Place != 3)
				{
					return (int)parcel.Place != 4;
				}
				return false;
			}
			return true;
		}

		public static IReadOnlyList<BoardColumn> Build(IEnumerable<ParcelInfo> parcels, BoardOptions options)
		{
			List<ParcelInfo> source = (parcels ?? Enumerable.Empty<ParcelInfo>()).Where((ParcelInfo parcel) => parcel != (ParcelInfo)null && Counted(parcel, options.Scope)).ToList();
			List<BoardColumn> list = new List<BoardColumn>();
			foreach (BoardList list2 in options.Lists)
			{
				ListVisibility listVisibility = options.Visibility(list2);
				if (listVisibility != ListVisibility.Never)
				{
					List<ParcelInfo> list3 = source.Where((ParcelInfo parcel) => Matches(list2, parcel)).ToList();
					if (list3.Count != 0 || listVisibility != ListVisibility.WhenNotEmpty)
					{
						IReadOnlyList<BoardRow> rows = ((list2 == BoardList.Sizes) ? SizeRows(list3, options) : RegionRows(list3, options));
						list.Add(new BoardColumn(list2, list3.Count, rows));
					}
				}
			}
			return list;
		}

		public static IReadOnlyList<BoardRow> RegionRows(IReadOnlyCollection<ParcelInfo> parcels, BoardOptions options)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ParcelRegion, int> counts = (from parcel in parcels
				group parcel by parcel.Region).ToDictionary((IGrouping<ParcelRegion, ParcelInfo> group) => group.Key, (IGrouping<ParcelRegion, ParcelInfo> group) => group.Count());
			HashSet<ParcelRegion> hashSet = new HashSet<ParcelRegion>(counts.Keys.Where((ParcelRegion region) => (int)region > 0));
			if (!options.HideEmptyRows)
			{
				hashSet.UnionWith(options.KnownRegions.Where((ParcelRegion region) => (int)region > 0));
			}
			List<BoardRow> list = new List<BoardRow>();
			if (hashSet.Remove((ParcelRegion)1))
			{
				list.Add(new BoardRow((ParcelRegion)1, (PackageSize)0, Count(counts, (ParcelRegion)1), Separated: false));
			}
			List<ParcelRegion> list2 = Ordered(hashSet, (ParcelRegion region) => Count(counts, region), (ParcelRegion region) => IndexOf(CatParcels.Regions, region), options.Order);
			for (int num = 0; num < list2.Count; num++)
			{
				list.Add(new BoardRow(list2[num], (PackageSize)0, Count(counts, list2[num]), num == 0 && list.Count > 0));
			}
			return list;
		}

		public static IReadOnlyList<BoardRow> SizeRows(IReadOnlyCollection<ParcelInfo> parcels, BoardOptions options)
		{
			Dictionary<PackageSize, int> counts = (from parcel in parcels
				group parcel by parcel.Size).ToDictionary((IGrouping<PackageSize, ParcelInfo> group) => group.Key, (IGrouping<PackageSize, ParcelInfo> group) => group.Count());
			HashSet<PackageSize> hashSet = new HashSet<PackageSize>(counts.Keys.Where((PackageSize size) => (int)size > 0));
			if (!options.HideEmptyRows)
			{
				hashSet.UnionWith(options.KnownSizes.Where((PackageSize size) => (int)size > 0));
			}
			return (from size in Ordered(hashSet, (PackageSize size) => Count(counts, size), (PackageSize size) => IndexOf(SizeOrder, size), options.Order)
				select new BoardRow((ParcelRegion)0, size, Count(counts, size), Separated: false)).ToList();
		}

		private static List<T> Ordered<T>(IEnumerable<T> items, Func<T, int> count, Func<T, int> gameIndex, RegionOrder order)
		{
			if (order != RegionOrder.ByCount)
			{
				return items.OrderBy(gameIndex).ToList();
			}
			return items.OrderByDescending(count).ThenBy(gameIndex).ToList();
		}

		private static int Count<T>(Dictionary<T, int> counts, T key)
		{
			if (!counts.TryGetValue(key, out var value))
			{
				return 0;
			}
			return value;
		}

		private static int IndexOf<T>(IReadOnlyList<T> list, T item)
		{
			for (int i = 0; i < list.Count; i++)
			{
				if (EqualityComparer<T>.Default.Equals(list[i], item))
				{
					return i;
				}
			}
			return int.MaxValue;
		}

		static BoardCounter()
		{
			PackageSize[] array = new PackageSize[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			SizeOrder = (IReadOnlyList<PackageSize>)(object)array;
		}
	}
	public enum BoardList
	{
		All,
		Heavy,
		Fragile,
		Dark,
		Frozen,
		Hot,
		Cold,
		Bright,
		ContactForbidden,
		Lover,
		Corrupted,
		Damaged,
		NeedsStamps,
		Sizes
	}
	public enum ListVisibility
	{
		Always,
		WhenNotEmpty,
		Never
	}
	public enum RegionOrder
	{
		ByCount,
		GameOrder
	}
	public enum BoardCorner
	{
		TopLeft,
		TopRight,
		BottomLeft,
		BottomRight
	}
	public enum CountScope
	{
		Everything,
		WithoutBoatAndCustomers
	}
	public sealed record TableLine(ParcelRegion Region, IReadOnlyList<int> Counts, bool Separated)
	{
		[CompilerGenerated]
		public void Deconstruct(out ParcelRegion Region, out IReadOnlyList<int> Counts, out bool Separated)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected I4, but got Unknown
			Region = (ParcelRegion)(int)this.Region;
			Counts = this.Counts;
			Separated = this.Separated;
		}
	}
	public sealed record BoardTableModel(IReadOnlyList<BoardColumn> Columns, IReadOnlyList<TableLine> Lines, BoardColumn Sizes);
	public static class BoardTable
	{
		public const int MinSizeRows = 4;

		public static int SizeRowsPerBlock(int sizes, int lines)
		{
			if (sizes <= 0 || lines <= 0)
			{
				return 0;
			}
			int num = Math.Max(lines, 4);
			if (sizes <= num)
			{
				return 0;
			}
			int num2 = (sizes + num - 1) / num;
			return (sizes + num2 - 1) / num2;
		}

		public static BoardTableModel Build(IReadOnlyList<BoardColumn> columns, RegionOrder order)
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			List<BoardColumn> list = columns.Where((BoardColumn column) => column.List != BoardList.Sizes).ToList();
			BoardColumn sizes = columns.FirstOrDefault((BoardColumn column) => column.List == BoardList.Sizes);
			List<Dictionary<ParcelRegion, int>> counts = list.Select((BoardColumn column) => column.Rows.ToDictionary((BoardRow row) => row.Region, (BoardRow row) => row.Count)).ToList();
			HashSet<ParcelRegion> hashSet = new HashSet<ParcelRegion>(from row in list.SelectMany((BoardColumn column) => column.Rows)
				select row.Region);
			int all = list.FindIndex((BoardColumn column) => column.List == BoardList.All);
			List<TableLine> list2 = new List<TableLine>();
			if (hashSet.Remove((ParcelRegion)1))
			{
				list2.Add(Line((ParcelRegion)1, counts, separated: false));
			}
			List<ParcelRegion> list3 = ((order == RegionOrder.ByCount) ? hashSet.OrderByDescending(Weight).ThenBy(GameIndex).ToList() : hashSet.OrderBy(GameIndex).ToList());
			for (int num = 0; num < list3.Count; num++)
			{
				list2.Add(Line(list3[num], counts, num == 0 && list2.Count > 0));
			}
			return new BoardTableModel(list, list2, sizes);
			int Weight(ParcelRegion region)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				if (all < 0)
				{
					return counts.Sum((Dictionary<ParcelRegion, int> map) => Count(map, region));
				}
				return Count(counts[all], region);
			}
		}

		private static TableLine Line(ParcelRegion region, List<Dictionary<ParcelRegion, int>> counts, bool separated)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return new TableLine(region, counts.Select((Dictionary<ParcelRegion, int> map) => Count(map, region)).ToList(), separated);
		}

		private static int Count(Dictionary<ParcelRegion, int> counts, ParcelRegion region)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!counts.TryGetValue(region, out var value))
			{
				return 0;
			}
			return value;
		}

		private static int GameIndex(ParcelRegion region)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < CatParcels.Regions.Count; i++)
			{
				if (CatParcels.Regions[i] == region)
				{
					return i;
				}
			}
			return int.MaxValue;
		}
	}
}