Decompiled source of PinABuildCost v0.1.0

plugins/PinABuildCost.dll

Decompiled 37 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using HarmonyLib;
using SuperFantasyKingdom;
using SuperFantasyKingdom.Buildings;
using SuperFantasyKingdom.Clickable;
using SuperFantasyKingdom.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("PinChecks")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PinABuildCost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+6f797cf28c688780b8722735eb51c0d199e642d9")]
[assembly: AssemblyProduct("PinABuildCost")]
[assembly: AssemblyTitle("PinABuildCost")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace PinABuildCost;

[HarmonyPatch(typeof(UIOverlayBuildingSelection), "AddBuildingButtons")]
internal static class BuildCards
{
	internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Expected O, but got Unknown
		List<CodeInstruction> list = instructions.ToList();
		MethodInfo draw = AccessTools.Method(typeof(UIOverlayBuildingSelection), "DisplayCosts", (Type[])null, (Type[])null);
		MethodInfo canBuild = AccessTools.Method(typeof(BuildingCity), "CanBeBuilt", (Type[])null, (Type[])null);
		int num = list.FindIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, draw));
		int num2 = list.FindIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, canBuild));
		if (num < 2 || num2 <= num || !LoadsLocal(list[num - 2].opcode) || list.Count((CodeInstruction i) => CodeInstructionExtensions.Calls(i, draw)) != 1 || list.Count((CodeInstruction i) => CodeInstructionExtensions.Calls(i, canBuild)) != 1)
		{
			return PinPlugin.UnsupportedLayout(list, "construction");
		}
		list.InsertRange(num2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[4]
		{
			new CodeInstruction(OpCodes.Dup, (object)null),
			new CodeInstruction(list[num - 2].opcode, list[num - 2].operand),
			new CodeInstruction(OpCodes.Ldarg_2, (object)null),
			CodeInstruction.Call(typeof(BuildCards), "Attach", (Type[])null, (Type[])null)
		});
		return list;
	}

	internal static bool LoadsLocal(OpCode op)
	{
		if (!(op == OpCodes.Ldloc) && !(op == OpCodes.Ldloc_S) && !(op == OpCodes.Ldloc_0) && !(op == OpCodes.Ldloc_1) && !(op == OpCodes.Ldloc_2))
		{
			return op == OpCodes.Ldloc_3;
		}
		return true;
	}

	internal static bool IsBonusList(BuildingSize size)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		if ((int)size != 6)
		{
			return (int)size == 7;
		}
		return true;
	}

	private static void Attach(BuildingCity prefab, GameObject card, BuildingSize size)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (IsBonusList(size))
		{
			return;
		}
		PinPlugin.TryAttach(delegate
		{
			bool trackedRoster = InRoster();
			PinTarget target = new PinTarget((Component)(object)prefab, ((Building)prefab).GetTitle(), () => prefab.GetCost(false), 0, (ResourceAmount[] _) => CanOffer(prefab), () => trackedRoster && !InRoster());
			PinRow.Create(card, card.GetComponent<Button>(), target);
		});
		bool InRoster()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return RaceManager.Instance.GetBuildings(prefab.GetBuildingSize()).Contains(((Component)prefab).gameObject);
		}
	}

	internal static bool CanOffer(BuildingCity prefab)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Invalid comparison between Unknown and I4
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		BuildingType buildingType = ((Building)prefab).GetBuildingType();
		CityManager instance = CityManager.Instance;
		if (instance.CanBuild(buildingType) && ((int)buildingType != 309 || WorldManager.Instance.CanBuildBonfires() > 0) && (RaceManager.Instance.GetCanBeBuiltMultipleTimes().Contains(buildingType) || (Object)(object)instance.GetBuilding(buildingType) == (Object)null))
		{
			return prefab.CanBeBuilt();
		}
		return false;
	}
}
[HarmonyPatch(typeof(UIBuildingOverlayElementUpgrade), "Draw", new Type[] { typeof(Building) })]
internal static class UpgradeCards
{
	private static readonly Func<UIBuildingOverlayElementUpgrade, Building, ResourceAmount[]> Price = AccessTools.MethodDelegate<Func<UIBuildingOverlayElementUpgrade, Building, ResourceAmount[]>>(AccessTools.Method(typeof(UIBuildingOverlayElementUpgrade), "GetCosts", (Type[])null, (Type[])null), (object)null, true);

	private static void Prefix(out int __state)
	{
		__state = OverlayManager.Instance.GetOverlaySelection().childCount;
	}

	private static void Postfix(UIBuildingOverlayElementUpgrade __instance, Building building, int ___amountOfUpgrades, int __state)
	{
		if (building.GetUpgradeAmount() >= ___amountOfUpgrades)
		{
			return;
		}
		Transform overlaySelection = OverlayManager.Instance.GetOverlaySelection();
		for (int i = __state; i < overlaySelection.childCount; i++)
		{
			Transform card = overlaySelection.GetChild(i);
			Transform obj = card.Find("Upgrade/Container/Button");
			Button purchase = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
			Transform obj2 = card.Find("Upgrade/Title");
			TMP_Text title = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
			if ((Object)(object)purchase == (Object)null || (Object)(object)title == (Object)null)
			{
				continue;
			}
			PinPlugin.TryAttach(delegate
			{
				PinTarget target = new PinTarget((Component)(object)building, building.GetTitle() + " · " + title.text, () => Price(__instance, building), building.GetUpgradeAmount() + 1, (ResourceAmount[] cost) => building.CanBeUpgraded() && ResourceManager.Instance.CanBeBuilt(cost), TrackRemoval(building, (UIBuildingOverlayElement)(object)__instance), "", null, __instance);
				GameObject gameObject = ((Component)card).gameObject;
				Button purchase2 = purchase;
				object actionStrip = (object)/*isinst with value type is only supported in some contexts*/;
				Transform transform = ((Component)purchase).transform;
				PinRow pinRow = PinRow.Create(gameObject, purchase2, target, (RectTransform)actionStrip, null, (RectTransform)(object)((transform is RectTransform) ? transform : null));
				GamepadManager.Instance.SetGameObjectToSelect(((Component)pinRow).gameObject, false);
			});
			break;
		}
	}

	internal static Func<bool> TrackRemoval(Building building, UIBuildingOverlayElement element)
	{
		UIBuildingOverlay overlay = ((Component)building).GetComponent<UIBuildingOverlay>();
		if (!((Object)(object)overlay == (Object)null))
		{
			List<UIBuildingOverlayElement> buttons = overlay.buttons;
			if (buttons != null && buttons.Contains(element))
			{
				return delegate
				{
					if (!((Object)(object)overlay == (Object)null))
					{
						List<UIBuildingOverlayElement> buttons2 = overlay.buttons;
						if (buttons2 == null)
						{
							return true;
						}
						return !buttons2.Contains(element);
					}
					return true;
				};
			}
		}
		return null;
	}
}
[HarmonyPatch(typeof(UITabController), "ChangeTab")]
internal static class TabFocus
{
	private static void Postfix(UITabController __instance, int tab)
	{
		GamepadManager instance = GamepadManager.Instance;
		Transform val = ((Component)__instance).transform.Find("Tab" + tab + "/ScrollArea/Viewport/Content");
		if ((Object)(object)val == (Object)null || (Object)(object)instance == (Object)null || (Object)(object)((Component)val).GetComponentInChildren<PinRow>(true) == (Object)null)
		{
			return;
		}
		GameObject gameObjectToSelect = instance.GetGameObjectToSelect();
		if ((Object)(object)gameObjectToSelect != (Object)null && gameObjectToSelect.activeSelf && (Object)(object)gameObjectToSelect.transform.parent == (Object)(object)val)
		{
			Button component = gameObjectToSelect.GetComponent<Button>();
			if (component != null && ((Selectable)component).IsInteractable())
			{
				return;
			}
		}
		Button[] componentsInChildren = ((Component)val).GetComponentsInChildren<Button>(true);
		foreach (Button val2 in componentsInChildren)
		{
			if (!((Object)(object)((Component)val2).transform.parent != (Object)(object)val) && ((Component)val2).gameObject.activeSelf && ((Selectable)val2).IsInteractable())
			{
				instance.SetGameObjectToSelect(((Component)val2).gameObject, true);
				break;
			}
		}
	}
}
[HarmonyPatch(typeof(CityManager), "Build", new Type[]
{
	typeof(BuildingCity),
	typeof(Vector2),
	typeof(bool)
})]
internal static class BuildCompletion
{
	private static void Postfix(BuildingCity buildingPrototype, bool fromSave, BuildingCity __result)
	{
		if (!fromSave && (Object)(object)__result != (Object)null)
		{
			PinPlugin.Instance?.Built(buildingPrototype);
		}
	}
}
public sealed class ChecklistMark : MaskableGraphic
{
	private bool isMet;

	internal bool IsMet
	{
		get
		{
			return isMet;
		}
		set
		{
			if (isMet != value)
			{
				isMet = value;
				((Graphic)this).SetVerticesDirty();
			}
		}
	}

