using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Network; using ProjectM.Shared.WarEvents; using ProjectM.Shared.WorldEvents; using ProjectM.Terrain; using ProjectM.UI; using Stunlock.Core; using Stunlock.Localization; using TMPro; using Unity.Collections; using Unity.Entities; using Unity.Transforms; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("HuntsAndRifts")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Client-only V Rising UI: servant hunts grouped with timers, power and specializations, click-to-focus map; both Mortium Rift tiers with timers on the map card and plot tooltips; pickup bag totals.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HuntsAndRifts")] [assembly: AssemblyTitle("HuntsAndRifts")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HuntClock { public static class MyPluginInfo { public const string PLUGIN_GUID = "fangly.HuntsAndRifts"; public const string PLUGIN_NAME = "HuntsAndRifts"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace HuntsAndRifts { internal static class HuntHeaders { internal sealed class Header { public GameObject Root; public RectTransform Rect; public Image Bg; public TextMeshProUGUI Title; public TextMeshProUGUI Right; public readonly Image[] Icons = (Image[])(object)new Image[4]; public readonly Image[] Rings = (Image[])(object)new Image[4]; public string Dest; public string FirstServant; public int Mission; public string LastTitle; public float Width; public int IconCount = 2; public float CardHeight; public IntPtr EntryPointer; } private const float IconSize = 20f; private const float IconGap = 3f; private const float RightTextWidth = 40f; private const float Pad = 8f; internal const string HeaderPrefix = "HuntsAndRifts_Hunt_"; private static readonly Dictionary ByEntry = new Dictionary(); private static readonly Dictionary ByRoot = new Dictionary(); private static readonly Dictionary ByDest = new Dictionary(StringComparer.Ordinal); private static bool _loggedOnce; internal const float HeaderHeight = 24f; internal static IEnumerable
All => ByDest.Values; internal static bool TryGetByEntry(IntPtr entryPointer, out Header header) { if (ByEntry.TryGetValue(entryPointer, out header)) { return header != null; } return false; } internal static Header FindByRoot(Transform root) { if ((Object)(object)root == (Object)null) { return null; } if (!ByRoot.TryGetValue(((Il2CppObjectBase)root).Pointer, out var value)) { return null; } return value; } internal static void SetCardHeight(Header h, float height) { //IL_003a: 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) if (h != null && !((Object)(object)h.Bg == (Object)null) && !(Mathf.Abs(h.CardHeight - height) < 0.5f)) { h.CardHeight = height; RectTransform rectTransform = ((Graphic)h.Bg).rectTransform; rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Mathf.Max(24f, height)); } } internal static void Clear() { foreach (KeyValuePair item in ByDest) { try { if ((Object)(object)item.Value.Root != (Object)null && item.Value.Root.activeSelf) { item.Value.Root.SetActive(false); } if ((Object)(object)item.Value.Root != (Object)null) { Object.Destroy((Object)(object)item.Value.Root); } } catch { } } ByDest.Clear(); ByRoot.Clear(); ByEntry.Clear(); } internal static Header Get(string dest, Transform gridParent, TextMeshProUGUI fontTemplate, RectTransform rowTemplate, float contentWidth) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(dest) || (Object)(object)gridParent == (Object)null) { return null; } if (ByDest.TryGetValue(dest, out var value) && (Object)(object)value.Root != (Object)null) { if ((Object)(object)ServantScroll.OriginalParent(value.Root.transform.parent) != (Object)(object)gridParent) { value.Root.transform.SetParent(gridParent, false); } MatchRow(value, rowTemplate); Layout(value, contentWidth); return value; } try { value = Build(dest, gridParent, fontTemplate); MatchRow(value, rowTemplate); Layout(value, contentWidth); ByDest[dest] = value; ByRoot[((Il2CppObjectBase)value.Root.transform).Pointer] = value; if (!_loggedOnce) { _loggedOnce = true; object obj; if (!((Object)(object)rowTemplate != (Object)null)) { obj = "?"; } else { Rect rect = rowTemplate.rect; obj = ((object)((Rect)(ref rect)).size/*cast due to .constrained prefix*/).ToString(); } string text = (string)obj; string text2 = ""; try { GridLayoutGroup component = ((Component)gridParent).GetComponent(); if ((Object)(object)component != (Object)null) { text2 = "GridLayoutGroup cell " + ((object)component.cellSize/*cast due to .constrained prefix*/).ToString(); } else if ((Object)(object)((Component)gridParent).GetComponent() != (Object)null) { text2 = "VerticalLayoutGroup"; } } catch { } ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: hunt header rows added to " + ((Object)gridParent).name + " (row " + text + ", " + text2 + ", content width " + contentWidth.ToString("0") + ").")); } } return value; } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts header build: " + ex.Message)); } return null; } } private static void MatchRow(Header h, RectTransform row) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0140: 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_0038: 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_0068: 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_0081: 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_0076: 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_00a8: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (h == null || (Object)(object)h.Rect == (Object)null || (Object)(object)row == (Object)null) { return; } try { RectTransform rect = h.Rect; if (rect.anchorMin != row.anchorMin) { rect.anchorMin = row.anchorMin; } if (rect.anchorMax != row.anchorMax) { rect.anchorMax = row.anchorMax; } if (rect.pivot != row.pivot) { rect.pivot = row.pivot; } if (rect.sizeDelta != row.sizeDelta) { rect.sizeDelta = row.sizeDelta; } Rect rect2 = row.rect; Vector2 size = ((Rect)(ref rect2)).size; if (size.x > 1f && size.y > 1f) { LayoutElement val = h.Root.GetComponent(); if ((Object)(object)val == (Object)null) { val = h.Root.AddComponent(); } LayoutElement val2 = null; try { val2 = ((Component)row).GetComponent(); } catch { } float num = (((Object)(object)val2 != (Object)null && val2.preferredWidth > 0f) ? val2.preferredWidth : size.x); float num2 = (((Object)(object)val2 != (Object)null && val2.preferredHeight > 0f) ? val2.preferredHeight : size.y); if (val.preferredWidth != num) { val.preferredWidth = num; } if (val.preferredHeight != num2) { val.preferredHeight = num2; } if (val.minWidth != num) { val.minWidth = num; } if (val.minHeight != num2) { val.minHeight = num2; } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts header size: " + ex.Message)); } } } private static void Layout(Header h, float width) { //IL_0051: 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_007b: 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_00a1: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0275: 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_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) if (h == null || width < 60f) { return; } try { if (Mathf.Abs(h.Width - width) < 0.5f) { return; } h.Width = width; if ((Object)(object)h.Bg != (Object)null) { RectTransform rectTransform = ((Graphic)h.Bg).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.sizeDelta = new Vector2(width, Mathf.Max(24f, h.CardHeight)); rectTransform.anchoredPosition = Vector2.zero; } float num = 40f; float num2 = (float)Mathf.Max(1, h.IconCount) * 23f; if ((Object)(object)h.Title != (Object)null) { RectTransform rectTransform2 = ((TMP_Text)h.Title).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(0f, 1f); rectTransform2.pivot = new Vector2(0f, 0.5f); rectTransform2.sizeDelta = new Vector2(Mathf.Max(40f, width - 16f - num - num2 - 6f), 0f); rectTransform2.anchoredPosition = new Vector2(8f, 0f); } if ((Object)(object)h.Right != (Object)null) { RectTransform rectTransform3 = ((TMP_Text)h.Right).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 0f); rectTransform3.anchorMax = new Vector2(0f, 1f); rectTransform3.pivot = new Vector2(1f, 0.5f); rectTransform3.sizeDelta = new Vector2(num, 0f); rectTransform3.anchoredPosition = new Vector2(width - 8f, 0f); } for (int i = 0; i < h.Icons.Length; i++) { Image val = h.Icons[i]; if (!((Object)(object)val == (Object)null)) { float num3 = width - 8f - num - 6f - (float)i * 23f; RectTransform rectTransform4 = ((Graphic)val).rectTransform; rectTransform4.anchorMin = new Vector2(0f, 0.5f); rectTransform4.anchorMax = new Vector2(0f, 0.5f); rectTransform4.pivot = new Vector2(1f, 0.5f); rectTransform4.sizeDelta = new Vector2(20f, 20f); rectTransform4.anchoredPosition = new Vector2(num3, 0f); Image val2 = h.Rings[i]; if ((Object)(object)val2 != (Object)null) { RectTransform rectTransform5 = ((Graphic)val2).rectTransform; rectTransform5.anchorMin = new Vector2(0f, 0.5f); rectTransform5.anchorMax = new Vector2(0f, 0.5f); rectTransform5.pivot = new Vector2(1f, 0.5f); rectTransform5.sizeDelta = new Vector2(26f, 26f); rectTransform5.anchoredPosition = new Vector2(num3 + 3f, 0f); ((Component)val2).transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex()); } } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts header layout: " + ex.Message)); } } } private static Header Build(string dest, Transform gridParent, TextMeshProUGUI template) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) string text = "HuntsAndRifts_Hunt_" + dest; GameObject val = null; Transform val2 = gridParent.Find(text); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).gameObject; } if ((Object)(object)val == (Object)null) { val = new GameObject(text); RectTransform obj = val.AddComponent(); ((Transform)obj).SetParent(gridParent, false); ((Transform)obj).localScale = Vector3.one; } Header header = new Header { Root = val, Rect = val.GetComponent(), Dest = dest }; header.Bg = GetOrMake(val.transform, "Bg", (Func)delegate(GameObject go) { //IL_0007: 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_001d: 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_0053: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image obj2 = go.AddComponent(); ((Graphic)obj2).raycastTarget = true; ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.35f); return obj2; }); try { GridSelectionEntry val3 = val.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = val.AddComponent(); } header.EntryPointer = ((Il2CppObjectBase)val3).Pointer; ByEntry[header.EntryPointer] = header; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts header entry: " + ex.Message)); } } header.Title = GetOrMake(val.transform, "Title", (Func)delegate(GameObject go) { //IL_0011: 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_003b: 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) RectTransform component = go.GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.offsetMin = new Vector2(8f, 0f); component.offsetMax = new Vector2(-140f, 0f); TextMeshProUGUI val4 = go.AddComponent(); ((TMP_Text)val4).richText = true; ((Graphic)val4).raycastTarget = false; ((TMP_Text)val4).enableWordWrapping = false; ((TMP_Text)val4).overflowMode = (TextOverflowModes)1; ((TMP_Text)val4).alignment = (TextAlignmentOptions)4097; CopyFont(val4, (TMP_Text)(object)template); try { ((TMP_Text)val4).fontSize = ((TMP_Text)val4).fontSize * 0.95f; } catch { } return val4; }); header.Right = GetOrMake(val.transform, "Right", (Func)delegate(GameObject go) { //IL_0011: 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_003b: 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_0064: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.offsetMin = new Vector2(-48f, 0f); component.offsetMax = new Vector2(-8f, 0f); TextMeshProUGUI val4 = go.AddComponent(); ((TMP_Text)val4).richText = true; ((Graphic)val4).raycastTarget = false; ((TMP_Text)val4).enableWordWrapping = false; ((TMP_Text)val4).alignment = (TextAlignmentOptions)4100; CopyFont(val4, (TMP_Text)(object)template); try { ((TMP_Text)val4).fontSize = ((TMP_Text)val4).fontSize * 0.95f; } catch { } return val4; }); for (int num = 0; num < header.Rings.Length; num++) { header.Rings[num] = GetOrMake(val.transform, "Ring" + num, (Func)delegate(GameObject go) { //IL_0011: 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_003b: 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_0079: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.sizeDelta = new Vector2(26f, 26f); Image obj2 = go.AddComponent(); ((Graphic)obj2).raycastTarget = false; obj2.sprite = RingSprite.Get(); obj2.preserveAspect = true; ((Graphic)obj2).color = RowDecor.MatchRing; go.SetActive(false); return obj2; }); } for (int num2 = 0; num2 < header.Icons.Length; num2++) { int idx = num2; header.Icons[num2] = GetOrMake(val.transform, "Icon" + num2, (Func)delegate(GameObject go) { //IL_0011: 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_003b: 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_0073: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.sizeDelta = new Vector2(20f, 20f); component.anchoredPosition = new Vector2(0f - (54f + (float)idx * 23f), 0f); Image obj2 = go.AddComponent(); ((Graphic)obj2).raycastTarget = false; obj2.preserveAspect = true; go.SetActive(false); return obj2; }); } return header; } private static T GetOrMake(Transform parent, string name, Func make) where T : Component { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) Transform val = parent.Find(name); if ((Object)(object)val != (Object)null) { T component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } } GameObject val2 = new GameObject(name); RectTransform obj = val2.AddComponent(); ((Transform)obj).SetParent(parent, false); ((Transform)obj).localScale = Vector3.one; return make(val2); } private static void CopyFont(TextMeshProUGUI tmp, TMP_Text template) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)template == (Object)null)) { ((TMP_Text)tmp).font = template.font; ((TMP_Text)tmp).fontSharedMaterial = template.fontSharedMaterial; ((TMP_Text)tmp).fontSize = template.fontSize; ((Graphic)tmp).color = ((Graphic)template).color; } } catch { } } internal static void Fill(Header h, double remainingSeconds, PrefabGUID mission, MissionInfoReader.Info info, HashSet groupPerks, Color tint, string firstServant) { //IL_0047: 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_005b: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (h == null || (Object)(object)h.Root == (Object)null) { return; } h.FirstServant = firstServant; if (!h.Root.activeSelf) { h.Root.SetActive(true); } if ((Object)(object)h.Bg != (Object)null && ((Graphic)h.Bg).color != tint) { ((Graphic)h.Bg).color = tint; } string dest = h.Dest; if ((Object)(object)h.Title != (Object)null && h.LastTitle != dest) { h.LastTitle = dest; ((TMP_Text)h.Title).text = dest; } List list = info?.Perks; int num = list?.Count ?? 0; if (num < 1) { num = 1; } if (num > h.Icons.Length) { num = h.Icons.Length; } if (num != h.IconCount) { h.IconCount = num; float width = h.Width; h.Width = -1f; Layout(h, width); } for (int i = 0; i < h.Icons.Length; i++) { Image val = h.Icons[i]; if ((Object)(object)val == (Object)null) { continue; } if (list != null && i < list.Count && ServantInfoReader.TryGetPerk(list[i], out var icon, out var _) && (Object)(object)icon != (Object)null) { if ((Object)(object)val.sprite != (Object)(object)icon) { val.sprite = icon; } int num2; if (groupPerks != null) { PrefabGUID val2 = list[i]; num2 = (groupPerks.Contains(((PrefabGUID)(ref val2)).GuidHash) ? 1 : 0); } else { num2 = 0; } bool flag = (byte)num2 != 0; if (((Graphic)val).color != Color.white) { ((Graphic)val).color = Color.white; } if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } Image val3 = h.Rings[i]; if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeSelf != flag) { ((Component)val3).gameObject.SetActive(flag); } } else { if (((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); } Image val4 = h.Rings[i]; if ((Object)(object)val4 != (Object)null && ((Component)val4).gameObject.activeSelf) { ((Component)val4).gameObject.SetActive(false); } } } if ((Object)(object)h.Right != (Object)null) { string text = ((info != null) ? ("" + info.Difficulty + "") : ""); if (((TMP_Text)h.Right).text != text) { ((TMP_Text)h.Right).text = text; } } h.Mission = ((PrefabGUID)(ref mission)).GuidHash; } internal static void FillSection(Header h, string title, Color tint) { //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_0060: Unknown result type (might be due to invalid IL or missing references) if (h == null || (Object)(object)h.Root == (Object)null) { return; } h.FirstServant = null; h.Mission = 0; if (!h.Root.activeSelf) { h.Root.SetActive(true); } if ((Object)(object)h.Bg != (Object)null && ((Graphic)h.Bg).color != tint) { ((Graphic)h.Bg).color = tint; } if ((Object)(object)h.Title != (Object)null && h.LastTitle != title) { h.LastTitle = title; ((TMP_Text)h.Title).text = title; } for (int i = 0; i < h.Icons.Length; i++) { Image val = h.Icons[i]; if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); } Image val2 = h.Rings[i]; if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(false); } } if ((Object)(object)h.Right != (Object)null && ((TMP_Text)h.Right).text != "") { ((TMP_Text)h.Right).text = ""; } } internal static void HideExcept(HashSet used) { foreach (KeyValuePair item in ByDest) { if (used != null && used.Contains(item.Key)) { continue; } try { if ((Object)(object)item.Value.Root != (Object)null && item.Value.Root.activeSelf) { item.Value.Root.SetActive(false); } } catch { } } } internal static void SweepOrphans(Transform gridParent, HashSet used) { if ((Object)(object)gridParent == (Object)null) { return; } try { int childCount = gridParent.childCount; for (int i = 0; i < childCount; i++) { Transform child = gridParent.GetChild(i); if ((Object)(object)child == (Object)null) { continue; } string name = ((Object)child).name; if (name.StartsWith("HuntsAndRifts_Hunt_", StringComparison.Ordinal)) { string item = name.Substring("HuntsAndRifts_Hunt_".Length); if ((used == null || !used.Contains(item)) && ((Component)child).gameObject.activeSelf) { ((Component)child).gameObject.SetActive(false); } } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts header sweep: " + ex.Message)); } } } } internal static class HuntMapFocus { private static MapMenuMapper _mapper; private const float FocusScale = 1f; private static int _verifyFrame = -1; private static Vector2 _verifyOffset; private static MapType _verifyType; internal unsafe static void SetMapper(MapMenuMapper mapper) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0098: 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) _mapper = mapper; if (_verifyFrame < 0 || Time.frameCount < _verifyFrame || mapper == null) { return; } _verifyFrame = -1; try { OffsetAndScale zoneOffsetAndScale = mapper.GetZoneOffsetAndScale(_verifyType, 1f); string text = "?"; try { MapMenu mapMenu = mapper.GetMapMenu(); if ((Object)(object)mapMenu != (Object)null && (Object)(object)mapMenu.MapTexture != (Object)null) { string? text2 = ((object)((Graphic)mapMenu.MapTexture).rectTransform.anchoredPosition/*cast due to .constrained prefix*/).ToString(); Rect rect = ((Graphic)mapMenu.MapTexture).rectTransform.rect; text = text2 + " size " + ((object)((Rect)(ref rect)).size/*cast due to .constrained prefix*/).ToString(); } } catch { } ManualLogSource logger = Plugin.Logger; if (logger != null) { string[] obj2 = new string[10] { "HuntsAndRifts map focus check: wanted offset ", null, null, null, null, null, null, null, null, null }; Vector2 verifyOffset = _verifyOffset; obj2[1] = ((object)(*(Vector2*)(&verifyOffset))/*cast due to .constrained prefix*/).ToString(); obj2[2] = ", zone offset now "; verifyOffset = zoneOffsetAndScale.Offset; obj2[3] = ((object)(*(Vector2*)(&verifyOffset))/*cast due to .constrained prefix*/).ToString(); obj2[4] = " scale "; obj2[5] = zoneOffsetAndScale.Scale.ToString("0.###"); obj2[6] = ", map rect "; obj2[7] = text; obj2[8] = ", pan "; obj2[9] = ((object)mapper._PanAdjust/*cast due to .constrained prefix*/).ToString(); logger.LogInfo((object)string.Concat(obj2)); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts map focus check: " + ex.Message)); } } } internal static void Clear() { _mapper = null; } internal unsafe static bool CenterOn(Vector2 worldXZ) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0163: 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_0187: 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_01a2: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) MapMenuMapper mapper = _mapper; if (mapper == null) { return false; } try { Matrix4x4 worldToAnchoredSpace = mapper._WorldToAnchoredSpace; if (IsZero(worldToAnchoredSpace)) { return false; } Vector3 val = ((Matrix4x4)(ref worldToAnchoredSpace)).MultiplyPoint(new Vector3(worldXZ.x, 0f, worldXZ.y)); if (float.IsNaN(val.x) || float.IsNaN(val.y) || float.IsInfinity(val.x) || float.IsInfinity(val.y)) { return false; } MapType lastPlayerMapType = mapper._LastPlayerMapType; OffsetAndScale zoneOffsetAndScale = mapper.GetZoneOffsetAndScale(lastPlayerMapType, 1f); float num = zoneOffsetAndScale.Scale; if (num < 1f) { num = 1f; } try { MapMenu mapMenu = mapper.GetMapMenu(); if ((Object)(object)mapMenu != (Object)null && mapMenu.MaxZoomScale > 0f && num > mapMenu.MaxZoomScale) { num = mapMenu.MaxZoomScale; } } catch { } float num2 = ((zoneOffsetAndScale.Scale > 0f) ? (num / zoneOffsetAndScale.Scale) : 1f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((0f - val.x) * num2, (0f - val.y) * num2); mapper.SetZoneOffsetAndScale(lastPlayerMapType, new OffsetAndScale { Offset = val2, Scale = num }); mapper._PanAdjust = Vector2.zero; _verifyFrame = Time.frameCount + 3; _verifyOffset = val2; _verifyType = lastPlayerMapType; ManualLogSource logger = Plugin.Logger; if (logger != null) { string[] obj2 = new string[13] { "HuntsAndRifts map focus: world ", null, null, null, null, null, null, null, null, null, null, null, null }; Vector2 val3 = worldXZ; obj2[1] = ((object)(*(Vector2*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj2[2] = " -> anchored "; Vector3 val4 = val; obj2[3] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj2[4] = " scale "; obj2[5] = zoneOffsetAndScale.Scale.ToString("0.###"); obj2[6] = " -> "; obj2[7] = num.ToString("0.###"); obj2[8] = " offset "; val3 = val2; obj2[9] = ((object)(*(Vector2*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj2[10] = " (mapType "; obj2[11] = ((object)(*(MapType*)(&lastPlayerMapType))/*cast due to .constrained prefix*/).ToString(); obj2[12] = ")"; logger.LogInfo((object)string.Concat(obj2)); } return true; } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts map focus: " + ex.Message)); } return false; } } private static bool IsZero(Matrix4x4 m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0027: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (m.m00 == 0f && m.m01 == 0f && m.m02 == 0f && m.m03 == 0f && m.m10 == 0f && m.m11 == 0f && m.m12 == 0f) { return m.m13 == 0f; } return false; } } internal static class HuntReader { private static float _nextRefresh; private static readonly Dictionary HuntRemainingByName = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary HuntDestByName = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary DestByMission = new Dictionary(); private static readonly Dictionary PosByMission = new Dictionary(); private static readonly Dictionary HuntPosByName = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary InjuryRemainingByName = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary GearLevelByName = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary HuntRemainingById = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary HuntDestById = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary HuntPosById = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary InjuryRemainingById = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary GearLevelById = new Dictionary(StringComparer.Ordinal); private static bool _netTypeReady; private static TypeIndex _networkIdIndex; private static bool _loggedMissingWorld; private static bool _loggedClockSanity; private static bool _loggedDest; private static readonly Dictionary MissionByZoneName = new Dictionary(StringComparer.Ordinal); private static bool _zoneNamesBuilt; private static bool Lookup(Dictionary byName, Dictionary byId, string servantName, out T value) { if (ServantInfoReader.TryGetNetworkKey(servantName, out var key) && byId.TryGetValue(key, out value)) { return true; } value = default(T); return false; } private unsafe static string ServantNetworkKey(EntityManager em, Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0048: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0060: Unknown result type (might be due to invalid IL or missing references) try { if (servant == Entity.Null) { return null; } if (!_netTypeReady) { _netTypeReady = true; try { _networkIdIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } } if (_networkIdIndex.Value == 0) { return null; } if (!((EntityManager)(ref em)).HasComponent(servant, ComponentType.ReadOnly(_networkIdIndex))) { return null; } long* componentDataRawRO = (long*)((EntityManager)(ref em)).GetComponentDataRawRO(servant, _networkIdIndex); if (componentDataRawRO == null) { return null; } long num = *componentDataRawRO; uint num2 = ((uint*)componentDataRawRO)[2]; return (num != 0L || num2 != 0) ? (num + ":" + num2) : null; } catch { return null; } } internal static bool TryGetGearLevel(string servantName, out float gearLevel) { RefreshIfNeeded(); gearLevel = 0f; if (string.IsNullOrEmpty(servantName)) { return false; } return Lookup(GearLevelByName, GearLevelById, servantName, out gearLevel); } internal static void RefreshIfNeeded() { float unscaledTime = Time.unscaledTime; if (!(unscaledTime < _nextRefresh)) { _nextRefresh = unscaledTime + 1f; RefreshNow(); } } internal static bool TryGetHuntRemaining(string servantName, out double seconds) { RefreshIfNeeded(); if (string.IsNullOrEmpty(servantName)) { seconds = 0.0; return false; } return Lookup(HuntRemainingByName, HuntRemainingById, servantName, out seconds); } internal static bool TryGetHuntDest(string servantName, out string dest) { RefreshIfNeeded(); dest = ""; if (string.IsNullOrEmpty(servantName)) { return false; } if (Lookup(HuntDestByName, HuntDestById, servantName, out dest)) { return !string.IsNullOrEmpty(dest); } return false; } internal static bool TryGetHuntPos(string servantName, out Vector2 worldXZ) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) RefreshIfNeeded(); worldXZ = default(Vector2); if (string.IsNullOrEmpty(servantName)) { return false; } return Lookup(HuntPosByName, HuntPosById, servantName, out worldXZ); } internal static bool TryGetInjuryRemaining(string servantName, out double seconds) { RefreshIfNeeded(); if (string.IsNullOrEmpty(servantName)) { seconds = 0.0; return false; } return Lookup(InjuryRemainingByName, InjuryRemainingById, servantName, out seconds); } internal static string FormatRemaining(double seconds) { if (seconds < 0.0) { seconds = 0.0; } int num = (int)Math.Floor(seconds); if (num >= 3600) { int num2 = num / 3600; int num3 = num % 3600 / 60; return num2 + "h " + num3 + "m"; } if (num >= 60) { return num / 60 + "m"; } return num + "s"; } private unsafe static void RefreshNow() { //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_0086: 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_009e: 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_00a8: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_014e: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0168: 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_018a: 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_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_019e: 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_01ac: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: 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_0280: 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_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_035d: 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_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) HuntRemainingByName.Clear(); HuntDestByName.Clear(); HuntPosByName.Clear(); InjuryRemainingByName.Clear(); GearLevelByName.Clear(); HuntRemainingById.Clear(); HuntDestById.Clear(); HuntPosById.Clear(); InjuryRemainingById.Clear(); GearLevelById.Clear(); if (!TryGetClientWorld(out var world)) { return; } EntityManager entityManager = world.EntityManager; long ticks = DateTime.UtcNow.Ticks; NativeArray val = default(NativeArray); NativeArray val2 = default(NativeArray); try { EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); val = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); List list = new List(8); for (int i = 0; i < val.Length; i++) { if (((EntityManager)(ref entityManager)).HasBuffer(val[i])) { DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val[i], false); for (int j = 0; j < buffer.Length; j++) { list.Add(buffer[j]); } } } EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); val2 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int k = 0; k < val2.Length; k++) { ServantCoffinstation componentData = ((EntityManager)(ref entityManager)).GetComponentData(val2[k]); string text = ((object)(*(FixedString64Bytes*)(&componentData.ServantName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text)) { continue; } string text2 = ServantNetworkKey(entityManager, componentData.ConnectedServant._Entity); if (componentData.ServantGearLevel > 0f && !float.IsNaN(componentData.ServantGearLevel)) { GearLevelByName[text] = componentData.ServantGearLevel; if (text2 != null) { GearLevelById[text2] = componentData.ServantGearLevel; } } if (componentData.InjuryEndTimeTicks > ticks) { double num = (double)(componentData.InjuryEndTimeTicks - ticks) / 10000000.0; if (num > 0.0 && num < 172800.0) { InjuryRemainingByName[text] = num; if (text2 != null) { InjuryRemainingById[text2] = num; } } } for (int l = 0; l < list.Count; l++) { ActiveServantMission mission = list[l]; if (!ServantOnMission(ref mission, componentData)) { continue; } double num2 = ActiveMissionExtensions.GetSecondsUntilCompletion(ref mission, ticks); if (!IsSaneRemaining(num2, mission.MissionLengthSeconds)) { num2 = (double)(mission.MissionStartTimeTicks + (long)(mission.MissionLengthSeconds * 10000000f) - ticks) / 10000000.0; } if (!IsSaneRemaining(num2, mission.MissionLengthSeconds)) { LogClockOnce(num2, mission.MissionStartTimeTicks, mission.MissionLengthSeconds); continue; } if (num2 < 0.0) { num2 = 0.0; } HuntRemainingByName[text] = num2; if (text2 != null) { HuntRemainingById[text2] = num2; } string text3 = DestForMission(entityManager, world, mission.MissionID); if (string.IsNullOrEmpty(text3)) { break; } HuntDestByName[text] = text3; if (text2 != null) { HuntDestById[text2] = text3; } if (PosByMission.TryGetValue(((PrefabGUID)(ref mission.MissionID)).GuidHash, out var value)) { HuntPosByName[text] = value; if (text2 != null) { HuntPosById[text2] = value; } } if (!_loggedDest) { _loggedDest = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts hunt dest: " + text + " -> " + text3 + (HuntPosByName.ContainsKey(text) ? (" @ " + ((object)HuntPosByName[text]/*cast due to .constrained prefix*/).ToString()) : " (no zone position)"))); } } break; } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts refresh skipped: " + ex.Message)); } } finally { if (val.IsCreated) { val.Dispose(); } if (val2.IsCreated) { val2.Dispose(); } } } private static bool ServantOnMission(ref ActiveServantMission mission, ServantCoffinstation station) { //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_000d: 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_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_001b: 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_0059: 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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Entity syncedEntityOrNull = ((NetworkedEntity)(ref station.ConnectedServant)).GetSyncedEntityOrNull(); if (syncedEntityOrNull != Entity.Null && ActiveMissionExtensions.ContainsServant(ref mission, syncedEntityOrNull)) { return true; } Entity entity = station.ConnectedServant._Entity; if (entity == Entity.Null) { return false; } if (!(mission.Servant1._Entity == entity) && !(mission.Servant2._Entity == entity)) { return mission.Servant3._Entity == entity; } return true; } private static bool IsSaneRemaining(double remaining, float missionLengthSeconds) { if (double.IsNaN(remaining) || double.IsInfinity(remaining)) { return false; } float num = Math.Max(missionLengthSeconds, 0f) + 120f; if (num < 120f) { num = 172800f; } if (remaining > -5.0) { return remaining <= (double)(num + 1f); } return false; } private static void LogClockOnce(double remaining, long startTicks, float lengthSeconds) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (_loggedClockSanity) { return; } _loggedClockSanity = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(103, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HuntsAndRifts could not map remaining time (got "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(remaining, "0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s, startTicks="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(startTicks); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", length="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(lengthSeconds); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s). Leaving vanilla status text."); } logger.LogWarning(val); } } internal static bool TryGetMissionForZoneName(string zoneName, out PrefabGUID mission) { //IL_0001: 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_0074: Unknown result type (might be due to invalid IL or missing references) mission = default(PrefabGUID); if (string.IsNullOrEmpty(zoneName)) { return false; } if (!_zoneNamesBuilt) { BuildZoneNames(); } if (MissionByZoneName.TryGetValue(zoneName.Trim(), out mission)) { return true; } string text = NormalizeZone(zoneName); if (text.Length == 0) { return false; } foreach (KeyValuePair item in MissionByZoneName) { if (NormalizeZone(item.Key) == text) { mission = item.Value; return true; } } return false; } private static string NormalizeZone(string s) { StringBuilder stringBuilder = new StringBuilder(s.Length); foreach (char c in s) { if (char.IsLetterOrDigit(c)) { stringBuilder.Append(char.ToLowerInvariant(c)); } } string text = stringBuilder.ToString(); if (text.EndsWith("s") && text.Length > 3) { text = text.Substring(0, text.Length - 1); } return text; } private static void BuildZoneNames() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_00ab: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) if (!TryGetClientWorld(out var world)) { return; } EntityManager entityManager = world.EntityManager; NativeArray val = default(NativeArray); try { EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return; } val = ((EntityQuery)(ref val2)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val.Length; i++) { MapZoneData val3 = val[i]; if (((PrefabGUID)(ref val3.ServantMissionAsset)).GuidHash != 0) { string text = null; try { text = Localization.Get(val3.Name, false); } catch { } if (!string.IsNullOrWhiteSpace(text) && text.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { MissionByZoneName[text.Trim()] = val3.ServantMissionAsset; } } } _zoneNamesBuilt = MissionByZoneName.Count > 0; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts zone names: " + MissionByZoneName.Count + " hunt zones indexed: " + string.Join(", ", MissionByZoneName.Keys))); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts zone names: " + ex.Message)); } } finally { if (val.IsCreated) { val.Dispose(); } } } private static string DestForMission(EntityManager em, World world, PrefabGUID mission) { //IL_0026: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref mission)).GuidHash == 0) { return ""; } if (DestByMission.TryGetValue(((PrefabGUID)(ref mission)).GuidHash, out var value)) { return value; } string text = LookupZoneName(em, mission); if (string.IsNullOrEmpty(text)) { text = PrettyMission(world, mission); } DestByMission[((PrefabGUID)(ref mission)).GuidHash] = text ?? ""; return text ?? ""; } private static string LookupZoneName(EntityManager em, PrefabGUID mission) { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0059: 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_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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0088: 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_0136: Unknown result type (might be due to invalid IL or missing references) NativeArray val = default(NativeArray); NativeArray val2 = default(NativeArray); try { EntityQuery val3 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (((EntityQuery)(ref val3)).IsEmptyIgnoreFilter) { return ""; } val = ((EntityQuery)(ref val3)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val.Length; i++) { MapZoneData zone = val[i]; if (((PrefabGUID)(ref zone.ServantMissionAsset)).GuidHash != ((PrefabGUID)(ref mission)).GuidHash) { continue; } string text = null; try { string text2 = Localization.Get(zone.Name, false); if (!string.IsNullOrWhiteSpace(text2) && text2.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { text = text2; } } catch { try { string text3 = Localization.Get(zone.Name, true); if (!string.IsNullOrWhiteSpace(text3) && text3.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { text = text3; } } catch { } } if (text == null) { text = PrettyMissionName(zone.ServantMissionAsset, null); } Entity zoneEntity = ((i < val2.Length) ? val2[i] : Entity.Null); if (ZoneLocator.TryGetCenter(em, zoneEntity, ref zone, text, out var worldXZ)) { PosByMission[((PrefabGUID)(ref mission)).GuidHash] = worldXZ; } return text; } } catch { } finally { if (val.IsCreated) { val.Dispose(); } if (val2.IsCreated) { val2.Dispose(); } } return ""; } private unsafe static string PrettyMission(World world, PrefabGUID guid) { //IL_0037: 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_0017: 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) string raw = null; try { GameDataSystem existingSystemManaged = world.GetExistingSystemManaged(); if (existingSystemManaged != null) { PrefabLookupMap prefabLookupMap = existingSystemManaged.ManagedDataRegistry._PrefabLookupMap; FixedString128Bytes val = default(FixedString128Bytes); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetFixedName(guid, ref val)) { raw = ((object)(*(FixedString128Bytes*)(&val))/*cast due to .constrained prefix*/).ToString(); } } } catch { } return PrettyMissionName(guid, raw); } private static string PrettyMissionName(PrefabGUID guid, string raw) { if (string.IsNullOrWhiteSpace(raw)) { return ""; } int num = raw.IndexOf(' '); if (num > 0) { raw = raw.Substring(0, num); } if (raw.StartsWith("ServantMission_", StringComparison.OrdinalIgnoreCase)) { raw = raw.Substring("ServantMission_".Length); } return raw.Replace('_', ' '); } internal static bool TryGetClientWorld(out World world) { world = null; List s_AllWorlds = World.s_AllWorlds; if (s_AllWorlds == null) { return false; } for (int i = 0; i < s_AllWorlds.Count; i++) { World val = s_AllWorlds[i]; if (val != null && val.IsCreated && val.Name == "Client_0") { world = val; return true; } } if (!_loggedMissingWorld) { _loggedMissingWorld = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)"HuntsAndRifts: Client_0 world not ready yet."); } } return false; } } internal sealed class LayoutSnapshot { private readonly LayoutElement _element; private readonly bool _owned; private readonly bool _enabled; private readonly float _preferred; private readonly float _minimum; internal LayoutElement Element => _element; internal LayoutSnapshot(GameObject go) { _element = go.GetComponent(); _owned = (Object)(object)_element == (Object)null; if (_owned) { _element = go.AddComponent(); } _enabled = ((Behaviour)_element).enabled; _preferred = _element.preferredHeight; _minimum = _element.minHeight; } internal void Restore() { if (!((Object)(object)_element == (Object)null)) { ((Behaviour)_element).enabled = _enabled; _element.preferredHeight = _preferred; _element.minHeight = _minimum; if (_owned) { ((Behaviour)_element).enabled = false; Object.Destroy((Object)(object)_element); } } } } internal static class LootReader { private static readonly Dictionary NameToPrefab = new Dictionary(StringComparer.Ordinal); private static readonly HashSet MissingNames = new HashSet(StringComparer.Ordinal); private static PrefabGUID _resourceGainType; private static bool _resolvedResourceGain; private static bool _loggedLut; internal static bool IsResourceGain(PrefabGUID type) { EnsureResourceGainType(); if (((PrefabGUID)(ref _resourceGainType)).IsEmpty()) { return ((PrefabGUID)(ref type)).GuidHash == 1876501183; } if (((PrefabGUID)(ref type)).GuidHash != ((PrefabGUID)(ref _resourceGainType)).GuidHash) { return ((PrefabGUID)(ref type)).GuidHash == 1876501183; } return true; } internal static bool TryGetBagTotal(PrefabGUID item, out int total) { //IL_003c: 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_0042: 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_004b: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) total = 0; if (((PrefabGUID)(ref item)).IsEmpty()) { return false; } if (!HuntReader.TryGetClientWorld(out var world)) { return false; } Entity val = default(Entity); if (!ConsoleShared.TryGetLocalCharacterInCurrentWorld(ref val, world)) { return false; } try { total = InventoryUtilities.GetItemAmountInInventories(world.EntityManager, val, item); return true; } catch { try { total = InventoryUtilities.GetItemAmount(world.EntityManager, val, item, default(Nullable_Unboxed)); return true; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts bag total skipped: " + ex.Message)); } return false; } } } internal static bool TryResolveItem(string localizedName, out PrefabGUID prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) prefab = default(PrefabGUID); if (string.IsNullOrEmpty(localizedName)) { return false; } EnsureLut(); if (NameToPrefab.TryGetValue(localizedName, out prefab) && !((PrefabGUID)(ref prefab)).IsEmpty()) { return true; } RebuildLut(); if (NameToPrefab.TryGetValue(localizedName, out prefab)) { return !((PrefabGUID)(ref prefab)).IsEmpty(); } return false; } internal unsafe static void RebuildLut() { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_003a: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) NameToPrefab.Clear(); if (!HuntReader.TryGetClientWorld(out var world)) { return; } GameDataSystem existingSystemManaged; try { existingSystemManaged = world.GetExistingSystemManaged(); } catch { return; } if (existingSystemManaged == null) { return; } NativeParallelHashMap itemHashLookupMap; try { itemHashLookupMap = existingSystemManaged.ItemHashLookupMap; } catch { return; } NativeArray val = default(NativeArray); try { if (itemHashLookupMap.Count() == 0) { return; } val = itemHashLookupMap.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2)); ManagedDataRegistry managedDataRegistry = existingSystemManaged.ManagedDataRegistry; PrefabLookupMap prefabLookupMap = managedDataRegistry._PrefabLookupMap; FixedString128Bytes val4 = default(FixedString128Bytes); for (int i = 0; i < val.Length; i++) { PrefabGUID val2 = val[i]; ManagedItemData val3 = null; try { val3 = managedDataRegistry.GetOrDefault(val2, (ManagedItemData)null); } catch { continue; } if (val3 == null) { continue; } string text = null; try { if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetFixedName(val2, ref val4)) { text = ((object)(*(FixedString128Bytes*)(&val4))/*cast due to .constrained prefix*/).ToString(); } } catch { } if (text == "Item_Ingredient_Kit_Base" || text == "Item_Ingredient_Gem_Base") { continue; } string text2 = null; try { text2 = Localization.Get(val3.Name, false); } catch { try { text2 = Localization.Get(val3.Name, true); goto end_IL_00f2; } catch { } continue; end_IL_00f2:; } if (!string.IsNullOrEmpty(text2)) { NameToPrefab[text2] = val2; } } if (!_loggedLut) { _loggedLut = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts loot LUT: " + NameToPrefab.Count + " item names.")); } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts loot LUT rebuild: " + ex.Message)); } } finally { if (val.IsCreated) { val.Dispose(); } } } internal static void NoteMissing(string name) { if (!string.IsNullOrEmpty(name) && !MissingNames.Contains(name)) { MissingNames.Add(name); ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts: no prefab for pickup name '" + name + "'.")); } } } private static void EnsureLut() { if (NameToPrefab.Count == 0) { RebuildLut(); } } private static void EnsureResourceGainType() { //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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (_resolvedResourceGain) { return; } _resolvedResourceGain = true; if (!HuntReader.TryGetClientWorld(out var world)) { return; } try { PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged(); if (existingSystemManaged == null) { return; } Dictionary spawnableNameToPrefabGuidDictionary = existingSystemManaged.SpawnableNameToPrefabGuidDictionary; if (spawnableNameToPrefabGuidDictionary == null) { return; } Enumerator enumerator = spawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; string key = current.Key; if (!string.IsNullOrEmpty(key) && (key.IndexOf("ResourceGain", StringComparison.OrdinalIgnoreCase) >= 0 || key.IndexOf("ResouceGain", StringComparison.OrdinalIgnoreCase) >= 0)) { _resourceGainType = current.Value; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts ResourceGain SCT prefab: " + key + " " + ((object)current.Value/*cast due to .constrained prefix*/).ToString())); } if (key.IndexOf("SCT", StringComparison.OrdinalIgnoreCase) >= 0) { break; } } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts ResourceGain resolve: " + ex.Message)); } } } } internal static class MapRiftOverlay { private static GameObject _host; private static bool _mapOpen; private static GUIStyle _labelStyle; private static Texture2D _bg; private static string _cachedText = ""; private static float _nextFormat; private static int _cachedLines; private static bool _hasWidgetAnchor; private static Rect _widgetScreen; private static bool _huntMode; private static bool _widgetTakenOver; private static bool _loggedTakeover; private static float _lastApply = -1f; private static string _cachedPrimary; private static string _cachedLevel; private static float _cachedFill; private static RiftTrack? _secondaryTrack; private static RiftTrack? _primaryTrack; private static float _lastInfoSeen = -100f; private static readonly Regex HourMinRx = new Regex("(\\d+)\\s*h\\s*(\\d+)\\s*m(?:\\s*(\\d+)\\s*s)?", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex MinSecRx = new Regex("(\\d+)\\s*m\\s*(\\d+)\\s*s", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex MinOnlyRx = new Regex("(\\d+)\\s*m\\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex SecOnlyRx = new Regex("(\\d+)\\s*s\\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); internal static string VanillaPhase { get; private set; } = "active"; internal static void Spawn() { } internal static void DestroyHost() { _mapOpen = false; RiftDisplayCompatibility.Reset(); RiftRowBadge.Reset(); if (!((Object)(object)_host == (Object)null)) { Object.Destroy((Object)(object)_host); _host = null; } } internal static void SetMapOpen(bool open) { _mapOpen = open; if (!open) { _huntMode = false; _widgetTakenOver = false; RiftCardExtension.Reset(); RiftDisplayCompatibility.Reset(); RiftRowBadge.Reset(); _cachedText = ""; _cachedLines = 0; _hasWidgetAnchor = false; } } internal static void CaptureWidget(MapMenuMapper mapper) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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) _hasWidgetAnchor = false; if (mapper == null) { return; } try { _huntMode = (int)mapper._MenuMode == 3; } catch { _huntMode = false; } try { MapMenu mapMenu = mapper.GetMapMenu(); if ((Object)(object)mapMenu == (Object)null) { return; } MapWarEventInfoEntry warEventInfo = mapMenu.WarEventInfo; if ((Object)(object)warEventInfo == (Object)null) { return; } _lastInfoSeen = Time.unscaledTime; LocalizedText timerText = warEventInfo.TimerText; UiTextState.Track((TMP_Text)(object)((timerText != null) ? timerText.Text : null)); LocalizedText levelText = warEventInfo.LevelText; UiTextState.Track((TMP_Text)(object)((levelText != null) ? levelText.Text : null)); try { float unscaledTime = Time.unscaledTime; if (unscaledTime - _lastApply >= 0.25f || !_widgetTakenOver) { _lastApply = unscaledTime; _widgetTakenOver = ApplyToWidget(warEventInfo); } else { ReapplyCached(warEventInfo); } } catch (Exception ex) { _widgetTakenOver = false; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts widget takeover: " + ex.Message)); } } RiftCardExtension.Apply(warEventInfo, mapMenu, _widgetTakenOver ? _secondaryTrack : ((RiftTrack?)null)); RiftRowBadge.Apply(warEventInfo, _widgetTakenOver ? _primaryTrack : ((RiftTrack?)null)); RiftDisplayCompatibility.Apply(warEventInfo, _widgetTakenOver && !_huntMode); Rect imgui = default(Rect); bool any = false; try { Acc(((Component)warEventInfo).GetComponent()); } catch { } try { Acc(warEventInfo.PositionRect); } catch { } try { if ((Object)(object)warEventInfo.FillImage != (Object)null) { Acc(((Graphic)warEventInfo.FillImage).rectTransform); } } catch { } try { if ((Object)(object)warEventInfo.TextGroup != (Object)null) { Acc(((Component)warEventInfo.TextGroup).GetComponent()); } } catch { } try { if ((Object)(object)warEventInfo.TimerText != (Object)null) { Acc(((Component)warEventInfo.TimerText).GetComponent()); } } catch { } try { if ((Object)(object)warEventInfo.WarEventIcon != (Object)null) { Acc(((Graphic)warEventInfo.WarEventIcon).rectTransform); } } catch { } if (any) { _widgetScreen = imgui; _hasWidgetAnchor = true; } void Acc(RectTransform rt) { //IL_0022: 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_0028: 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_002d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null) && TryImguiRect(rt, out var imgui2)) { imgui = (any ? Union(imgui, imgui2) : imgui2); any = true; } } } catch (Exception ex2) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts overlay widget anchor: " + ex2.Message)); } } } private static void ReapplyCached(MapWarEventInfoEntry info) { if ((Object)(object)info == (Object)null) { return; } try { if ((Object)(object)info.FillImage != (Object)null) { info.FillImage.fillAmount = _cachedFill; } LocalizedText timerText = info.TimerText; if ((Object)(object)timerText != (Object)null && _cachedPrimary != null && timerText.GetText() != _cachedPrimary) { timerText.ForceSet(_cachedPrimary); } LocalizedText levelText = info.LevelText; if ((Object)(object)levelText != (Object)null && _cachedLevel != null && levelText.GetText() != _cachedLevel) { levelText.ForceSet(_cachedLevel); } } catch { } } private unsafe static string TierName(WarEventType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)t switch { 1 => "T1", 0 => "T2", 2 => "Primal", _ => ((object)(*(WarEventType*)(&t))/*cast due to .constrained prefix*/).ToString(), }; } private static string TierLine(RiftTrack track, bool primary) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) string text = TierName(track.Type) + ((track.Level > 0) ? (" (" + track.Level + "+)") : ""); if (track.IsActive) { if (track.RemainingSeconds < 0.0) { return text + " active"; } string text2 = "active"; return text + " " + text2 + ": " + FormatRift(track.RemainingSeconds); } double nextInSeconds = track.NextInSeconds; if (nextInSeconds < 0.0) { return text + " awaiting schedule"; } return text + " next in " + FormatRift(nextInSeconds); } private static bool ApplyToWidget(MapWarEventInfoEntry info) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_004c: 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_005b: Invalid comparison between Unknown and I4 if ((Object)(object)info == (Object)null) { return false; } IReadOnlyList tracks = RiftReader.GetTracks(); if (tracks == null || tracks.Count == 0) { return false; } List list = new List(); foreach (RiftTrack item in tracks) { if (!item.IsTest && ((int)item.Type == 1 || (int)item.Type == 0 || (int)item.Type == 2)) { list.Add(item); } } if (list.Count == 0) { return false; } list.Sort((RiftTrack a, RiftTrack b) => (a.IsActive != b.IsActive) ? ((!a.IsActive) ? 1 : (-1)) : ((a.NextInSeconds < 0.0) ? double.MaxValue : a.NextInSeconds).CompareTo((b.NextInSeconds < 0.0) ? double.MaxValue : b.NextInSeconds)); try { Image warEventIcon = info.WarEventIcon; if ((Object)(object)warEventIcon != (Object)null) { bool flag = false; foreach (RiftTrack item2 in list) { if (item2.IsActive) { flag = true; break; } } if (((Component)warEventIcon).gameObject.activeSelf != flag) { ((Component)warEventIcon).gameObject.SetActive(flag); } } } catch { } string text = TierLine(list[0], primary: true); string text2 = ((list.Count > 1) ? TierLine(list[1], primary: false) : ""); _secondaryTrack = ((list.Count > 1) ? new RiftTrack?(list[1]) : ((RiftTrack?)null)); _primaryTrack = list[0]; _cachedPrimary = text; _cachedFill = RiftCardExtension.Fill(list[0]); if ((Object)(object)info.FillImage != (Object)null) { info.FillImage.fillAmount = _cachedFill; } bool flag2 = false; LocalizedText timerText = info.TimerText; if ((Object)(object)timerText != (Object)null) { if (timerText.GetText() != text) { timerText.ForceSet(text); } flag2 = true; } LocalizedText levelText = info.LevelText; if ((Object)(object)levelText != (Object)null) { string text3 = levelText.GetText() ?? ""; int num = text3.IndexOf(','); if (num > 0) { string text4 = text3.Substring(0, num).Trim(); if (text4.Length > 0) { _cachedLevel = text4; if (levelText.GetText() != text4) { levelText.ForceSet(text4); } } } } if (flag2 && !_loggedTakeover) { _loggedTakeover = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: rift card shows '" + text + "' / '" + text2 + "' (IMGUI overlay off).")); } } return flag2; } internal static void DrawImgui() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!_mapOpen || _huntMode || _widgetTakenOver || Time.unscaledTime - _lastInfoSeen < 2f || (Event.current != null && (int)Event.current.type != 7)) { return; } FormatIfNeeded(); if (_cachedLines <= 0 || string.IsNullOrEmpty(_cachedText)) { return; } EnsureStyles(); if (_labelStyle != null) { float height = 20f + 22f * (float)_cachedLines; Rect val = PlaceRect(280f, height); Color color = GUI.color; GUI.color = Color.white; if ((Object)(object)_bg != (Object)null) { GUI.DrawTexture(val, (Texture)(object)_bg); } GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height - 8f), _cachedText, _labelStyle); GUI.color = color; } } private static void FormatIfNeeded() { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextFormat && _cachedLines > 0) { return; } _nextFormat = unscaledTime + 0.25f; IReadOnlyList tracks = RiftReader.GetTracks(); if (tracks == null || tracks.Count == 0) { _cachedText = ""; _cachedLines = 0; return; } StringBuilder stringBuilder = new StringBuilder(192); int num = 0; for (int i = 0; i < tracks.Count; i++) { string value = FormatLine(tracks[i]); if (!string.IsNullOrEmpty(value)) { if (num > 0) { stringBuilder.Append('\n'); } stringBuilder.Append(value); num++; } } _cachedText = stringBuilder.ToString(); _cachedLines = num; } private static string FormatLine(RiftTrack track) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected I4, but got Unknown //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) WarEventType type = track.Type; string text = (int)type switch { 1 => "T1", 0 => "T2", 2 => "Primal", _ => ((object)track.Type/*cast due to .constrained prefix*/).ToString(), }; string text2 = ((track.Level > 0) ? (" (" + track.Level + "+)") : ""); string text3 = (track.IsTest ? " TEST" : ""); if (track.IsActive) { if (!(track.RemainingSeconds < 0.0)) { return text + text2 + " remaining " + FormatRift(track.RemainingSeconds) + text3; } return text + text2 + " active" + text3; } double nextInSeconds = track.NextInSeconds; if (nextInSeconds < 0.0) { return text + " awaiting schedule"; } return text + text2 + " next in " + FormatRift(nextInSeconds) + text3; } private static string FormatRift(double seconds) { if (seconds < 0.0) { seconds = 0.0; } int num = (int)Math.Floor(seconds); int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; if (num2 > 0) { return num2 + "h " + num3 + "m"; } if (num3 > 0) { return num3 + "m " + num4 + "s"; } return num4 + "s"; } private static bool TryReadVanillaTimer(MapWarEventInfoEntry info, out double seconds) { seconds = 0.0; if ((Object)(object)info == (Object)null) { return false; } string text = ReadLocalized(info.TimerText); if (!RiftTiming.IsOwnText(text) && TryParseTimerText(text, out seconds)) { int num = text.IndexOf(':'); if (num > 0) { string text2 = text.Substring(0, num).Trim().ToLowerInvariant(); if (text2.Length > 0 && text2.Length < 16) { VanillaPhase = text2; } } return true; } string text3 = ReadLocalized(info.SubHeaderText); if (!RiftTiming.IsOwnText(text3)) { return TryParseTimerText(text3, out seconds); } return false; } private static string ReadLocalized(LocalizedText loc) { if ((Object)(object)loc == (Object)null) { return ""; } try { string text = loc.GetText(); if (!string.IsNullOrWhiteSpace(text)) { return text; } } catch { } try { TextMeshProUGUI text2 = loc.Text; if ((Object)(object)text2 != (Object)null && !string.IsNullOrWhiteSpace(((TMP_Text)text2).text)) { return ((TMP_Text)text2).text; } } catch { } return ""; } internal static bool TryParseTimerText(string text, out double seconds) { seconds = 0.0; if (string.IsNullOrWhiteSpace(text)) { return false; } string input = text.Trim(); Match match = HourMinRx.Match(input); if (match.Success) { seconds = IntPart(match, 1) * 3600 + IntPart(match, 2) * 60 + IntPart(match, 3); return true; } match = MinSecRx.Match(input); if (match.Success) { seconds = IntPart(match, 1) * 60 + IntPart(match, 2); return true; } match = MinOnlyRx.Match(input); if (match.Success) { seconds = IntPart(match, 1) * 60; return true; } match = SecOnlyRx.Match(input); if (match.Success) { seconds = IntPart(match, 1); return true; } return false; } private static int IntPart(Match m, int i) { if (i >= m.Groups.Count || !m.Groups[i].Success || string.IsNullOrEmpty(m.Groups[i].Value)) { return 0; } if (!int.TryParse(m.Groups[i].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return 0; } return result; } private static Rect Union(Rect a, Rect b) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) float num = Math.Min(((Rect)(ref a)).x, ((Rect)(ref b)).x); float num2 = Math.Min(((Rect)(ref a)).y, ((Rect)(ref b)).y); float num3 = Math.Max(((Rect)(ref a)).xMax, ((Rect)(ref b)).xMax); float num4 = Math.Max(((Rect)(ref a)).yMax, ((Rect)(ref b)).yMax); return new Rect(num, num2, num3 - num, num4 - num2); } private static bool TryImguiRect(RectTransform rt, out Rect imgui) { //IL_0001: 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_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_0070: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_00a3: 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) imgui = default(Rect); Vector3[] array = (Vector3[])(object)new Vector3[4]; rt.GetWorldCorners(Il2CppStructArray.op_Implicit(array)); Canvas val = null; try { val = ((Component)rt).GetComponentInParent(); } catch { } Camera val2 = null; if ((Object)(object)val != (Object)null && (int)val.renderMode != 0) { val2 = val.worldCamera; } float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; float num3 = float.PositiveInfinity; float num4 = float.NegativeInfinity; for (int i = 0; i < 4; i++) { Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val2, array[i]); if (val3.x < num) { num = val3.x; } if (val3.x > num2) { num2 = val3.x; } if (val3.y < num3) { num3 = val3.y; } if (val3.y > num4) { num4 = val3.y; } } if (num2 - num < 8f || num4 - num3 < 8f) { return false; } imgui = new Rect(num, (float)Screen.height - num4, num2 - num, num4 - num3); return true; } private static Rect PlaceRect(float width, float height) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) float num; float num2; if (_hasWidgetAnchor) { num = ((Rect)(ref _widgetScreen)).x; num2 = ((Rect)(ref _widgetScreen)).yMax + 10f; } else { ContentRect(out var x, out var y, out var w, out var h); num = x + w - width - 10f; num2 = y + h - height - 88f; } if (num < 16f) { num = 16f; } if (num2 < 16f) { num2 = 16f; } if (num + width > (float)Screen.width - 16f) { num = (float)Screen.width - width - 16f; } if (num2 + height > (float)Screen.height - 16f) { num2 = (float)Screen.height - height - 16f; } return new Rect(num, num2, width, height); } private static void ContentRect(out float x, out float y, out float w, out float h) { float num = Screen.width; float num2 = Screen.height; if (num / Math.Max(1f, num2) > 1.7777778f) { h = num2; w = h * 1.7777778f; x = (num - w) * 0.5f; y = 0f; } else { w = num; h = w / 1.7777778f; x = 0f; y = (num2 - h) * 0.5f; } } private static void EnsureStyles() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0066: 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_0089: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (_labelStyle != null) { return; } try { _labelStyle = new GUIStyle(); _labelStyle.fontSize = 16; _labelStyle.fontStyle = (FontStyle)1; _labelStyle.alignment = (TextAnchor)0; _labelStyle.wordWrap = false; _labelStyle.richText = false; GUIStyleState val = new GUIStyleState(); val.textColor = new Color(0.96f, 0.9f, 0.72f, 1f); _labelStyle.normal = val; _bg = new Texture2D(1, 1, (TextureFormat)4, false); _bg.SetPixel(0, 0, new Color(0.04f, 0.05f, 0.07f, 0.72f)); _bg.Apply(); ((Object)_bg).hideFlags = (HideFlags)61; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts overlay style: " + ex.Message)); } } } } internal sealed class RiftOverlayBehaviour : MonoBehaviour { public RiftOverlayBehaviour(IntPtr ptr) : base(ptr) { } private void OnGUI() { try { MapRiftOverlay.DrawImgui(); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts overlay OnGUI: " + ex.Message)); } } } } internal static class MissionInfoReader { internal sealed class Info { public int Difficulty; public int ServantSlots; public readonly List Perks = new List(); } private static readonly Dictionary Cache = new Dictionary(); private static bool _typesReady; private static TypeIndex _missionDataIndex; private static TypeIndex _perksIndex; private static bool _loggedOnce; private static void EnsureTypes() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (_typesReady) { return; } _typesReady = true; try { _missionDataIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } try { _perksIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } } internal static Info Get(PrefabGUID mission) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref mission)).GuidHash == 0) { return null; } if (Cache.TryGetValue(((PrefabGUID)(ref mission)).GuidHash, out var value)) { return value; } Info info = null; try { info = Read(mission); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts mission info: " + ex.Message)); } } Cache[((PrefabGUID)(ref mission)).GuidHash] = info; return info; } private unsafe static Info Read(PrefabGUID mission) { //IL_0022: 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_002a: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0093: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0113: 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_0146: Unknown result type (might be due to invalid IL or missing references) EnsureTypes(); if (!HuntReader.TryGetClientWorld(out var world)) { return null; } GameDataSystem existingSystemManaged = world.GetExistingSystemManaged(); if (existingSystemManaged == null) { return null; } PrefabLookupMap prefabLookupMap = existingSystemManaged.ManagedDataRegistry._PrefabLookupMap; Entity val = default(Entity); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValueWithoutLogging(mission, ref val) || val == Entity.Null) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts mission info: prefab " + ((PrefabGUID)(ref mission)).GuidHash + " not in PrefabLookupMap.")); } return null; } EntityManager entityManager = world.EntityManager; Info info = new Info(); bool flag = false; if (_missionDataIndex.Value != 0 && ((EntityManager)(ref entityManager)).HasComponent(val, ComponentType.ReadOnly(_missionDataIndex))) { int* componentDataRawRO = (int*)((EntityManager)(ref entityManager)).GetComponentDataRawRO(val, _missionDataIndex); if (componentDataRawRO != null) { info.Difficulty = componentDataRawRO[1]; info.ServantSlots = componentDataRawRO[2]; flag = true; } } if (_perksIndex.Value != 0 && ((EntityManager)(ref entityManager)).HasComponent(val, ComponentType.ReadOnly(_perksIndex))) { int bufferLength = ((EntityManager)(ref entityManager)).GetBufferLength(val, _perksIndex); if (bufferLength > 0 && bufferLength <= 16) { int* bufferRawRO = (int*)((EntityManager)(ref entityManager)).GetBufferRawRO(val, _perksIndex); if (bufferRawRO != null) { for (int i = 0; i < bufferLength; i++) { if (bufferRawRO[i] != 0) { info.Perks.Add(new PrefabGUID(bufferRawRO[i])); } } flag = true; } } } if (!flag) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts mission info: prefab " + ((PrefabGUID)(ref mission)).GuidHash + " has neither MissionData nor PerksBuffer (typeIndex " + _missionDataIndex.Value + "/" + _perksIndex.Value + ").")); } return null; } if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogInfo((object)("HuntsAndRifts mission info: " + ((PrefabGUID)(ref mission)).GuidHash + " difficulty " + info.Difficulty + " slots " + info.ServantSlots + " perks " + info.Perks.Count)); } } return info; } } [HarmonyPatch] internal static class LootPopupPatches { [HarmonyPatch(typeof(GameDataSystem), "RegisterItems")] [HarmonyPostfix] private static void RegisterItemsPostfix(GameDataSystem __instance) { try { LootReader.RebuildLut(); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts RegisterItems postfix: " + ex.Message)); } } } [HarmonyPatch(typeof(ScrollingCombatTextParentMapper), "_InitializeUI_b__5_1")] [HarmonyPostfix] private static void SctEntryPostfix(SCTText element, EntryData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { AppendBagTotal(element, data); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts SCT postfix: " + ex.Message)); } } } private unsafe static void AppendBagTotal(SCTText text, EntryData entry) { //IL_000a: 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) //IL_0063: 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) if ((Object)(object)text == (Object)null || !LootReader.IsResourceGain(entry.Type)) { return; } string text2 = ((object)(*(FixedString128Bytes*)(&entry.SourceTypeText))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text2) || (text2.IndexOf('(') >= 0 && text2.IndexOf(')') > text2.IndexOf('('))) { return; } if (!LootReader.TryResolveItem(text2, out var prefab)) { LootReader.NoteMissing(text2); } else { if (!LootReader.TryGetBagTotal(prefab, out var total)) { return; } string text3 = text2 + " (" + total + ")"; try { entry.SourceTypeText = new FixedString128Bytes(text3); } catch { } TextMeshProUGUI text4 = text.Text; if (!((Object)(object)text4 == (Object)null)) { string text5 = ((TMP_Text)text4).text; if (string.IsNullOrEmpty(text5)) { text5 = ((TMP_Text)text4).m_text; } if (!string.IsNullOrEmpty(text5) && text5.IndexOf(text3, StringComparison.Ordinal) < 0) { string text6 = (((TMP_Text)text4).text = text5.Replace(text2, text3)); ((TMP_Text)text4).m_text = text6; } } } } } [HarmonyPatch] internal static class MapWarEventPatches { private static bool _loggedTip; private static GameObject _hiddenTip; [HarmonyPatch(typeof(MapMenuMapper), "OnStartRunning")] [HarmonyPostfix] private static void OnStartRunningPostfix() { MapRiftOverlay.SetMapOpen(open: true); } [HarmonyPatch(typeof(MapMenuMapper), "OnUpdate")] [HarmonyPostfix] private static void OnUpdatePostfix(MapMenuMapper __instance) { MapRiftOverlay.SetMapOpen(open: true); MapRiftOverlay.CaptureWidget(__instance); HuntMapFocus.SetMapper(__instance); RiftReader.RefreshIfNeeded(); ServantListPatches.Tick(); TooltipDecor.Tick(__instance); HideMapTipIfConfigured(__instance); } internal static void RestoreTip() { if ((Object)(object)_hiddenTip != (Object)null) { _hiddenTip.SetActive(true); } _hiddenTip = null; } private static void HideMapTipIfConfigured(MapMenuMapper mapper) { try { if (Plugin.NoMapTip == null || !Plugin.NoMapTip.Value) { RestoreTip(); return; } MapMenu mapMenu = mapper.GetMapMenu(); if ((Object)(object)mapMenu == (Object)null) { return; } GameObject parent_ServantThroneHelper = mapMenu.Parent_ServantThroneHelper; if ((Object)(object)parent_ServantThroneHelper == (Object)null || !parent_ServantThroneHelper.activeSelf) { return; } _hiddenTip = parent_ServantThroneHelper; parent_ServantThroneHelper.SetActive(false); if (!_loggedTip) { _loggedTip = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: no_map_tip hides '" + ((Object)parent_ServantThroneHelper).name + "'.")); } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts map tip: " + ex.Message)); } } } [HarmonyPatch(typeof(MapMenuMapper), "OnStopRunning")] [HarmonyPostfix] private static void OnStopRunningPostfix() { RestoreTip(); MapRiftOverlay.SetMapOpen(open: false); HuntMapFocus.Clear(); } } [HarmonyPatch] internal static class ServantListPatches { private struct TrackedRow { public ServantListItem Item; public string Name; public Status Status; } private sealed class Group { public string Dest; public double Remaining = double.MaxValue; public readonly List<(ServantListItem item, int sibling, string name)> Rows = new List<(ServantListItem, int, string)>(); public readonly HashSet ServantPerks = new HashSet(); } private static readonly Regex ClockSuffix = new Regex("\\s+\\d+h(?: \\d+m)?$|\\s+\\d+m$|\\s+\\d+s$|]*>.*?|]*>", RegexOptions.Compiled | RegexOptions.Singleline); private const string DestColor = "#6CE38A"; private static readonly Dictionary Tracked = new Dictionary(); private static readonly Dictionary HuntRows = new Dictionary(); private static readonly Dictionary AllRows = new Dictionary(); private static int _lastCenterFrame = -1; private static bool _mouseWasDown; private static bool _loggedNoMouse; private static readonly Color[] GroupPalette = (Color[])(object)new Color[2] { new Color(0.07f, 0.11f, 0.19f, 0.92f), new Color(0.21f, 0.08f, 0.09f, 0.92f) }; private static readonly Color[] InsetPalette = (Color[])(object)new Color[2] { new Color(0.16f, 0.22f, 0.34f, 0.88f), new Color(0.36f, 0.16f, 0.17f, 0.88f) }; private static readonly Color SectionCard = new Color(0.12f, 0.12f, 0.14f, 0.92f); private static readonly Color SectionInset = new Color(0.24f, 0.24f, 0.27f, 0.85f); private const float CardInset = 5f; private const float ListMargin = 12f; private const float ListMarginRight = 20f; private static float _nextRegroup; private static bool _loggedMultiParent; private static bool _loggedRegroupError; private static bool _loggedLayoutError; private static bool _loggedRegroup; private static float _nextDecor; private static int _refreshCalls; private static int _rowSwaps; private static float _nextRateLog; private static readonly Dictionary> RowHuntPerks = new Dictionary>(); private const string SectionAvailable = "§available"; private const string SectionUnavailable = "§unavailable"; private static string _labelAvailable; private static string _labelUnavailable; private static float _measuredWidth; private static GridLayoutGroup _grid; private static ContentSizeFitter _fitter; private static bool _gridWasEnabled; private static bool _fitterWasEnabled; private static bool _layoutTaken; private static bool _loggedLayout; private static bool _loggedViewport; private static LayoutElement _contentElement; private static LayoutSnapshot _layoutSnapshot; private static RectSnapshot _listRect; private static Transform _layoutParent; private const float RowHeight = 48f; private const float RowSpacing = 2f; private const float HeaderSpacingBefore = 6f; [HarmonyPatch(typeof(ServantListItem), "RefreshData")] [HarmonyPostfix] private static void RefreshDataPostfix(ServantListItem __0, Data __1) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__0 == (Object)null) { return; } LocalizedText currentStatus = __0.CurrentStatus; if ((Object)(object)currentStatus == (Object)null) { return; } Status status = __1.Status; string servantName = __1.ServantName; IntPtr pointer = ((Il2CppObjectBase)currentStatus).Pointer; if (AllRows.TryGetValue(((Il2CppObjectBase)__0).Pointer, out var value) && value.Name != servantName) { _rowSwaps++; } _refreshCalls++; AllRows[((Il2CppObjectBase)__0).Pointer] = new TrackedRow { Item = __0, Name = servantName, Status = status }; RowHuntPerks.TryGetValue(((Il2CppObjectBase)__0).Pointer, out var value2); RowDecor.Apply(__0, servantName, value2); if ((int)status == 0 || (int)status == 4) { Tracked[pointer] = new TrackedRow { Item = __0, Name = servantName, Status = status }; if ((int)status == 0) { HuntRows[((Il2CppObjectBase)__0).Pointer] = servantName; } else { HuntRows.Remove(((Il2CppObjectBase)__0).Pointer); } ApplyClock(currentStatus, servantName, status); } else { Tracked.Remove(pointer); HuntRows.Remove(((Il2CppObjectBase)__0).Pointer); } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts RefreshData postfix: " + ex.Message)); } } } [HarmonyPatch(typeof(LocalizedText), "LateUpdate")] [HarmonyPostfix] private static void LocalizedTextLateUpdatePostfix(LocalizedText __instance) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) try { if (Tracked.Count != 0 && !((Object)(object)__instance == (Object)null) && Tracked.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out var value)) { if ((Object)(object)value.Item == (Object)null) { Tracked.Remove(((Il2CppObjectBase)__instance).Pointer); } else { ApplyClock(__instance, value.Name, value.Status); } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts LateUpdate postfix: " + ex.Message)); } } } [HarmonyPatch(typeof(MapMenuMapper), "OnStopRunning")] [HarmonyPostfix] internal static void MapMenuStopPostfix() { RestoreLayout(); Tracked.Clear(); HuntRows.Clear(); AllRows.Clear(); RowHuntPerks.Clear(); RowDecor.Clear(); HuntHeaders.Clear(); TooltipDecor.Clear(); UiTextState.Restore(); RestoreLayout(); } [HarmonyPatch(typeof(GridSelectionEntry), "OnPointerClick")] [HarmonyPostfix] private static void EntryClickPostfix(GridSelectionEntry __instance, PointerEventData eventData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || eventData == null || (int)eventData.button != 0) { return; } string value; if (HuntHeaders.TryGetByEntry(((Il2CppObjectBase)__instance).Pointer, out var header)) { if (!string.IsNullOrEmpty(header.FirstServant)) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: click on hunt card '" + header.Dest + "'.")); } CenterOnServant(header.FirstServant); } } else if (HuntRows.Count != 0 && HuntRows.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out value)) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts: click on servant row '" + value + "'.")); } CenterOnServant(value); } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogDebug((object)("HuntsAndRifts row click postfix: " + ex.Message)); } } } internal static void Tick() { PollRowClicks(); RegroupIfDue(); DecorateIfDue(); } private static void DecorateIfDue() { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextDecor) { return; } _nextDecor = unscaledTime + 0.5f; if (unscaledTime >= _nextRateLog) { if (_nextRateLog > 0f && _refreshCalls > 0) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: " + _refreshCalls + " row refreshes / " + _rowSwaps + " name swaps in the last 5 s (" + AllRows.Count + " rows).")); } } _nextRateLog = unscaledTime + 5f; _refreshCalls = 0; _rowSwaps = 0; } if (AllRows.Count == 0) { return; } try { foreach (KeyValuePair allRow in AllRows) { TrackedRow value = allRow.Value; if ((Object)(object)value.Item == (Object)null) { continue; } try { if ((Object)(object)((Component)value.Item).gameObject == (Object)null || !((Component)value.Item).gameObject.activeSelf) { continue; } goto IL_0126; } catch { } continue; IL_0126: RowHuntPerks.TryGetValue(allRow.Key, out var value2); RowDecor.Apply(value.Item, value.Name, value2); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts decorate: " + ex.Message)); } } } private static void CenterOnServant(string name) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_lastCenterFrame == Time.frameCount) { return; } if (!HuntReader.TryGetHuntPos(name, out var worldXZ)) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: clicked hunt row " + name + " but no zone position is known.")); } } else { _lastCenterFrame = Time.frameCount; HuntMapFocus.CenterOn(worldXZ); } } private static void PollRowClicks() { //IL_0070: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if (HuntRows.Count == 0) { return; } Vector2 value; try { Mouse current = Mouse.current; if (current == null) { if (!_loggedNoMouse) { _loggedNoMouse = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)"HuntsAndRifts: InputSystem Mouse.current is null; relying on UI click handlers."); } } return; } bool isPressed = current.leftButton.isPressed; bool num = isPressed && !_mouseWasDown; _mouseWasDown = isPressed; if (!num) { return; } value = ((InputControl)(object)((Pointer)current).position).value; } catch { return; } foreach (HuntHeaders.Header item2 in HuntHeaders.All) { try { if ((Object)(object)item2.Root == (Object)null || !item2.Root.activeInHierarchy || string.IsNullOrEmpty(item2.FirstServant) || !Contains(item2.Rect, value)) { continue; } ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts: click on hunt header '" + item2.Dest + "'.")); } CenterOnServant(item2.FirstServant); return; } catch { } } foreach (KeyValuePair huntRow in HuntRows) { if (!AllRows.TryGetValue(huntRow.Key, out var value2) || (Object)(object)value2.Item == (Object)null) { continue; } ServantListItem item; try { item = value2.Item; if ((Object)(object)((Component)item).gameObject == (Object)null || !((Component)item).gameObject.activeInHierarchy) { continue; } goto IL_0191; } catch { } continue; IL_0191: if (RowContains(item, value)) { ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogInfo((object)("HuntsAndRifts: click on servant row '" + huntRow.Value + "'.")); } CenterOnServant(huntRow.Value); break; } } } private static bool RowContains(ServantListItem item, Vector2 screen) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) try { if (Contains(((Component)item).GetComponent(), screen)) { return true; } TextMeshProUGUI servantName = item.ServantName; if ((Object)(object)servantName != (Object)null && Contains(((TMP_Text)servantName).rectTransform, screen)) { return true; } LocalizedText currentStatus = item.CurrentStatus; if ((Object)(object)currentStatus != (Object)null && (Object)(object)currentStatus.Text != (Object)null && Contains(((TMP_Text)currentStatus.Text).rectTransform, screen)) { return true; } Image servantIcon = item.ServantIcon; if ((Object)(object)servantIcon != (Object)null && Contains(((Graphic)servantIcon).rectTransform, screen)) { return true; } } catch { } return false; } private static bool Contains(RectTransform rt, Vector2 screen) { //IL_0032: 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) if ((Object)(object)rt == (Object)null) { return false; } Camera val = null; try { Canvas componentInParent = ((Component)rt).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) { val = componentInParent.worldCamera; } } catch { } return RectTransformUtility.RectangleContainsScreenPoint(rt, screen, val); } private static void RegroupIfDue() { //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: 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_083a: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_0934: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Invalid comparison between Unknown and I4 //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Invalid comparison between Unknown and I4 //IL_0729: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextRegroup) { return; } _nextRegroup = unscaledTime + 0.25f; if (AllRows.Count == 0) { return; } try { List<(ServantListItem, int, string, Status, Transform)> list = new List<(ServantListItem, int, string, Status, Transform)>(AllRows.Count); Dictionary dictionary = new Dictionary(); foreach (KeyValuePair allRow in AllRows) { TrackedRow value = allRow.Value; ServantListItem item = value.Item; if ((Object)(object)item == (Object)null) { continue; } GameObject gameObject; try { gameObject = ((Component)item).gameObject; } catch { continue; } if (!((Object)(object)gameObject == (Object)null) && gameObject.activeInHierarchy) { Transform transform = ((Component)item).transform; Transform val = ServantScroll.OriginalParent(transform.parent); if (!((Object)(object)val == (Object)null)) { list.Add((item, transform.GetSiblingIndex(), value.Name, value.Status, val)); dictionary[((Il2CppObjectBase)val).Pointer] = ((!dictionary.TryGetValue(((Il2CppObjectBase)val).Pointer, out var value2)) ? 1 : (value2 + 1)); } } } Transform val2 = null; int num = 0; foreach (var item3 in list) { if (dictionary[((Il2CppObjectBase)item3.Item5).Pointer] > num) { num = dictionary[((Il2CppObjectBase)item3.Item5).Pointer]; val2 = item3.Item5; } } List<(ServantListItem, int, string, Status)> list2 = new List<(ServantListItem, int, string, Status)>(list.Count); TextMeshProUGUI val3 = null; RectTransform rowTemplate = null; foreach (var item4 in list) { if ((Object)(object)val2 == (Object)null || (Object)(object)item4.Item5 != (Object)(object)val2) { continue; } if ((Object)(object)val3 == (Object)null) { try { val3 = item4.Item1.ServantName; } catch { } try { rowTemplate = ((Component)item4.Item1).GetComponent(); } catch { } } list2.Add((item4.Item1, item4.Item2, item4.Item3, item4.Item4)); } if (dictionary.Count > 1 && !_loggedMultiParent) { _loggedMultiParent = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: servant rows found under " + dictionary.Count + " containers; using the one with " + num + " rows.")); } } if (list2.Count == 0 || (Object)(object)val2 == (Object)null) { HuntHeaders.HideExcept(null); return; } list2.Sort(((ServantListItem item, int sibling, string name, Status status) a, (ServantListItem item, int sibling, string name, Status status) b) => a.sibling.CompareTo(b.sibling)); float num2 = Mathf.Max(60f, MeasureRowWidth(list2[0].Item1) - 14f); Dictionary dictionary2 = new Dictionary(StringComparer.Ordinal); List<(ServantListItem, int, string, Status)> list3 = new List<(ServantListItem, int, string, Status)>(); RowHuntPerks.Clear(); foreach (var item5 in list2) { if ((int)item5.Item4 != 0) { list3.Add(item5); continue; } if (!HuntReader.TryGetHuntDest(item5.Item3, out var dest) || string.IsNullOrEmpty(dest)) { dest = "Hunt"; } if (!dictionary2.TryGetValue(dest, out var value3)) { Group obj4 = new Group { Dest = dest }; value3 = (dictionary2[dest] = obj4); } HuntReader.TryGetHuntRemaining(item5.Item3, out var seconds); if (seconds < value3.Remaining) { value3.Remaining = seconds; } value3.Rows.Add((item5.Item1, item5.Item2, item5.Item3)); if (ServantInfoReader.TryGetInfo(item5.Item3, out var info)) { if (((PrefabGUID)(ref info.Perk0)).GuidHash != 0) { value3.ServantPerks.Add(((PrefabGUID)(ref info.Perk0)).GuidHash); } if (((PrefabGUID)(ref info.Perk1)).GuidHash != 0) { value3.ServantPerks.Add(((PrefabGUID)(ref info.Perk1)).GuidHash); } } } List list4 = new List(dictionary2.Values); list4.Sort(delegate(Group x, Group y) { int num6 = x.Remaining.CompareTo(y.Remaining); return (num6 == 0) ? string.CompareOrdinal(x.Dest, y.Dest) : num6; }); List list5 = new List(list2.Count + list4.Count); HashSet hashSet = new HashSet(StringComparer.Ordinal); for (int num3 = 0; num3 < list4.Count; num3++) { Group obj6 = list4[num3]; Color value4 = InsetPalette[num3 % InsetPalette.Length]; Color tint = GroupPalette[num3 % GroupPalette.Length]; obj6.Rows.Sort(delegate((ServantListItem item, int sibling, string name) x, (ServantListItem item, int sibling, string name) y) { HuntReader.TryGetHuntRemaining(x.name, out var seconds2); HuntReader.TryGetHuntRemaining(y.name, out var seconds3); int num6 = seconds2.CompareTo(seconds3); return (num6 == 0) ? x.sibling.CompareTo(y.sibling) : num6; }); MissionInfoReader.Info info2 = null; PrefabGUID mission = default(PrefabGUID); if (HuntReader.TryGetMissionForZoneName(obj6.Dest, out mission)) { info2 = MissionInfoReader.Get(mission); } HashSet hashSet2 = null; if (info2 != null && info2.Perks.Count > 0) { hashSet2 = new HashSet(); foreach (PrefabGUID perk in info2.Perks) { PrefabGUID current4 = perk; hashSet2.Add(((PrefabGUID)(ref current4)).GuidHash); } } HuntHeaders.Header header = HuntHeaders.Get(obj6.Dest, val2, val3, rowTemplate, num2); if (header != null) { HuntHeaders.Fill(header, obj6.Remaining, mission, info2, obj6.ServantPerks, tint, obj6.Rows[0].name); list5.Add(header.Root.transform); hashSet.Add(obj6.Dest); } foreach (var row in obj6.Rows) { RowDecor.SetGroupTint(row.item, value4, num2 - 10f); if (hashSet2 != null) { RowHuntPerks[((Il2CppObjectBase)row.item).Pointer] = hashSet2; } RowDecor.Apply(row.item, row.name, hashSet2); list5.Add(((Component)row.item).transform); } } List<(ServantListItem, int, string, Status)> list6 = new List<(ServantListItem, int, string, Status)>(); List<(ServantListItem, int, string, Status)> list7 = new List<(ServantListItem, int, string, Status)>(); List<(ServantListItem, int, string, Status)> list8 = new List<(ServantListItem, int, string, Status)>(); foreach (var item6 in list3) { if ((int)item6.Item4 == 2 || (int)item6.Item4 == 4) { list7.Add(item6); } else if ((int)item6.Item4 == 0) { list8.Add(item6); } else { list6.Add(item6); } } Color sectionCard = SectionCard; ServantListItem item2 = list2[0].Item1; if (list8.Count > 0) { HuntHeaders.Header header2 = HuntHeaders.Get("__HuntsAndRifts_UnresolvedHunts", val2, val3, rowTemplate, num2); if (header2 != null) { string title = "Away on Hunt"; try { title = Localization.Get(item2.OnAHunt, false); } catch { } HuntHeaders.FillSection(header2, title, sectionCard); list5.Add(header2.Root.transform); hashSet.Add("__HuntsAndRifts_UnresolvedHunts"); } foreach (var item7 in list8) { RowDecor.SetGroupTint(item7.Item1, SectionInset, num2 - 10f); list5.Add(((Component)item7.Item1).transform); } } if (list6.Count > 0) { HuntHeaders.Header header3 = HuntHeaders.Get("§available", val2, val3, rowTemplate, num2); if (header3 != null) { HuntHeaders.FillSection(header3, SectionLabel(item2, available: true), sectionCard); list5.Add(header3.Root.transform); hashSet.Add("§available"); } foreach (var item8 in list6) { RowDecor.SetGroupTint(item8.Item1, SectionInset, num2 - 10f); list5.Add(((Component)item8.Item1).transform); } } if (list7.Count > 0) { HuntHeaders.Header header4 = HuntHeaders.Get("§unavailable", val2, val3, rowTemplate, num2); if (header4 != null) { HuntHeaders.FillSection(header4, SectionLabel(item2, available: false), sectionCard); list5.Add(header4.Root.transform); hashSet.Add("§unavailable"); } foreach (var item9 in list7) { RowDecor.SetGroupTint(item9.Item1, SectionInset, num2 - 10f); list5.Add(((Component)item9.Item1).transform); } } HuntHeaders.HideExcept(hashSet); HuntHeaders.SweepOrphans(val2, hashSet); bool flag = false; for (int num4 = 0; num4 < list5.Count; num4++) { if (list5[num4].GetSiblingIndex() != num4) { flag = true; break; } } if (flag) { for (int num5 = 0; num5 < list5.Count; num5++) { list5[num5].SetSiblingIndex(num5); } } ManualLayout(val2, list5, num2); if (flag && !_loggedRegroup) { _loggedRegroup = true; ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts: grouped " + list2.Count + " servant rows into " + list4.Count + " hunts (+" + list3.Count + " other).")); } } } catch (Exception ex) { if (!_loggedRegroupError) { _loggedRegroupError = true; ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogInfo((object)("HuntsAndRifts regroup failed: " + ex)); } } } } private static string SectionLabel(ServantListItem template, bool available) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (available && _labelAvailable != null) { return _labelAvailable; } if (!available && _labelUnavailable != null) { return _labelUnavailable; } try { if (available) { _labelAvailable = (((Object)(object)template != (Object)null) ? Loc(template.Available, "Available") : "Available"); } else { string obj = (((Object)(object)template != (Object)null) ? Loc(template.Injured, "Injured") : "Injured"); string text = (((Object)(object)template != (Object)null) ? Loc(template.Dead, "Dead") : "Dead"); _labelUnavailable = obj + " / " + text; } } catch { if (available) { _labelAvailable = "Available"; } else { _labelUnavailable = "Injured / Dead"; } } if (!available) { return _labelUnavailable; } return _labelAvailable; static string Loc(LocalizationKey key, string fallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { string text2 = Localization.Get(key, false); if (!string.IsNullOrWhiteSpace(text2) && text2.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { return text2.Trim(); } } catch { } return fallback; } } private static void ManualLayout(Transform parent, List order, float contentWidth) { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: 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_03db: Unknown result type (might be due to invalid IL or missing references) try { RectTransform val = (RectTransform)(((object)((parent is RectTransform) ? parent : null)) ?? ((object)((Component)parent).GetComponent())); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)_layoutParent == (Object)null || (Object)(object)_layoutParent != (Object)(object)parent) { RestoreLayout(); _layoutParent = parent; _listRect = new RectSnapshot(val); _layoutSnapshot = new LayoutSnapshot(((Component)parent).gameObject); _grid = ((Component)parent).GetComponent(); _fitter = ((Component)parent).GetComponent(); _gridWasEnabled = (Object)(object)_grid != (Object)null && ((Behaviour)_grid).enabled; _fitterWasEnabled = (Object)(object)_fitter != (Object)null && ((Behaviour)_fitter).enabled; _layoutTaken = false; } if (!_layoutTaken) { if ((Object)(object)_grid != (Object)null) { ((Behaviour)_grid).enabled = false; } _layoutTaken = true; if (!_loggedLayout) { _loggedLayout = true; ScrollRect val2 = null; try { val2 = ((Component)parent).GetComponentInParent(); } catch { } string text = "none"; if ((Object)(object)val2 != (Object)null) { text = ((Object)val2).name + (((Object)(object)val2.verticalScrollbar != (Object)null) ? " with scrollbar" : " no scrollbar"); } ManualLogSource logger = Plugin.Logger; if (logger != null) { string[] obj2 = new string[9] { "HuntsAndRifts: manual servant layout (grid ", ((Object)(object)_grid != (Object)null).ToString(), ", fitter ", ((Object)(object)_fitter != (Object)null).ToString(), ", scroll view ", text, ", content ", null, null }; Rect rect = val.rect; obj2[7] = ((object)((Rect)(ref rect)).size/*cast due to .constrained prefix*/).ToString(); obj2[8] = ")."; logger.LogInfo((object)string.Concat(obj2)); } } } float num = (((Object)(object)_grid != (Object)null) ? _grid.cellSize.x : 100f); ServantScroll.Prepare(val, order); float num2 = 0f; float num3 = 0f; try { if ((Object)(object)_grid != (Object)null) { num2 = 12f; num3 = Mathf.Max(0f, (float)((LayoutGroup)_grid).padding.top - 14f); } if (!_loggedViewport) { _loggedViewport = true; ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts: list starts at grid padding " + num2 + "/" + num3 + ".")); } } } catch { } HuntHeaders.Header card = null; float cardTop = 0f; Vector2 val5 = default(Vector2); Vector2 val6 = default(Vector2); for (int i = 0; i < order.Count; i++) { Transform val3 = order[i]; RectTransform val4 = (RectTransform)(((object)((val3 is RectTransform) ? val3 : null)) ?? ((object)((Component)val3).GetComponent())); if ((Object)(object)val4 == (Object)null) { continue; } bool flag = ((Object)val3).name.StartsWith("HuntsAndRifts_Hunt_", StringComparison.Ordinal); float num4 = (flag ? 24f : 48f); if (flag) { if (i > 0) { CloseCard(num3 - 2f); num3 += 6f; } card = HuntHeaders.FindByRoot(val3); cardTop = num3; } val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(0f, 1f); val4.pivot = new Vector2(0f, 1f); ((Vector2)(ref val5))..ctor(flag ? contentWidth : num, num4); if (val4.sizeDelta != val5) { val4.sizeDelta = val5; } ((Vector2)(ref val6))..ctor(flag ? num2 : (num2 + 5f), 0f - num3); if (val4.anchoredPosition != val6) { val4.anchoredPosition = val6; } num3 += num4 + 2f; } CloseCard(num3 - 2f); float total = Mathf.Max(0f, num3 - 2f) + (((Object)(object)_grid != (Object)null) ? ((float)((LayoutGroup)_grid).padding.bottom) : 0f) + 8f; total = ServantScroll.Size(total); LayoutElement val7 = (_contentElement = _layoutSnapshot.Element); if (!((Behaviour)val7).enabled) { ((Behaviour)val7).enabled = true; } if (Mathf.Abs(val7.preferredHeight - total) > 0.5f) { val7.preferredHeight = total; val7.minHeight = total; } void CloseCard(float bottom) { if (card != null) { HuntHeaders.SetCardHeight(card, bottom - cardTop + 5f); } card = null; } } catch (Exception ex) { if (!_loggedLayoutError) { _loggedLayoutError = true; ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogInfo((object)("HuntsAndRifts manual layout failed: " + ex)); } } } } internal static void RestoreLayout() { ServantScroll.Reset(); try { if (_layoutTaken) { if ((Object)(object)_grid != (Object)null) { ((Behaviour)_grid).enabled = _gridWasEnabled; } if ((Object)(object)_fitter != (Object)null) { ((Behaviour)_fitter).enabled = _fitterWasEnabled; } _layoutSnapshot?.Restore(); _listRect?.Restore(); } } catch { } _layoutTaken = false; _layoutSnapshot = null; _listRect = null; _layoutParent = null; _grid = null; _fitter = null; } private static float MeasureRowWidth(ServantListItem item) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) try { RectTransform rowRt = ((Component)item).GetComponent(); if ((Object)(object)rowRt == (Object)null) { return _measuredWidth; } Vector3[] corners = (Vector3[])(object)new Vector3[4]; float maxX = float.NegativeInfinity; try { Acc(((Object)(object)item.ServantName != (Object)null) ? ((TMP_Text)item.ServantName).rectTransform : null); } catch { } try { Acc(((Object)(object)item.CurrentStatus != (Object)null && (Object)(object)item.CurrentStatus.Text != (Object)null) ? ((TMP_Text)item.CurrentStatus.Text).rectTransform : null); } catch { } try { Acc(((Object)(object)item.ServantIcon != (Object)null) ? ((Graphic)item.ServantIcon).rectTransform : null); } catch { } float num = 0f - rowRt.pivot.x; Rect rect = rowRt.rect; float num2 = num * ((Rect)(ref rect)).width; float num3 = (float.IsInfinity(maxX) ? 0f : (maxX - num2)); try { Transform parent = ((Transform)rowRt).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val == (Object)null && (Object)(object)((Transform)rowRt).parent != (Object)null) { val = ((Component)((Transform)rowRt).parent).GetComponent(); } if ((Object)(object)val != (Object)null) { rect = val.rect; float num4 = ((Rect)(ref rect)).width - 12f - 20f; if (num4 > num3) { num3 = num4; } } } catch { } if (num3 < 150f || num3 >= 2000f) { num3 = 240f; } if (Mathf.Abs(num3 - _measuredWidth) > 0.5f) { _measuredWidth = num3; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts: servant row content width " + num3.ToString("0") + " (children max x " + (float.IsInfinity(maxX) ? "none" : maxX.ToString("0")) + ").")); } } return _measuredWidth; void Acc(RectTransform rt) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0046: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { rt.GetWorldCorners(Il2CppStructArray.op_Implicit(corners)); for (int i = 0; i < 4; i++) { Vector3 val2 = ((Transform)rowRt).InverseTransformPoint(corners[i]); if (val2.x > maxX) { maxX = val2.x; } } } } } catch { return _measuredWidth; } } private static void ApplyClock(LocalizedText statusText, string servantName, Status status) { //IL_0015: 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_0025: Invalid comparison between Unknown and I4 //IL_00be: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)statusText == (Object)null) { return; } UiTextState.Track((TMP_Text)(object)statusText.Text); bool flag; double seconds; if ((int)status == 0) { flag = HuntReader.TryGetHuntRemaining(servantName, out seconds); } else { if ((int)status != 4) { return; } flag = HuntReader.TryGetInjuryRemaining(servantName, out seconds); } if (!flag) { return; } string text = statusText.GetText(); if (string.IsNullOrEmpty(text)) { return; } text = ClockSuffix.Replace(text, string.Empty).TrimEnd(); string text2 = "" + text + " " + HuntReader.FormatRemaining(seconds) + ""; if (statusText.GetText() == text2) { return; } try { if ((Object)(object)statusText.Text != (Object)null) { ((TMP_Text)statusText.Text).richText = true; if ((int)((TMP_Text)statusText.Text).fontStyle != 0) { ((TMP_Text)statusText.Text).fontStyle = (FontStyles)0; } } } catch { } statusText.ForceSet(text2); } } [HarmonyPatch(typeof(ServantInfoEventSystem_Client), "Refresh")] internal static class ServantResponsePatches { [HarmonyPrefix] private static void Prefix(Entity __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { ServantInfoReader.BeginThrone(__0); } catch (Exception ex) { ServantInfoReader.Clear(); ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogWarning((object)("HuntsAndRifts servant response reset: " + ex.Message)); } } } } [HarmonyPatch] internal static class ServantSelectPatches { private static readonly Regex ClockSuffix = new Regex("\\s+\\d+h(?: \\d+m)?$|\\s+\\d+m$|\\s+\\d+s$", RegexOptions.Compiled); private static readonly Dictionary Tracked = new Dictionary(); [HarmonyPatch(typeof(ServantSelectEntry), "RefreshData")] [HarmonyPostfix] private static void RefreshDataPostfix(ServantSelectEntry __0, Data __1) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 try { if ((Object)(object)__0 == (Object)null) { return; } LocalizedText issueText = __0.IssueText; if (!((Object)(object)issueText == (Object)null)) { UiTextState.Track((TMP_Text)(object)issueText.Text); State state = __1.State; string name = __1.Name; if ((int)state == 5 || (int)state == 1) { Tracked[((Il2CppObjectBase)issueText).Pointer] = (name, (int)state == 5); Apply(issueText, name, (int)state == 5); } else { Tracked.Remove(((Il2CppObjectBase)issueText).Pointer); } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts select refresh: " + ex.Message)); } } } [HarmonyPatch(typeof(LocalizedText), "LateUpdate")] [HarmonyPostfix] private static void LateUpdatePostfix(LocalizedText __instance) { try { if (Tracked.Count != 0 && !((Object)(object)__instance == (Object)null) && Tracked.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out (string, bool) value)) { Apply(__instance, value.Item1, value.Item2); } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts select late: " + ex.Message)); } } } [HarmonyPatch(typeof(MapMenuMapper), "OnStopRunning")] [HarmonyPostfix] internal static void MapMenuStopPostfix() { Tracked.Clear(); } private static void Apply(LocalizedText issue, string name, bool hunt) { if ((Object)(object)issue == (Object)null || string.IsNullOrEmpty(name) || !(hunt ? HuntReader.TryGetHuntRemaining(name, out var seconds) : HuntReader.TryGetInjuryRemaining(name, out seconds))) { return; } string text = issue.GetText(); if (!string.IsNullOrEmpty(text)) { text = ClockSuffix.Replace(text, string.Empty).TrimEnd(); string text2 = text + " " + HuntReader.FormatRemaining(seconds); if (!(issue.GetText() == text2)) { issue.ForceSet(text2); } } } } [BepInPlugin("fangly.HuntsAndRifts", "HuntsAndRifts", "1.0.0")] [BepInProcess("VRising.exe")] public class Plugin : BasePlugin { internal const string GUID = "fangly.HuntsAndRifts"; internal const string NAME = "HuntsAndRifts"; internal const string VERSION = "1.0.0"; private Harmony _harmony; internal static Plugin Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static ConfigEntry IncludeTestTiers { get; private set; } internal static ConfigEntry NoMapTip { get; private set; } internal static ConfigEntry WaitMinorSeconds { get; private set; } internal static ConfigEntry WaitMajorSeconds { get; private set; } public override void Load() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown Instance = this; Logger = ((BasePlugin)this).Log; if (Application.productName == "VRisingServer") { ((BasePlugin)this).Log.LogInfo((object)"HuntsAndRifts is a client-only plugin; not loading on VRisingServer."); return; } IncludeTestTiers = ((BasePlugin)this).Config.Bind("Rifts", "IncludeTestTiers", false, "When false (default), overlay shows only live rift tiers the client actually has. When true, also fill missing T1/T2 rows with TEST countdowns."); NoMapTip = ((BasePlugin)this).Config.Bind("Map", "no_map_tip", true, "When true (default), hide the 'Servant Hunts' help box (\"Maximize resource gathering...\") in the map's servant view."); WaitMinorSeconds = ((BasePlugin)this).Config.Bind("Rifts", "observed_wait_minor_seconds", 6000, "Full wait between T1 rifts as last observed (drives the T1 countdown bar). Updated automatically."); WaitMajorSeconds = ((BasePlugin)this).Config.Bind("Rifts", "observed_wait_major_seconds", 6000, "Full wait between T2 rifts as last observed (drives the T2 countdown bar). Updated automatically."); MapRiftOverlay.Spawn(); _harmony = new Harmony("fangly.HuntsAndRifts"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BasePlugin)this).Log.LogInfo((object)"HuntsAndRifts 1.0.0 loaded (client). Hunt remaining on the throne Servants list; pickup floaters show bag total; map overlay shows T1 and T2 Mortium rifts under the rift card."); } public override bool Unload() { ServantListPatches.MapMenuStopPostfix(); ServantSelectPatches.MapMenuStopPostfix(); ServantInfoReader.Clear(); MapWarEventPatches.RestoreTip(); HuntMapFocus.Clear(); RiftCardExtension.Reset(); MapRiftOverlay.DestroyHost(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } internal static class PluginInfo { public const string GUID = "fangly.HuntsAndRifts"; public const string Name = "HuntsAndRifts"; public const string Version = "1.0.0"; } internal sealed class RectSnapshot { private readonly RectTransform _rect; private readonly Transform _parent; private readonly int _sibling; private readonly Vector2 _min; private readonly Vector2 _max; private readonly Vector2 _pivot; private readonly Vector2 _size; private readonly Vector2 _position; private readonly Vector3 _scale; internal RectSnapshot(RectTransform rect) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //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_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_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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) _rect = rect; _parent = ((Transform)rect).parent; _sibling = ((Transform)rect).GetSiblingIndex(); _min = rect.anchorMin; _max = rect.anchorMax; _pivot = rect.pivot; _size = rect.sizeDelta; _position = rect.anchoredPosition; _scale = ((Transform)rect).localScale; } internal void Restore() { //IL_0047: 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_0069: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_rect == (Object)null)) { if ((Object)(object)_parent != (Object)null) { ((Transform)_rect).SetParent(_parent, false); } ((Transform)_rect).SetSiblingIndex(_sibling); _rect.anchorMin = _min; _rect.anchorMax = _max; _rect.pivot = _pivot; _rect.sizeDelta = _size; _rect.anchoredPosition = _position; ((Transform)_rect).localScale = _scale; } } } internal static class RiftCardExtension { private const string RowName = "HuntsAndRifts_RiftRow"; private static GameObject _row; private static RectTransform _rowRect; private static Image _rowBg; private static TextMeshProUGUI _label; private static TextMeshProUGUI _timer; private static Image _fill; private static Image _badge; private static float _height; private static float _baseHeight; private static bool _parentIsLayout; private static bool _parentControlsHeight; private static RectTransform _territories; private static float _territoriesShift; private static bool _loggedOnce; private static bool _built; private static IntPtr _cardPtr; private static RectSnapshot _cardRectSnapshot; private static LayoutSnapshot _cardLayoutSnapshot; private static RectTransform _card; private static Vector2 _lastShiftedPosition; private static bool _loggedError; private static bool _loggedFail; private static int _retries; private static readonly Dictionary Waits = new Dictionary(); internal static void Reset() { //IL_0057: 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) _cardLayoutSnapshot?.Restore(); _cardRectSnapshot?.Restore(); _cardLayoutSnapshot = null; _cardRectSnapshot = null; _card = null; _built = false; try { if ((Object)(object)_territories != (Object)null && _territoriesShift != 0f) { RectTransform territories = _territories; territories.anchoredPosition -= new Vector2(0f, _territoriesShift); } } catch { } _territories = null; _territoriesShift = 0f; _retries = 0; try { if ((Object)(object)_row != (Object)null && _row.activeSelf) { _row.SetActive(false); } if ((Object)(object)_row != (Object)null) { Object.Destroy((Object)(object)_row); } _row = null; } catch { } } internal static void Apply(MapWarEventInfoEntry info, MapMenu menu, RiftTrack? secondary) { //IL_0149: 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_015c: 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_0170: Unknown result type (might be due to invalid IL or missing references) //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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected I4, but got Unknown try { if ((Object)(object)info == (Object)null) { return; } RectTransform component = ((Component)info).GetComponent(); if ((Object)(object)component == (Object)null) { Fail("card has no RectTransform"); return; } if (!secondary.HasValue) { if (_built) { Reset(); } return; } if (!_built || (Object)(object)_row == (Object)null || _cardPtr != ((Il2CppObjectBase)component).Pointer) { if (_built) { Reset(); } if (!Build(info, component)) { return; } _cardPtr = ((Il2CppObjectBase)component).Pointer; _built = true; } if (!_row.activeSelf) { _row.SetActive(true); } if (_parentIsLayout) { LayoutElement val = ((Component)component).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)component).gameObject.AddComponent(); } float num = _baseHeight + _height; if (Mathf.Abs(val.preferredHeight - num) > 0.5f) { val.preferredHeight = num; val.minHeight = num; } if (Mathf.Abs(component.sizeDelta.y - num) > 0.5f && !_parentControlsHeight) { component.sizeDelta = new Vector2(component.sizeDelta.x, num); } } else { if (component.anchoredPosition != _lastShiftedPosition) { component.anchoredPosition += new Vector2(0f, _height); _lastShiftedPosition = component.anchoredPosition; } ShiftTerritories(menu); } RiftTrack value = secondary.Value; string text = TierName(value.Type) + ((value.Level > 0) ? (" (" + value.Level + "+)") : ""); string text2 = ((!value.IsActive) ? ((value.NextInSeconds < 0.0) ? (text + " awaiting schedule") : (text + " next in " + Format(value.NextInSeconds))) : ((value.RemainingSeconds < 0.0) ? (text + " active") : (text + " active: " + Format(value.RemainingSeconds)))); if ((Object)(object)_timer != (Object)null && ((TMP_Text)_timer).text != text2) { ((TMP_Text)_timer).text = text2; } if ((Object)(object)_label != (Object)null && ((TMP_Text)_label).text != "Status") { ((TMP_Text)_label).text = "Status"; } if ((Object)(object)_fill != (Object)null) { float num2 = Fill(value); if (Mathf.Abs(_fill.fillAmount - num2) > 0.002f) { _fill.fillAmount = num2; } } if ((Object)(object)_badge != (Object)null) { Sprite val2 = null; try { WarEventType type = value.Type; val2 = (Sprite)((int)type switch { 1 => info.WarEvent_Minor_Icon, 0 => info.WarEvent_Major_Icon, 2 => info.WarEvent_Primal_Icon, _ => null, }); } catch { } if ((Object)(object)val2 != (Object)null && (Object)(object)_badge.sprite != (Object)(object)val2) { _badge.sprite = val2; } bool flag = value.IsActive && (Object)(object)val2 != (Object)null; if (((Component)_badge).gameObject.activeSelf != flag) { ((Component)_badge).gameObject.SetActive(flag); } } } catch (Exception ex) { if (!_loggedError) { _loggedError = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift row failed: " + ex)); } } } } private static void Fail(string why) { if (!_loggedFail) { _loggedFail = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift row not built: " + why + ".")); } } } internal static void ResetTiming() { Waits.Clear(); } internal static float Fill(RiftTrack t) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_00d9: Unknown result type (might be due to invalid IL or missing references) Waits.TryGetValue(t.Type, out (bool, double) value); if (t.IsActive) { Waits[t.Type] = (true, 0.0); if (t.RemainingSeconds < 0.0) { return 1f; } if (RiftReader.TryGetSchedule(t.Type, out var duration, out var _) && duration > 0.0) { return Mathf.Clamp01((float)(t.RemainingSeconds / duration)); } return 1f; } if (t.NextInSeconds < 0.0) { return 0f; } double nextInSeconds = t.NextInSeconds; double num = ((value.Item1 || value.Item2 <= 0.0) ? nextInSeconds : Math.Max(value.Item2, nextInSeconds)); Waits[t.Type] = (false, num); if (num <= 0.0) { return 0f; } return Mathf.Clamp01((float)(1.0 - nextInSeconds / num)); } private static string Format(double seconds) { if (seconds < 0.0) { seconds = 0.0; } int num = (int)Math.Floor(seconds); int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; if (num2 > 0) { return num2 + "h " + num3 + "m"; } if (num3 > 0) { return num3 + "m " + num4 + "s"; } return num4 + "s"; } private unsafe static string TierName(WarEventType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)t switch { 1 => "T1", 0 => "T2", 2 => "Primal", _ => ((object)(*(WarEventType*)(&t))/*cast due to .constrained prefix*/).ToString(), }; } private unsafe static bool Build(MapWarEventInfoEntry info, RectTransform card) { //IL_0b1f: Unknown result type (might be due to invalid IL or missing references) //IL_0b21: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Unknown result type (might be due to invalid IL or missing references) //IL_0b3d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_013b: 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_0144: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: 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_021a: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Expected O, but got Unknown //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0790: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Invalid comparison between Unknown and I4 //IL_08eb: Unknown result type (might be due to invalid IL or missing references) //IL_08f0: Unknown result type (might be due to invalid IL or missing references) //IL_0912: Unknown result type (might be due to invalid IL or missing references) //IL_0927: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_0967: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_0990: Unknown result type (might be due to invalid IL or missing references) Image fillImage = info.FillImage; LocalizedText timerText = info.TimerText; if ((Object)(object)fillImage == (Object)null || (Object)(object)timerText == (Object)null || (Object)(object)timerText.Text == (Object)null) { Fail("FillImage " + ((Object)(object)fillImage != (Object)null) + ", TimerText " + ((Object)(object)timerText != (Object)null) + ", TimerText.Text " + ((Object)(object)timerText != (Object)null && (Object)(object)timerText.Text != (Object)null)); return false; } Transform parent = ((Component)fillImage).transform.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val == (Object)null) { val = (((Object)(object)((Component)fillImage).transform.parent != (Object)null) ? ((Component)((Component)fillImage).transform.parent).GetComponent() : null); } if ((Object)(object)val == (Object)null) { Fail("bar parent has no RectTransform"); return false; } RectTransform rectTransform = ((TMP_Text)timerText.Text).rectTransform; float num = 0f - card.pivot.x; Rect val2 = card.rect; float cardLeft = num * ((Rect)(ref val2)).width; Rect val3 = LocalRect(val); Rect val4 = LocalRect(rectTransform); Rect val5 = default(Rect); ((Rect)(ref val5))..ctor(((Rect)(ref val4)).x, ((Rect)(ref val4)).yMax + 2f, 200f, 16f); val2 = card.rect; float num2; if (!(((Rect)(ref val2)).width > 50f)) { num2 = 400f; } else { val2 = card.rect; num2 = ((Rect)(ref val2)).width; } float num3 = num2; bool flag = ((Rect)(ref val3)).width > 10f && ((Rect)(ref val4)).height > 4f && Mathf.Abs(((Rect)(ref val3)).y) < 2000f && Mathf.Abs(((Rect)(ref val4)).y) < 2000f; if (_retries == 0) { ManualLogSource logger = Plugin.Logger; if (logger != null) { string[] obj = new string[10] { "HuntsAndRifts rift row: measured bar ", null, null, null, null, null, null, null, null, null }; val2 = val3; obj[1] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[2] = " timer "; val2 = val4; obj[3] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[4] = " label "; val2 = val5; obj[5] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[6] = " card "; val2 = card.rect; obj[7] = ((object)((Rect)(ref val2)).size/*cast due to .constrained prefix*/).ToString(); obj[8] = " sane "; obj[9] = flag.ToString(); logger.LogInfo((object)string.Concat(obj)); } } if (!flag) { _retries++; if (_retries < 30) { return false; } ((Rect)(ref val5))..ctor(34f, 60f, 200f, 16f); ((Rect)(ref val4))..ctor(24f, 36f, num3 - 48f, 24f); ((Rect)(ref val3))..ctor(0f, 8f, num3, 20f); } float num4 = Mathf.Max(new float[3] { ((Rect)(ref val5)).yMax, ((Rect)(ref val4)).yMax, ((Rect)(ref val3)).yMax }); float num5 = Mathf.Min(new float[3] { ((Rect)(ref val5)).y, ((Rect)(ref val4)).y, ((Rect)(ref val3)).y }); _height = num4 - num5 + 12f; Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(((Rect)(ref val5)).x, 6f + (((Rect)(ref val5)).y - num5), ((Rect)(ref val5)).width, ((Rect)(ref val5)).height); Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(((Rect)(ref val4)).x, 6f + (((Rect)(ref val4)).y - num5), Mathf.Max(((Rect)(ref val4)).width, 240f), ((Rect)(ref val4)).height); Rect val8 = default(Rect); ((Rect)(ref val8))..ctor(((Rect)(ref val3)).x, 6f + (((Rect)(ref val3)).y - num5), ((Rect)(ref val3)).width, ((Rect)(ref val3)).height); val2 = card.rect; _baseHeight = ((Rect)(ref val2)).height; _card = card; _cardRectSnapshot = new RectSnapshot(card); _cardLayoutSnapshot = new LayoutSnapshot(((Component)card).gameObject); _lastShiftedPosition = new Vector2(float.NaN, float.NaN); Transform val9 = ((Transform)card).Find("HuntsAndRifts_RiftRow"); if ((Object)(object)val9 != (Object)null) { Object.Destroy((Object)(object)((Component)val9).gameObject); } _row = new GameObject("HuntsAndRifts_RiftRow"); _rowRect = _row.AddComponent(); ((Transform)_rowRect).SetParent((Transform)(object)card, false); _rowRect.anchorMin = new Vector2(0f, 0f); _rowRect.anchorMax = new Vector2(1f, 0f); _rowRect.pivot = new Vector2(0.5f, 0f); _rowRect.sizeDelta = new Vector2(0f, _height); _rowRect.anchoredPosition = Vector2.zero; ((Transform)_rowRect).localScale = Vector3.one; _rowBg = _row.AddComponent(); ((Graphic)_rowBg).raycastTarget = false; Image component = ((Component)card).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null) { _rowBg.sprite = component.sprite; _rowBg.type = component.type; ((Graphic)_rowBg).color = ((Graphic)component).color; ((Graphic)_rowBg).material = ((Graphic)component).material; } else { ((Graphic)_rowBg).color = new Color(0.06f, 0.07f, 0.09f, 0.92f); } _label = MakeText("Label", (TMP_Text)(object)timerText.Text, 0.72f); RectTransform rectTransform2 = ((TMP_Text)_label).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(0f, 1f); rectTransform2.pivot = new Vector2(0f, 1f); rectTransform2.sizeDelta = new Vector2(Mathf.Max(((Rect)(ref val6)).width, 120f), ((Rect)(ref val6)).height); rectTransform2.anchoredPosition = new Vector2(((Rect)(ref val6)).xMin, 0f - (_height - ((Rect)(ref val6)).yMax)); ((Graphic)_label).color = new Color(0.62f, 0.62f, 0.62f, 1f); ((TMP_Text)_label).fontStyle = (FontStyles)0; _timer = MakeText("Timer", (TMP_Text)(object)timerText.Text, 1f); RectTransform rectTransform3 = ((TMP_Text)_timer).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 1f); rectTransform3.anchorMax = new Vector2(0f, 1f); rectTransform3.pivot = new Vector2(0f, 1f); rectTransform3.sizeDelta = new Vector2(((Rect)(ref val7)).width, ((Rect)(ref val7)).height); rectTransform3.anchoredPosition = new Vector2(((Rect)(ref val7)).xMin, 0f - (_height - ((Rect)(ref val7)).yMax)); GameObject val10 = Object.Instantiate(((Component)val).gameObject, _row.transform, false); ((Object)val10).name = "Bar"; RectTransform component2 = val10.GetComponent(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(0f, 1f); component2.pivot = new Vector2(0f, 1f); component2.sizeDelta = new Vector2(((Rect)(ref val8)).width, ((Rect)(ref val8)).height); component2.anchoredPosition = new Vector2(((Rect)(ref val8)).xMin, 0f - (_height - ((Rect)(ref val8)).yMax)); ((Transform)component2).localScale = Vector3.one; _fill = null; string name = ((Object)fillImage).name; foreach (Image componentsInChild in val10.GetComponentsInChildren(true)) { if (((Object)componentsInChild).name == name) { _fill = componentsInChild; break; } } if ((Object)(object)_fill == (Object)null) { foreach (Image componentsInChild2 in val10.GetComponentsInChildren(true)) { if ((int)componentsInChild2.type == 3) { _fill = componentsInChild2; break; } } } foreach (Graphic componentsInChild3 in val10.GetComponentsInChildren(true)) { componentsInChild3.raycastTarget = false; } try { GameObject val11 = new GameObject("Badge"); RectTransform obj2 = val11.AddComponent(); ((Transform)obj2).SetParent(_row.transform, false); obj2.anchorMin = new Vector2(1f, 1f); obj2.anchorMax = new Vector2(1f, 1f); obj2.pivot = new Vector2(1f, 1f); float num6 = Mathf.Clamp(_height - 8f, 28f, 52f); obj2.sizeDelta = new Vector2(num6, num6); obj2.anchoredPosition = new Vector2(-14f, -4f); ((Transform)obj2).localScale = Vector3.one; _badge = val11.AddComponent(); ((Graphic)_badge).raycastTarget = false; _badge.preserveAspect = true; val11.SetActive(false); } catch { _badge = null; } _parentIsLayout = false; _parentControlsHeight = false; string text = "none"; try { Transform parent2 = ((Transform)card).parent; if ((Object)(object)parent2 != (Object)null) { VerticalLayoutGroup component3 = ((Component)parent2).GetComponent(); HorizontalOrVerticalLayoutGroup component4 = ((Component)parent2).GetComponent(); HorizontalOrVerticalLayoutGroup val12 = (HorizontalOrVerticalLayoutGroup)(((object)component3) ?? ((object)component4)); _parentIsLayout = (Object)(object)val12 != (Object)null; _parentControlsHeight = (Object)(object)val12 != (Object)null && val12.childControlHeight; text = ((Object)parent2).name + (((Object)(object)val12 != (Object)null) ? (" (layout, controlHeight " + val12.childControlHeight + ")") : " (no layout)"); } } catch { } try { LayoutElement component5 = ((Component)card).GetComponent(); if ((Object)(object)component5 != (Object)null && _parentIsLayout) { component5.preferredHeight = _baseHeight + _height; component5.minHeight = _baseHeight + _height; } } catch { } if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { string[] obj6 = new string[13] { "HuntsAndRifts rift row: height ", _height.ToString("0"), " (card base ", _baseHeight.ToString("0"), "), bar ", null, null, null, null, null, null, null, null }; val2 = val8; obj6[5] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj6[6] = ", timer "; val2 = val7; obj6[7] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj6[8] = ", fill "; obj6[9] = (((Object)(object)_fill != (Object)null) ? ((Object)_fill).name : "none"); obj6[10] = ", parent "; obj6[11] = text; obj6[12] = "."; logger2.LogInfo((object)string.Concat(obj6)); } } return true; Rect LocalRect(RectTransform rt) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 val13 = ((Transform)card).InverseTransformPoint(((Transform)rt).position); Rect rect = rt.rect; float width = ((Rect)(ref rect)).width; rect = rt.rect; float height = ((Rect)(ref rect)).height; float num7 = val13.x - rt.pivot.x * width; float num8 = val13.y - rt.pivot.y * height; return new Rect(num7 - cardLeft, num8, width, height); } } private static TextMeshProUGUI MakeText(string name, TMP_Text template, float scale) { //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_001d: 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_0081: 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) GameObject val = new GameObject(name); RectTransform obj = val.AddComponent(); ((Transform)obj).SetParent(_row.transform, false); ((Transform)obj).localScale = Vector3.one; TextMeshProUGUI val2 = val.AddComponent(); ((TMP_Text)val2).richText = true; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)4097; try { ((TMP_Text)val2).font = template.font; ((TMP_Text)val2).fontSharedMaterial = template.fontSharedMaterial; ((TMP_Text)val2).fontSize = template.fontSize * scale; ((Graphic)val2).color = ((Graphic)template).color; ((TMP_Text)val2).fontStyle = template.fontStyle; ((TMP_Text)val2).characterSpacing = template.characterSpacing; ((TMP_Text)val2).alignment = template.alignment; } catch { } return val2; } private static void ShiftTerritories(MapMenu menu) { //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00bd: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_territories == (Object)null) { GridLayoutGroup val = (((Object)(object)menu != (Object)null) ? menu.Grid_TerritoryList : null); if ((Object)(object)val == (Object)null) { return; } Transform parent = ((Component)val).transform.parent; RectTransform val2 = null; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 8; i++) { if (!((Object)(object)parent != (Object)null)) { break; } RectTransform val3 = (RectTransform)(((object)((parent is RectTransform) ? parent : null)) ?? ((object)((Component)parent).GetComponent())); if ((Object)(object)val3 != (Object)null) { StringBuilder stringBuilder2 = stringBuilder.Append(((Object)parent).name).Append(' '); Rect rect = val3.rect; stringBuilder2.Append(((Rect)(ref rect)).size).Append(" > "); rect = val3.rect; float height = ((Rect)(ref rect)).height; rect = val3.rect; float width = ((Rect)(ref rect)).width; if ((Object)(object)val2 == (Object)null && height > 120f && height < 900f && width > 150f && width < 700f && (Object)(object)((Component)parent).GetComponent() != (Object)null) { val2 = val3; } } parent = parent.parent; } ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift row: territory list ancestors: " + stringBuilder)); } if ((Object)(object)val2 == (Object)null) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)"HuntsAndRifts rift row: no panel-sized ancestor found; territories not shifted."); } _territories = null; return; } _territories = val2; _territoriesShift = 0f; ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogInfo((object)("HuntsAndRifts rift row: shifting territories panel '" + ((Object)val2).name + "' up by " + _height.ToString("0") + ".")); } } if (Mathf.Abs(_territoriesShift - _height) > 0.5f) { RectTransform territories = _territories; territories.anchoredPosition += new Vector2(0f, _height - _territoriesShift); _territoriesShift = _height; } } catch (Exception ex) { ManualLogSource logger4 = Plugin.Logger; if (logger4 != null) { logger4.LogDebug((object)("HuntsAndRifts rift row territories: " + ex.Message)); } } } } internal static class RiftDisplayCompatibility { private const string SampleRows = "progenitor-ui-greeneye.progenitor.sample-MapWarEventInfo"; private static CanvasGroup _mask; private static bool _logged; internal static void Apply(MapWarEventInfoEntry info, bool cardHasTimers) { Transform val = (((Object)(object)info != (Object)null) ? ((Component)info).transform.parent : null); Transform val2 = ((cardHasTimers && (Object)(object)val != (Object)null) ? val.Find("progenitor-ui-greeneye.progenitor.sample-MapWarEventInfo") : null); if ((Object)(object)_mask != (Object)null && ((Object)(object)val2 == (Object)null || ((Il2CppObjectBase)((Component)_mask).transform).Pointer != ((Il2CppObjectBase)val2).Pointer)) { Reset(); } if ((Object)(object)val2 == (Object)null || (Object)(object)_mask != (Object)null) { return; } _mask = ((Component)val2).gameObject.AddComponent(); _mask.alpha = 0f; _mask.interactable = false; _mask.blocksRaycasts = false; if (!_logged) { _logged = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)"HuntsAndRifts: hid duplicate Progenitor sample rift rows beside the map card."); } } } internal static void Reset() { if ((Object)(object)_mask != (Object)null) { _mask.alpha = 1f; _mask.interactable = true; _mask.blocksRaycasts = true; Object.Destroy((Object)(object)_mask); } _mask = null; } } internal static class RiftGates { internal readonly struct OpenGate { public readonly WarEventType Type; public readonly float Progress; public readonly float TotalProgress; public OpenGate(WarEventType type, float progress, float total) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Type = type; Progress = progress; TotalProgress = total; } } private static bool _typesReady; private static TypeIndex _gateIndex; private static TypeIndex _nodeIndex; private static bool _loggedOnce; private static string _lastLog; private const int VariantStride = 184; private const int VariantTypeOffset = 132; internal unsafe static List Scan(EntityManager em) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) //IL_011c: 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_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_0130: 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_00a3: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_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_028c: 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_0214: 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_0219: Invalid comparison between Unknown and I4 //IL_0225: 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_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Invalid comparison between Unknown and I4 List list = new List(); try { if (!_typesReady) { _typesReady = true; try { _gateIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } try { _nodeIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } } if (_gateIndex.Value == 0 || _nodeIndex.Value == 0) { return list; } Dictionary dictionary = new Dictionary(); NativeArray val = default(NativeArray); NativeArray val2 = default(NativeArray); try { EntityQuery val3 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(_nodeIndex) }); if (!((EntityQuery)(ref val3)).IsEmptyIgnoreFilter) { val = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val.Length; i++) { byte* componentDataRawRO = (byte*)((EntityManager)(ref em)).GetComponentDataRawRO(val[i], _nodeIndex); if (componentDataRawRO != null) { int num = (sbyte)(*componentDataRawRO); int num2 = (sbyte)componentDataRawRO[1]; byte* ptr = *(byte**)(componentDataRawRO + 8); if (ptr != null) { dictionary[(num << 16) ^ (num2 & 0xFFFF)] = (IntPtr)ptr; } } } } EntityQuery val4 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(_gateIndex) }); if (((EntityQuery)(ref val4)).IsEmptyIgnoreFilter) { return list; } val2 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); int num3 = 0; for (int j = 0; j < val2.Length; j++) { byte* componentDataRawRO2 = (byte*)((EntityManager)(ref em)).GetComponentDataRawRO(val2[j], _gateIndex); if (componentDataRawRO2 == null || componentDataRawRO2[17] == 0) { continue; } num3++; float progress = *(float*)componentDataRawRO2; float total = ((float*)componentDataRawRO2)[1]; int num4 = ((int*)componentDataRawRO2)[2]; int num5 = ((int*)componentDataRawRO2)[3]; byte b = componentDataRawRO2[16]; if (!dictionary.TryGetValue((num4 << 16) ^ (num5 & 0xFFFF), out var value)) { continue; } byte* ptr2 = (byte*)(void*)value; int num6 = *(int*)ptr2; int num7 = ((int*)ptr2)[1]; if (num7 > 0 && num7 <= 16 && b < num7 && num6 > 0 && num6 <= 1048576) { WarEventType val5 = (WarEventType)((int*)(ptr2 + num6 + b * 184))[33]; if ((int)val5 == 1 || (int)val5 == 0 || (int)val5 == 2) { list.Add(new OpenGate(val5, progress, total)); } } } string text = num3 + " open gates, " + list.Count + " resolved"; foreach (OpenGate item in list) { text = text + " " + ((object)item.Type/*cast due to .constrained prefix*/).ToString(); } if (!_loggedOnce || text != _lastLog) { _loggedOnce = true; _lastLog = text; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts gates: " + text + " (" + dictionary.Count + " map nodes).")); } } } finally { if (val.IsCreated) { val.Dispose(); } if (val2.IsCreated) { val2.Dispose(); } } } catch (Exception ex) { if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts gates: scan failed: " + ex.Message)); } } } return list; } } internal readonly struct RiftTrack { internal WarEventType Type { get; init; } internal bool IsActive { get; init; } internal double RemainingSeconds { get; init; } internal double NextInSeconds { get; init; } internal int Level { get; init; } internal long StartTicks { get; init; } internal long EndTicks { get; init; } internal long NextTicks { get; init; } internal long DecayTicks { get; init; } internal bool IsTest { get; init; } } internal static class RiftReader { private readonly struct Levels { public int Minor { get; init; } public int Major { get; init; } public int Primal { get; init; } public int For(WarEventType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)type switch { 1 => Minor, 0 => Major, 2 => Primal, _ => 0, }; } } internal const string ServerJsonPath = "C:\\VRisingServer\\BepInEx\\Log\\HuntsAndRifts-rifts.json"; internal const double TestMinorSeconds = 720.0; internal const double TestMajorSeconds = 1181.0; private static float _nextRefresh; private static readonly List Tracks = new List(4); private static bool _loggedQuery; private static bool _loggedJson; private static bool _loggedClock; private static int _lastNetworkedCount = -1; private static int _lastWarEventCount = -1; private static long _testEpochMinor; private static long _testEpochMajor; private static float _widgetFill = -1f; private static double _widgetTimer = -1.0; private static float _widgetTimerAt = -1f; private static bool _loggedWidget; private static readonly RiftTimerSample WidgetSample = new RiftTimerSample(); private static long _worldSequence = -1L; private static string _loggedEventKey; private static bool _hasMapperTime; private static ServerTime _mapperTime; private static readonly Dictionary Observed = new Dictionary(); private static float _gatesAt = -10f; private static List _gates = new List(); private static float _scheduleAt = -1f; private static bool _scheduleOk; private static StructData _schedule; internal static IReadOnlyList GetTracks() { RefreshIfNeeded(); return Tracks; } internal static void SetMapperTime(ServerTime time) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) _mapperTime = time; _hasMapperTime = true; } internal static void SetWidgetFill(float fill) { if (float.IsNaN(fill) || float.IsInfinity(fill)) { _widgetFill = -1f; } else { _widgetFill = Math.Clamp(fill, 0f, 1f); } } internal static void SetWidgetTimer(double seconds) { if (!double.IsNaN(seconds) && !double.IsInfinity(seconds) && !(seconds < 0.0) && !(seconds > 1209600.0)) { if (_widgetTimer < 0.0 || Math.Abs(_widgetTimer - seconds) > 0.4) { _nextRefresh = 0f; } _widgetTimer = seconds; _widgetTimerAt = Time.unscaledTime; } } private static double WidgetTimerNow() { if (_widgetTimer < 0.0) { return -1.0; } float num = ((_widgetTimerAt >= 0f) ? (Time.unscaledTime - _widgetTimerAt) : 0f); double num2 = _widgetTimer - (double)num; if (!(num2 < 0.0)) { return num2; } return 0.0; } internal static void RefreshIfNeeded() { float unscaledTime = Time.unscaledTime; if (!(unscaledTime < _nextRefresh)) { _nextRefresh = unscaledTime + 0.5f; RefreshNow(); } } private static void RefreshNow() { //IL_0037: 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_004c: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) Tracks.Clear(); long ticks = DateTime.UtcNow.Ticks; bool flag = Plugin.IncludeTestTiers != null && Plugin.IncludeTestTiers.Value; Dictionary dictionary = new Dictionary(4); ServerTime time = default(ServerTime); bool flag2 = false; if (_hasMapperTime) { time = _mapperTime; flag2 = true; } if (HuntReader.TryGetClientWorld(out var world)) { long sequenceNumber = (long)world.SequenceNumber; if (_worldSequence != sequenceNumber) { _worldSequence = sequenceNumber; WidgetSample.Reset(); _loggedEventKey = null; Observed.Clear(); _gates.Clear(); _gatesAt = -10f; _scheduleAt = -1f; RiftCardExtension.ResetTiming(); } try { if (!flag2) { flag2 = TryReadServerTime(world.EntityManager, out time); } ApplyClientEcs(world.EntityManager, dictionary, ticks, flag2, time); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts rift ECS skipped: " + ex.Message)); } } } if (flag) { if (!dictionary.ContainsKey((WarEventType)1)) { dictionary[(WarEventType)1] = MakeTestTrack((WarEventType)1, 57, ticks); } if (!dictionary.ContainsKey((WarEventType)0)) { dictionary[(WarEventType)0] = MakeTestTrack((WarEventType)0, 80, ticks); } } if (HuntReader.TryGetClientWorld(out var world2)) { try { TrySynthesizeMissing(dictionary, world2.EntityManager, ReadLevels(world2.EntityManager)); } catch (Exception ex2) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts derive other rift skipped: " + ex2.Message)); } } } if (HuntReader.TryGetClientWorld(out var world3)) { try { foreach (RiftGates.OpenGate item in CachedGates(world3.EntityManager)) { if (!dictionary.TryGetValue(item.Type, out var value) || !value.IsActive) { RiftTrack value2; int level = (dictionary.TryGetValue(item.Type, out value2) ? value2.Level : 0); dictionary[item.Type] = new RiftTrack { Type = item.Type, IsActive = true, RemainingSeconds = -1.0, NextInSeconds = 0.0, Level = level, IsTest = false }; } } } catch (Exception ex3) { ManualLogSource logger3 = Plugin.Logger; if (logger3 != null) { logger3.LogDebug((object)("HuntsAndRifts gate override: " + ex3.Message)); } } } AddIfWanted(dictionary, (WarEventType)1, flag); AddIfWanted(dictionary, (WarEventType)0, flag); AddIfWanted(dictionary, (WarEventType)2, flag); } private static void TrySynthesizeMissing(Dictionary byType, EntityManager em, Levels levels) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00a5: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; foreach (KeyValuePair item in byType) { if (!item.Value.IsTest) { Observed[item.Key] = (item.Value, unscaledTime); } } WarEventType[] array = (WarEventType[])(object)new WarEventType[2] { (WarEventType)1, default(WarEventType) }; foreach (WarEventType val in array) { if (byType.ContainsKey(val)) { continue; } bool flag = false; double num = -1.0; double num2 = -1.0; if (Observed.TryGetValue(val, out (RiftTrack, float) value)) { num = RiftTiming.Age(value.Item1.RemainingSeconds, value.Item2, unscaledTime); num2 = RiftTiming.Age(value.Item1.NextInSeconds, value.Item2, unscaledTime); flag = value.Item1.IsActive && num > 0.0; if (value.Item1.IsActive || num2 <= 0.0) { num2 = -1.0; } } byType[val] = new RiftTrack { Type = val, Level = levels.For(val), IsActive = flag, RemainingSeconds = (flag ? num : (-1.0)), NextInSeconds = num2 }; } } private static List CachedGates(EntityManager em) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (unscaledTime - _gatesAt >= 2f) { _gatesAt = unscaledTime; _gates = RiftGates.Scan(em); } return _gates; } internal static bool TryGetSchedule(WarEventType type, out double duration, out double gap) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) duration = 0.0; gap = 0.0; try { float unscaledTime = Time.unscaledTime; if (_scheduleAt < 0f || unscaledTime - _scheduleAt > 5f) { _scheduleAt = unscaledTime; _scheduleOk = HuntReader.TryGetClientWorld(out var world) && TryReadWarSettings(world.EntityManager, out _schedule); } if (!_scheduleOk) { return false; } float totalDuration = ((StructData)(ref _schedule)).GetTotalDuration(type); float totalTimeBetweenEvents = ((StructData)(ref _schedule)).GetTotalTimeBetweenEvents(type); duration = totalDuration; gap = totalTimeBetweenEvents; return IsSaneSchedule(totalDuration, allowZero: false) && IsSaneSchedule(totalTimeBetweenEvents, allowZero: true); } catch { return false; } } private static bool TryReadWarSettings(EntityManager em, out StructData war) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) war = default(StructData); NativeArray val = default(NativeArray); try { EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); try { if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return false; } val = ((EntityQuery)(ref val2)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); if (val.Length == 0) { return false; } war = val[0].WarEventSettings; return true; } finally { ((EntityQuery)(ref val2)).Dispose(); } } catch { return false; } finally { if (val.IsCreated) { val.Dispose(); } } } private static bool IsSaneSchedule(float seconds, bool allowZero) { if (float.IsNaN(seconds) || float.IsInfinity(seconds)) { return false; } if (seconds < 0f) { return false; } if (seconds == 0f) { return allowZero; } return seconds <= 1209600f; } private static void AddIfWanted(Dictionary byType, WarEventType type, bool includeTest) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (byType.TryGetValue(type, out var value) && (!value.IsTest || includeTest)) { Tracks.Add(value); } } private static RiftTrack MakeTestTrack(WarEventType type, int level, long nowTicks) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) double remainingSeconds = (((int)type != 0) ? TestRemaining(720.0, ref _testEpochMinor, nowTicks) : TestRemaining(1181.0, ref _testEpochMajor, nowTicks)); return new RiftTrack { Type = type, IsActive = true, RemainingSeconds = remainingSeconds, NextInSeconds = 0.0, Level = level, IsTest = true }; } internal static double TestRemaining(double durationSeconds, ref long epochTicks, long nowTicks) { if (epochTicks <= 0) { epochTicks = nowTicks; } double num = (double)(nowTicks - epochTicks) / 10000000.0; if (num < 0.0) { num = 0.0; } double num2 = durationSeconds - num % durationSeconds; if (num2 <= 0.05) { num2 = durationSeconds; } return num2; } private static bool TryApplyJson(Dictionary byType, long utcNowTicks, bool includeTest) { string text; try { if (!File.Exists("C:\\VRisingServer\\BepInEx\\Log\\HuntsAndRifts-rifts.json")) { return false; } using FileStream stream = new FileStream("C:\\VRisingServer\\BepInEx\\Log\\HuntsAndRifts-rifts.json", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using StreamReader streamReader = new StreamReader(stream); text = streamReader.ReadToEnd(); } catch { return false; } if (string.IsNullOrEmpty(text)) { return false; } if (!TryExtractLong(text, "utcTicks", out var value)) { return false; } if ((double)(utcNowTicks - value) / 10000000.0 > 10.0) { return false; } if (0 + (TryApplyJsonTier(text, "Minor", (WarEventType)1, byType, includeTest) ? 1 : 0) + (TryApplyJsonTier(text, "Major", (WarEventType)0, byType, includeTest) ? 1 : 0) == 0) { return false; } if (!_loggedJson) { _loggedJson = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)"HuntsAndRifts reading server JSON C:\\VRisingServer\\BepInEx\\Log\\HuntsAndRifts-rifts.json"); } } return true; } private static bool TryApplyJsonTier(string json, string typeName, WarEventType type, Dictionary byType, bool includeTest) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_0093: Unknown result type (might be due to invalid IL or missing references) string value = "\"type\":\"" + typeName + "\""; int num = json.IndexOf(value, StringComparison.Ordinal); if (num < 0) { return false; } int num2 = json.LastIndexOf('{', num); int num3 = json.IndexOf('}', num); if (num2 < 0 || num3 < 0 || num3 <= num2) { return false; } string obj = json.Substring(num2, num3 - num2 + 1); bool flag = ExtractBool(obj, "test", fallback: true); if (flag && !includeTest) { return false; } if (byType.TryGetValue(type, out var value2) && !value2.IsTest) { return false; } TryExtractInt(obj, "level", out var value3); if (value3 <= 0) { value3 = (((int)type == 0) ? 80 : 57); } TryExtractDouble(obj, "remaining", out var value4); TryExtractDouble(obj, "next", out var value5); bool isActive = ExtractBool(obj, "active", fallback: true); byType[type] = new RiftTrack { Type = type, IsActive = isActive, RemainingSeconds = value4, NextInSeconds = value5, Level = value3, IsTest = flag }; return true; } private static bool ExtractBool(string obj, string key, bool fallback) { string text = "\"" + key + "\":"; int num = obj.IndexOf(text, StringComparison.Ordinal); if (num < 0) { return fallback; } for (num += text.Length; num < obj.Length && obj[num] == ' '; num++) { } if (num + 4 <= obj.Length && string.Compare(obj, num, "true", 0, 4, StringComparison.OrdinalIgnoreCase) == 0) { return true; } if (num + 5 <= obj.Length && string.Compare(obj, num, "false", 0, 5, StringComparison.OrdinalIgnoreCase) == 0) { return false; } return fallback; } private static bool TryExtractLong(string obj, string key, out long value) { value = 0L; string text = "\"" + key + "\":"; int num = obj.IndexOf(text, StringComparison.Ordinal); if (num < 0) { return false; } num += text.Length; int i; for (i = num; i < obj.Length && (char.IsDigit(obj[i]) || obj[i] == '-'); i++) { } return long.TryParse(obj.Substring(num, i - num), NumberStyles.Integer, CultureInfo.InvariantCulture, out value); } private static bool TryExtractInt(string obj, string key, out int value) { value = 0; if (!TryExtractLong(obj, key, out var value2)) { return false; } value = (int)value2; return true; } private static bool TryExtractDouble(string obj, string key, out double value) { value = 0.0; string text = "\"" + key + "\":"; int num = obj.IndexOf(text, StringComparison.Ordinal); if (num < 0) { return false; } num += text.Length; int i; for (i = num; i < obj.Length && (char.IsDigit(obj[i]) || obj[i] == '-' || obj[i] == '.'); i++) { } return double.TryParse(obj.Substring(num, i - num), NumberStyles.Float, CultureInfo.InvariantCulture, out value); } private static void ApplyClientEcs(EntityManager em, Dictionary byType, long utcNowTicks, bool hasServerTime, ServerTime serverTime) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_007a: 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_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_0079: 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_009a: 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: Invalid comparison between Unknown and I4 //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Invalid comparison between Unknown and I4 //IL_00ce: 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_012e: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_0148: 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_0129: Invalid comparison between Unknown and I4 Levels levels = ReadLevels(em); NativeArray warEvents = default(NativeArray); NativeArray networked = default(NativeArray); try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (!((EntityQuery)(ref val)).IsEmptyIgnoreFilter) { warEvents = ((EntityQuery)(ref val)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); } EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (!((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { networked = ((EntityQuery)(ref val2)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); } LogCountsOnce(warEvents, networked); if (networked.IsCreated) { for (int i = 0; i < networked.Length; i++) { RiftTrack value = FromNetworked(networked[i], utcNowTicks, hasServerTime, serverTime, levels, networked.Length == 1); if ((int)value.Type == 1 || (int)value.Type == 0 || (int)value.Type == 2) { byType[value.Type] = value; } } } if (!warEvents.IsCreated) { return; } for (int j = 0; j < warEvents.Length; j++) { RiftTrack value2 = FromWarEvent(warEvents[j], utcNowTicks, hasServerTime, serverTime, levels); if (((int)value2.Type == 1 || (int)value2.Type == 0 || (int)value2.Type == 2) && (!byType.TryGetValue(value2.Type, out var value3) || value3.IsTest)) { byType[value2.Type] = value2; } } } finally { _widgetTimer = -1.0; if (warEvents.IsCreated) { warEvents.Dispose(); } if (networked.IsCreated) { networked.Dispose(); } } } private static RiftTrack WithLevel(RiftTrack track, int level) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new RiftTrack { Type = track.Type, IsActive = track.IsActive, RemainingSeconds = track.RemainingSeconds, NextInSeconds = track.NextInSeconds, Level = level, StartTicks = track.StartTicks, EndTicks = track.EndTicks, NextTicks = track.NextTicks, DecayTicks = track.DecayTicks, IsTest = track.IsTest }; } private unsafe static void LogCountsOnce(NativeArray warEvents, NativeArray networked) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) int num = (warEvents.IsCreated ? warEvents.Length : 0); int num2 = (networked.IsCreated ? networked.Length : 0); if (num == _lastWarEventCount && num2 == _lastNetworkedCount && _loggedQuery) { return; } _lastWarEventCount = num; _lastNetworkedCount = num2; _loggedQuery = true; string text = ""; if (networked.IsCreated) { for (int i = 0; i < networked.Length; i++) { if (text.Length > 0) { text += ", "; } WarEvent_NetworkedData val = networked[i]; text = text + ((object)(*(WarEventType*)(&val.ActiveType))/*cast due to .constrained prefix*/).ToString() + (val.IsActive ? " active" : " upcoming"); } } ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)($"HuntsAndRifts rifts: {num2} WarEvent_NetworkedData, {num} WarEvent on client" + ((text.Length > 0) ? (" [" + text + "]") : "") + " (live only; TEST rows off unless IncludeTestTiers).")); } } private static RiftTrack FromWarEvent(WarEvent ev, long utcNowTicks, bool hasServerTime, ServerTime serverTime, Levels levels) { //IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) double num = SecondsUntil(ev.EndTimeTicks, utcNowTicks, hasServerTime, serverTime, allowLong: false); double num2 = SecondsUntil(ev.StartTimeTicks, utcNowTicks, hasServerTime, serverTime, allowLong: true); bool isActive = num > 0.0 && num2 <= 0.0; return new RiftTrack { Type = ev.EventType, IsActive = isActive, RemainingSeconds = num, NextInSeconds = num2, Level = levels.For(ev.EventType), StartTicks = ev.StartTimeTicks, EndTicks = ev.EndTimeTicks, NextTicks = ev.StartTimeTicks, DecayTicks = ev.DecayDurationTicks, IsTest = false }; } private unsafe static RiftTrack FromNetworked(WarEvent_NetworkedData data, long utcNowTicks, bool hasServerTime, ServerTime serverTime, Levels levels, bool useWidget) { //IL_0000: 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_0010: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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_024b: Unknown result type (might be due to invalid IL or missing references) double num = SecondsUntil(data.ActiveEventEndTimeTicks, utcNowTicks, hasServerTime, serverTime, allowLong: false); _ = (double)(data.ActiveEventEndTimeTicks - data.ActiveEventStartTimeTicks) / 10000000.0; double val = SecondsUntil(data.ActiveEventStartTimeTicks, utcNowTicks, hasServerTime, serverTime, allowLong: true); double num2 = SecondsUntil(data.NextEventTimeTicks, utcNowTicks, hasServerTime, serverTime, allowLong: true); string text = ((object)(*(WarEventType*)(&data.ActiveType))/*cast due to .constrained prefix*/).ToString() + ":" + data.IsActive + ":" + data.ActiveEventStartTimeTicks + ":" + data.ActiveEventEndTimeTicks + ":" + data.NextEventTimeTicks; if (!double.IsFinite(num) || num < 0.0 || num > 86400.0) { num = -1.0; } if (!double.IsFinite(num2) || num2 < 0.0 || num2 > 1209600.0) { num2 = -1.0; } if (_loggedEventKey != text) { _loggedEventKey = text; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift timing: " + ((object)(*(WarEventType*)(&data.ActiveType))/*cast due to .constrained prefix*/).ToString() + (data.IsActive ? " active" : " upcoming") + " remaining=" + num.ToString("0.0", CultureInfo.InvariantCulture) + " next=" + num2.ToString("0.0", CultureInfo.InvariantCulture) + " source=event ticks.")); } } return new RiftTrack { Type = data.ActiveType, IsActive = data.IsActive, RemainingSeconds = num, NextInSeconds = (data.IsActive ? Math.Max(0.0, val) : num2), Level = levels.For(data.ActiveType), StartTicks = data.ActiveEventStartTimeTicks, EndTicks = data.ActiveEventEndTimeTicks, NextTicks = data.NextEventTimeTicks, DecayTicks = data.ActiveEventDecayTicks, IsTest = false }; } private static bool TryReadServerTime(EntityManager em, out ServerTime time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) time = default(ServerTime); NativeArray val = default(NativeArray); try { EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return false; } val = ((EntityQuery)(ref val2)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); if (val.Length == 0) { return false; } time = val[0]; return true; } catch { return false; } finally { if (val.IsCreated) { val.Dispose(); } } } private static double SecondsUntil(long targetTicks, long utcNowTicks, bool hasServerTime, ServerTime serverTime, bool allowLong) { return RiftTiming.SecondsUntil(targetTicks, utcNowTicks); } private static void LogWidgetOnce(string detail) { if (!_loggedWidget) { _loggedWidget = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift remaining: " + detail)); } } } private static void LogClockOnce(string clock) { if (!_loggedClock) { _loggedClock = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift clock: " + clock)); } } } private static bool TrySane(double seconds, double cap, out double value) { value = seconds; if (!double.IsNaN(seconds) && !double.IsInfinity(seconds) && seconds > -5.0) { return seconds <= cap; } return false; } private static Levels ReadLevels(EntityManager em) { //IL_0026: 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_0059: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e2: Unknown result type (might be due to invalid IL or missing references) Levels result = new Levels { Minor = 57, Major = 80, Primal = 0 }; NativeArray val = default(NativeArray); try { EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return result; } val = ((EntityQuery)(ref val2)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); if (val.Length == 0) { return result; } WarEventSettingsComponent val3 = val[0]; result = new Levels { Minor = FirstPositive(val3.MinorWarEventSettings.RecommendedGearLevel, val3.MinorWarEventSettings.MinGearLevel, 57), Major = FirstPositive(val3.MajorWarEventSettings.RecommendedGearLevel, val3.MajorWarEventSettings.MinGearLevel, 80), Primal = FirstPositive(val3.PrimalWarEventSettings.RecommendedGearLevel, val3.PrimalWarEventSettings.MinGearLevel, 0) }; } catch { } finally { if (val.IsCreated) { val.Dispose(); } } return result; } private static int FirstPositive(int a, int b, int fallback) { if (a > 0) { return a; } if (b > 0) { return b; } return fallback; } } internal static class RiftRowBadge { private static Image _badge; private static Image _header; private static bool _headerWasActive; internal static void Apply(MapWarEventInfoEntry info, RiftTrack? track) { //IL_0147: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0161: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01b4: 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_01c9: Expected I4, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) RectTransform component = ((Component)info).GetComponent(); LocalizedText timerText = info.TimerText; TextMeshProUGUI val = ((timerText != null) ? timerText.Text : null); if ((Object)(object)component == (Object)null || (Object)(object)val == (Object)null || !track.HasValue) { Reset(); return; } if ((Object)(object)_badge != (Object)null && ((Il2CppObjectBase)((Component)_badge).transform.parent).Pointer != ((Il2CppObjectBase)component).Pointer) { Reset(); } if ((Object)(object)_badge == (Object)null) { GameObject val2 = new GameObject("HuntsAndRifts_PrimaryRiftBadge"); RectTransform obj = val2.AddComponent(); ((Transform)obj).SetParent((Transform)(object)component, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 0f); obj.anchorMax = val3; obj.anchorMin = val3; obj.pivot = new Vector2(1f, 0.5f); obj.sizeDelta = new Vector2(52f, 52f); val2.AddComponent().ignoreLayout = true; _badge = val2.AddComponent(); ((Graphic)_badge).raycastTarget = false; _badge.preserveAspect = true; _header = info.WarEventIcon; _headerWasActive = (Object)(object)_header != (Object)null && ((Component)_header).gameObject.activeSelf; } RectTransform rectTransform = ((TMP_Text)val).rectTransform; Rect rect = ((TMP_Text)val).rectTransform.rect; Vector3 val4 = ((Transform)rectTransform).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); Vector3 val5 = ((Transform)component).InverseTransformPoint(val4); RectTransform rectTransform2 = ((Graphic)_badge).rectTransform; float y = val5.y; rect = component.rect; rectTransform2.anchoredPosition = new Vector2(-14f, y - ((Rect)(ref rect)).yMin + 8f); RiftTrack value = track.Value; Image badge = _badge; WarEventType type = value.Type; badge.sprite = (Sprite)((int)type switch { 1 => info.WarEvent_Minor_Icon, 0 => info.WarEvent_Major_Icon, 2 => info.WarEvent_Primal_Icon, _ => null, }); ((Component)_badge).gameObject.SetActive(value.IsActive && (Object)(object)_badge.sprite != (Object)null); if ((Object)(object)_header != (Object)null && ((Component)_header).gameObject.activeSelf) { ((Component)_header).gameObject.SetActive(false); } } internal static void Reset() { if ((Object)(object)_badge != (Object)null) { ((Component)_badge).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)_badge).gameObject); } if ((Object)(object)_header != (Object)null) { ((Component)_header).gameObject.SetActive(_headerWasActive); } _badge = null; _header = null; } } internal static class RiftTiming { internal static double SecondsUntil(long targetTicks, long nowTicks) { if (targetTicks > 0) { return (double)(targetTicks - nowTicks) / 10000000.0; } return -1.0; } internal static bool IsOwnText(string text) { return Regex.IsMatch(text ?? "", "\\bT[12]\\b|\\bPrimal\\b", RegexOptions.CultureInvariant); } internal static double Age(double seconds, double capturedAt, double now) { if (!(seconds < 0.0)) { return Math.Max(0.0, seconds - Math.Max(0.0, now - capturedAt)); } return -1.0; } } internal sealed class RiftTimerSample { private string _event; private double _seconds = -1.0; private double _at; internal void Reset() { _event = null; _seconds = -1.0; } internal double Read(string eventKey, double freshSeconds, double now) { if (_event != eventKey) { Reset(); _event = eventKey; } if (freshSeconds >= 0.0) { _seconds = freshSeconds; _at = now; } return RiftTiming.Age(_seconds, _at, now); } } internal static class RiftTooltip { private static readonly Regex Suffix = new Regex("\\s*.*?\\s*$", RegexOptions.Compiled | RegexOptions.Singleline); private static readonly Regex LevelRx = new Regex("(\\d+)", RegexOptions.Compiled); private static bool _loggedOnce; private static float _nextDiag = 0f; private static int _diagCount; private static bool _loggedGrow; internal static void Tick(MapMenuMapper mapper, MapMenu menu, MapTooltip tooltip) { try { LocalizedText warEventStatusText = tooltip.WarEventStatusText; if ((Object)(object)warEventStatusText == (Object)null) { return; } UiTextState.Track((TMP_Text)(object)warEventStatusText.Text); bool flag; try { flag = ((Component)warEventStatusText).gameObject.activeInHierarchy; } catch { flag = false; } try { CanvasGroup mainAlpha = tooltip.MainAlpha; if ((Object)(object)mainAlpha != (Object)null && mainAlpha.alpha < 0.05f) { flag = false; } } catch { } if (!flag) { RestoreVanilla(warEventStatusText); return; } DiagnoseStray(); IReadOnlyList tracks = RiftReader.GetTracks(); if (tracks == null || tracks.Count == 0) { return; } int? level = ReadLevel(tooltip); string text = Describe(tracks, level); if (string.IsNullOrEmpty(text)) { return; } string text2 = warEventStatusText.GetText(); if (string.IsNullOrEmpty(text2)) { return; } text2 = Suffix.Replace(text2, "").TrimEnd(); string text3 = (text.Contains('\n') ? (text2 + "\n" + text + "") : (text2 + " " + text + "")); if (warEventStatusText.GetText() == text3) { return; } try { if ((Object)(object)warEventStatusText.Text != (Object)null) { ((TMP_Text)warEventStatusText.Text).richText = true; } } catch { } warEventStatusText.ForceSet(text3); GrowToFit(warEventStatusText, text3); if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift tooltip: '" + text3 + "' (level " + (level.HasValue ? level.Value.ToString() : "n/a") + ").")); } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts rift tooltip: " + ex.Message)); } } } private static void RestoreVanilla(LocalizedText status) { try { string text = status.GetText(); if (!string.IsNullOrEmpty(text) && text.IndexOf("", StringComparison.Ordinal) >= 0) { string text2 = Suffix.Replace(text, "").TrimEnd(); if (text2 != text) { status.ForceSet(text2); } } } catch { } } private static void DiagnoseStray() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) try { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextDiag || _diagCount >= 3) { return; } _nextDiag = unscaledTime + 5f; Il2CppArrayBase val = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); if (val == null) { return; } foreach (TextMeshProUGUI item in val) { if ((Object)(object)item == (Object)null) { continue; } string text = null; try { text = ((TMP_Text)item).text; } catch { } if (string.IsNullOrEmpty(text) || (!text.StartsWith("T1 (") && !text.StartsWith("T2 (") && !text.Contains("\nT2 ("))) { continue; } StringBuilder stringBuilder = new StringBuilder(); Transform val2 = ((TMP_Text)item).transform; for (int i = 0; i < 8; i++) { if (!((Object)(object)val2 != (Object)null)) { break; } stringBuilder.Append(((Object)val2).name).Append(" < "); val2 = val2.parent; } _diagCount++; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts stray-diag: '" + text.Replace("\n", "|") + "' at " + ((object)((TMP_Text)item).transform.position/*cast due to .constrained prefix*/).ToString() + " chain " + stringBuilder)); } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts stray-diag: " + ex.Message)); } } } private static void GrowToFit(LocalizedText status, string text) { //IL_001d: 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_0042: 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_0083: 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) try { TextMeshProUGUI text2 = status.Text; if ((Object)(object)text2 == (Object)null) { return; } RectTransform rectTransform = ((TMP_Text)text2).rectTransform; Rect rect = rectTransform.rect; float num = ((Rect)(ref rect)).width; if (num < 40f) { num = 300f; } float num2 = ((TMP_Text)text2).GetPreferredValues(text, num, 0f).y + 4f; if (num2 < 10f || num2 > 400f) { return; } if (Mathf.Abs(rectTransform.sizeDelta.y - num2) > 0.5f) { rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, num2); } LayoutElement val = ((Component)text2).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)text2).gameObject.AddComponent(); } if (Mathf.Abs(val.preferredHeight - num2) > 0.5f) { val.preferredHeight = num2; val.minHeight = num2; } if (!_loggedGrow) { _loggedGrow = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts rift tooltip: status text height " + num2.ToString("0") + " (width " + num.ToString("0") + ").")); } } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts rift tooltip grow: " + ex.Message)); } } } private static int? ReadLevel(MapTooltip tooltip) { try { LocalizedText warEventLevelText = tooltip.WarEventLevelText; if ((Object)(object)warEventLevelText == (Object)null) { return null; } if (!((Component)warEventLevelText).gameObject.activeInHierarchy) { return null; } string text = null; try { text = warEventLevelText.GetText(); } catch { } if (string.IsNullOrWhiteSpace(text) && (Object)(object)warEventLevelText.Text != (Object)null) { text = ((TMP_Text)warEventLevelText.Text).text; } if (string.IsNullOrWhiteSpace(text)) { return null; } Match match = LevelRx.Match(text); if (!match.Success) { return null; } return int.Parse(match.Groups[1].Value); } catch { return null; } } private unsafe static string TierName(WarEventType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)t switch { 1 => "T1", 0 => "T2", 2 => "Primal", _ => ((object)(*(WarEventType*)(&t))/*cast due to .constrained prefix*/).ToString(), }; } private static string Line(RiftTrack t, bool thisPlot = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) string text = TierName(t.Type) + ((t.Level > 0) ? (" (" + t.Level + "+)") : ""); if (t.IsActive) { if (t.RemainingSeconds < 0.0) { if (!thisPlot) { return text + " active elsewhere"; } return text + " active"; } if (!thisPlot) { return text + " active elsewhere, " + HuntReader.FormatRemaining(t.RemainingSeconds) + " left"; } return text + " " + HuntReader.FormatRemaining(t.RemainingSeconds) + " left"; } double nextInSeconds = t.NextInSeconds; if (nextInSeconds < 0.0) { return text + " awaiting schedule"; } return text + " next in " + HuntReader.FormatRemaining(nextInSeconds); } private static string Describe(IReadOnlyList tracks, int? level) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_002b: 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_003a: Invalid comparison between Unknown and I4 List list = new List(); foreach (RiftTrack track in tracks) { if (!track.IsTest && ((int)track.Type == 1 || (int)track.Type == 0 || (int)track.Type == 2)) { list.Add(track); } } if (list.Count == 0) { return null; } if (level.HasValue) { foreach (RiftTrack item in list) { if (item.Level == level.Value) { return Line(item); } } } list.Sort((RiftTrack a, RiftTrack b) => (a.IsActive != b.IsActive) ? ((!a.IsActive) ? 1 : (-1)) : ((a.NextInSeconds < 0.0) ? double.MaxValue : a.NextInSeconds).CompareTo((b.NextInSeconds < 0.0) ? double.MaxValue : b.NextInSeconds)); List list2 = new List(); foreach (RiftTrack item2 in list) { list2.Add(Line(item2, thisPlot: false)); } return string.Join("\n", list2); } } internal static class RingSprite { private static Sprite _sprite; private static bool _tried; internal static Sprite Get() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sprite != (Object)null || _tried) { return _sprite; } _tried = true; try { Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; float num = 31.5f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)); float num3 = Mathf.Clamp01(30f - num2) * Mathf.Clamp01(num2 - 25f); val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(); _sprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); ((Object)_sprite).hideFlags = (HideFlags)61; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts ring sprite: " + ex.Message)); } _sprite = null; } return _sprite; } } internal static class RowDecor { private sealed class State { public RectTransform Holder; public Image[] Icons = (Image[])(object)new Image[2]; public Image[] Glows = (Image[])(object)new Image[2]; public int Perk0; public int Perk1; public float IconSize; public string MeasuredText; public TextMeshProUGUI Text; public float MeasuredWidth; } private const string HolderName = "HuntsAndRifts_Perks"; private const float IconGap = 3f; private const float NameGap = 8f; internal const string GearColor = "#C9B37E"; internal static readonly Color MatchRing = new Color(0.45f, 0.95f, 0.5f, 0.95f); private static readonly Regex GearSuffix = new Regex("\\s*]*>]*>(?:GS )?\\d+", RegexOptions.Compiled); private static readonly Regex NameTags = new Regex("]*>", RegexOptions.Compiled); private const string NameOpen = ""; private const string NameClose = ""; private static readonly Dictionary States = new Dictionary(); private static bool _loggedOnce; private static bool _loggedPower; private const string BgName = "HuntsAndRifts_Bg"; private static readonly Dictionary Bgs = new Dictionary(); internal static void Clear() { foreach (State value in States.Values) { if ((Object)(object)value.Text != (Object)null) { ((TMP_Text)value.Text).text = BaseName(((TMP_Text)value.Text).text); } if ((Object)(object)value.Holder != (Object)null) { ((Component)value.Holder).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)value.Holder).gameObject); } } foreach (Image value2 in Bgs.Values) { if ((Object)(object)value2 != (Object)null) { ((Component)value2).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)value2).gameObject); } } States.Clear(); Bgs.Clear(); } internal static void Apply(ServantListItem item, string servantName, HashSet huntPerks = null) { if ((Object)(object)item == (Object)null) { return; } try { ApplyToText(item.ServantName, servantName, 22f, huntPerks); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts row decor: " + ex.Message)); } } } internal static bool TryGetPower(string servantName, out float power) { power = 0f; if (ServantInfoReader.TryGetInfo(servantName, out var info) && info.HuntProficiency > 0f) { power = info.HuntProficiency; if (!_loggedPower) { _loggedPower = true; HuntReader.TryGetGearLevel(servantName, out var gearLevel); ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts power: " + servantName + " HuntProficiency=" + info.HuntProficiency + " LootFactor=" + info.LootFactor + " coffin gear=" + gearLevel)); } } return true; } return false; } internal static void SetGroupTint(ServantListItem item, Color? color, float contentWidth = 0f, float inset = 0f) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return; } try { IntPtr pointer = ((Il2CppObjectBase)item).Pointer; if (!Bgs.TryGetValue(pointer, out var value) || (Object)(object)value == (Object)null) { Transform transform = ((Component)item).transform; Transform val = transform.Find("HuntsAndRifts_Bg"); if ((Object)(object)val != (Object)null) { value = ((Component)val).GetComponent(); } if ((Object)(object)value == (Object)null) { if (!color.HasValue) { return; } GameObject val2 = new GameObject("HuntsAndRifts_Bg"); RectTransform obj = val2.AddComponent(); ((Transform)obj).SetParent(transform, false); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; ((Transform)obj).localScale = Vector3.one; value = val2.AddComponent(); ((Graphic)value).raycastTarget = true; val2.AddComponent().ignoreLayout = true; } ((Component)value).transform.SetAsFirstSibling(); Bgs[pointer] = value; } if (!color.HasValue) { if (((Component)value).gameObject.activeSelf) { ((Component)value).gameObject.SetActive(false); } return; } if (contentWidth >= 60f) { RectTransform rectTransform = ((Graphic)value).rectTransform; float num = contentWidth - 2f * inset; if (rectTransform.anchorMax.x != 0f || Mathf.Abs(rectTransform.sizeDelta.x - num) > 0.5f || Mathf.Abs(rectTransform.anchoredPosition.x - inset) > 0.5f) { rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.sizeDelta = new Vector2(num, 0f); rectTransform.anchoredPosition = new Vector2(inset, 0f); } } if (((Graphic)value).color != color.Value) { ((Graphic)value).color = color.Value; } if (!((Component)value).gameObject.activeSelf) { ((Component)value).gameObject.SetActive(true); } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts group tint: " + ex.Message)); } } } internal static string BaseName(string text) { if (string.IsNullOrEmpty(text)) { return ""; } string input = GearSuffix.Replace(text, ""); input = NameTags.Replace(input, ""); return input.Trim(); } internal static void ApplyToText(TextMeshProUGUI nameText, string servantName, float iconSize, HashSet huntPerks = null) { //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0385: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)nameText == (Object)null || string.IsNullOrEmpty(servantName)) { return; } UiTextState.Track((TMP_Text)(object)nameText); try { if (TryGetPower(servantName, out var power)) { string text = BaseName(((TMP_Text)nameText).text); if (text.Length == 0) { text = servantName; } string text2 = "" + text + " " + Mathf.RoundToInt(power) + ""; if (((TMP_Text)nameText).text != text2) { ((TMP_Text)nameText).richText = true; ((TMP_Text)nameText).text = text2; } } if (!ServantInfoReader.TryGetInfo(servantName, out var info)) { ((TMP_Text)nameText).text = BaseName(((TMP_Text)nameText).text); if (States.TryGetValue(((Il2CppObjectBase)nameText).Pointer, out var value) && (Object)(object)value.Holder != (Object)null) { ((Component)value.Holder).gameObject.SetActive(false); } return; } State state = GetState(nameText, iconSize); if (state == null) { return; } state.Text = nameText; ((Component)state.Holder).gameObject.SetActive(true); if (state.Perk0 != ((PrefabGUID)(ref info.Perk0)).GuidHash || state.Perk1 != ((PrefabGUID)(ref info.Perk1)).GuidHash || (((PrefabGUID)(ref info.Perk0)).GuidHash != 0 && ((Object)(object)state.Icons[0] == (Object)null || (Object)(object)state.Icons[0].sprite == (Object)null)) || (((PrefabGUID)(ref info.Perk1)).GuidHash != 0 && ((Object)(object)state.Icons[1] == (Object)null || (Object)(object)state.Icons[1].sprite == (Object)null))) { SetIcon(state.Icons[0], info.Perk0); SetIcon(state.Icons[1], info.Perk1); state.Perk0 = ((PrefabGUID)(ref info.Perk0)).GuidHash; state.Perk1 = ((PrefabGUID)(ref info.Perk1)).GuidHash; if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts row decor: perk icons on '" + servantName + "'.")); } } } for (int i = 0; i < 2; i++) { int num = ((i == 0) ? ((PrefabGUID)(ref info.Perk0)).GuidHash : ((PrefabGUID)(ref info.Perk1)).GuidHash); Image val = state.Icons[i]; if ((Object)(object)val != (Object)null && ((Graphic)val).color != Color.white) { ((Graphic)val).color = Color.white; } Image val2 = state.Glows[i]; if (!((Object)(object)val2 == (Object)null)) { bool flag = huntPerks != null && num != 0 && huntPerks.Contains(num) && (Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf; if (((Component)val2).gameObject.activeSelf != flag) { ((Component)val2).gameObject.SetActive(flag); } } } string text3 = ((TMP_Text)nameText).text ?? ""; float num2; if (state.MeasuredText == text3) { num2 = state.MeasuredWidth; } else { try { num2 = ((TMP_Text)nameText).GetPreferredValues(text3).x; } catch { num2 = ((TMP_Text)nameText).preferredWidth; } state.MeasuredText = text3; state.MeasuredWidth = num2; } float num3 = num2 + 8f; if (float.IsNaN(num3) || float.IsInfinity(num3)) { num3 = 8f; } if (Mathf.Abs(state.Holder.anchoredPosition.x - num3) > 0.5f) { state.Holder.anchoredPosition = new Vector2(num3, 0f); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts text decor: " + ex.Message)); } } } private static State GetState(TextMeshProUGUI nameText, float iconSize) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00d5: 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_015e: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) IntPtr pointer = ((Il2CppObjectBase)nameText).Pointer; if (States.TryGetValue(pointer, out var value) && (Object)(object)value.Holder != (Object)null) { return value; } RectTransform rectTransform = ((TMP_Text)nameText).rectTransform; RectTransform val = null; Transform val2 = ((Transform)rectTransform).Find("HuntsAndRifts_Perks"); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).GetComponent(); } if ((Object)(object)val == (Object)null) { val = new GameObject("HuntsAndRifts_Perks").AddComponent(); ((Transform)val).SetParent((Transform)(object)rectTransform, false); val.anchorMin = new Vector2(0f, 0.5f); val.anchorMax = new Vector2(0f, 0.5f); val.pivot = new Vector2(0f, 0.5f); val.sizeDelta = new Vector2(iconSize * 2f + 3f, iconSize); val.anchoredPosition = new Vector2(8f, 0f); ((Transform)val).localScale = Vector3.one; } value = new State { Holder = val, Perk0 = int.MinValue, Perk1 = int.MinValue, IconSize = iconSize }; for (int i = 0; i < 2; i++) { string text = "Icon" + i; Image val3 = null; Transform val4 = ((Transform)val).Find(text); if ((Object)(object)val4 != (Object)null) { val3 = ((Component)val4).GetComponent(); } if ((Object)(object)val3 == (Object)null) { GameObject val5 = new GameObject(text); RectTransform obj = val5.AddComponent(); ((Transform)obj).SetParent((Transform)(object)val, false); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(0f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.sizeDelta = new Vector2(iconSize, iconSize); obj.anchoredPosition = new Vector2((float)i * (iconSize + 3f), 0f); ((Transform)obj).localScale = Vector3.one; val3 = val5.AddComponent(); ((Graphic)val3).raycastTarget = false; val3.preserveAspect = true; val5.SetActive(false); } value.Icons[i] = val3; Image val6 = null; string text2 = "Ring" + i; Transform val7 = ((Transform)val).Find(text2); if ((Object)(object)val7 != (Object)null) { val6 = ((Component)val7).GetComponent(); } if ((Object)(object)val6 == (Object)null) { GameObject val8 = new GameObject(text2); RectTransform obj2 = val8.AddComponent(); ((Transform)obj2).SetParent((Transform)(object)val, false); obj2.anchorMin = new Vector2(0f, 0.5f); obj2.anchorMax = new Vector2(0f, 0.5f); obj2.pivot = new Vector2(0f, 0.5f); obj2.sizeDelta = new Vector2(iconSize + 6f, iconSize + 6f); obj2.anchoredPosition = new Vector2((float)i * (iconSize + 3f) - 3f, 0f); ((Transform)obj2).localScale = Vector3.one; val6 = val8.AddComponent(); ((Graphic)val6).raycastTarget = false; val6.sprite = RingSprite.Get(); val6.preserveAspect = true; ((Graphic)val6).color = MatchRing; val8.SetActive(false); } ((Component)val6).transform.SetAsFirstSibling(); value.Glows[i] = val6; } States[pointer] = value; return value; } internal static void SetIcon(Image img, PrefabGUID perk) { //IL_000a: 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) if (!((Object)(object)img == (Object)null)) { if (ServantInfoReader.TryGetPerk(perk, out var icon, out var _) && (Object)(object)icon != (Object)null) { img.sprite = icon; ((Graphic)img).color = Color.white; ((Component)img).gameObject.SetActive(true); } else { img.sprite = null; ((Component)img).gameObject.SetActive(false); } } } } internal sealed class ServantIdentityIndex { private readonly Dictionary _byId = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _names = new Dictionary(StringComparer.Ordinal); internal void Clear() { _byId.Clear(); _names.Clear(); } internal void Add(string name, string id, T value) { if (!string.IsNullOrEmpty(id)) { _byId[id] = value; if (_names.TryGetValue(name, out var value2) && value2 != id) { _names[name] = null; } else if (!_names.ContainsKey(name)) { _names[name] = id; } } } internal bool TryGet(string name, out T value) { value = default(T); if (name != null && _names.TryGetValue(name, out var value2) && value2 != null) { return _byId.TryGetValue(value2, out value); } return false; } } internal static class ServantInfoReader { internal struct Info { public PrefabGUID Perk0; public PrefabGUID Perk1; public float HuntProficiency; public float LootFactor; public string NetworkKey; } private static readonly ServantIdentityIndex Records = new ServantIdentityIndex(); private static long _worldSequence = -1L; private static Entity _throne; private static bool _awaitingResponse; private static ulong _lastResponseHash; private static readonly Dictionary PerkCache = new Dictionary(); private static readonly Dictionary PerkRetryAt = new Dictionary(); private static float _nextRefresh; private static bool _loggedOnce; private static bool _loggedPerk; private const int EntrySize = 112; private const int DataOffset = 8; internal static bool TryGetNetworkKey(string servantName, out string key) { key = null; if (!TryGetInfo(servantName, out var info) || string.IsNullOrEmpty(info.NetworkKey)) { return false; } key = info.NetworkKey; return true; } internal static void BeginThrone(Entity throne) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) RefreshNow(); if (!(_throne == throne)) { _throne = throne; Records.Clear(); _awaitingResponse = true; _nextRefresh = 0f; } } internal static void Clear() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Records.Clear(); PerkCache.Clear(); PerkRetryAt.Clear(); _nextRefresh = 0f; _worldSequence = -1L; _throne = default(Entity); _awaitingResponse = false; _lastResponseHash = 0uL; } internal static bool TryGetInfo(string servantName, out Info info) { RefreshIfNeeded(); info = default(Info); if (string.IsNullOrEmpty(servantName)) { return false; } return Records.TryGet(servantName, out info); } internal static bool TryGetPerk(PrefabGUID perk, out Sprite icon, out string name) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) RefreshIfNeeded(); icon = null; name = ""; if (((PrefabGUID)(ref perk)).GuidHash == 0) { return false; } if (PerkCache.TryGetValue(((PrefabGUID)(ref perk)).GuidHash, out (Sprite, string) value)) { if ((Object)(object)value.Item1 != (Object)null) { (icon, name) = value; return true; } PerkCache.Remove(((PrefabGUID)(ref perk)).GuidHash); } if (PerkRetryAt.TryGetValue(((PrefabGUID)(ref perk)).GuidHash, out var value2) && Time.unscaledTime < value2) { return false; } PerkRetryAt[((PrefabGUID)(ref perk)).GuidHash] = Time.unscaledTime + 0.5f; try { if (!HuntReader.TryGetClientWorld(out var world)) { return false; } GameDataSystem existingSystemManaged = world.GetExistingSystemManaged(); if (existingSystemManaged == null) { return false; } ManagedPerkData val = default(ManagedPerkData); if (existingSystemManaged.ManagedDataRegistry.TryGetWithoutLogging(perk, ref val) && val != null) { icon = val.Icon; try { name = Localization.Get(val.Name, false); } catch { name = ""; } if (string.IsNullOrWhiteSpace(name) || name.IndexOf("not found", StringComparison.OrdinalIgnoreCase) >= 0) { name = ""; } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts perk lookup: " + ex.Message)); } } if ((Object)(object)icon != (Object)null) { PerkCache[((PrefabGUID)(ref perk)).GuidHash] = (icon, name); PerkRetryAt.Remove(((PrefabGUID)(ref perk)).GuidHash); } if (!_loggedPerk && (Object)(object)icon != (Object)null) { _loggedPerk = true; ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("HuntsAndRifts perk icon: " + ((PrefabGUID)(ref perk)).GuidHash + " -> '" + name + "' (" + ((Object)icon).name + ")")); } } return (Object)(object)icon != (Object)null; } private static void RefreshIfNeeded() { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextRefresh) { return; } _nextRefresh = unscaledTime + 0.25f; try { RefreshNow(); } catch (Exception ex) { Records.Clear(); ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts servant info: " + ex.Message)); } } } private unsafe static void RefreshNow() { //IL_0060: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) Records.Clear(); if (!HuntReader.TryGetClientWorld(out var world)) { PerkCache.Clear(); PerkRetryAt.Clear(); _worldSequence = -1L; return; } if (_worldSequence != (long)world.SequenceNumber) { PerkCache.Clear(); PerkRetryAt.Clear(); _worldSequence = (long)world.SequenceNumber; _throne = default(Entity); _lastResponseHash = 0uL; _awaitingResponse = false; } ServantInfoEventSystem_Client existingSystemManaged = world.GetExistingSystemManaged(); if (existingSystemManaged == null) { return; } FixedList4096Bytes result = existingSystemManaged.LastResponse.Result; byte* ptr = (byte*)(&result); ushort num = *(ushort*)ptr; if (num == 0 || num > 36) { return; } ulong num2 = 14695981039346656037uL; for (int i = 0; i < 8 + num * 112; i++) { num2 = (num2 ^ ptr[i]) * 1099511628211L; } if (_awaitingResponse && num2 == _lastResponseHash) { return; } _awaitingResponse = false; _lastResponseHash = num2; byte[] array = new byte[62]; for (int j = 0; j < num; j++) { byte* ptr2 = ptr + 8 + j * 112; ushort num3 = *(ushort*)ptr2; if (num3 != 0 && num3 <= 62) { for (int k = 0; k < num3; k++) { array[k] = ptr2[2 + k]; } string text = Encoding.UTF8.GetString(array, 0, num3); if (!string.IsNullOrEmpty(text)) { long num4 = ((long*)ptr2)[8]; uint num5 = ((uint*)ptr2)[18]; string text2 = ((num4 != 0L || num5 != 0) ? (num4 + ":" + num5) : null); Records.Add(text, text2, new Info { HuntProficiency = ((float*)ptr2)[22], LootFactor = ((float*)ptr2)[23], Perk0 = new PrefabGUID(((int*)ptr2)[24]), Perk1 = new PrefabGUID(((int*)ptr2)[25]), NetworkKey = text2 }); } } } if (!_loggedOnce) { _loggedOnce = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts servant info: " + num + " records indexed by network ID.")); } } } } internal static class ServantScroll { private static RectTransform _owner; private static RectTransform _root; private static RectTransform _content; private static ScrollRect _scroll; private static Scrollbar _bar; private static readonly Dictionary Rows = new Dictionary(); internal static Transform OriginalParent(Transform parent) { if (!((Object)(object)_content != (Object)null) || !((Object)(object)parent == (Object)(object)_content)) { return parent; } return (Transform)(object)_owner; } private static RectTransform Rect(string name, Transform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) RectTransform obj = new GameObject(name).AddComponent(); ((Transform)obj).SetParent(parent, false); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; Vector2 offsetMin = (obj.offsetMax = Vector2.zero); obj.offsetMin = offsetMin; return obj; } internal static void Prepare(RectTransform owner, List rows) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_owner != (Object)null && (Object)(object)_owner != (Object)(object)owner) { Reset(); } if ((Object)(object)_root == (Object)null) { _owner = owner; _root = Rect("HuntsAndRifts_Scroll", (Transform)(object)owner); ((Component)_root).gameObject.AddComponent().ignoreLayout = true; Image obj = ((Component)_root).gameObject.AddComponent(); ((Graphic)obj).color = Color.clear; ((Graphic)obj).raycastTarget = true; RectTransform val = Rect("Viewport", (Transform)(object)_root); val.offsetMax = new Vector2(-14f, 0f); ((Component)val).gameObject.AddComponent(); _content = Rect("Content", (Transform)(object)val); _content.anchorMin = new Vector2(0f, 1f); _content.anchorMax = Vector2.one; _content.pivot = new Vector2(0f, 1f); RectTransform val2 = Rect("Scrollbar", (Transform)(object)_root); val2.anchorMin = new Vector2(1f, 0f); val2.offsetMin = new Vector2(-10f, 8f); GridLayoutGroup component = ((Component)owner).GetComponent(); val2.offsetMax = new Vector2(0f, 0f - Mathf.Max(0f, ((Object)(object)component != (Object)null) ? ((float)((LayoutGroup)component).padding.top - 14f) : 0f)); ((Graphic)((Component)val2).gameObject.AddComponent()).color = new Color(0.05f, 0.06f, 0.08f, 0.9f); RectTransform val3 = Rect("Handle", (Transform)(object)val2); Image val4 = ((Component)val3).gameObject.AddComponent(); ((Graphic)val4).color = new Color(0.55f, 0.51f, 0.43f, 1f); _bar = ((Component)val2).gameObject.AddComponent(); _bar.handleRect = val3; ((Selectable)_bar).targetGraphic = (Graphic)(object)val4; _bar.direction = (Direction)2; _scroll = ((Component)_root).gameObject.AddComponent(); _scroll.viewport = val; _scroll.content = _content; _scroll.horizontal = false; _scroll.vertical = true; _scroll.movementType = (MovementType)2; _scroll.scrollSensitivity = 30f; _scroll.verticalScrollbar = _bar; _scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1; _scroll.verticalNormalizedPosition = 1f; } foreach (Transform row in rows) { RectTransform component2 = ((Component)row).GetComponent(); if (!((Object)(object)component2 == (Object)null)) { if (!Rows.ContainsKey(((Il2CppObjectBase)row).Pointer)) { Rows[((Il2CppObjectBase)row).Pointer] = new RectSnapshot(component2); } if ((Object)(object)row.parent != (Object)(object)_content) { row.SetParent((Transform)(object)_content, false); } } } for (int i = 0; i < rows.Count; i++) { if (rows[i].GetSiblingIndex() != i) { rows[i].SetSiblingIndex(i); } } } internal static float Size(float total) { //IL_0045: 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) Canvas componentInParent = ((Component)_owner).GetComponentInParent(); float scale = (((Object)(object)componentInParent != (Object)null) ? Mathf.Max(0.1f, componentInParent.scaleFactor) : 1f); float num = ServantScrollPolicy.VisibleHeight(total, Screen.height, scale); _content.sizeDelta = new Vector2(0f, total); if (total <= num + 1f) { _content.anchoredPosition = Vector2.zero; } return num; } internal static void Reset() { if ((Object)(object)_scroll != (Object)null) { _scroll.StopMovement(); } foreach (RectSnapshot value in Rows.Values) { value.Restore(); } Rows.Clear(); if ((Object)(object)_root != (Object)null) { ((Component)_root).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)_root).gameObject); } _owner = (_root = (_content = null)); _scroll = null; _bar = null; } } internal static class ServantScrollPolicy { internal static float VisibleHeight(float total, float screenHeight, float scale) { return Math.Min(Math.Max(0f, total), Math.Max(120f, screenHeight / Math.Max(0.1f, scale) * 0.6f)); } } internal static class ThroneHuntOverlay { private struct PlotRow { public int Plot; public bool Here; public string Label; public List Servants; } private struct ServantRow { public int Index; public string Name; } internal const string JsonPath = "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\thrones-client.json"; internal const string MailboxPath = "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\req.json"; private static bool _huntOpen; private static GUIStyle _label; private static GUIStyle _button; private static GUIStyle _statusStyle; private static Texture2D _bg; private static readonly List Plots = new List(); private static float _nextRead; private static int _selectedPlot = -1; private static readonly HashSet SelectedServants = new HashSet(); private static string _status = "Pick a castle, then who goes, then click a territory."; private static string _lastArmed = ""; internal static void SetHuntOpen(bool open) { _huntOpen = open; if (!open) { _status = "Pick a castle, then who goes, then click a territory."; SelectedServants.Clear(); _lastArmed = ""; } } internal static void DrawImgui() { //IL_0118: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0368: 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_02b5: Unknown result type (might be due to invalid IL or missing references) if (!_huntOpen) { return; } RefreshJson(); EnsureStyles(); if (_label == null || _button == null) { return; } float num = 300f; float num2 = 52f + (float)Plots.Count * 26f + 12f; PlotRow plotRow = FindPlot(_selectedPlot); if (plotRow.Servants != null) { num2 += 26f + (float)plotRow.Servants.Count * 24f; } num2 += 44f; float num3 = Mathf.Min(560f, (float)Screen.width * 0.28f); float num4 = (float)Screen.width * 0.5f - num3 - num - 16f; if (num4 < 12f) { num4 = 12f; } float num5 = (float)Screen.height * 0.16f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num4, num5, num, num2); if ((Object)(object)_bg != (Object)null) { GUI.DrawTexture(val, (Texture)(object)_bg); } float num6 = ((Rect)(ref val)).y + 10f; GUI.Label(new Rect(((Rect)(ref val)).x + 10f, num6, num - 20f, 20f), "1. Castle to send from", _label); num6 += 22f; for (int i = 0; i < Plots.Count; i++) { PlotRow plotRow2 = Plots[i]; string text = ((plotRow2.Plot == _selectedPlot) ? " <" : (plotRow2.Here ? " (this chair)" : "")); if (GUI.Button(new Rect(((Rect)(ref val)).x + 10f, num6, num - 20f, 22f), plotRow2.Label + text, _button)) { _selectedPlot = plotRow2.Plot; SelectedServants.Clear(); _lastArmed = ""; _status = (plotRow2.Here ? "This chair — or pick another castle, then tick who goes." : "2. Tick who to send (up to 3), then click a territory."); } num6 += 24f; } plotRow = FindPlot(_selectedPlot); if (plotRow.Servants != null && plotRow.Servants.Count > 0) { GUI.Label(new Rect(((Rect)(ref val)).x + 10f, num6, num - 20f, 20f), "2. Who goes (up to 3)", _label); num6 += 22f; bool flag = false; for (int j = 0; j < plotRow.Servants.Count; j++) { ServantRow servantRow = plotRow.Servants[j]; bool flag2 = SelectedServants.Contains(servantRow.Index); bool flag3 = GUI.Toggle(new Rect(((Rect)(ref val)).x + 10f, num6, num - 20f, 22f), flag2, servantRow.Name); if (flag3 && !flag2) { if (SelectedServants.Count < 3) { SelectedServants.Add(servantRow.Index); flag = true; } } else if (!flag3 && flag2) { SelectedServants.Remove(servantRow.Index); flag = true; } num6 += 22f; } if (flag) { ArmMailbox(plotRow.Plot); } } if (_statusStyle != null) { GUI.Label(new Rect(((Rect)(ref val)).x + 10f, num6, num - 20f, 40f), _status, _statusStyle); } } private static PlotRow FindPlot(int plot) { for (int i = 0; i < Plots.Count; i++) { if (Plots[i].Plot == plot) { return Plots[i]; } } return default(PlotRow); } private static void ArmMailbox(int plot) { if (SelectedServants.Count == 0) { _lastArmed = ""; _status = "Tick who to send, then click a territory on the map."; return; } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); PlotRow plotRow = FindPlot(plot); foreach (int selectedServant in SelectedServants) { if (stringBuilder2.Length > 0) { stringBuilder2.Append(' '); } stringBuilder2.Append(selectedServant); if (plotRow.Servants == null) { continue; } for (int i = 0; i < plotRow.Servants.Count; i++) { if (plotRow.Servants[i].Index == selectedServant) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(plotRow.Servants[i].Name); } } } string text = plot + ":" + stringBuilder2; if (text == _lastArmed) { return; } try { string directoryName = Path.GetDirectoryName("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\req.json"); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } string text2 = "hc-" + DateTime.UtcNow.Ticks; string contents = "{\"id\":\"" + text2 + "\",\"op\":\"hunt\",\"plot\":" + plot + ",\"name\":\"" + stringBuilder2?.ToString() + "\"}"; File.WriteAllText("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\req.json", contents); _lastArmed = text; _status = "3. Click a colored territory to send " + stringBuilder?.ToString() + "."; } catch (Exception ex) { _status = "Could not talk to the server."; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts hunt mailbox: " + ex.Message)); } } } private static void RefreshJson() { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextRead) { return; } _nextRead = unscaledTime + 0.5f; try { if (File.Exists("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\thrones-client.json")) { ParsePlots(File.ReadAllText("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\thrones-client.json")); } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts throne json: " + ex.Message)); } } } private static void ParsePlots(string text) { Plots.Clear(); if (string.IsNullOrEmpty(text)) { return; } int startIndex = 0; while (true) { int num = text.IndexOf("\"plot\":", startIndex, StringComparison.Ordinal); if (num < 0) { break; } int num2 = num + 7; int i; for (i = num2; i < text.Length && (char.IsDigit(text[i]) || text[i] == '-'); i++) { } if (!int.TryParse(text.Substring(num2, i - num2), out var result)) { startIndex = i; continue; } bool here = text.IndexOf("\"here\":true", num, StringComparison.Ordinal) >= 0 && text.IndexOf("\"here\":true", num, StringComparison.Ordinal) < num + 80; string text2 = SliceString(text, "\"label\":", num); List list = new List(); int num3 = text.IndexOf("\"servants\":[", num, StringComparison.Ordinal); int num4 = text.IndexOf("\"plot\":", i, StringComparison.Ordinal); int num5 = ((num4 < 0) ? text.Length : num4); if (num3 >= 0 && num3 < num5) { int num6 = num3; while (num6 < num5) { int num7 = text.IndexOf("\"i\":", num6, StringComparison.Ordinal); if (num7 < 0 || num7 >= num5) { break; } int num8 = num7 + 4; int j; for (j = num8; j < text.Length && char.IsDigit(text[j]); j++) { } int.TryParse(text.Substring(num8, j - num8), out var result2); string name = SliceString(text, "\"name\":", num7); list.Add(new ServantRow { Index = result2, Name = name }); num6 = j + 1; } } Plots.Add(new PlotRow { Plot = result, Here = here, Label = (string.IsNullOrEmpty(text2) ? ("plot " + result) : text2), Servants = list }); startIndex = i + 1; } } private static string SliceString(string text, string key, int from) { int num = text.IndexOf(key, from, StringComparison.Ordinal); if (num < 0) { return ""; } int num2 = text.IndexOf('"', num + key.Length); if (num2 < 0) { return ""; } int num3 = text.IndexOf('"', num2 + 1); if (num3 < 0) { return ""; } return text.Substring(num2 + 1, num3 - num2 - 1); } private static void EnsureStyles() { //IL_0009: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0076: 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) //IL_009f: Expected O, but got Unknown //IL_009f: 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_00ac: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00f1: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) if (_label != null) { return; } try { GUIStyle val = new GUIStyle { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)0, wordWrap = false, richText = false }; val.normal.textColor = new Color(0.96f, 0.9f, 0.72f, 1f); _label = val; GUIStyle val2 = new GUIStyle { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val2.normal.textColor = new Color(0.96f, 0.9f, 0.72f, 1f); _button = val2; GUIStyle val3 = new GUIStyle { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)0, wordWrap = true, richText = false }; val3.normal.textColor = new Color(0.85f, 0.78f, 0.55f, 1f); _statusStyle = val3; _bg = new Texture2D(1, 1, (TextureFormat)4, false); _bg.SetPixel(0, 0, new Color(0.04f, 0.05f, 0.07f, 0.82f)); _bg.Apply(); ((Object)_bg).hideFlags = (HideFlags)61; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)("HuntsAndRifts throne style: " + ex.Message)); } } } } internal static class TooltipDecor { private sealed class Row { public GameObject Root; public RectTransform Rect; public TextMeshProUGUI Power; public readonly List Icons = new List(); public TextMeshProUGUI Names; public int Mission; public float Width; public bool PerksReady; public float RetryAt; } private const string RowName = "HuntsAndRifts_MissionRow"; private const float IconSize = 20f; private const float IconGap = 3f; private const float Line1Height = 24f; private static Row _row; private static IntPtr _rowTooltip; private static bool _loggedRow; private static string _lastMissTitle; private static bool _zoneTypeReady; private static TypeIndex _zoneTypeIndex; internal static void Clear() { if ((Object)(object)_row?.Root != (Object)null) { _row.Root.SetActive(false); Object.Destroy((Object)(object)_row.Root); } _row = null; _rowTooltip = IntPtr.Zero; } internal static void Tick(MapMenuMapper mapper) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_00ea: Unknown result type (might be due to invalid IL or missing references) try { if (mapper == null) { return; } MapMenu mapMenu = mapper.GetMapMenu(); if ((Object)(object)mapMenu == (Object)null) { return; } MapTooltip tooltip = mapMenu.Tooltip; if ((Object)(object)tooltip == (Object)null) { return; } bool flag; try { flag = ((Component)tooltip).gameObject.activeInHierarchy; } catch { flag = false; } if (!flag) { HideRow(); return; } RiftTooltip.Tick(mapper, mapMenu, tooltip); string text = ReadTitle(tooltip); PrefabGUID mission = HoveredZoneMission(mapper); if (((PrefabGUID)(ref mission)).GuidHash == 0 && (string.IsNullOrEmpty(text) || !HuntReader.TryGetMissionForZoneName(text, out mission))) { if (!string.IsNullOrEmpty(text) && _lastMissTitle != text) { _lastMissTitle = text; ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)("HuntsAndRifts tooltip: '" + text + "' is not an indexed hunt zone.")); } } HideRow(); return; } Row row = GetRow(tooltip); MissionInfoReader.Info info = MissionInfoReader.Get(mission); if (row != null) { if (info == null) { HideRow(); } else { FillRow(row, tooltip, mission, info); } } DecorateServants(tooltip, info); } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts tooltip: " + ex.Message)); } } } private unsafe static PrefabGUID HoveredZoneMission(MapMenuMapper mapper) { //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_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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_008d: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00d3: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) try { Entity hoveredMapZoneEntity = mapper._HoveredMapZoneEntity; if (hoveredMapZoneEntity == Entity.Null) { return default(PrefabGUID); } if (!HuntReader.TryGetClientWorld(out var world)) { return default(PrefabGUID); } if (!_zoneTypeReady) { _zoneTypeReady = true; try { _zoneTypeIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } } if (_zoneTypeIndex.Value == 0) { return default(PrefabGUID); } EntityManager entityManager = world.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(hoveredMapZoneEntity) || !((EntityManager)(ref entityManager)).HasComponent(hoveredMapZoneEntity, ComponentType.ReadOnly(_zoneTypeIndex))) { return default(PrefabGUID); } byte* componentDataRawRO = (byte*)((EntityManager)(ref entityManager)).GetComponentDataRawRO(hoveredMapZoneEntity, _zoneTypeIndex); if (componentDataRawRO == null) { return default(PrefabGUID); } return new PrefabGUID(((int*)componentDataRawRO)[18]); } catch { return default(PrefabGUID); } } private static string ReadTitle(MapTooltip tooltip) { try { LocalizedText titleText = tooltip.TitleText; if ((Object)(object)titleText == (Object)null) { return null; } string text = null; try { text = titleText.GetText(); } catch { } if (string.IsNullOrWhiteSpace(text) && (Object)(object)titleText.Text != (Object)null) { text = ((TMP_Text)titleText.Text).text; } return text?.Trim(); } catch { return null; } } private static void HideRow() { try { if (_row != null && (Object)(object)_row.Root != (Object)null && _row.Root.activeSelf) { _row.Root.SetActive(false); } } catch { } } private static void DecorateServants(MapTooltip tooltip, MissionInfoReader.Info info) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) List servantList = tooltip.ServantList; if (servantList == null) { return; } HashSet hashSet = null; if (info != null && info.Perks.Count > 0) { hashSet = new HashSet(); foreach (PrefabGUID perk in info.Perks) { PrefabGUID current = perk; hashSet.Add(((PrefabGUID)(ref current)).GuidHash); } } int count = servantList.Count; for (int i = 0; i < count; i++) { TextMeshProUGUI val = servantList[i]; if ((Object)(object)val == (Object)null) { continue; } try { if (!((Component)val).gameObject.activeSelf) { continue; } } catch { continue; } string text = RowDecor.BaseName(((TMP_Text)val).text); if (!string.IsNullOrEmpty(text)) { RowDecor.ApplyToText(val, text, 20f, hashSet); } } } private static Row GetRow(MapTooltip tooltip) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0235: 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) if (_row != null && (Object)(object)_row.Root != (Object)null && _rowTooltip == ((Il2CppObjectBase)tooltip).Pointer) { return _row; } try { RectTransform descriptionRect = tooltip.DescriptionRect; LocalizedText descriptionText = tooltip.DescriptionText; if ((Object)(object)descriptionRect == (Object)null || (Object)(object)descriptionText == (Object)null) { return null; } Transform parent = ((Transform)descriptionRect).parent; if ((Object)(object)parent == (Object)null) { return null; } TextMeshProUGUI text = descriptionText.Text; Transform val = parent.Find("HuntsAndRifts_MissionRow"); GameObject val2; RectTransform val3; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).gameObject; val3 = val2.GetComponent(); } else { val2 = new GameObject("HuntsAndRifts_MissionRow"); val3 = val2.AddComponent(); ((Transform)val3).SetParent(parent, false); ((Transform)val3).localScale = Vector3.one; } val3.anchorMin = descriptionRect.anchorMin; val3.anchorMax = descriptionRect.anchorMax; val3.pivot = descriptionRect.pivot; val3.sizeDelta = new Vector2(descriptionRect.sizeDelta.x, 24f); val2.transform.SetSiblingIndex(((Transform)descriptionRect).GetSiblingIndex() + 1); LayoutElement val4 = val2.GetComponent(); if ((Object)(object)val4 == (Object)null) { val4 = val2.AddComponent(); } val4.preferredHeight = 24f; val4.minHeight = 24f; Row row = new Row { Root = val2, Rect = val3, Mission = 0 }; row.Power = GetOrMakeText(val2.transform, "Power", (TMP_Text)(object)text, wrap: false); for (int i = 0; i < 4; i++) { row.Icons.Add(GetOrMakeIcon(val2.transform, "Icon" + i)); } row.Names = GetOrMakeText(val2.transform, "Names", (TMP_Text)(object)text, wrap: true); _row = row; _rowTooltip = ((Il2CppObjectBase)tooltip).Pointer; if (!_loggedRow) { _loggedRow = true; ManualLogSource logger = Plugin.Logger; if (logger != null) { string[] obj = new string[5] { "HuntsAndRifts tooltip: mission block added under ", ((Object)parent).name, " (description ", null, null }; Rect rect = descriptionRect.rect; obj[3] = ((object)((Rect)(ref rect)).size/*cast due to .constrained prefix*/).ToString(); obj[4] = ")."; logger.LogInfo((object)string.Concat(obj)); } } return row; } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; if (logger2 != null) { logger2.LogDebug((object)("HuntsAndRifts tooltip row: " + ex.Message)); } return null; } } private static TextMeshProUGUI GetOrMakeText(Transform parent, string name, TMP_Text template, bool wrap) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) Transform val = parent.Find(name); TextMeshProUGUI val2 = null; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).GetComponent(); } if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject(name); RectTransform obj = val3.AddComponent(); ((Transform)obj).SetParent(parent, false); ((Transform)obj).localScale = Vector3.one; val2 = val3.AddComponent(); } ((TMP_Text)val2).richText = true; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).enableWordWrapping = wrap; ((TMP_Text)val2).alignment = (TextAlignmentOptions)(wrap ? 257 : 4097); try { if ((Object)(object)template != (Object)null) { ((TMP_Text)val2).font = template.font; ((TMP_Text)val2).fontSharedMaterial = template.fontSharedMaterial; ((TMP_Text)val2).fontSize = template.fontSize; ((Graphic)val2).color = ((Graphic)template).color; } } catch { } RectTransform rectTransform = ((TMP_Text)val2).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); return val2; } private static Image GetOrMakeIcon(Transform parent, string name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0039: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) Transform val = parent.Find(name); if ((Object)(object)val != (Object)null) { Image component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } } GameObject val2 = new GameObject(name); RectTransform obj = val2.AddComponent(); ((Transform)obj).SetParent(parent, false); ((Transform)obj).localScale = Vector3.one; obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(0f, 1f); obj.pivot = new Vector2(0f, 1f); obj.sizeDelta = new Vector2(20f, 20f); Image obj2 = val2.AddComponent(); ((Graphic)obj2).raycastTarget = false; obj2.preserveAspect = true; val2.SetActive(false); return obj2; } private static void FillRow(Row row, MapTooltip tooltip, PrefabGUID mission, MissionInfoReader.Info info) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_004e: 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_013e: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)row.Root == (Object)null) { return; } if (!row.Root.activeSelf) { row.Root.SetActive(true); } float num = 0f; Rect rect; try { float num2; if (!((Object)(object)tooltip.DescriptionRect != (Object)null)) { num2 = 0f; } else { rect = tooltip.DescriptionRect.rect; num2 = ((Rect)(ref rect)).width; } num = num2; } catch { } if (num < 40f) { rect = row.Rect.rect; num = ((Rect)(ref rect)).width; } if (num < 40f) { num = 300f; } if (row.Mission == ((PrefabGUID)(ref mission)).GuidHash && Mathf.Abs(row.Width - num) < 0.5f && (row.PerksReady || Time.unscaledTime < row.RetryAt)) { return; } row.Mission = ((PrefabGUID)(ref mission)).GuidHash; row.Width = num; row.PerksReady = true; row.RetryAt = Time.unscaledTime + 0.5f; string text = "Power " + info.Difficulty + ""; ((TMP_Text)row.Power).text = text; RectTransform rectTransform = ((TMP_Text)row.Power).rectTransform; float num3 = ((TMP_Text)row.Power).GetPreferredValues(text).x + 2f; rectTransform.sizeDelta = new Vector2(num3, 24f); rectTransform.anchoredPosition = new Vector2(0f, 0f); float num4 = num3 + 8f; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < row.Icons.Count; i++) { Image val = row.Icons[i]; if ((Object)(object)val == (Object)null) { continue; } if (i < info.Perks.Count && ServantInfoReader.TryGetPerk(info.Perks[i], out var icon, out var name) && (Object)(object)icon != (Object)null) { val.sprite = icon; ((Graphic)val).color = Color.white; ((Graphic)val).rectTransform.anchoredPosition = new Vector2(num4, -2f); ((Component)val).gameObject.SetActive(true); num4 += 23f; if (!string.IsNullOrEmpty(name)) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(name); } } else { if (i < info.Perks.Count) { row.PerksReady = false; } ((Component)val).gameObject.SetActive(false); } } float num5 = 24f; if (stringBuilder.Length > 0) { string text2 = "" + stringBuilder?.ToString() + ""; ((TMP_Text)row.Names).text = text2; float num6 = ((TMP_Text)row.Names).GetPreferredValues(text2, num, 0f).y + 2f; RectTransform rectTransform2 = ((TMP_Text)row.Names).rectTransform; rectTransform2.sizeDelta = new Vector2(num, num6); rectTransform2.anchoredPosition = new Vector2(0f, -24f); ((Component)row.Names).gameObject.SetActive(true); num5 += num6; } else { ((Component)row.Names).gameObject.SetActive(false); } row.Rect.sizeDelta = new Vector2(row.Rect.sizeDelta.x, num5); LayoutElement component = row.Root.GetComponent(); if ((Object)(object)component != (Object)null) { component.preferredHeight = num5; component.minHeight = num5; } } } internal static class UiTextState { private sealed class State { internal TMP_Text Text; internal string Value; internal bool Rich; internal FontStyles Style; internal RectSnapshot Rect; } private static readonly Dictionary Saved = new Dictionary(); internal static void Track(TMP_Text text) { //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) if (!((Object)(object)text == (Object)null) && !Saved.ContainsKey(((Il2CppObjectBase)text).Pointer)) { Saved[((Il2CppObjectBase)text).Pointer] = new State { Text = text, Value = text.text, Rich = text.richText, Style = text.fontStyle, Rect = new RectSnapshot(text.rectTransform) }; } } internal static void Restore() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) foreach (State value in Saved.Values) { if (!((Object)(object)value.Text == (Object)null)) { value.Text.text = value.Value; value.Text.richText = value.Rich; value.Text.fontStyle = value.Style; value.Rect.Restore(); } } Saved.Clear(); } } internal static class ZoneLocator { private static bool _typesReady; private static TypeIndex _uiPolygonMeshIndex; private static TypeIndex _regionNameIndex; private static TypeIndex _translationIndex; private static TypeIndex _vertexIndex; private static readonly HashSet Logged = new HashSet(StringComparer.Ordinal); private static void EnsureTypes() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0057: Unknown result type (might be due to invalid IL or missing references) if (_typesReady) { return; } _typesReady = true; try { _uiPolygonMeshIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } try { _regionNameIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } try { _translationIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } try { _vertexIndex = TypeManager.GetTypeIndex(Il2CppType.Of()); } catch { } } internal unsafe static bool TryGetCenter(EntityManager em, Entity zoneEntity, ref MapZoneData zone, string zoneLabel, out Vector2 worldXZ) { //IL_0002: 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_005d: 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) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) //IL_0091: 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_009e: Unknown result type (might be due to invalid IL or missing references) worldXZ = default(Vector2); EnsureTypes(); string text = null; if (zone.CenterPosWS.x != 0f || zone.CenterPosWS.y != 0f) { worldXZ = new Vector2(zone.CenterPosWS.x, zone.CenterPosWS.y); text = "CenterPosWS"; } else if (zoneEntity != Entity.Null && TryAabbCenter(em, zoneEntity, out worldXZ)) { text = "UiPolygonMesh.Aabb"; } else if (TryRegionName(em, ref zone, out worldXZ)) { text = "MapRegionName Translation"; } else if (zoneEntity != Entity.Null && TryVertexMean(em, zoneEntity, out worldXZ)) { text = "polygon vertex mean"; } if (text == null) { LogOnce(zoneLabel, "HuntsAndRifts zone '" + zoneLabel + "': no position source (CenterPosWS zero, no Aabb, no region label, no vertices)."); return false; } string[] obj = new string[7] { "HuntsAndRifts zone '", zoneLabel, "' centre ", null, null, null, null }; Vector2 val = worldXZ; obj[3] = ((object)(*(Vector2*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[4] = " from "; obj[5] = text; obj[6] = "."; LogOnce(zoneLabel, string.Concat(obj)); return true; } private unsafe static bool TryAabbCenter(EntityManager em, Entity entity, out Vector2 xz) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) xz = default(Vector2); if (_uiPolygonMeshIndex.Value == 0) { return false; } try { if (!((EntityManager)(ref em)).HasComponent(entity, ComponentType.ReadOnly(_uiPolygonMeshIndex))) { return false; } float* componentDataRawRO = (float*)((EntityManager)(ref em)).GetComponentDataRawRO(entity, _uiPolygonMeshIndex); if (componentDataRawRO == null) { return false; } float num = *componentDataRawRO; float num2 = componentDataRawRO[2]; float num3 = componentDataRawRO[3]; float num4 = componentDataRawRO[5]; if (!Finite(num) || !Finite(num2) || !Finite(num3) || !Finite(num4)) { return false; } if (num3 - num <= 0f && num4 - num2 <= 0f) { return false; } xz = new Vector2((num + num3) * 0.5f, (num2 + num4) * 0.5f); return xz.x != 0f || xz.y != 0f; } catch { return false; } } private unsafe static bool TryRegionName(EntityManager em, ref MapZoneData zone, out Vector2 xz) { //IL_0001: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) xz = default(Vector2); if (_regionNameIndex.Value == 0 || _translationIndex.Value == 0) { return false; } NativeArray val = default(NativeArray); try { EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadOnly(_regionNameIndex), ComponentType.ReadOnly(_translationIndex) }); if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return false; } val = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); fixed (MapZoneData* ptr = &zone) { long* ptr2 = (long*)(&((MapZoneData)ptr).Name); for (int i = 0; i < val.Length; i++) { long* componentDataRawRO = (long*)((EntityManager)(ref em)).GetComponentDataRawRO(val[i], _regionNameIndex); if (componentDataRawRO != null && *componentDataRawRO == *ptr2 && componentDataRawRO[1] == ptr2[1]) { float* componentDataRawRO2 = (float*)((EntityManager)(ref em)).GetComponentDataRawRO(val[i], _translationIndex); if (componentDataRawRO2 != null) { xz = new Vector2(*componentDataRawRO2, componentDataRawRO2[2]); return Finite(xz.x) && Finite(xz.y); } } } } } catch { } finally { if (val.IsCreated) { val.Dispose(); } } return false; } private unsafe static bool TryVertexMean(EntityManager em, Entity entity, out Vector2 xz) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) xz = default(Vector2); if (_vertexIndex.Value == 0) { return false; } try { if (!((EntityManager)(ref em)).HasComponent(entity, ComponentType.ReadOnly(_vertexIndex))) { return false; } int bufferLength = ((EntityManager)(ref em)).GetBufferLength(entity, _vertexIndex); if (bufferLength <= 0 || bufferLength > 4096) { return false; } float* bufferRawRO = (float*)((EntityManager)(ref em)).GetBufferRawRO(entity, _vertexIndex); if (bufferRawRO == null) { return false; } double num = 0.0; double num2 = 0.0; for (int i = 0; i < bufferLength; i++) { num += (double)bufferRawRO[i * 2]; num2 += (double)bufferRawRO[i * 2 + 1]; } xz = new Vector2((float)(num / (double)bufferLength), (float)(num2 / (double)bufferLength)); return Finite(xz.x) && Finite(xz.y) && (xz.x != 0f || xz.y != 0f); } catch { return false; } } private static bool Finite(float f) { if (!float.IsNaN(f)) { return !float.IsInfinity(f); } return false; } private static void LogOnce(string key, string msg) { if (Logged.Add(key ?? "")) { ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogInfo((object)msg); } } } } }