using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
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.Localization;
using UnityEngine.TextCore;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ProductionBottlenecks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.4.0")]
[assembly: AssemblyInformationalVersion("0.2.4+428af01ec305322c9b15156aaf19e8697c69e85b")]
[assembly: AssemblyProduct("ProductionBottlenecks")]
[assembly: AssemblyTitle("ProductionBottlenecks")]
[assembly: AssemblyVersion("0.2.4.0")]
namespace ProductionBottlenecks;
internal sealed class BlockedBuildingsList : MonoBehaviour
{
private sealed class Entry
{
public BuildingCity Building;
public Button Button;
public TextMeshProUGUI Text;
public Image Icon;
public bool Present;
public string Title;
public string Reason;
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__34_0;
internal void <Build>b__34_0()
{
OverlayManager.Instance.Cancel(true);
}
}
private const float RowHeight = 74f;
private const float Gap = 6f;
private const float BackHeight = 42f;
private static readonly FieldRef<OverlayManager, GameObject> CancelPrompt = AccessTools.FieldRefAccess<OverlayManager, GameObject>("cancelButtonPrompt");
private readonly Dictionary<BuildingCity, Entry> entries = new Dictionary<BuildingCity, Entry>();
private readonly Dictionary<string, int> titleCounts = new Dictionary<string, int>();
private readonly HashSet<BuildingCity> seen = new HashSet<BuildingCity>();
private List<Entry> rows = new List<Entry>();
private List<Entry> nextRows = new List<Entry>();
private ScrollRect scroll;
private RectTransform content;
private RectTransform viewport;
private LayoutElement windowSize;
private Transform resourceBar;
private RectTransform panel;
private RectTransform frame;
private RectTransform title;
private float lowerEdge;
private float upperEdge;
private float appliedShift;
private Camera uiCamera;
private readonly List<Graphic> hudGraphics = new List<Graphic>();
private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];
private Button back;
private TextMeshProUGUI visitHint;
private GameObject empty;
private TextMeshProUGUI promptStyle;
private GameObject lastSelection;
private GameObject focusMark;
private float nextRefresh;
private static Button AddButton(Transform parent, string title, float height, UnityAction action)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
Button componentInChildren = Resources.Load<GameObject>("UI/OverlayElementButton").GetComponentInChildren<Button>(true);
TextMeshProUGUI componentInChildren2 = ((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>(true);
GameObject val = new GameObject(title, new Type[4]
{
typeof(RectTransform),
typeof(Image),
typeof(Button),
typeof(LayoutElement)
});
val.transform.SetParent(parent, false);
Image component = val.GetComponent<Image>();
Image val2 = (Image)((Selectable)componentInChildren).targetGraphic;
component.sprite = val2.sprite;
component.type = val2.type;
((Graphic)component).color = ((Graphic)val2).color;
component.pixelsPerUnitMultiplier = val2.pixelsPerUnitMultiplier;
Button component2 = val.GetComponent<Button>();
((Selectable)component2).targetGraphic = (Graphic)(object)component;
((Selectable)component2).colors = ((Selectable)componentInChildren).colors;
((Selectable)component2).transition = ((Selectable)componentInChildren).transition;
((Selectable)component2).spriteState = ((Selectable)componentInChildren).spriteState;
TextMeshProUGUI component3 = new GameObject("Text", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
}).GetComponent<TextMeshProUGUI>();
RectTransform rectTransform = ((TMP_Text)component3).rectTransform;
((Transform)rectTransform).SetParent(val.transform, false);
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = new Vector2(8f, 0f);
rectTransform.offsetMax = new Vector2(-8f, 0f);
((TMP_Text)component3).font = ((TMP_Text)componentInChildren2).font;
((TMP_Text)component3).fontSharedMaterial = ((TMP_Text)componentInChildren2).fontSharedMaterial;
((TMP_Text)component3).spriteAsset = ((TMP_Text)componentInChildren2).spriteAsset;
((Graphic)component3).color = ((Graphic)componentInChildren2).color;
((TMP_Text)component3).alignment = (TextAlignmentOptions)514;
((TMP_Text)component3).fontSize = 28f;
((TMP_Text)component3).text = title;
((Graphic)component3).raycastTarget = false;
LayoutElement component4 = val.GetComponent<LayoutElement>();
float minHeight = (component4.preferredHeight = height);
component4.minHeight = minHeight;
component4.preferredWidth = 300f;
component4.flexibleWidth = 1f;
((RectTransform)val.transform).sizeDelta = new Vector2(300f, height);
((UnityEvent)component2.onClick).AddListener(action);
Navigation navigation = ((Selectable)component2).navigation;
((Navigation)(ref navigation)).mode = (Mode)3;
((Selectable)component2).navigation = navigation;
((Component)component2).gameObject.SetActive(true);
return component2;
}
internal static GameObject AddLauncher(Transform panel, UnityAction open)
{
return ((Component)AddButton(panel, "Blocked Buildings", 42f, open)).gameObject;
}
internal static void Open(Transform panel)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Blocked buildings list", new Type[4]
{
typeof(RectTransform),
typeof(VerticalLayoutGroup),
typeof(LayoutElement),
typeof(ContentSizeFitter)
});
val.transform.SetParent(panel, false);
VerticalLayoutGroup component = val.GetComponent<VerticalLayoutGroup>();
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)component).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)component).spacing = 6f;
LayoutElement component2 = val.GetComponent<LayoutElement>();
float minWidth = (component2.preferredWidth = 440f);
component2.minWidth = minWidth;
((RectTransform)val.transform).sizeDelta = new Vector2(440f, 0f);
val.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
val.AddComponent<BlockedBuildingsList>().Build();
}
private void Build()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Invalid comparison between Unknown and I4
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Expected O, but got Unknown
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: 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_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Invalid comparison between Unknown and I4
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_036f: Unknown result type (might be due to invalid IL or missing references)
//IL_0374: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Expected O, but got Unknown
//IL_048e: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Expected O, but got Unknown
GameObject val = new GameObject("Building rows", new Type[3]
{
typeof(RectTransform),
typeof(ScrollRect),
typeof(LayoutElement)
});
val.transform.SetParent(((Component)this).transform, false);
windowSize = val.GetComponent<LayoutElement>();
scroll = val.GetComponent<ScrollRect>();
scroll.horizontal = false;
scroll.inertia = false;
scroll.movementType = (MovementType)2;
scroll.scrollSensitivity = 80f;
viewport = NewRect("Viewport", val.transform);
viewport.anchorMin = Vector2.zero;
viewport.anchorMax = Vector2.one;
RectTransform obj = viewport;
Vector2 offsetMin = (viewport.offsetMax = Vector2.zero);
obj.offsetMin = offsetMin;
((Graphic)((Component)viewport).gameObject.AddComponent<Image>()).color = Color.clear;
((Component)viewport).gameObject.AddComponent<RectMask2D>();
scroll.viewport = viewport;
content = NewRect("Content", (Transform)(object)viewport);
content.anchorMin = new Vector2(0f, 1f);
RectTransform obj2 = content;
offsetMin = (content.pivot = Vector2.one);
obj2.anchorMax = offsetMin;
RectTransform obj3 = content;
offsetMin = (content.anchoredPosition = Vector2.zero);
obj3.sizeDelta = offsetMin;
VerticalLayoutGroup obj4 = ((Component)content).gameObject.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)obj4).spacing = 6f;
bool flag = (((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true);
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = flag);
((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
scroll.content = content;
Scrollbar[] componentsInChildren = ((Component)OverlayManager.Instance).GetComponentsInChildren<Scrollbar>(true);
foreach (Scrollbar val2 in componentsInChildren)
{
if ((int)val2.direction == 2 || (int)val2.direction == 3)
{
Scrollbar val3 = Object.Instantiate<Scrollbar>(val2, val.transform);
((Object)val3).name = "Scroll bar";
val3.onValueChanged = new ScrollEvent();
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)val3).navigation = navigation;
val3.direction = (Direction)2;
RectTransform val4 = (RectTransform)((Component)val3).transform;
val4.anchorMin = new Vector2(1f, 0f);
val4.anchorMax = Vector2.one;
val4.pivot = new Vector2(1f, 0.5f);
val4.sizeDelta = new Vector2(20f, 0f);
val4.anchoredPosition = Vector2.zero;
scroll.verticalScrollbar = val3;
break;
}
}
empty = Object.Instantiate<GameObject>(Resources.Load<GameObject>("UI/OverlayElementText"), ((Component)this).transform);
TextMeshProUGUI componentInChildren = empty.GetComponentInChildren<TextMeshProUGUI>(true);
((TMP_Text)componentInChildren).text = "No blocked buildings.";
((Graphic)componentInChildren).raycastTarget = false;
RectTransform val5 = NewRect("Footer", ((Component)this).transform);
HorizontalLayoutGroup obj5 = ((Component)val5).gameObject.AddComponent<HorizontalLayoutGroup>();
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)obj5).spacing = 6f;
object obj6 = <>c.<>9__34_0;
if (obj6 == null)
{
UnityAction val6 = delegate
{
OverlayManager.Instance.Cancel(true);
};
<>c.<>9__34_0 = val6;
obj6 = (object)val6;
}
back = AddButton((Transform)(object)val5, "Back", 42f, (UnityAction)obj6);
LayoutElement component = ((Component)back).GetComponent<LayoutElement>();
float minWidth = (component.preferredWidth = 96f);
component.minWidth = minWidth;
component.flexibleWidth = 0f;
promptStyle = ((Component)back).GetComponentInChildren<TextMeshProUGUI>(true);
visitHint = Object.Instantiate<TextMeshProUGUI>(promptStyle, (Transform)(object)val5);
((Object)visitHint).name = "Visit hint";
((TMP_Text)visitHint).transform.SetAsFirstSibling();
((TMP_Text)visitHint).alignment = (TextAlignmentOptions)4097;
((TMP_Text)visitHint).margin = new Vector4(8f, 0f, 0f, 0f);
((TMP_Text)visitHint).fontSize = 24f;
((TMP_Text)visitHint).text = "Select a building to visit.";
((Component)visitHint).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
UIHeader obj7 = Object.FindObjectOfType<UIHeader>();
resourceBar = ((obj7 != null) ? ((Component)obj7).transform.Find("PanelResources") : null);
panel = (RectTransform)((Component)this).transform.parent;
while ((Object)(object)panel != (Object)null && ((Object)panel).name != "Panel")
{
ref RectTransform reference = ref panel;
Transform parent = ((Transform)panel).parent;
reference = (RectTransform)(object)((parent is RectTransform) ? parent : null);
}
RectTransform obj8 = panel;
ref RectTransform reference2 = ref frame;
Transform obj9 = ((obj8 != null) ? ((Transform)obj8).parent : null);
reference2 = (RectTransform)(object)((obj9 is RectTransform) ? obj9 : null);
RectTransform obj10 = frame;
ref RectTransform reference3 = ref title;
Transform obj11 = ((obj10 != null) ? ((Transform)obj10).Find("HeaderContainer/Header") : null);
reference3 = (RectTransform)(object)((obj11 is RectTransform) ? obj11 : null);
GameObject obj12 = CancelPrompt.Invoke(OverlayManager.Instance);
if (obj12 != null)
{
obj12.SetActive(true);
}
Refresh(opening: true);
}
private static RectTransform NewRect(string name, Transform parent)
{
//IL_0014: 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_002c: Expected O, but got Unknown
RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
((Transform)val).SetParent(parent, false);
return val;
}
private Entry AddRow(BuildingCity building)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: 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_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
Entry entry = new Entry
{
Building = building
};
entry.Button = AddButton((Transform)(object)content, "Building " + ((Object)building).GetInstanceID(), 74f, (UnityAction)delegate
{
Jump(building);
});
entry.Text = ((Component)entry.Button).GetComponentInChildren<TextMeshProUGUI>(true);
((TMP_Text)entry.Text).alignment = (TextAlignmentOptions)4097;
((TMP_Text)entry.Text).enableAutoSizing = true;
((TMP_Text)entry.Text).fontSizeMin = 15f;
((TMP_Text)entry.Text).fontSizeMax = 30f;
((TMP_Text)entry.Text).rectTransform.anchorMin = Vector2.zero;
((TMP_Text)entry.Text).rectTransform.anchorMax = Vector2.one;
((TMP_Text)entry.Text).rectTransform.offsetMin = new Vector2(68f, 3f);
((TMP_Text)entry.Text).rectTransform.offsetMax = new Vector2(-10f, -3f);
GameObject val = new GameObject("Building icon", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
entry.Icon = val.GetComponent<Image>();
RectTransform rectTransform = ((Graphic)entry.Icon).rectTransform;
((Transform)rectTransform).SetParent(((Component)entry.Button).transform, false);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 0.5f);
rectTransform.anchorMax = val2;
rectTransform.anchorMin = val2;
rectTransform.anchoredPosition = new Vector2(35f, 0f);
rectTransform.sizeDelta = new Vector2(50f, 54f);
((Graphic)entry.Icon).raycastTarget = false;
entry.Icon.preserveAspect = true;
RectTransform obj = NewRect("Focus mark", ((Component)entry.Button).transform);
obj.anchorMin = new Vector2(0f, 0.15f);
obj.anchorMax = new Vector2(0f, 0.85f);
obj.pivot = new Vector2(0f, 0.5f);
obj.sizeDelta = new Vector2(4f, 0f);
obj.anchoredPosition = new Vector2(5f, 0f);
Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
((Graphic)obj2).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)224, (byte)170, byte.MaxValue));
((Graphic)obj2).raycastTarget = false;
((Component)obj).gameObject.SetActive(false);
return entry;
}
private void Update()
{
if (Time.unscaledTime >= nextRefresh)
{
Refresh(opening: false);
}
EventSystem current = EventSystem.current;
GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
if ((Object)(object)val != (Object)(object)lastSelection)
{
RevealSelection(val);
}
}
private void RevealSelection(GameObject current)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
lastSelection = current;
if ((Object)(object)focusMark != (Object)null)
{
focusMark.SetActive(false);
}
object obj;
if (!((Object)(object)current != (Object)null) || !((Object)(object)current.transform.parent == (Object)(object)content))
{
obj = null;
}
else
{
Transform obj2 = current.transform.Find("Focus mark");
obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
}
focusMark = (GameObject)obj;
if ((Object)(object)focusMark != (Object)null)
{
focusMark.SetActive(true);
}
if (scroll.vertical && !((Object)(object)current == (Object)null) && !((Object)(object)current.transform.parent != (Object)(object)content))
{
float num = (float)current.transform.GetSiblingIndex() * 80f;
float y = content.anchoredPosition.y;
float preferredHeight = windowSize.preferredHeight;
float num2 = Mathf.Clamp(y, num + 74f - preferredHeight, num);
if (!Mathf.Approximately(num2, y))
{
SetOffset(num2);
}
}
}
private void SetOffset(float offset)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Rect rect = content.rect;
float num = ((Rect)(ref rect)).height - windowSize.preferredHeight;
scroll.verticalNormalizedPosition = ((num > 0f) ? (1f - Mathf.Clamp01(offset / num)) : 1f);
}
private void Refresh(bool opening)
{
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0529: Expected O, but got Unknown
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
nextRefresh = Time.unscaledTime + 0.2f;
EventSystem current = EventSystem.current;
GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
int num = (((Object)(object)val != (Object)null && (Object)(object)val.transform.parent == (Object)(object)content) ? val.transform.GetSiblingIndex() : (-1));
foreach (Entry row in rows)
{
row.Present = false;
}
nextRows.Clear();
seen.Clear();
titleCounts.Clear();
CityManager instance = CityManager.Instance;
if ((Object)(object)instance != (Object)null)
{
Collect(instance.GetBuildings());
Collect(instance.GetOutposts());
}
Button val2 = null;
if (num >= 0 && num < rows.Count && !rows[num].Present)
{
for (int i = 1; i < rows.Count; i++)
{
if (!((Object)(object)val2 == (Object)null))
{
break;
}
if (num + i < rows.Count && rows[num + i].Present)
{
val2 = rows[num + i].Button;
}
else if (num >= i && rows[num - i].Present)
{
val2 = rows[num - i].Button;
}
}
}
foreach (Entry nextRow in nextRows)
{
string text = nextRow.Title;
if (titleCounts[text] > 1)
{
Vector3 position = ((Component)nextRow.Building).transform.position;
text += $" <color=#FFE0AA>({position.x:0.##}, {position.y:0.##})</color>";
}
string text2 = text + "\n" + nextRow.Reason;
if (((TMP_Text)nextRow.Text).text != text2)
{
((TMP_Text)nextRow.Text).text = text2;
}
}
foreach (Entry row2 in rows)
{
if (!row2.Present)
{
entries.Remove(row2.Building);
((Component)row2.Button).gameObject.SetActive(false);
((Component)row2.Button).transform.SetParent((Transform)null, false);
Object.Destroy((Object)(object)((Component)row2.Button).gameObject);
}
}
List<Entry> list = nextRows;
List<Entry> list2 = rows;
rows = list;
nextRows = list2;
for (int j = 0; j < rows.Count; j++)
{
Link(rows[j].Button, (j > 0) ? rows[j - 1].Button : null, (j + 1 < rows.Count) ? rows[j + 1].Button : back);
}
Link(back, (rows.Count > 0) ? rows[rows.Count - 1].Button : null, null);
float num2 = Mathf.Max(0f, (float)rows.Count * 80f - 6f);
float num3 = Mathf.Min(num2, AvailableHeight());
int num4;
if (Mathf.Approximately(num3, windowSize.preferredHeight))
{
Rect rect = content.rect;
num4 = ((!Mathf.Approximately(num2, ((Rect)(ref rect)).height)) ? 1 : 0);
}
else
{
num4 = 1;
}
bool flag = (byte)num4 != 0;
Scrollbar verticalScrollbar = scroll.verticalScrollbar;
scroll.vertical = num2 > num3 + 0.5f;
if ((Object)(object)verticalScrollbar != (Object)null)
{
((Component)verticalScrollbar).gameObject.SetActive(scroll.vertical);
viewport.offsetMax = new Vector2((float)(scroll.vertical ? (-26) : 0), 0f);
}
empty.SetActive(rows.Count == 0);
((Behaviour)visitHint).enabled = rows.Count > 0;
((Component)scroll).gameObject.SetActive(rows.Count > 0);
if (flag)
{
float y = content.anchoredPosition.y;
LayoutElement obj = windowSize;
float minHeight = (windowSize.preferredHeight = num3);
obj.minHeight = minHeight;
content.SetSizeWithCurrentAnchors((Axis)1, num2);
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)((Component)this).transform);
SetOffset(y);
}
if (opening || (num >= 0 && ((Object)(object)val == (Object)null || !val.activeInHierarchy)))
{
Button val3 = val2 ?? ((rows.Count == 0) ? back : rows[Mathf.Clamp(num, 0, rows.Count - 1)].Button);
GamepadManager.Instance.SetGameObjectToSelect(((Component)val3).gameObject, true);
EventSystem current4 = EventSystem.current;
if (current4 != null)
{
current4.SetSelectedGameObject(((Component)val3).gameObject);
}
RevealSelection(((Component)val3).gameObject);
}
else if (num >= 0 && (val.transform.GetSiblingIndex() != num || (flag && GamepadManager.Instance.IsGamepadInUse())))
{
RevealSelection(val);
}
}
private float AvailableHeight()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
Canvas rootCanvas = ((Component)scroll).GetComponentInParent<Canvas>().rootCanvas;
Camera val = (((int)rootCanvas.renderMode == 0) ? null : rootCanvas.worldCamera);
Vector2 val2 = RectTransformUtility.WorldToScreenPoint(val, ((Component)this).transform.position);
float num = Mathf.Max(0.01f, RectTransformUtility.WorldToScreenPoint(val, ((Component)this).transform.TransformPoint(Vector3.up)).y - val2.y);
Rect safeArea = Screen.safeArea;
float num2 = ((Rect)(ref safeArea)).yMax;
if ((Object)(object)resourceBar != (Object)null)
{
((Component)resourceBar).GetComponentsInChildren<Graphic>(false, hudGraphics);
Rect rect = ((RectTransform)((Component)this).transform).rect;
float num3 = (((Rect)(ref rect)).width / 2f + 50f) * num;
foreach (Graphic hudGraphic in hudGraphics)
{
if (((Behaviour)hudGraphic).isActiveAndEnabled && !(hudGraphic.color.a <= 0f))
{
hudGraphic.rectTransform.GetWorldCorners(corners);
Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val, corners[0]);
Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val, corners[2]);
if (val3.y > (float)Screen.height * 0.5f && val4.x > val2.x - num3 && val3.x < val2.x + num3)
{
num2 = Mathf.Min(num2, val3.y);
}
}
}
}
uiCamera = val;
lowerEdge = ((Rect)(ref safeArea)).yMin + 14f * num;
upperEdge = num2 - 14f * num;
return Mathf.Max(74f, Mathf.Floor((upperEdge - lowerEdge) / num - 90f - 42f - 6f));
}
private void LateUpdate()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0039: 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_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)title == (Object)null || !((Component)title).gameObject.activeInHierarchy)
{
return;
}
RectTransform val = (RectTransform)((Transform)frame).parent;
Vector2 val2 = RectTransformUtility.WorldToScreenPoint(uiCamera, ((Transform)val).position);
float num = RectTransformUtility.WorldToScreenPoint(uiCamera, ((Transform)val).TransformPoint(Vector3.up)).y - val2.y;
if (!(num <= 0f))
{
title.GetWorldCorners(corners);
float num2 = RectTransformUtility.WorldToScreenPoint(uiCamera, corners[2]).y - appliedShift * num;
panel.GetWorldCorners(corners);
float num3 = RectTransformUtility.WorldToScreenPoint(uiCamera, corners[0]).y - appliedShift * num;
float num4 = Mathf.Clamp(0f, lowerEdge - num3, upperEdge - num2) / num;
if (Mathf.Abs(num4 - appliedShift) > 0.25f)
{
RectTransform obj = frame;
obj.anchoredPosition += Vector2.up * (num4 - appliedShift);
appliedShift = num4;
}
}
}
private static void Link(Button button, Button up, Button down)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)4;
((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)up;
((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)down;
((Selectable)button).navigation = navigation;
}
private void Collect(List<BuildingCity> buildings)
{
foreach (BuildingCity building in buildings)
{
if ((Object)(object)building == (Object)null || !((Behaviour)building).isActiveAndEnabled || building.ShouldRemove() || !seen.Add(building) || (Object)(object)((Component)building).GetComponent<UIBuildingOverlay>() == (Object)null)
{
continue;
}
string key = ((Building)building).GetTitle() ?? string.Empty;
titleCounts.TryGetValue(key, out var value);
titleCounts[key] = value + 1;
string text = ProductionStatus.Read(building, (Sprite sprite) => ResourceIcon.Tag(promptStyle, sprite));
if (text == null)
{
continue;
}
if (!entries.TryGetValue(building, out var value2))
{
entries.Add(building, value2 = AddRow(building));
}
if (!value2.Present)
{
value2.Present = true;
if (((Component)value2.Button).transform.GetSiblingIndex() != nextRows.Count)
{
((Component)value2.Button).transform.SetSiblingIndex(nextRows.Count);
}
nextRows.Add(value2);
object obj = building.icon;
if (obj == null)
{
SpriteRenderer spriteRenderer = ((Building)building).GetSpriteRenderer();
obj = ((spriteRenderer != null) ? spriteRenderer.sprite : null);
}
Sprite val = (Sprite)obj;
value2.Icon.sprite = val;
((Behaviour)value2.Icon).enabled = (Object)(object)val != (Object)null;
value2.Title = key;
value2.Reason = text;
}
}
}
private void Jump(BuildingCity building)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_0233: 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_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
//IL_0160: 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_0173: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
CityManager instance = CityManager.Instance;
if ((Object)(object)building == (Object)null || !((Behaviour)building).isActiveAndEnabled || building.ShouldRemove() || (Object)(object)instance == (Object)null || (!instance.GetBuildings().Contains(building) && !instance.GetOutposts().Contains(building)) || ProductionStatus.Read(building, null) == null)
{
Refresh(opening: false);
return;
}
UIBuildingOverlay component = ((Component)building).GetComponent<UIBuildingOverlay>();
GameCamera instance2 = GameCamera.Instance;
OverlayManager instance3 = OverlayManager.Instance;
if ((Object)(object)component == (Object)null || (Object)(object)instance2 == (Object)null || !instance3.CloseOverlay(false) || instance3.IsOpen())
{
return;
}
bool flag = GamepadManager.Instance.IsGamepadInUse() && (Object)(object)EventSystem.current != (Object)null;
Collider2D component2 = ((Component)component).GetComponent<Collider2D>();
Vector3 val;
if (!((Object)(object)component2 != (Object)null))
{
val = ((Component)building).transform.position;
}
else
{
Bounds bounds = component2.bounds;
val = ((Bounds)(ref bounds)).center;
}
Vector3 position = val;
Collider2D val2 = null;
if (flag)
{
Collider2D[] componentsInChildren = ((Component)component).GetComponentsInChildren<Collider2D>();
foreach (Collider2D hit in componentsInChildren)
{
if (((Behaviour)hit).enabled && (ShaderParameters.LayerMaskUI & (1 << ((Component)hit).gameObject.layer)) != 0 && !((Object)(object)ExecuteEvents.GetEventHandler<IPointerEnterHandler>(((Component)hit).gameObject) != (Object)(object)((Component)component).gameObject))
{
Bounds bounds2 = hit.bounds;
Vector3 position2 = ((Component)hit).transform.position;
(float, float)? tuple = VisitPoint.Choose((X: ((Bounds)(ref bounds2)).center.x, Y: ((Bounds)(ref bounds2)).center.y), (X: position2.x, Y: position2.y), ((Bounds)(ref bounds2)).extents.x, ((Bounds)(ref bounds2)).extents.y, hit.isTrigger, (float x, float y) => IsClearVisitPoint(hit, new Vector2(x, y)));
if (tuple.HasValue)
{
((Vector3)(ref position))..ctor(tuple.Value.Item1, tuple.Value.Item2, ((Bounds)(ref bounds2)).center.z);
val2 = hit;
break;
}
}
}
}
instance2.SetCurrentNavigationVelocity(Vector2.zero);
instance2.SetPosition(position);
instance2.SetTarget(((Component)instance2).transform.position, 100f);
if (!flag)
{
return;
}
if ((Object)(object)val2 == (Object)null || !IsClearVisitPoint(val2, Vector2.op_Implicit(((Component)instance2).transform.position)))
{
if (((ClickableSprite)component).IsInteractable())
{
component.Open(false, "");
}
return;
}
PointerEventData val3 = new PointerEventData(EventSystem.current)
{
position = GamepadManager.Instance.GetCursorPosition()
};
BuildingCity highlightedBuilding = instance.GetHighlightedBuilding();
if ((Object)(object)highlightedBuilding != (Object)null && (Object)(object)highlightedBuilding != (Object)(object)building)
{
UIBuildingOverlay component3 = ((Component)highlightedBuilding).GetComponent<UIBuildingOverlay>();
if (component3 != null)
{
((ClickableSprite)component3).OnPointerExit(val3);
}
}
if ((Object)(object)instance.GetHighlightedBuilding() != (Object)(object)building)
{
((ClickableSprite)component).OnPointerEnter(val3);
}
}
private static bool IsClearVisitPoint(Collider2D target, Vector2 point)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (!target.OverlapPoint(point))
{
return false;
}
Collider2D[] array = Physics2D.OverlapCircleAll(point, 0.18f, ShaderParameters.LayerMaskUI);
if (array.Length == 1)
{
return (Object)(object)array[0] == (Object)(object)target;
}
return false;
}
private void OnDisable()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)frame != (Object)null)
{
RectTransform obj = frame;
obj.anchoredPosition -= Vector2.up * appliedShift;
}
appliedShift = 0f;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
[BepInPlugin("sfk.productionbottlenecks", "Production Bottlenecks", "0.2.4")]
public sealed class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIOverlayVariable), "Generate", new Type[]
{
typeof(Building),
typeof(List<UIBuildingOverlayElement>),
typeof(string)
})]
private static class BuildingPanel
{
private static void Postfix(UIOverlayVariable __instance, Building building, bool __runOriginal)
{
if ((Object)(object)instance == (Object)null)
{
return;
}
if (__runOriginal && !instance.openingList)
{
BuildingCity val = (BuildingCity)(object)((building is BuildingCity) ? building : null);
if (val != null)
{
instance.AttachRow(__instance, val);
return;
}
}
instance.ReleasePanelRow(__instance);
}
}
[HarmonyPatch(typeof(UIOverlayVariable), "Generate", new Type[]
{
typeof(BuildingWorld),
typeof(List<UIBuildingOverlayElement>),
typeof(string)
})]
private static class WorldBuildingPanel
{
private static void Postfix(UIOverlayVariable __instance)
{
if ((Object)(object)instance != (Object)null)
{
instance.ReleasePanelRow(__instance);
}
}
}
[HarmonyPatch(typeof(UIBuildingWarnings), "UIBuildingOnMouseEnter")]
private static class BuildingWarning
{
private static void Postfix(Building building, LocalizedString ___stringMissing, LocalizedString ___stringStorageFull, LocalizedString ___stringBadWeather, bool __runOriginal)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Invalid comparison between Unknown and I4
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.instance == (Object)null)
{
return;
}
Plugin.instance.nativeWarningOwner = null;
Plugin.instance.nativeWarningText = null;
Plugin.instance.emptyOutputWarning = false;
TooltipManager instance = TooltipManager.Instance;
if (!__runOriginal || (Object)(object)building == (Object)null || building.IsOutside() || (Object)(object)instance == (Object)null || !instance.IsOpen())
{
return;
}
string text = ((TMP_Text)TooltipLabel.Invoke(instance)).text;
ResourceType missingResource = building.GetMissingResource();
ResourceData val = (((int)missingResource != 0 && (Object)(object)RaceManager.Instance != (Object)null) ? RaceManager.Instance.GetResourceData(missingResource) : null);
bool flag = ((Object)(object)val != (Object)null && text == ___stringMissing.GetLocalizedString(new object[1] { val.GetName() })) || ((int)building.GetWeatherRestriction() != 0 && text == ___stringBadWeather.GetLocalizedString());
if (!flag && building.IsProducer() && text == ___stringStorageFull.GetLocalizedString())
{
ResourceStorage storage = building.GetStorage();
int[] array = (((Object)(object)storage != (Object)null) ? storage.GetStorageSpaces() : null);
ResourceType resource = building.GetResource();
if (array != null && (int)resource < array.Length && storage.SpaceForResource(resource, false) <= 0)
{
flag = true;
Plugin.instance.emptyOutputWarning = (int)resource == 0 || storage.GetStorageSpace(resource) == 0;
}
}
if (flag)
{
Plugin.instance.nativeWarningOwner = building;
Plugin.instance.nativeWarningText = text;
}
}
}
[HarmonyPatch(typeof(GameInputManager), "DisplayWorkerAmount")]
private static class WorkerCount
{
[HarmonyPriority(0)]
private static void Prefix(BuildingCity __0, bool __runOriginal, out bool __state)
{
TooltipManager instance = TooltipManager.Instance;
__state = __runOriginal && (Object)(object)Plugin.instance != (Object)null && (Object)(object)__0 != (Object)null && (Object)(object)instance != (Object)null && (Object)(object)GamepadManager.Instance != (Object)null && GamepadManager.Instance.IsGamepadInUse();
if (__state)
{
instance.StopFollowMouse();
instance.SetAnchor((AnchorPresets)1);
}
}
private static void Postfix(BuildingCity __0, bool __state, bool __runOriginal)
{
if (__state && __runOriginal)
{
TooltipManager instance = TooltipManager.Instance;
if (instance.IsOpen())
{
Plugin.instance.workerCountBuilding = __0;
Plugin.instance.workerCountText = ((TMP_Text)TooltipLabel.Invoke(instance)).text;
Plugin.instance.PlaceWorkerCount(instance);
}
}
}
}
private UIOverlayVariable rowPanel;
private GameObject launcher;
private bool openingList;
private const string Id = "sfk.productionbottlenecks";
private static Plugin instance;
private Harmony patches;
private BuildingCity hovered;
private string tooltipText;
private HoverVisibility hoverVisibility;
private Building nativeWarningOwner;
private string nativeWarningText;
private bool emptyOutputWarning;
private bool gamepad;
private BuildingCity workerCountBuilding;
private string workerCountText;
private float nextRefresh;
private BuildingCity selected;
private GameObject row;
private TextMeshProUGUI label;
private static readonly FieldRef<TooltipManager, TextMeshProUGUI> TooltipLabel = AccessTools.FieldRefAccess<TooltipManager, TextMeshProUGUI>("text");
private static readonly FieldRef<TooltipManager, RectTransform> TooltipFrame = AccessTools.FieldRefAccess<TooltipManager, RectTransform>("rectTransform");
private void OpenBlockedList(BuildingCity source)
{
if ((Object)(object)source == (Object)null || (Object)(object)selected != (Object)(object)source || (Object)(object)rowPanel == (Object)null)
{
return;
}
OverlayManager val = OverlayManager.Instance;
if (!val.IsOpen() || !val.CloseOverlay(false) || val.IsOpen())
{
return;
}
openingList = true;
try
{
val.OverlayVariable((Building)(object)source, new List<UIBuildingOverlayElement>(), "Blocked Buildings");
BlockedBuildingsList.Open(val.GetOverlaySelection());
}
finally
{
openingList = false;
}
}
private void ReleasePanelRow(UIOverlayVariable panel)
{
if ((Object)(object)rowPanel == (Object)(object)panel)
{
ReleaseRow();
}
}
private void ReleaseRow()
{
if ((Object)(object)launcher != (Object)null)
{
launcher.SetActive(false);
Object.Destroy((Object)(object)launcher);
launcher = null;
}
if ((Object)(object)row != (Object)null)
{
row.SetActive(false);
Object.Destroy((Object)(object)row);
}
rowPanel = null;
row = null;
label = null;
selected = null;
}
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;
patches = new Harmony("sfk.productionbottlenecks");
try
{
patches.PatchAll(typeof(BuildingWarning));
patches.PatchAll(typeof(BuildingPanel));
patches.PatchAll(typeof(WorldBuildingPanel));
patches.PatchAll(typeof(WorkerCount));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Production Bottlenecks ready.");
}
catch
{
patches.UnpatchSelf();
instance = null;
((Behaviour)this).enabled = false;
throw;
}
}
private void PlaceWorkerCount(TooltipManager tip)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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_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_0047: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = GamepadManager.Instance.GetCursorPosition();
Camera val2 = (((Object)(object)GameCamera.Instance != (Object)null) ? GameCamera.Instance.GetCamera() : null);
if ((Object)(object)val2 != (Object)null)
{
Vector3 val3 = val2.WorldToScreenPoint(((Component)workerCountBuilding).transform.position);
if (val3.z > 0f)
{
val = Vector2.op_Implicit(val3);
}
}
TextMeshProUGUI val4 = TooltipLabel.Invoke(tip);
Vector3 lossyScale = ((Transform)TooltipFrame.Invoke(tip)).lossyScale;
(float, float) size = ((((TMP_Text)val4).preferredWidth + 20f) * lossyScale.x, (((TMP_Text)val4).preferredHeight + 10f) * lossyScale.y);
Rect safeArea = Screen.safeArea;
(float, float) tuple = HoverTooltip.FitBelowFocus((X: val.x, Y: val.y - 24f * SettingsManager.Instance.GetUIScaling()), size, (Left: ((Rect)(ref safeArea)).xMin, Bottom: ((Rect)(ref safeArea)).yMin, Right: ((Rect)(ref safeArea)).xMax, Top: ((Rect)(ref safeArea)).yMax), val.y);
((Component)tip).transform.position = new Vector3(tuple.Item1, tuple.Item2, ((Component)tip).transform.position.z);
}
private void RefreshWorkerCount(BuildingCity target, bool usingGamepad)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
if (workerCountText == null)
{
return;
}
TooltipManager val = TooltipManager.Instance;
if ((Object)(object)val != (Object)null && val.IsOpen() && ((TMP_Text)TooltipLabel.Invoke(val)).text == workerCountText)
{
if ((Object)(object)target != (Object)null && (Object)(object)target == (Object)(object)workerCountBuilding)
{
if (usingGamepad)
{
PlaceWorkerCount(val);
return;
}
val.FollowMouse();
val.SetAnchor((AnchorPresets)0);
val.Display(workerCountText, Vector3.zero, true);
}
else
{
val.StopFollowMouse();
}
}
workerCountText = null;
workerCountBuilding = null;
}
private void AttachRow(UIOverlayVariable panel, BuildingCity city)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
ReleaseRow();
GameObject val = Resources.Load<GameObject>("UI/OverlayElementText");
if ((Object)(object)val == (Object)null)
{
return;
}
row = Object.Instantiate<GameObject>(val, ((Component)panel).transform);
label = row.GetComponentInChildren<TextMeshProUGUI>(true);
if ((Object)(object)label == (Object)null)
{
ReleaseRow();
return;
}
Graphic[] componentsInChildren = row.GetComponentsInChildren<Graphic>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].raycastTarget = false;
}
launcher = BlockedBuildingsList.AddLauncher(((Component)panel).transform, (UnityAction)delegate
{
OpenBlockedList(city);
});
rowPanel = panel;
selected = city;
UpdateRow();
}
private void UpdateRow()
{
string text = (((Object)(object)selected != (Object)null) ? ProductionStatus.Read(selected, RowIcon) : null);
if (text != null && ((TMP_Text)label).text != text)
{
((TMP_Text)label).text = text;
}
if (row.activeSelf != (text != null))
{
row.SetActive(text != null);
}
}
private void LateUpdate()
{
if ((Object)(object)GameManager.Instance == (Object)null || !GameManager.Instance.IsGameLoaded() || GameManager.Instance.IsUnloading())
{
ClearTooltip();
RefreshWorkerCount(null, usingGamepad: false);
hovered = null;
hoverVisibility = default(HoverVisibility);
return;
}
UIManager val = UIManager.Instance;
CityManager val2 = CityManager.Instance;
BuildingCity val3 = (((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)OverlayManager.Instance != (Object)null && (Object)(object)PauseMenuManger.Instance != (Object)null && val.IsWorldInteractable()) ? val2.GetHighlightedBuilding() : null);
bool flag = (Object)(object)GamepadManager.Instance != (Object)null && GamepadManager.Instance.IsGamepadInUse();
RefreshWorkerCount(val3, flag);
int num;
if (!((Object)(object)val3 != (Object)(object)hovered))
{
num = ((gamepad != flag) ? 1 : 0);
if (num == 0 && (!((Object)(object)val3 == (Object)null) || tooltipText == null))
{
goto IL_0119;
}
}
else
{
num = 1;
}
bool flag2 = ClearTooltip();
if ((Object)(object)val3 != (Object)(object)hovered || flag2)
{
hoverVisibility = default(HoverVisibility);
}
hovered = val3;
gamepad = flag;
goto IL_0119;
IL_0119:
if (!gamepad && tooltipText != null)
{
FitMouseTooltip();
}
if (num != 0 || !(Time.unscaledTime < nextRefresh))
{
nextRefresh = Time.unscaledTime + 0.2f;
if ((Object)(object)row != (Object)null && (Object)(object)label != (Object)null && ((Component)row.transform.parent).gameObject.activeInHierarchy)
{
UpdateRow();
}
if ((Object)(object)val3 != (Object)null)
{
UpdateTooltip(ProductionStatus.Read(val3, TooltipIcon));
}
}
}
private string RowIcon(Sprite sprite)
{
return ResourceIcon.Tag(label, sprite);
}
private void FitMouseTooltip()
{
//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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
TooltipManager val = TooltipManager.Instance;
if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled || !val.IsOpen() || ((TMP_Text)TooltipLabel.Invoke(val)).text != tooltipText)
{
return;
}
RectTransform val2 = TooltipFrame.Invoke(val);
if (((Component)val2).gameObject.activeInHierarchy)
{
Vector3 position = ((Component)val).transform.position;
Rect rect = val2.rect;
Vector2 val3 = Vector2.Scale(((Rect)(ref rect)).size, Vector2.op_Implicit(((Transform)val2).lossyScale));
Rect safeArea = Screen.safeArea;
(float, float) tuple = HoverTooltip.FitBelowFocus((X: position.x, Y: position.y), (Width: val3.x, Height: val3.y), (Left: ((Rect)(ref safeArea)).xMin, Bottom: ((Rect)(ref safeArea)).yMin, Right: ((Rect)(ref safeArea)).xMax, Top: ((Rect)(ref safeArea)).yMax), GamepadManager.Instance.GetCursorPosition().y);
if (tuple.Item1 != position.x || tuple.Item2 != position.y)
{
((Component)val).transform.position = new Vector3(tuple.Item1, tuple.Item2, position.z);
}
}
}
private string TooltipIcon(Sprite sprite)
{
TooltipManager val = TooltipManager.Instance;
if (!((Object)(object)val != (Object)null))
{
return null;
}
return ResourceIcon.Tag(TooltipLabel.Invoke(val), sprite);
}
private void UpdateTooltip(string reason)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
TooltipManager val = TooltipManager.Instance;
if ((Object)(object)val == (Object)null)
{
return;
}
bool flag = val.IsOpen();
bool flag2 = hoverVisibility.Observe(reason, flag);
if (reason == null && tooltipText == null && (Object)(object)nativeWarningOwner != (Object)(object)hovered)
{
return;
}
string text = (flag ? ((TMP_Text)TooltipLabel.Invoke(val)).text : null);
if (text != tooltipText)
{
tooltipText = null;
}
if (flag2)
{
return;
}
string text2 = HoverTooltip.NextText(((Building)hovered).GetTitle(), reason, text, tooltipText, ((Object)(object)nativeWarningOwner == (Object)(object)hovered) ? nativeWarningText : null, emptyOutputWarning);
if (text2 != null)
{
val.StopFollowMouse();
val.SetAnchor((AnchorPresets)(reason != null));
Vector3 val2 = Vector3.zero;
if (gamepad)
{
val2 = Vector2.op_Implicit(GamepadManager.Instance.GetCursorPosition());
val2.y -= 24f * SettingsManager.Instance.GetUIScaling();
}
else
{
val.FollowMouse();
}
tooltipText = ((reason == null) ? null : text2);
val.Display(text2, val2, false);
hoverVisibility.Observe(reason, val.IsOpen());
}
}
private bool ClearTooltip()
{
TooltipManager val = TooltipManager.Instance;
int num;
if (tooltipText != null && (Object)(object)val != (Object)null && val.IsOpen())
{
num = ((((TMP_Text)TooltipLabel.Invoke(val)).text == tooltipText) ? 1 : 0);
if (num != 0)
{
val.StopFollowMouse();
}
}
else
{
num = 0;
}
tooltipText = null;
return (byte)num != 0;
}
private void OnDestroy()
{
ClearTooltip();
ReleaseRow();
Harmony obj = patches;
if (obj != null)
{
obj.UnpatchSelf();
}
instance = null;
}
}
internal struct HoverVisibility
{
private string lastReason;
private bool wasOpen;
private bool dismissed;
internal bool Observe(string reason, bool open)
{
if (reason != lastReason || reason == null)
{
dismissed = false;
}
else if (wasOpen && !open)
{
dismissed = true;
}
lastReason = reason;
wasOpen = open;
return dismissed;
}
}
internal static class HoverTooltip
{
internal static (float X, float Y) FitBelowFocus((float X, float Y) anchor, (float Width, float Height) size, (float Left, float Bottom, float Right, float Top) area, float focusY)
{
float num = Math.Max(area.Left, Math.Min(anchor.X - size.Width / 2f, area.Right - size.Width));
float num2 = anchor.Y;
if (num2 - size.Height < area.Bottom)
{
num2 = focusY + (focusY - anchor.Y) + size.Height;
}
return new ValueTuple<float, float>(item2: Math.Min(area.Top, Math.Max(num2, area.Bottom + size.Height)), item1: num + size.Width / 2f);
}
internal static string NextText(string title, string reason, string visible, string owned, string nativeWarning = null, bool emptyOutputWarning = false)
{
if (visible != null && visible != title && visible != owned && visible != nativeWarning)
{
return null;
}
if (reason == null)
{
if (visible == null || (!(visible == owned) && (!emptyOutputWarning || !(visible == nativeWarning))))
{
return null;
}
return title;
}
string text = title + "\n" + reason;
if (!(text != visible))
{
return null;
}
return text;
}
}
internal static class ProductionStatus
{
internal static string Read(BuildingCity city, Func<Sprite, string> iconTag)
{
//IL_0001: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Invalid comparison between Unknown and I4
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
if ((int)((Building)city).GetWeatherRestriction() != 0)
{
return "Waiting for better weather";
}
SpriteRenderer outOfWorkRenderer = city.GetOutOfWorkRenderer();
bool flag = (Object)(object)outOfWorkRenderer != (Object)null && ((Renderer)outOfWorkRenderer).enabled && ((Component)outOfWorkRenderer).gameObject.activeInHierarchy;
bool flag2 = city.GetCurrentlyWorking() > 0 || city.IsUpgradeWorking() || city.GetCurrentlyInside() > 0;
ResourceType missingResource = ((Building)city).GetMissingResource();
if (flag2 && !flag && ((Object)(object)outOfWorkRenderer != (Object)null || (int)missingResource == 0))
{
return null;
}
List<CraftingRecipe> craftingRecipes = city.GetCraftingRecipes(false);
bool flag3 = ((Building)city).IsProducer() || ((Building)city).IsProcessor() || (craftingRecipes != null && craftingRecipes.Count > 0);
if (!flag3 && !flag && (int)missingResource == 0)
{
return null;
}
int num = city.GetCurrentlyCrafting();
BuildingDemand val = (BuildingDemand)(object)((city is BuildingDemand) ? city : null);
if (val != null)
{
if (val.IsCrafting() && !flag)
{
return null;
}
if (!val.IsStarted() && !val.IsCrafting())
{
List<int> queue = ((BuildingCity)val).GetQueue();
if (queue == null || queue.Count == 0)
{
if (!flag)
{
return null;
}
return "Queue a task";
}
num = queue[0];
}
}
CraftingRecipe? val2 = ((craftingRecipes != null && (uint)num < (uint)craftingRecipes.Count) ? new CraftingRecipe?(craftingRecipes[num]) : ((CraftingRecipe?)null));
ResourceType val3 = (ResourceType)(((craftingRecipes == null || craftingRecipes.Count <= 0) && !(city is BuildingCrafting)) ? ((int)((Building)city).GetResource()) : (val2.HasValue ? ((int)val2.GetValueOrDefault().product) : 0));
if ((int)val3 != 0)
{
BuildingCrafting val4 = (BuildingCrafting)(object)((city is BuildingCrafting) ? city : null);
if (val4 != null && !val4.IsProductReal(val3))
{
val3 = (ResourceType)0;
}
}
ResourceStorage storage = ((Building)city).GetStorage();
int[] array = (((Object)(object)storage != (Object)null) ? storage.GetStorageSpaces() : null);
bool flag4 = (int)val3 != 0 && array != null && (int)val3 < array.Length && storage.GetStorageSpace(val3) > 0;
if (!flag && flag4 && city is BuildingCrafting && storage.GetAnnouncedResourceQuantity(val3) > 0)
{
return null;
}
if (!((Building)city).IsOutside() && !(city is BuildingGeneratingg) && !(city is BuildingVeinGenerate) && !(city is BuildingVeinGenerateMorning) && (flag3 || flag))
{
bool num2;
if ((int)city.GetBuildingSize() != 0 || !((Building)city).CanUpgradeBeActivated())
{
if (((Building)city).GetMaxWorkers() <= 0 || city.GetPossibleWorkers() != 0)
{
goto IL_0256;
}
num2 = city.GetPossibleJobs() == 0;
}
else
{
num2 = !((Building)city).IsUpgradeActive();
}
if (num2)
{
return "No worker assigned";
}
}
goto IL_0256;
IL_0256:
if (flag4 && storage.SpaceForResource(val3, false) <= 0)
{
return "Output storage full";
}
if ((int)missingResource != 0)
{
BuildingDemand val5 = (BuildingDemand)(object)((city is BuildingDemand) ? city : null);
return FormatShortage(city, missingResource, (val5 != null && val5.IsCrafting()) ? ((CraftingRecipe?)null) : val2, iconTag);
}
if (!flag)
{
return null;
}
if (!flag2)
{
return "Idle";
}
return "Work blocked";
}
private static string FormatShortage(BuildingCity city, ResourceType missing, CraftingRecipe? recipe, Func<Sprite, string> iconTag)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
RaceManager instance = RaceManager.Instance;
ResourceData val = (((Object)(object)instance != (Object)null) ? instance.GetResourceData(missing) : null);
Sprite val2 = (((Object)(object)instance != (Object)null) ? instance.GetResourceIcon(missing) : null);
string text = (((Object)(object)val != (Object)null) ? val.GetName() : null);
string text2 = ((!((Object)(object)val2 != (Object)null)) ? null : iconTag?.Invoke(val2));
if (string.IsNullOrEmpty(text) && text2 == null)
{
return "Missing resource";
}
string text3 = ((text2 != null) ? (text2 + " " + text).TrimEnd() : text);
ResourceAmount[] array = recipe?.ingredients;
ResourceStorage storage = ((Building)city).GetStorage();
int[] array2 = (((Object)(object)storage != (Object)null) ? storage.GetAllResourceQuantity() : null);
if (array != null && array2 != null && (int)missing < array2.Length)
{
int num = 0;
ResourceAmount[] array3 = array;
foreach (ResourceAmount val3 in array3)
{
if (val3.type == missing)
{
if (num > 0 || val3.amount <= 0)
{
return "Needs " + text3;
}
num = val3.amount;
}
}
if (num == 0 && array.Length != 0)
{
return "Reported shortage of " + text3;
}
int resourceQuantity = ((Building)city).GetResourceQuantity(missing, false);
if (resourceQuantity >= 0 && num > resourceQuantity)
{
return "Needs " + (num - resourceQuantity) + " " + text3;
}
if (num > 0 && resourceQuantity >= num)
{
return "Reported shortage of " + text3;
}
}
return "Needs " + text3;
}
}
internal static class ResourceIcon
{
private static readonly Dictionary<Sprite, string> CustomTags = new Dictionary<Sprite, string>();
private static readonly char[] InvalidName = new char[3] { '"', '<', '>' };
internal static bool MatchesGlyph(TMP_SpriteAsset atlas, int index, string name, Sprite sprite)
{
if ((Object)(object)atlas != (Object)null && index >= 0 && index < atlas.spriteCharacterTable.Count && atlas.GetSpriteIndexFromName(name) == index)
{
TMP_SpriteCharacter obj = atlas.spriteCharacterTable[index];
Glyph obj2 = ((obj != null) ? ((TMP_TextElement)obj).glyph : null);
TMP_SpriteGlyph val = (TMP_SpriteGlyph)(object)((obj2 is TMP_SpriteGlyph) ? obj2 : null);
if (val != null)
{
return (Object)(object)val.sprite == (Object)(object)sprite;
}
}
return false;
}
internal static string Tag(TextMeshProUGUI label, Sprite sprite)
{
//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)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Expected O, but got Unknown
if ((Object)(object)label == (Object)null || !((TMP_Text)label).richText)
{
return null;
}
string name = ((Object)sprite).name;
TMP_SpriteAsset val = (((Object)(object)((TMP_Text)label).spriteAsset != (Object)null) ? ((TMP_Text)label).spriteAsset : TMP_Settings.defaultSpriteAsset);
int index = default(int);
if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(name) && name.IndexOfAny(InvalidName) < 0 && MatchesGlyph(TMP_SpriteAsset.SearchForSpriteByHashCode(val, TMP_TextUtilities.GetSimpleHashCode(name), true, ref index), index, name, sprite))
{
return "<sprite name=\"" + name + "\">";
}
if (CustomTags.TryGetValue(sprite, out var value))
{
return value;
}
if ((Object)(object)sprite.texture == (Object)null || (sprite.packed && ((int)sprite.packingMode == 0 || (int)sprite.packingRotation != 0)))
{
return null;
}
Rect textureRect = sprite.textureRect;
Shader val2 = Shader.Find("TextMeshPro/Sprite");
if ((Object)(object)val2 == (Object)null || ((Rect)(ref textureRect)).width <= 0f || ((Rect)(ref textureRect)).height <= 0f)
{
return null;
}
string text = "ProductionBottlenecks_" + ((Object)sprite).GetInstanceID();
int simpleHashCode = TMP_TextUtilities.GetSimpleHashCode(text);
TMP_SpriteAsset val3 = default(TMP_SpriteAsset);
while (MaterialReferenceManager.TryGetSpriteAsset(simpleHashCode, ref val3))
{
text += "_";
simpleHashCode = TMP_TextUtilities.GetSimpleHashCode(text);
}
TMP_SpriteAsset val4 = ScriptableObject.CreateInstance<TMP_SpriteAsset>();
((Object)val4).name = text;
val4.spriteSheet = (Texture)(object)sprite.texture;
((TMP_Asset)val4).material = new Material(val2)
{
mainTexture = (Texture)(object)sprite.texture
};
val4.spriteInfoList = new List<TMP_Sprite>
{
new TMP_Sprite
{
name = "Resource",
sprite = sprite,
x = ((Rect)(ref textureRect)).x,
y = ((Rect)(ref textureRect)).y,
width = ((Rect)(ref textureRect)).width,
height = ((Rect)(ref textureRect)).height,
yOffset = ((Rect)(ref textureRect)).height,
xAdvance = ((Rect)(ref textureRect)).width,
scale = 1f
}
};
val4.UpdateLookupTables();
MaterialReferenceManager.AddSpriteAsset(simpleHashCode, val4);
value = "<sprite=\"" + text + "\" index=0>";
CustomTags.Add(sprite, value);
return value;
}
}
internal static class VisitPoint
{
internal const float Clearance = 0.18f;
internal static (float X, float Y)? Choose((float X, float Y) center, (float X, float Y) pivot, float halfWidth, float halfHeight, bool trigger, Func<float, float, bool> clear)
{
if (!trigger)
{
if (!clear(pivot.X, pivot.Y))
{
return null;
}
return pivot;
}
if (clear(center.X, center.Y))
{
return center;
}
(float, float) tuple = pivot;
(float, float) tuple2 = center;
if ((tuple.Item1 != tuple2.Item1 || tuple.Item2 != tuple2.Item2) && clear(pivot.X, pivot.Y))
{
return pivot;
}
float[] array = new float[2] { 0.5f, 0.85f };
foreach (float num in array)
{
for (int j = -1; j <= 1; j++)
{
for (int k = -1; k <= 1; k++)
{
if (k != 0 || j != 0)
{
(float, float) value = (center.X + (float)k * halfWidth * num, center.Y + (float)j * halfHeight * num);
if (clear(value.Item1, value.Item2))
{
return value;
}
}
}
}
}
return null;
}
}