	protected override void OnPopulateMesh(VertexHelper mesh)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		mesh.Clear();
		Rect rect = ((Graphic)this).GetPixelAdjustedRect();
		Patch(0, 0, 10, 10, isMet ? new Color32((byte)167, (byte)204, (byte)118, byte.MaxValue) : new Color32((byte)194, (byte)163, (byte)119, byte.MaxValue));
		Patch(1, 1, 8, 8, new Color32((byte)48, (byte)35, (byte)25, byte.MaxValue));
		if (isMet)
		{
			Color32 tint = default(Color32);
			((Color32)(ref tint))..ctor((byte)183, (byte)227, (byte)138, byte.MaxValue);
			Patch(2, 4, 2, 2, tint);
			Patch(3, 3, 2, 2, tint);
			for (int i = 0; i < 4; i++)
			{
				Patch(4 + i, 3 + i, 2, 2, tint);
			}
		}
		void Patch(int x, int y, int w, int h, Color32 val)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref rect)).xMin + (float)x * ((Rect)(ref rect)).width / 10f;
			float num2 = ((Rect)(ref rect)).yMin + (float)y * ((Rect)(ref rect)).height / 10f;
			float num3 = num + (float)w * ((Rect)(ref rect)).width / 10f;
			float num4 = num2 + (float)h * ((Rect)(ref rect)).height / 10f;
			int currentVertCount = mesh.currentVertCount;
			mesh.AddVert(new Vector3(num, num2), val, Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(num, num4), val, Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(num3, num4), val, Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(num3, num2), val, Vector4.op_Implicit(Vector2.zero));
			mesh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
			mesh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
		}
	}
}
public static class PinCostApi
{
	public static bool Attach(GameObject card, Button purchase, Component source, string operation, string title, Func<ResourceAmount[]> readCost, Func<bool> isComplete, Func<bool> canPurchase = null, Func<ResourceType, int> readStock = null)
	{
		return Attach(card, purchase, source, operation, title, readCost, isComplete, canPurchase, readStock, readStock == null);
	}

	public static bool Attach(GameObject card, Button purchase, Component source, string operation, string title, Func<ResourceAmount[]> readCost, Func<bool> isComplete, Func<bool> canPurchase, Func<ResourceType, int> readStock, bool honorFreeBuilding)
	{
		if ((Object)(object)PinPlugin.Instance == (Object)null || (Object)(object)card == (Object)null || (Object)(object)purchase == (Object)null || (Object)(object)source == (Object)null || string.IsNullOrWhiteSpace(operation) || string.IsNullOrWhiteSpace(title) || readCost == null || isComplete == null)
		{
			return false;
		}
		PinTarget target = new PinTarget(source, title, readCost, 0, (ResourceAmount[] cost) => (canPurchase == null || canPurchase()) && (readStock != null || ResourceManager.Instance.CanBeBuilt(cost)), isComplete, "mod:" + operation, readStock, null, honorFreeBuilding);
		PinRow.Create(card, purchase, target);
		return true;
	}
}
public sealed class PinHud : MonoBehaviour
{
	private RectTransform bar;

	private RectTransform frame;

	private RectTransform viewport;

	private RectTransform selection;

	private RectTransform tabs;

	private RectTransform book;

	private RectTransform empty;

	private CanvasGroup visibility;

	private bool sizeDirty;

	private Rect lastScreen;

	private Rect lastBar;

	private Rect lastReserved;

	private Rect lastObstacle;

	private readonly List<Image> headerDetails = new List<Image>();

	private Rect[] detailBounds;

	private bool lastSideHidden;

	private Text label;

	private Text status;

	private readonly List<ChecklistMark> marks = new List<ChecklistMark>();

	private readonly List<Text> materials = new List<Text>();

	private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

	internal static PinHud Create(UIHeader header)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Expected O, but got Unknown
		//IL_01ba: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: 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_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: 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_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Expected O, but got Unknown
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e3: 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_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: 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_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		Transform obj = ((Component)header).transform.Find("PanelResources");
		RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
		object obj2;
		if (val == null)
		{
			obj2 = null;
		}
		else
		{
			Transform obj3 = ((Transform)val).Find("Wood/Amount");
			obj2 = ((obj3 != null) ? ((Component)obj3).GetComponent<Text>() : null);
		}
		Text val2 = (Text)obj2;
		Canvas componentInParent = ((Component)header).GetComponentInParent<Canvas>();
		if ((Object)(object)val2 == (Object)null || (Object)(object)componentInParent == (Object)null)
		{
			return null;
		}
		GameObject val3 = new GameObject("Pinned build cost", new Type[2]
		{
			typeof(RectTransform),
			typeof(LayoutElement)
		});
		val3.GetComponent<LayoutElement>().ignoreLayout = true;
		PinHud pinHud = val3.AddComponent<PinHud>();
		pinHud.visibility = val3.AddComponent<CanvasGroup>();
		pinHud.visibility.interactable = false;
		pinHud.visibility.blocksRaycasts = false;
		pinHud.bar = val;
		pinHud.viewport = (RectTransform)((Component)componentInParent.rootCanvas).transform;
		pinHud.TrackDetails(((Component)header).transform.Find("PanelFood/Dropwdown"));
		pinHud.TrackDetails(((Component)header).transform.Find("PanelTaxes/SpellContainerDISABLE"));
		pinHud.TrackDetails(((Component)header).transform.parent.Find("UpperLeft"));
		pinHud.detailBounds = (Rect[])(object)new Rect[pinHud.headerDetails.Count];
		OverlayManager instance = OverlayManager.Instance;
		if ((Object)(object)instance != (Object)null)
		{
			Transform overlaySelection = instance.GetOverlaySelection();
			ref RectTransform reference = ref pinHud.selection;
			Transform obj4 = ((overlaySelection != null) ? overlaySelection.parent : null);
			reference = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null);
			ref RectTransform reference2 = ref pinHud.tabs;
			Transform overlayTabsSelection = instance.GetOverlayTabsSelection();
			reference2 = (RectTransform)(object)((overlayTabsSelection is RectTransform) ? overlayTabsSelection : null);
			ref RectTransform reference3 = ref pinHud.empty;
			Transform overlayEmpty = instance.GetOverlayEmpty();
			reference3 = (RectTransform)(object)((overlayEmpty is RectTransform) ? overlayEmpty : null);
		}
		pinHud.frame = (RectTransform)val3.transform;
		((Transform)pinHud.frame).SetParent((Transform)(object)val, false);
		RectTransform obj5 = pinHud.frame;
		Vector2 anchorMin = (pinHud.frame.anchorMax = Vector2.zero);
		obj5.anchorMin = anchorMin;
		pinHud.frame.pivot = Vector2.one;
		Image val4 = val3.AddComponent<Image>();
		Image component = ((Component)val).GetComponent<Image>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null)
		{
			val4.sprite = component.sprite;
			val4.type = component.type;
			val4.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier;
			((Graphic)val4).color = ((Graphic)component).color;
		}
		else
		{
			((Graphic)val4).color = Color32.op_Implicit(new Color32((byte)47, (byte)34, (byte)26, (byte)248));
		}
		((Graphic)val4).raycastTarget = false;
		Image component2 = new GameObject("Inset", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		}).GetComponent<Image>();
		((Transform)((Graphic)component2).rectTransform).SetParent((Transform)(object)pinHud.frame, false);
		((Graphic)component2).rectTransform.anchorMin = Vector2.zero;
		((Graphic)component2).rectTransform.anchorMax = Vector2.one;
		((Graphic)component2).rectTransform.offsetMin = new Vector2(5f, 5f);
		((Graphic)component2).rectTransform.offsetMax = new Vector2(-5f, -5f);
		((Graphic)component2).color = Color32.op_Implicit(new Color32((byte)48, (byte)35, (byte)25, byte.MaxValue));
		((Graphic)component2).raycastTarget = false;
		GameObject val5 = new GameObject("Pinned target", new Type[2]
		{
			typeof(RectTransform),
			typeof(Text)
		});
		val5.transform.SetParent((Transform)(object)pinHud.frame, false);
		pinHud.label = val5.GetComponent<Text>();
		pinHud.label.font = val2.font;
		pinHud.label.fontSize = 24;
		pinHud.label.fontStyle = val2.fontStyle;
		((Graphic)pinHud.label).color = Color.white;
		pinHud.label.alignment = (TextAnchor)0;
		pinHud.label.supportRichText = false;
		((Graphic)pinHud.label).raycastTarget = false;
		RectTransform rectTransform = ((Graphic)pinHud.label).rectTransform;
		Vector2 val6 = (rectTransform.pivot = Vector2.up);
		anchorMin = (rectTransform.anchorMax = val6);
		rectTransform.anchorMin = anchorMin;
		pinHud.status = Object.Instantiate<Text>(pinHud.label, (Transform)(object)pinHud.frame);
		((Object)pinHud.status).name = "Purchase status";
		return pinHud;
	}

	internal void Show(string title, CostChecklist checklist)
	{
		//IL_00e7: 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_0121: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).gameObject.SetActive(true);
		sizeDirty |= label.text != title || status.text != (checklist.Status ?? "");
		label.text = title;
		status.text = checklist.Status ?? "";
		((Component)status).gameObject.SetActive(checklist.Status != null);
		for (int i = 0; i < checklist.Items.Length; i++)
		{
			if (i == materials.Count)
			{
				Text val = Object.Instantiate<Text>(label, (Transform)(object)frame);
				((Object)val).name = "Material";
				ChecklistMark component = new GameObject("Checkbox", new Type[2]
				{
					typeof(RectTransform),
					typeof(ChecklistMark)
				}).GetComponent<ChecklistMark>();
				((Transform)((Graphic)component).rectTransform).SetParent((Transform)(object)((Graphic)val).rectTransform, false);
				RectTransform rectTransform = ((Graphic)component).rectTransform;
				RectTransform rectTransform2 = ((Graphic)component).rectTransform;
				Vector2 val2 = (((Graphic)component).rectTransform.pivot = Vector2.up);
				Vector2 anchorMin = (rectTransform2.anchorMax = val2);
				rectTransform.anchorMin = anchorMin;
				((Graphic)component).rectTransform.anchoredPosition = new Vector2(-23f, -3f);
				((Graphic)component).rectTransform.sizeDelta = new Vector2(18f, 18f);
				((Graphic)component).raycastTarget = false;
				materials.Add(val);
				marks.Add(component);
				sizeDirty = true;
			}
			MaterialCheck materialCheck = checklist.Items[i];
			Text val4 = materials[i];
			sizeDirty |= !((Component)val4).gameObject.activeSelf || val4.text != materialCheck.Text;
			((Component)val4).gameObject.SetActive(true);
			val4.text = materialCheck.Text;
			marks[i].IsMet = materialCheck.IsMet;
		}
		for (int j = checklist.Items.Length; j < materials.Count; j++)
		{
			sizeDirty |= ((Component)materials[j]).gameObject.activeSelf;
			((Component)materials[j]).gameObject.SetActive(false);
		}
		if ((Object)(object)book == (Object)null)
		{
			ref RectTransform reference = ref book;
			Transform obj = ((Transform)bar).Find("Daybook");
			reference = (RectTransform)(object)((obj is RectTransform) ? obj : null);
		}
		Position();
	}

	private void LateUpdate()
	{
		if ((Object)(object)label != (Object)null)
		{
			Position();
		}
	}

	private void Position()
	{
		//IL_0007: 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)
		//IL_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: 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_01aa: 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: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: 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_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: 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_0184: 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)
		Rect val = Bounds(viewport);
		Rect val2 = (((Object)(object)book != (Object)null && ((Component)book).gameObject.activeInHierarchy) ? Bounds(book) : bar.rect);
		Rect rect = bar.rect;
		float top = ((Rect)(ref rect)).yMin - 6f;
		float num = ((Rect)(ref val)).width * 0.16f;
		RectTransform val3 = (((Object)(object)selection != (Object)null && ((Component)selection).gameObject.activeInHierarchy) ? selection : tabs);
		if ((Object)(object)empty != (Object)null && ((Component)empty).gameObject.activeInHierarchy && ((Transform)empty).childCount > 0)
		{
			Transform child = ((Transform)empty).GetChild(((Transform)empty).childCount - 1);
			val3 = (RectTransform)(object)((child is RectTransform) ? child : null);
		}
		Rect val4 = (((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy) ? Bounds(val3) : Rect.zero);
		bool flag = UpdateDetailBounds();
		bool flag2 = (Object)(object)UIManager.Instance != (Object)null && UIManager.Instance.IsHidden();
		if (sizeDirty || flag || flag2 != lastSideHidden || !(val == lastScreen) || !(bar.rect == lastBar) || !(val2 == lastReserved) || !(val4 == lastObstacle))
		{
			lastSideHidden = flag2;
			lastScreen = val;
			lastBar = bar.rect;
			lastReserved = val2;
			lastObstacle = val4;
			float left = ((Rect)(ref val)).xMin + (flag2 ? 8f : num);
			rect = bar.rect;
			int num2;
			if (!Place(left, Mathf.Min(((Rect)(ref rect)).xMin, ((Rect)(ref val2)).xMin) - 6f, top, ((Rect)(ref val)).yMin, val4, alignRight: true))
			{
				rect = bar.rect;
				num2 = (Place(Mathf.Max(((Rect)(ref rect)).xMax, ((Rect)(ref val2)).xMax) + 6f, ((Rect)(ref val)).xMax - num, top, ((Rect)(ref val)).yMin, val4, alignRight: false) ? 1 : 0);
			}
			else
			{
				num2 = 1;
			}
			bool flag3 = (byte)num2 != 0;
			visibility.alpha = (flag3 ? 1 : 0);
			sizeDirty = false;
		}
	}

	private void TrackDetails(Transform group)
	{
		//IL_002e: 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)
		if ((Object)(object)group == (Object)null)
		{
			return;
		}
		Image[] componentsInChildren = ((Component)group).GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			if ((Object)(object)val.sprite != (Object)null && val.sprite.border != Vector4.zero)
			{
				headerDetails.Add(val);
			}
		}
	}

	private bool UpdateDetailBounds()
	{
		//IL_0024: 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_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		for (int i = 0; i < headerDetails.Count; i++)
		{
			Image val = headerDetails[i];
			Rect val2 = (((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled) ? Bounds(((Graphic)val).rectTransform) : Rect.zero);
			flag |= detailBounds[i] != val2;
			detailBounds[i] = val2;
		}
		return flag;
	}

	private Rect Bounds(RectTransform item)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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)
		//IL_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		item.GetWorldCorners(corners);
		Vector2 val = Vector2.op_Implicit(((Transform)bar).InverseTransformPoint(corners[0]));
		Vector2 val2 = Vector2.op_Implicit(((Transform)bar).InverseTransformPoint(corners[2]));
		return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y);
	}

	private bool Place(float left, float right, float top, float bottom, Rect obstacle, bool alignRight)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 2; i++)
		{
			float num = Mathf.Min(300f, Mathf.Floor(right - left));
			if (num < 112f)
			{
				return false;
			}
			Resize(num);
			Rect val = frame.rect;
			float height = ((Rect)(ref val)).height;
			float num2 = (alignRight ? (right - num) : left);
			float num3 = top;
			Rect[] array = detailBounds;
			for (int j = 0; j < array.Length; j++)
			{
				Rect val2 = array[j];
				if (((Rect)(ref val2)).width > 0f && num2 < ((Rect)(ref val2)).xMax + 6f && num2 + num > ((Rect)(ref val2)).xMin - 6f && ((Rect)(ref val2)).yMin < top)
				{
					num3 = Mathf.Min(num3, ((Rect)(ref val2)).yMin - 6f);
				}
			}
			if (num3 - height < bottom + 6f)
			{
				return false;
			}
			val = new Rect(num2, num3 - height, num, height);
			if (!((Rect)(ref val)).Overlaps(obstacle) || ((Rect)(ref obstacle)).width == 0f)
			{
				RectTransform obj = frame;
				float num4 = num2 + num;
				val = bar.rect;
				float num5 = Mathf.Round(num4 - ((Rect)(ref val)).xMin);
				float num6 = num3;
				val = bar.rect;
				obj.anchoredPosition = new Vector2(num5, Mathf.Floor(num6 - ((Rect)(ref val)).yMin));
				return true;
			}
			if (alignRight)
			{
				right = ((Rect)(ref obstacle)).xMin - 6f;
			}
			else
			{
				left = ((Rect)(ref obstacle)).xMax + 6f;
			}
		}
		return false;
	}

	private void Resize(float width)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!sizeDirty)
		{
			Rect rect = frame.rect;
			if (Mathf.Approximately(((Rect)(ref rect)).width, width))
			{
				return;
			}
		}
		frame.SetSizeWithCurrentAnchors((Axis)0, width);
		float y = 8f;
		PlaceLine(label, 12);
		foreach (Text material in materials)
		{
			if (((Component)material).gameObject.activeSelf)
			{
				PlaceLine(material, 35);
			}
		}
		if (((Component)status).gameObject.activeSelf)
		{
			PlaceLine(status, 12);
		}
		frame.SetSizeWithCurrentAnchors((Axis)1, y + 6f);
		sizeDirty = false;
		void PlaceLine(Text line, int left)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			RectTransform rectTransform = ((Graphic)line).rectTransform;
			rectTransform.SetSizeWithCurrentAnchors((Axis)0, width - (float)left - 12f);
			float num = Mathf.Ceil(line.preferredHeight);
			rectTransform.anchoredPosition = new Vector2((float)left, 0f - y);
			rectTransform.SetSizeWithCurrentAnchors((Axis)1, num);
			y += num + 2f;
		}
	}
}
[BepInPlugin("sfk.pinabuildcost", "Pin a Build Cost", "0.1.0")]
public sealed class PinPlugin : BaseUnityPlugin
{
	internal static PinPlugin Instance;

	private Harmony hooks;

	private PinHud hud;

	private float refreshAt;

	private string lastProblem;

	private PinCardLink hovered;

	private readonly List<PinRow> visibleRows = new List<PinRow>();

	private PinRow shortcutRow;

	private int lastActivationFrame = -1;

	private static readonly FieldRef<OverlayManager, GameObject> ActivePanel = AccessTools.FieldRefAccess<OverlayManager, GameObject>("m_CurrentlyActive");

	internal PinTarget Pinned { get; private set; }

	internal event Action Changed;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		Instance = this;
		hooks = new Harmony("sfk.pinabuildcost");
		try
		{
			hooks.PatchAll(typeof(BuildCards));
			hooks.PatchAll(typeof(UpgradeCards));
			hooks.PatchAll(typeof(CastleUpgradeCards));
			hooks.PatchAll(typeof(TabFocus));
			hooks.PatchAll(typeof(BuildCompletion));
			hooks.PatchAll(typeof(WorldBuildOffers));
			hooks.PatchAll(typeof(WorldUnlockCompletion));
			hooks.PatchAll(typeof(CapacityCards));
			hooks.PatchAll(typeof(EvolutionPlot));
			hooks.PatchAll(typeof(EvolutionCards));
		}
		catch
		{
			hooks.UnpatchSelf();
			throw;
		}
		GameManager.OnGameInit += Clear;
		CityManager.OnBuildingRemoved += Removed;
		CityManager.OnBuildingUpgrade += Upgraded;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Pin a Build Cost 0.1.0 ready.");
	}

	internal static void TryAttach(Action attach)
	{
		try
		{
			attach();
		}
		catch (Exception ex)
		{
			Instance?.Report(ex);
		}
	}

	internal static List<CodeInstruction> UnsupportedLayout(List<CodeInstruction> original, string screen)
	{
		PinPlugin instance = Instance;
		if (instance != null)
		{
			((BaseUnityPlugin)instance).Logger.LogWarning((object)("Unrecognized " + screen + " card layout. Automatic pin actions are unavailable on this screen."));
		}
		return original;
	}

	private void Report(Exception ex)
	{
		if (lastProblem != ex.Message)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)ex);
		}
		lastProblem = ex.Message;
	}

	internal void Hover(PinCardLink link)
	{
		hovered = link;
	}

	internal void Leave(PinCardLink link)
	{
		if ((Object)(object)hovered == (Object)(object)link)
		{
			hovered = null;
		}
	}

	internal void Toggle(PinTarget target)
	{
		Set(target.Toggle(Pinned));
	}

	internal void Activate(PinTarget target)
	{
		if (lastActivationFrame != Time.frameCount)
		{
			lastActivationFrame = Time.frameCount;
			Toggle(target);
		}
	}

	internal void Register(PinRow row)
	{
		visibleRows.Add(row);
	}

	internal void Unregister(PinRow row)
	{
		visibleRows.Remove(row);
	}

	private PinRow ResolveShortcut(GamepadManager pad)
	{
		OverlayManager instance = OverlayManager.Instance;
		if (visibleRows.Count == 0 || (Object)(object)pad == (Object)null || (Object)(object)instance == (Object)null || !instance.IsOpen() || ((Object)(object)PauseMenuManger.Instance != (Object)null && PauseMenuManger.Instance.InMenu()))
		{
			return null;
		}
		GameObject val = ActivePanel.Invoke(instance);
		if ((Object)(object)val == (Object)null || !val.activeInHierarchy)
		{
			return null;
		}
		EventSystem current = EventSystem.current;
		GameObject val2 = ((current != null) ? current.currentSelectedGameObject : null);
		if ((Object)(object)val2 != (Object)null && val2.activeInHierarchy && !val2.transform.IsChildOf(val.transform))
		{
			return null;
		}
		PinRow pinRow = (((Object)(object)val2 == (Object)null) ? null : val2.GetComponentInParent<PinCardLink>()?.Row);
		PinRow pinRow2 = (((Object)(object)hovered != (Object)null && !pad.IsGamepadInUse()) ? hovered.Row : null);
		int num = 0;
		PinRow result = null;
		PinRow pinRow3 = null;
		foreach (PinRow visibleRow in visibleRows)
		{
			if (visibleRow.HasVisibleOffer && ((Component)visibleRow).transform.IsChildOf(val.transform))
			{
				if ((Object)(object)visibleRow == (Object)(object)pinRow)
				{
					return visibleRow;
				}
				if ((Object)(object)visibleRow == (Object)(object)pinRow2)
				{
					pinRow3 = visibleRow;
				}
				result = visibleRow;
				num++;
			}
		}
		if (!((Object)(object)pinRow3 != (Object)null))
		{
			if (num != 1)
			{
				return null;
			}
			return result;
		}
		return pinRow3;
	}

	internal void RefreshOffer(PinTarget target)
	{
		if (Pinned != null && target.IsSameOffer(Pinned))
		{
			Set(target);
		}
	}

	private void Set(PinTarget target)
	{
		Pinned = target;
		refreshAt = 0f;
		if ((Object)(object)hud != (Object)null)
		{
			((Component)hud).gameObject.SetActive(target != null);
		}
		this.Changed?.Invoke();
	}

	private void Clear()
	{
		Set(null);
	}

	internal void Built(BuildingCity prefab)
	{
		PinTarget pinned = Pinned;
		if (pinned != null && pinned.Matches((Component)(object)prefab, 0))
		{
			Clear();
		}
	}

	internal void Completed(Component source, string operation)
	{
		PinTarget pinned = Pinned;
		if (pinned != null && pinned.Matches(source, 0, operation))
		{
			Clear();
		}
	}

	private void Removed(BuildingCity building, bool cancelJobs)
	{
		if (Pinned != null && (object)Pinned.Source == building)
		{
			Clear();
		}
	}

	private void Upgraded(BuildingCity building, bool fromSave)
	{
		if (!fromSave)
		{
			PinTarget pinned = Pinned;
			if (pinned != null && pinned.CompletedUpgrade((Building)(object)building, ((Building)building).GetUpgradeAmount()))
			{
				Clear();
			}
		}
	}

	private void LateUpdate()
	{
		GamepadManager instance = GamepadManager.Instance;
		PinRow pinRow = ResolveShortcut(instance);
		if ((Object)(object)pinRow != (Object)(object)shortcutRow)
		{
			if ((Object)(object)shortcutRow != (Object)null)
			{
				shortcutRow.SetShortcutHint(show: false);
			}
			shortcutRow = pinRow;
			if ((Object)(object)pinRow != (Object)null)
			{
				pinRow.SetShortcutHint(show: true);
			}
		}
		if ((Object)(object)pinRow != (Object)null)
		{
			pinRow.CheckShortcut(instance);
		}
		if (Pinned == null || Time.unscaledTime < refreshAt)
		{
			return;
		}
		refreshAt = Time.unscaledTime + 0.5f;
		if ((Object)(object)Pinned.Source == (Object)null || (Object)(object)GameManager.Instance == (Object)null || GameManager.Instance.IsUnloading())
		{
			Clear();
		}
		else
		{
			if ((Object)(object)ResourceManager.Instance == (Object)null || (Object)(object)RaceManager.Instance == (Object)null)
			{
				return;
			}
			try
			{
				if (Pinned.IsFinished())
				{
					Clear();
					return;
				}
				if ((Object)(object)hud == (Object)null)
				{
					UIHeader val = Object.FindObjectOfType<UIHeader>();
					if ((Object)(object)val != (Object)null)
					{
						hud = PinHud.Create(val);
					}
					if ((Object)(object)hud == (Object)null)
					{
						return;
					}
				}
				hud.Show(Pinned.Title, Pinned.Read(ResourceManager.Instance.IsEverythingFree(), (ResourceType type) => ResourceManager.Instance.GetResourceAvailableAmount(type, true), ResourceName));
			}
			catch (Exception ex)
			{
				hud?.Show(Pinned.Title, CostChecklist.Unavailable);
				Report(ex);
				refreshAt = Time.unscaledTime + 1f;
			}
		}
	}

	private unsafe static string ResourceName(ResourceType type)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		ResourceData resourceData = RaceManager.Instance.GetResourceData(type);
		if (!((Object)(object)resourceData != (Object)null) || resourceData.type != type)
		{
			return ((object)(*(ResourceType*)(&type))/*cast due to .constrained prefix*/).ToString();
		}
		return resourceData.GetName();
	}

	private void OnDestroy()
	{
		GameManager.OnGameInit -= Clear;
		CityManager.OnBuildingRemoved -= Removed;
		CityManager.OnBuildingUpgrade -= Upgraded;
		Harmony obj = hooks;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
		if ((Object)(object)hud != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)hud).gameObject);
		}
		Instance = null;
	}
}
public sealed class PinCardLink : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
	internal PinRow Row;

	public void OnPointerEnter(PointerEventData eventData)
	{
		PinPlugin.Instance?.Hover(this);
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		PinPlugin.Instance?.Leave(this);
	}

	private void OnDisable()
	{
		PinPlugin.Instance?.Leave(this);
		if (!((Component)this).gameObject.activeSelf && (Object)(object)Row != (Object)null && (Object)(object)((Component)Row).gameObject != (Object)(object)((Component)this).gameObject)
		{
			Row.RetireRow();
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)Row != (Object)null && (Object)(object)((Component)Row).gameObject != (Object)(object)((Component)this).gameObject)
		{
			Row.RetireRow();
		}
	}
}
public sealed class PinRow : MonoBehaviour
{
	private PinTarget target;

	private TMP_Text caption;

	private Image glyph;

	private PinPlugin owner;

	private Button purchaseButton;

	private bool retired;

	private bool showShortcut;

	private InputAction shortcut;

	private string displayedPath;

	private string bindingText;

	private bool shortcutSupported;

	private static Button nativeButton;

	private RectTransform face;

	private RectTransform actionStrip;

	private RectTransform leftButton;

	private RectTransform rightButton;

	private RectTransform cardRect;

	private LayoutElement dialogStripLayout;

	private float originalStripWidth;

	private float reservedStripWidth = -1f;

	private float faceWidth;

	private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

	internal bool HasVisibleOffer
	{
		get
		{
			if (!retired && (Object)(object)cardRect != (Object)null && (Object)(object)purchaseButton != (Object)null && ((Component)cardRect).gameObject.activeInHierarchy)
			{
				return ((Behaviour)purchaseButton).isActiveAndEnabled;
			}
			return false;
		}
	}

	internal static PinRow Create(GameObject card, Button purchase, PinTarget target, RectTransform actionStrip = null, RectTransform leftButton = null, RectTransform rightButton = null)
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00d6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Expected O, but got Unknown
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: 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_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Invalid comparison between Unknown and I4
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Expected O, but got Unknown
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Expected O, but got Unknown
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Expected O, but got Unknown
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Expected O, but got Unknown
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Expected O, but got Unknown
		PinPlugin.Instance.RefreshOffer(target);
		PinRow pinRow = ((Component)purchase).GetComponent<PinCardLink>()?.Row;
		if ((Object)(object)pinRow != (Object)null && !pinRow.retired && (Object)(object)pinRow.cardRect == (Object)(object)card.transform && (Object)(object)pinRow.purchaseButton == (Object)(object)purchase)
		{
			pinRow.target = target;
			pinRow.Label();
			return pinRow;
		}
		if ((Object)(object)pinRow != (Object)null)
		{
			pinRow.RetireRow();
		}
		GameObject val = new GameObject("Pin cost · " + target.Title, new Type[1] { typeof(RectTransform) });
		val.SetActive(false);
		RectTransform val2 = (RectTransform)val.transform;
		((Transform)val2).SetParent(card.transform.parent, false);
		((Transform)val2).SetSiblingIndex(card.transform.GetSiblingIndex() + 1);
		Rect rect = ((RectTransform)card.transform).rect;
		val2.sizeDelta = new Vector2(((Rect)(ref rect)).width, 44f);
		LayoutElement obj = val.AddComponent<LayoutElement>();
		float minHeight = (obj.preferredHeight = 44f);
		obj.minHeight = minHeight;
		obj.flexibleWidth = 1f;
		GameObject val3 = new GameObject("Button", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		RectTransform val4 = (RectTransform)val3.transform;
		((Transform)val4).SetParent((Transform)(object)val2, false);
		Image component = val3.GetComponent<Image>();
		Button val5 = val.AddComponent<Button>();
		((Selectable)val5).targetGraphic = (Graphic)(object)component;
		if ((Object)(object)nativeButton == (Object)null)
		{
			GameObject obj2 = Resources.Load<GameObject>("UI/OverlayMessage");
			object obj3;
			if (obj2 == null)
			{
				obj3 = null;
			}
			else
			{
				Transform obj4 = obj2.transform.Find("Buttons/Cancel");
				obj3 = ((obj4 != null) ? ((Component)obj4).GetComponent<Button>() : null);
			}
			nativeButton = (Button)obj3;
		}
		Button val6 = (((Object)(object)nativeButton != (Object)null) ? nativeButton : purchase);
		Graphic targetGraphic = ((Selectable)val6).targetGraphic;
		Image val7 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
		if (val7 != null)
		{
			component.sprite = val7.sprite;
			component.type = val7.type;
			((Graphic)component).color = ((Graphic)val7).color;
			component.pixelsPerUnitMultiplier = val7.pixelsPerUnitMultiplier;
		}
		((Selectable)val5).colors = ((Selectable)val6).colors;
		((Selectable)val5).spriteState = ((Selectable)val6).spriteState;
		((Selectable)val5).transition = (Transition)(((int)((Selectable)val6).transition != 2) ? 1 : 2);
		HorizontalLayoutGroup obj5 = val3.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)obj5).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)obj5).spacing = 4f;
		((LayoutGroup)obj5).padding = new RectOffset(8, 8, 0, 0);
		bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true);
		((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = childControlWidth;
		childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false);
		((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = childControlWidth;
		PinRow pinRow2 = val.AddComponent<PinRow>();
		pinRow2.target = target;
		pinRow2.owner = PinPlugin.Instance;
		pinRow2.purchaseButton = purchase;
		pinRow2.face = val4;
		pinRow2.cardRect = (RectTransform)card.transform;
		pinRow2.actionStrip = actionStrip;
		pinRow2.leftButton = leftButton;
		pinRow2.rightButton = rightButton;
		if ((Object)(object)leftButton != (Object)null && (Object)(object)rightButton != (Object)null && (Object)(object)actionStrip == (Object)(object)card.transform)
		{
			pinRow2.dialogStripLayout = ((Component)actionStrip).GetComponent<LayoutElement>();
		}
		GameObject val8 = new GameObject("Binding", new Type[3]
		{
			typeof(RectTransform),
			typeof(Image),
			typeof(LayoutElement)
		});
		val8.transform.SetParent((Transform)(object)val4, false);
		pinRow2.glyph = val8.GetComponent<Image>();
		pinRow2.glyph.preserveAspect = true;
		((Graphic)pinRow2.glyph).raycastTarget = false;
		val8.GetComponent<LayoutElement>().preferredWidth = 26f;
		val8.GetComponent<LayoutElement>().preferredHeight = 26f;
		GameObject val9 = new GameObject("Action", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val9.transform.SetParent((Transform)(object)val4, false);
		pinRow2.caption = (TMP_Text)(object)val9.GetComponent<TextMeshProUGUI>();
		TMP_Text componentInChildren = ((Component)val6).GetComponentInChildren<TMP_Text>(true);
		if ((Object)(object)componentInChildren != (Object)null)
		{
			pinRow2.caption.font = componentInChildren.font;
			pinRow2.caption.fontSharedMaterial = componentInChildren.fontSharedMaterial;
			((Graphic)pinRow2.caption).color = ((Graphic)componentInChildren).color;
		}
		pinRow2.caption.fontSize = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.fontSize : 32f);
		pinRow2.caption.enableWordWrapping = false;
		pinRow2.caption.overflowMode = (TextOverflowModes)1;
		((Graphic)pinRow2.caption).raycastTarget = false;
		pinRow2.caption.alignment = (TextAlignmentOptions)514;
		((UnityEvent)val5.onClick).AddListener(new UnityAction(pinRow2.Activate));
		AddLink(val, pinRow2);
		AddLink(((Component)purchase).gameObject, pinRow2);
		if ((Object)(object)((Component)purchase).gameObject != (Object)(object)card && (Object)(object)card.transform != (Object)(object)actionStrip)
		{
			AddLink(card, pinRow2);
		}
		val.SetActive(true);
		return pinRow2;
	}

	private static void AddLink(GameObject obj, PinRow row)
	{
		(obj.GetComponent<PinCardLink>() ?? obj.AddComponent<PinCardLink>()).Row = row;
	}

	internal void RetireRow()
	{
		if (!retired)
		{
			retired = true;
			if (((Component)this).gameObject.activeInHierarchy)
			{
				((Component)this).gameObject.SetActive(false);
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void OnEnable()
	{
		if (!((Object)(object)owner == (Object)null))
		{
			owner.Register(this);
			owner.Changed += Label;
			GamepadManager.OnControlSchemeChanged += SchemeChanged;
			Bind();
		}
	}

	private void OnDisable()
	{
		if ((Object)(object)dialogStripLayout != (Object)null && dialogStripLayout.preferredWidth == reservedStripWidth && reservedStripWidth >= 0f)
		{
			dialogStripLayout.preferredWidth = originalStripWidth;
		}
		reservedStripWidth = -1f;
		if ((Object)(object)owner != (Object)null)
		{
			owner.Unregister(this);
			owner.Changed -= Label;
		}
		GamepadManager.OnControlSchemeChanged -= SchemeChanged;
	}

	private void SchemeChanged(string current, string previous)
	{
		Bind();
	}

	private void Bind()
	{
		//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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		GamepadManager instance = GamepadManager.Instance;
		PlayerInput val = (((Object)(object)instance == (Object)null) ? null : instance.GetPlayerInput());
		shortcut = (((Object)(object)val == (Object)null) ? null : val.actions.FindAction("UI/Tab", false));
		displayedPath = null;
		int num = (((Object)(object)val == (Object)null || string.IsNullOrEmpty(val.currentControlScheme) || shortcut == null) ? (-1) : InputActionRebindingExtensions.GetBindingIndex(shortcut, val.currentControlScheme, (string)null));
		if (num >= 0)
		{
			InputBinding val2 = shortcut.bindings[num];
			displayedPath = ((InputBinding)(ref val2)).effectivePath;
		}
		shortcutSupported = SupportsShortcut(shortcut, num);
		glyph.sprite = (shortcutSupported ? instance.GetButtonPrompt(displayedPath, false) : null);
		bindingText = ((shortcutSupported && (Object)(object)glyph.sprite == (Object)null) ? InputActionRebindingExtensions.GetBindingDisplayString(shortcut, num, (DisplayStringOptions)0) : null);
		Label();
	}

	internal void SetShortcutHint(bool show)
	{
		showShortcut = show;
		Label();
	}

	private void Label()
	{
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		string text = target.Action(owner.Pinned);
		((Component)glyph).gameObject.SetActive(showShortcut && (Object)(object)glyph.sprite != (Object)null);
		caption.text = ((showShortcut && !string.IsNullOrEmpty(bindingText)) ? (bindingText + "  " + text) : text);
		HorizontalLayoutGroup component = ((Component)face).GetComponent<HorizontalLayoutGroup>();
		float num = caption.preferredWidth;
		bool flag = ((Component)glyph).gameObject.activeSelf;
		if ((Object)(object)leftButton != (Object)null && (Object)(object)rightButton != (Object)null)
		{
			string text2 = (string.IsNullOrEmpty(bindingText) ? "Replace Pin" : (bindingText + "  Replace Pin"));
			num = Mathf.Max(num, caption.GetPreferredValues(text2).x);
			flag = (Object)(object)glyph.sprite != (Object)null;
		}
		float num2 = (flag ? (((Component)glyph).GetComponent<LayoutElement>().preferredWidth + ((HorizontalOrVerticalLayoutGroup)component).spacing) : 0f);
		faceWidth = Mathf.Max(84f, Mathf.Ceil(num + num2) + (float)((LayoutGroup)component).padding.horizontal + 4f);
		FitFace();
	}

	private void OnRectTransformDimensionsChange()
	{
		FitFace();
	}

	private void FitFace()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)face == (Object)null) && !(faceWidth <= 0f))
		{
			float num = faceWidth;
			Rect rect = ((RectTransform)((Component)this).transform).rect;
			float num2 = Mathf.Min(num, ((Rect)(ref rect)).width);
			face.sizeDelta = new Vector2(Mathf.Max(0f, num2), 38f);
		}
	}

	private void LateUpdate()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: 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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: 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_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Expected O, but got Unknown
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		if (!HasVisibleOffer)
		{
			RetireRow();
		}
		else
		{
			if ((Object)(object)actionStrip == (Object)null || (Object)(object)rightButton == (Object)null)
			{
				return;
			}
			RectTransform val = (RectTransform)((Component)this).transform;
			bool flag = (Object)(object)((Transform)val).parent == (Object)(object)actionStrip;
			Rect rect;
			if ((Object)(object)dialogStripLayout != (Object)null && (Object)(object)leftButton != (Object)null && ((Transform)actionStrip).childCount == (flag ? 3 : 2))
			{
				rect = leftButton.rect;
				float num = Mathf.Max(((Rect)(ref rect)).width, LayoutUtility.GetPreferredWidth(leftButton));
				rect = rightButton.rect;
				float num2 = Mathf.Max(((Rect)(ref rect)).width, LayoutUtility.GetPreferredWidth(rightButton));
				float num3 = Mathf.Ceil(Mathf.Max(num, num2) * 0.25f) + 6f;
				float num4 = Mathf.Ceil(num + faceWidth + num2 + 2f * num3);
				if (dialogStripLayout.preferredWidth < num4)
				{
					if (dialogStripLayout.preferredWidth != reservedStripWidth || reservedStripWidth < 0f)
					{
						originalStripWidth = dialogStripLayout.preferredWidth;
					}
					dialogStripLayout.preferredWidth = (reservedStripWidth = num4);
					LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)((Transform)actionStrip).parent);
				}
			}
			rightButton.GetWorldCorners(corners);
			Vector2 val2 = Vector2.op_Implicit(((Transform)actionStrip).InverseTransformPoint(corners[0]));
			rect = actionStrip.rect;
			float num5 = ((Rect)(ref rect)).xMin + 2f;
			if ((Object)(object)leftButton != (Object)null)
			{
				leftButton.GetWorldCorners(corners);
				num5 = ((Transform)actionStrip).InverseTransformPoint(corners[2]).x + 4f;
			}
			int num6;
			if (((Transform)actionStrip).childCount == 1 + ((!((Object)(object)leftButton == (Object)null)) ? 1 : 0) + (flag ? 1 : 0) && val2.x - num5 >= faceWidth + 4f)
			{
				rect = actionStrip.rect;
				num6 = ((((Rect)(ref rect)).height >= 38f) ? 1 : 0);
				if (num6 != 0 && !flag)
				{
					((Component)this).GetComponent<LayoutElement>().ignoreLayout = true;
					((Transform)val).SetParent((Transform)(object)actionStrip, false);
					Vector2 val3 = (val.pivot = Vector2.zero);
					Vector2 anchorMin = (val.anchorMax = val3);
					val.anchorMin = anchorMin;
				}
			}
			else
			{
				num6 = 0;
			}
			if (num6 != 0)
			{
				float num7 = (((Object)(object)leftButton == (Object)null) ? num5 : ((num5 + val2.x - 4f - faceWidth) / 2f));
				float num8 = val2.y;
				if ((Object)(object)dialogStripLayout != (Object)null && (Object)(object)leftButton != (Object)null)
				{
					float x = ((Transform)leftButton).localPosition.x;
					rect = leftButton.rect;
					float num9 = x + ((Rect)(ref rect)).xMax;
					float x2 = ((Transform)rightButton).localPosition.x;
					rect = rightButton.rect;
					float num10 = x2 + ((Rect)(ref rect)).xMin;
					num7 = (num9 + num10 - faceWidth) / 2f;
					float y = ((Transform)rightButton).localPosition.y;
					rect = rightButton.rect;
					num8 = y + ((Rect)(ref rect)).center.y - 19f;
				}
				float num11 = num7;
				rect = actionStrip.rect;
				float num12 = Mathf.Round(num11 - ((Rect)(ref rect)).xMin);
				float num13 = num8;
				rect = actionStrip.rect;
				val.anchoredPosition = new Vector2(num12, Mathf.Round(num13 - ((Rect)(ref rect)).yMin));
				val.sizeDelta = new Vector2(faceWidth, 38f);
			}
			else if (flag)
			{
				((Transform)val).SetParent(((Transform)cardRect).parent, false);
				((Component)this).GetComponent<LayoutElement>().ignoreLayout = false;
				((Transform)val).SetSiblingIndex(((Transform)cardRect).GetSiblingIndex() + 1);
				val.pivot = new Vector2(0.5f, 0.5f);
				rect = cardRect.rect;
				val.sizeDelta = new Vector2(((Rect)(ref rect)).width, 44f);
			}
		}
	}

	internal void CheckShortcut(GamepadManager pad)
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00ba: 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)
		PlayerInput playerInput = pad.GetPlayerInput();
		if ((Object)(object)playerInput == (Object)null || string.IsNullOrEmpty(playerInput.currentControlScheme))
		{
			return;
		}
		int num = ((shortcut != null) ? InputActionRebindingExtensions.GetBindingIndex(shortcut, playerInput.currentControlScheme, (string)null) : (-1));
		object obj;
		if (num >= 0)
		{
			InputBinding val = shortcut.bindings[num];
			obj = ((InputBinding)(ref val)).effectivePath;
		}
		else
		{
			obj = null;
		}
		if ((string?)obj != displayedPath || shortcutSupported != SupportsShortcut(shortcut, num))
		{
			Bind();
		}
		if (!shortcutSupported)
		{
			return;
		}
		if (shortcut.enabled)
		{
			if (shortcut.WasPerformedThisFrame())
			{
				Activate();
			}
			return;
		}
		Enumerator<InputDevice> enumerator = playerInput.devices.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ButtonControl val2 = InputControlPath.TryFindControl<ButtonControl>((InputControl)(object)enumerator.Current, displayedPath, 0);
				if (val2 != null && val2.wasPressedThisFrame)
				{
					Activate();
					break;
				}
			}
		}
		finally
		{
			((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	internal static bool SupportsShortcut(InputAction action, int index)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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)
		if (action == null || index < 0)
		{
			return false;
		}
		return SupportsBinding(action.enabled, action.interactions, action.bindings[index]);
	}

	internal static bool SupportsBinding(bool enabled, string interactions, InputBinding binding)
	{
		if (!string.IsNullOrEmpty(((InputBinding)(ref binding)).effectivePath))
		{
			if (!enabled)
			{
				if (string.IsNullOrEmpty(interactions) && string.IsNullOrEmpty(((InputBinding)(ref binding)).effectiveInteractions) && !((InputBinding)(ref binding)).isComposite)
				{
					return !((InputBinding)(ref binding)).isPartOfComposite;
				}
				return false;
			}
			return true;
		}
		return false;
	}

	private void Activate()
	{
		if ((Object)(object)owner != (Object)null && HasVisibleOffer && (Object)(object)target.Source != (Object)null)
		{
			owner.Activate(target);
		}
	}
}
internal readonly struct MaterialCheck
{
	internal readonly string Text;

	internal readonly bool IsMet;

	internal MaterialCheck(string text, bool isMet)
	{
		Text = text;
		IsMet = isMet;
	}
}
internal sealed class CostChecklist
{
	internal static readonly CostChecklist Unavailable = new CostChecklist(Array.Empty<MaterialCheck>(), "Cost Unavailable");

	internal readonly MaterialCheck[] Items;

	internal readonly string Status;

	internal CostChecklist(MaterialCheck[] items, string status)
	{
		Items = items;
		Status = status;
	}
}
internal sealed class PinTarget
{
	internal readonly Component Source;

	internal readonly string Title;

	internal readonly int Level;

	internal readonly Func<ResourceAmount[]> Price;

	private readonly Func<bool> complete;

	private readonly Func<ResourceAmount[], bool> permitted;

	private readonly string operation;

	private readonly object definition;

	private readonly Func<ResourceType, int> readStock;

	private readonly bool honorFreeBuilding;

	private readonly bool purchaseChecksStock;

	internal const string ReplaceLabel = "Replace Pin";

	internal PinTarget(Component source, string name, Func<ResourceAmount[]> price, int level = 0, Func<ResourceAmount[], bool> permitted = null, Func<bool> complete = null, string operation = "", Func<ResourceType, int> readStock = null, object definition = null, bool? honorFreeBuilding = null)
	{
		Source = source;
		Level = level;
		Price = price;
		this.permitted = permitted;
		this.operation = operation;
		this.definition = definition;
		this.readStock = readStock;
		this.honorFreeBuilding = honorFreeBuilding ?? (readStock == null);
		purchaseChecksStock = readStock == null;
		this.complete = complete;
		Title = ((level == 0) ? name : (name + " · Lv " + level));
	}

	internal bool Matches(Component source, int level, string action = "")
	{
		if (Source == source && Level == level)
		{
			return operation == action;
		}
		return false;
	}

	internal bool IsSameOffer(PinTarget other)
	{
		if (other != null && Matches(other.Source, other.Level, other.operation))
		{
			return definition == other.definition;
		}
		return false;
	}

	internal string Action(PinTarget pinned)
	{
		if (pinned != null)
		{
			if (!IsSameOffer(pinned))
			{
				return "Replace Pin";
			}
			return "Unpin";
		}
		return "Pin Cost";
	}

	internal PinTarget Toggle(PinTarget pinned)
	{
		if (!IsSameOffer(pinned))
		{
			return this;
		}
		return null;
	}

	internal bool CompletedUpgrade(Building source, int achieved)
	{
		if (operation == "" && Level > 0 && (object)Source == source)
		{
			return achieved >= Level;
		}
		return false;
	}

	internal bool IsFinished()
	{
		Func<bool> func = complete;
		if (func == null || !func())
		{
			if (operation == "" && Level > 0)
			{
				Component source = Source;
				Building val = (Building)(object)((source is Building) ? source : null);
				if (val != null)
				{
					return val.GetUpgradeAmount() >= Level;
				}
			}
			return false;
		}
		return true;
	}

	internal CostChecklist Read(bool free, Func<ResourceType, int> stock, Func<ResourceType, string> name)
	{
		return Describe(Price(), readStock ?? stock, name, free && honorFreeBuilding, permitted, purchaseChecksStock && (!free || honorFreeBuilding));
	}

	internal static CostChecklist Describe(ResourceAmount[] price, Func<ResourceType, int> stock, Func<ResourceType, string> name, bool free = false, Func<ResourceAmount[], bool> permitted = null, bool purchaseChecksStock = true)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		if (price == null)
		{
			return CostChecklist.Unavailable;
		}
		Dictionary<ResourceType, long> dictionary = new Dictionary<ResourceType, long>();
		foreach (ResourceAmount val in price)
		{
			if (val.amount < 0)
			{
				return CostChecklist.Unavailable;
			}
			if (val.amount != 0)
			{
				dictionary.TryGetValue(val.type, out var value);
				dictionary[val.type] = value + val.amount;
			}
		}
		MaterialCheck[] array = new MaterialCheck[dictionary.Count];
		int num = 0;
		bool flag = true;
		foreach (KeyValuePair<ResourceType, long> item in dictionary)
		{
			long num2 = (free ? 0 : (item.Value - stock(item.Key)));
			bool flag2 = num2 <= 0;
			flag = flag && flag2;
			string text = (free ? "Free" : (flag2 ? $"{item.Value}/{item.Value}" : $"{num2} short"));
			array[num++] = new MaterialCheck(name(item.Key) + " · " + text, flag2);
		}
		bool num3;
		if (permitted != null)
		{
			if (!(purchaseChecksStock || flag))
			{
				goto IL_016c;
			}
			num3 = permitted(price);
		}
		else
		{
			num3 = flag;
		}
		if (!num3)
		{
			goto IL_016c;
		}
		object obj = "Ready";
		goto IL_017e;
		IL_016c:
		obj = (flag ? "Materials Ready · Requirements Pending" : null);
		goto IL_017e;
		IL_017e:
		string status = (string)obj;
		return new CostChecklist(array, status);
	}
}
[HarmonyPatch(typeof(UIBuildingOverlayElementCityEvent), "Draw", new Type[] { typeof(Building) })]
internal static class CastleUpgradeCards
{
	private static readonly FieldRef<UIBuildingOverlayElementCityEvent, ResourceAmount[]> Costs = AccessTools.FieldRefAccess<UIBuildingOverlayElementCityEvent, ResourceAmount[]>("m_Cost");

	private static void Postfix(UIBuildingOverlayElementCityEvent __instance, Building building, GameObject __result)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_0058: Invalid comparison between Unknown and I4
		if (!(building is BuildingCastle) || (Object)(object)__result == (Object)null)
		{
			return;
		}
		UIBuildingOverlayElementCityEvent offer = __instance;
		CityEvent cityEvent = offer.eventToTrigger;
		if ((int)cityEvent == 0 || (int)cityEvent == 25)
		{
			return;
		}
		ResourceAmount[] obj = Costs.Invoke(offer);
		if (obj == null || obj.Length == 0)
		{
			return;
		}
		PinPlugin.TryAttach(delegate
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			Button component = __result.GetComponent<Button>();
			if (!((Object)(object)component == (Object)null))
			{
				string text = ((Component)__result.transform.Find("TextName")).GetComponent<TMP_Text>().text;
				if ((int)cityEvent == 8 || (int)cityEvent == 9 || (int)cityEvent == 14)
				{
					Transform obj2 = __result.transform.Find("TextDescription");
					object obj3;
					if (obj2 == null)
					{
						obj3 = null;
					}
					else
					{
						TMP_Text component2 = ((Component)obj2).GetComponent<TMP_Text>();
						obj3 = ((component2 != null) ? component2.text : null);
					}
					string text2 = (string)obj3;
					if (!string.IsNullOrWhiteSpace(text2))
					{
						text = text2;
					}
				}
				Func<bool> retired = UpgradeCards.TrackRemoval(building, (UIBuildingOverlayElement)(object)offer);
				PinTarget target = new PinTarget((Component)(object)building, building.GetTitle() + " · " + text, () => Costs.Invoke(offer), 0, (ResourceAmount[] cost) => CityManager.Instance.DidCityEventHappen(offer.ConditionGreyedOut) && ResourceManager.Instance.CanBeBuilt(cost), delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: 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_0058: Unknown result type (might be due to invalid IL or missing references)
					if (offer.eventToTrigger == cityEvent)
					{
						Func<bool> func = retired;
						if ((func == null || !func()) && !CityManager.Instance.DidCityEventHappen(cityEvent))
						{
							return !CityManager.Instance.DidCityEventHappen(offer.Condition);
						}
					}
					return true;
				}, "castle", null, offer);
				PinRow pinRow = PinRow.Create(__result, component, target);
				GamepadManager.Instance.SetGameObjectToSelect(((Component)pinRow).gameObject, false);
			}
		});
	}
}
[HarmonyPatch(typeof(UIBuildingOverlayElementPortal), "Draw", new Type[] { typeof(Building) })]
internal static class CapacityCards
{
	private static readonly Func<UIBuildingOverlayElementPortal, int, ResourceAmount[]> Price = AccessTools.MethodDelegate<Func<UIBuildingOverlayElementPortal, int, ResourceAmount[]>>(AccessTools.Method(typeof(UIBuildingOverlayElementPortal), "GetCost", (Type[])null, (Type[])null), (object)null, true);

	private static void Postfix(UIBuildingOverlayElementPortal __instance, Building building, GameObject __result)
	{
		if ((Object)(object)__result == (Object)null)
		{
			return;
		}
		PinPlugin.TryAttach(delegate
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_0023: 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)
			ResourceType resource = (ResourceType)(((int)building.GetBuildingType() == 15) ? 27 : 28);
			int next = building.GetResourceQuantity(resource, false) + 1;
			Func<bool> retired = UpgradeCards.TrackRemoval(building, (UIBuildingOverlayElement)(object)__instance);
			FieldRef<UIBuildingOverlayElementPortal, bool> needsSpace = AccessTools.FieldRefAccess<UIBuildingOverlayElementPortal, bool>("checkIfSpaceForUnit");
			string text = ((Component)__result.transform.Find("TextName")).GetComponent<TMP_Text>().text;
			PinTarget target = new PinTarget((Component)(object)building, building.GetTitle() + " · " + text, () => Price(__instance, building.GetResourceQuantity(resource, false)), next, (ResourceAmount[] cost) => ResourceManager.Instance.CanBeBuilt(cost) && !DaytimeManager.Instance.IsNight() && (!needsSpace.Invoke(__instance) || UnitManager.Instance.CanAddMoreUnits()), delegate
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				Func<bool> func = retired;
				return (func != null && func()) || building.GetResourceQuantity(resource, false) >= next;
			}, "capacity", null, __instance);
			PinRow pinRow = PinRow.Create(__result, __result.GetComponent<Button>(), target);
			GamepadManager.Instance.SetGameObjectToSelect(((Component)pinRow).gameObject, false);
		});
	}
}
[HarmonyPatch(typeof(UIOverlayBuildingSelection), "GenerateSelection")]
internal static class EvolutionPlot
{
	internal static GameObject Current;

	private static void Prefix(GameObject gridButton, BuildingSize size, out GameObject __state)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Invalid comparison between Unknown and I4
		__state = Current;
		Current = (((int)size == 8) ? gridButton : null);
	}

	private static void Finalizer(GameObject __state)
	{
		Current = __state;
	}
}
[HarmonyPatch(typeof(UIOverlayBuildingSelection), "AddUnitButtons")]
internal static class EvolutionCards
{
	internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Expected O, but got Unknown
		List<CodeInstruction> list = instructions.ToList();
		MethodInfo price = AccessTools.Method(typeof(UnitManager), "GetUpgradeCost", new Type[1] { typeof(UnitBase) }, (Type[])null);
		MethodInfo display = AccessTools.Method(typeof(UIOverlayBuildingSelection), "DisplayCosts", (Type[])null, (Type[])null);
		int num = list.FindIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, price));
		int num2 = list.FindIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, display));
		if (num < 1 || num2 < num + 3 || !BuildCards.LoadsLocal(list[num - 1].opcode) || !BuildCards.LoadsLocal(list[num2 - 2].opcode) || list.Count((CodeInstruction i) => CodeInstructionExtensions.Calls(i, display)) != 1 || list.Count((CodeInstruction i) => CodeInstructionExtensions.Calls(i, price)) != 1)
		{
			return PinPlugin.UnsupportedLayout(list, "evolution outpost");
		}
		list.InsertRange(num2 + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
		{
			new CodeInstruction(list[num - 1].opcode, list[num - 1].operand),
			new CodeInstruction(list[num2 - 2].opcode, list[num2 - 2].operand),
			CodeInstruction.Call(typeof(EvolutionCards), "Attach", (Type[])null, (Type[])null)
		});
		return list;
	}

	private static void Attach(Unit unit, GameObject card)
	{
		PinPlugin.TryAttach(delegate
		{
			GameObject current = EvolutionPlot.Current;
			if (!((Object)(object)current == (Object)null))
			{
				PinTarget target = ForPlot(unit, current, ((Component)card.transform.Find("TextName")).GetComponent<TMP_Text>().text);
				PinRow.Create(card, card.GetComponent<Button>(), target);
			}
		});
	}

	internal static PinTarget ForPlot(Unit unit, GameObject plot, string title)
	{
		return new PinTarget((Component)(object)unit, title + " · Outpost", () => (ResourceAmount[])(object)new ResourceAmount[1] { UnitManager.Instance.GetUpgradeCost((UnitBase)(object)unit) }, 0, (ResourceAmount[] cost) => (Object)(object)plot != (Object)null && plot.activeInHierarchy && ((UnitBase)unit).GetRank() == 2 && ((UnitBase)unit).CanRankUp() && ResourceManager.Instance.CanBeBuilt(cost[0]), () => (Object)(object)plot == (Object)null || !plot.activeInHierarchy || ((Entity)unit).IsEvolved(), "evolution", null, plot);
	}
}
[HarmonyPatch(typeof(UIOverlayMessage), "SetAccept", new Type[]
{
	typeof(ResourceAmount),
	typeof(UnityAction),
	typeof(bool)
})]
internal static class WorldBuildOffers
{
	private static void Postfix(ResourceAmount resourceAmount, UnityAction call, Button __result)
	{
		//IL_000e: 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)
		if ((Object)(object)__result == (Object)null || call == null)
		{
			return;
		}
		PinPlugin.TryAttach(delegate
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			PinTarget pinTarget = ForCallback(call, resourceAmount);
			if (pinTarget != null)
			{
				RectTransform val = (RectTransform)((Component)__result).transform.parent;
				GameObject gameObject = ((Component)val).gameObject;
				Button purchase = __result;
				object leftButton = (object)/*isinst with value type is only supported in some contexts*/;
				Transform obj = ((Transform)val).Find("Cancel");
				PinRow.Create(gameObject, purchase, pinTarget, val, (RectTransform)leftButton, (RectTransform)(object)((obj is RectTransform) ? obj : null));
			}
		});
	}

	internal unsafe static PinTarget ForCallback(UnityAction call, ResourceAmount quote)
	{
		//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_0123: 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)
		object? target = ((Delegate)(object)call).Target;
		BuildingWitch val = (BuildingWitch)((target is BuildingWitch) ? target : null);
		if (val != null && ((Delegate)(object)call).Method.Name == "UnlockBonfire")
		{
			int count = RaceDataManager.Instance.GetBonfiresUnlocked();
			return Single((Component)(object)val, "Bonfire Unlock", () => quote, () => RaceDataManager.Instance.GetBonfiresUnlocked() > count, count + 1);
		}
		if (((Delegate)(object)call).Method.Name != "Callback")
		{
			return null;
		}
		object target2 = ((Delegate)(object)call).Target;
		RepairableBuilding repair = (RepairableBuilding)((target2 is RepairableBuilding) ? target2 : null);
		if (repair != null)
		{
			BuildingCity val2 = AccessTools.FieldRefAccess<RepairableBuilding, BuildingCity>(repair, "toSpawn");
			return Single((Component)(object)repair, ((Building)val2).GetTitle(), () => repair.cost);
		}
		target2 = ((Delegate)(object)call).Target;
		BuildingSpotWorld spot = (BuildingSpotWorld)((target2 is BuildingSpotWorld) ? target2 : null);
		if (spot != null)
		{
			ResourceType val3 = AccessTools.FieldRefAccess<BuildingSpotWorld, ResourceType>(spot, "resource");
			ResourceData resourceData = RaceManager.Instance.GetResourceData(val3);
			string text = ((resourceData != null) ? resourceData.GetName() : null) ?? ((object)(*(ResourceType*)(&val3))/*cast due to .constrained prefix*/).ToString();
			Func<BuildingSpotWorld, int> price = AccessTools.MethodDelegate<Func<BuildingSpotWorld, int>>(AccessTools.Method(typeof(BuildingSpotWorld), "GetTotalCost", (Type[])null, (Type[])null), (object)null, true);
			return Single((Component)(object)spot, text + " · Rebuild", () => new ResourceAmount(quote.type, price(spot)));
		}
		target2 = ((Delegate)(object)call).Target;
		BuildingWorldStartingResource site = (BuildingWorldStartingResource)((target2 is BuildingWorldStartingResource) ? target2 : null);
		if (site != null)
		{
			int next = site.GetUpgrade() + 1;
			FieldRef<BuildingWorldStartingResource, ResourceAmount[]> field = AccessTools.FieldRefAccess<BuildingWorldStartingResource, ResourceAmount[]>("cost");
			return StartingTier((Component)(object)site, Title((BuildingWorld)(object)site), next, (Func<ResourceAmount[]>)(() => field.Invoke(site)), (Func<int>)site.GetUpgrade, (Func<bool>)(() => ResourceManager.Instance.GetStars() >= AccessTools.FieldRefAccess<BuildingWorldStartingResource, int>(site, "requiredStars")), (Func<ResourceAmount[], bool>)((ResourceAmount[] cost) => ResourceManager.Instance.CanBeBuilt(cost)));
		}
		target2 = ((Delegate)(object)call).Target;
		RaceUnlockablePlaceholder unlock = (RaceUnlockablePlaceholder)((target2 is RaceUnlockablePlaceholder) ? target2 : null);
		if (unlock != null)
		{
			return Single((Component)(object)unlock, Title((BuildingWorld)(object)unlock), () => AccessTools.FieldRefAccess<RaceUnlockablePlaceholder, ResourceAmount>(unlock, "cost"), null, 0, delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				RaceEvent val4 = AccessTools.FieldRefAccess<RaceUnlockablePlaceholder, RaceEvent>(unlock, "requirement");
				return (int)val4 == 0 || RaceDataManager.Instance.HasRaceEventFlag(val4);
			});
		}
		return null;
	}

	internal static PinTarget StartingTier(Component site, string title, int next, Func<ResourceAmount[]> tiers, Func<int> level, Func<bool> unlocked, Func<ResourceAmount[], bool> affordable)
	{
		return new PinTarget(site, title, ReadTier, next, (ResourceAmount[] cost) => unlocked() && affordable(cost), delegate
		{
			if (level() < next)
			{
				int num = next;
				ResourceAmount[] array = tiers();
				return num > ((array != null) ? array.Length : 0);
			}
			return true;
		}, "world");
		ResourceAmount[] ReadTier()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			ResourceAmount[] array = tiers();
			if (array != null && next > 0 && next <= array.Length)
			{
				return (ResourceAmount[])(object)new ResourceAmount[1] { array[next - 1] };
			}
			return null;
		}
	}

	private static string Title(BuildingWorld site)
	{
		string title = site.GetTitle();
		if (!string.IsNullOrWhiteSpace(title))
		{
			return title;
		}
		return Regex.Replace(((Object)site).name.Replace("(Clone)", "").Trim(), "(?<=[a-z])(?=[A-Z])", " ");
	}

	private static PinTarget Single(Component owner, string title, Func<ResourceAmount> price, Func<bool> complete = null, int level = 0, Func<bool> allowed = null)
	{
		return new PinTarget(owner, title, () => (ResourceAmount[])(object)new ResourceAmount[1] { price() }, level, (ResourceAmount[] cost) => (allowed == null || allowed()) && ResourceManager.Instance.CanBeBuilt(cost), complete, "world");
	}
}
[HarmonyPatch(typeof(RaceUnlockablePlaceholder), "Upgrade")]
internal static class WorldUnlockCompletion
{
	private static void Postfix(RaceUnlockablePlaceholder __instance, bool fromSave)
	{
		if (!fromSave)
		{
			PinPlugin.Instance?.Completed((Component)(object)__instance, "world");
		}
	}
}