Decompiled source of HuntsAndRifts v1.0.0
plugins/HuntsAndRifts.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
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<IntPtr, Header> ByEntry = new Dictionary<IntPtr, Header>(); private static readonly Dictionary<IntPtr, Header> ByRoot = new Dictionary<IntPtr, Header>(); private static readonly Dictionary<string, Header> ByDest = new Dictionary<string, Header>(StringComparer.Ordinal); private static bool _loggedOnce; internal const float HeaderHeight = 24f; internal static IEnumerable<Header> 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<string, Header> 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<GridLayoutGroup>(); 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<VerticalLayoutGroup>() != (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<LayoutElement>(); if ((Object)(object)val == (Object)null) { val = h.Root.AddComponent<LayoutElement>(); } LayoutElement val2 = null; try { val2 = ((Component)row).GetComponent<LayoutElement>(); } 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<RectTransform>(); ((Transform)obj).SetParent(gridParent, false); ((Transform)obj).localScale = Vector3.one; } Header header = new Header { Root = val, Rect = val.GetComponent<RectTransform>(), Dest = dest }; header.Bg = GetOrMake<Image>(val.transform, "Bg", (Func<GameObject, Image>)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<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image obj2 = go.AddComponent<Image>(); ((Graphic)obj2).raycastTarget = true; ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.35f); return obj2; }); try { GridSelectionEntry val3 = val.GetComponent<GridSelectionEntry>(); if ((Object)(object)val3 == (Object)null) { val3 = val.AddComponent<GridSelectionEntry>(); } 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<TextMeshProUGUI>(val.transform, "Title", (Func<GameObject, TextMeshProUGUI>)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<RectTransform>(); 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<TextMeshProUGUI>(); ((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<TextMeshProUGUI>(val.transform, "Right", (Func<GameObject, TextMeshProUGUI>)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<RectTransform>(); 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<TextMeshProUGUI>(); ((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<Image>(val.transform, "Ring" + num, (Func<GameObject, Image>)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<RectTransform>(); 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<Image>(); ((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<Image>(val.transform, "Icon" + num2, (Func<GameObject, Image>)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<RectTransform>(); 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<Image>(); ((Graphic)obj2).raycastTarget = false; obj2.preserveAspect = true; go.SetActive(false); return obj2; }); } return header; } private static T GetOrMake<T>(Transform parent, string name, Func<GameObject, T> 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<T>(); if ((Object)(object)component != (Object)null) { return component; } } GameObject val2 = new GameObject(name); RectTransform obj = val2.AddComponent<RectTransform>(); ((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<int> 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<PrefabGUID> 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) ? ("<color=#E6CF8F>" + info.Difficulty + "</color>") : ""); 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<string> used) { foreach (KeyValuePair<string, Header> 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<string> 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<string, double> HuntRemainingByName = new Dictionary<string, double>(StringComparer.Ordinal); private static readonly Dictionary<string, string> HuntDestByName = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly Dictionary<int, string> DestByMission = new Dictionary<int, string>(); private static readonly Dictionary<int, Vector2> PosByMission = new Dictionary<int, Vector2>(); private static readonly Dictionary<string, Vector2> HuntPosByName = new Dictionary<string, Vector2>(StringComparer.Ordinal); private static readonly Dictionary<string, double> InjuryRemainingByName = new Dictionary<string, double>(StringComparer.Ordinal); private static readonly Dictionary<string, float> GearLevelByName = new Dictionary<string, float>(StringComparer.Ordinal); private static readonly Dictionary<string, double> HuntRemainingById = new Dictionary<string, double>(StringComparer.Ordinal); private static readonly Dictionary<string, string> HuntDestById = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly Dictionary<string, Vector2> HuntPosById = new Dictionary<string, Vector2>(StringComparer.Ordinal); private static readonly Dictionary<string, double> InjuryRemainingById = new Dictionary<string, double>(StringComparer.Ordinal); private static readonly Dictionary<string, float> GearLevelById = new Dictionary<string, float>(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<string, PrefabGUID> MissionByZoneName = new Dictionary<string, PrefabGUID>(StringComparer.Ordinal); private static bool _zoneNamesBuilt; private static bool Lookup<T>(Dictionary<string, T> byName, Dictionary<string, T> 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<NetworkId>()); } 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<Entity> val = default(NativeArray<Entity>); NativeArray<Entity> val2 = default(NativeArray<Entity>); try { EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ActiveServantMission>() }); val = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); List<ActiveServantMission> list = new List<ActiveServantMission>(8); for (int i = 0; i < val.Length; i++) { if (((EntityManager)(ref entityManager)).HasBuffer<ActiveServantMission>(val[i])) { DynamicBuffer<ActiveServantMission> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ActiveServantMission>(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<ServantCoffinstation>() }); val2 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int k = 0; k < val2.Length; k++) { ServantCoffinstation componentData = ((EntityManager)(ref entityManager)).GetComponentData<ServantCoffinstation>(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<double>(remaining, "0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s, startTicks="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<long>(startTicks); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", length="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(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<string, PrefabGUID> 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<MapZoneData> val = default(NativeArray<MapZoneData>); try { EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<MapZoneData>() }); if (((EntityQuery)(ref val2)).IsEmptyIgnoreFilter) { return; } val = ((EntityQuery)(ref val2)).ToComponentDataArray<MapZoneData>(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<MapZoneData> val = default(NativeArray<MapZoneData>); NativeArray<Entity> val2 = default(NativeArray<Entity>); try { EntityQuery val3 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<MapZoneData>() }); if (((EntityQuery)(ref val3)).IsEmptyIgnoreFilter) { return ""; } val = ((EntityQuery)(ref val3)).ToComponentDataArray<MapZoneData>(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<GameDataSystem>(); 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<World> 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<LayoutElement>(); _owned = (Object)(object)_element == (Object)null; if (_owned) { _element = go.AddComponent<LayoutElement>(); } _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<string, PrefabGUID> NameToPrefab = new Dictionary<string, PrefabGUID>(StringComparer.Ordinal); private static readonly HashSet<string> MissingNames = new HashSet<string>(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<EntityManager>(world.EntityManager, val, item); return true; } catch { try { total = InventoryUtilities.GetItemAmount<EntityManager>(world.EntityManager, val, item, default(Nullable_Unboxed<int>)); 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<GameDataSystem>(); } catch { return; } if (existingSystemManaged == null) { return; } NativeParallelHashMap<PrefabGUID, ItemData> itemHashLookupMap; try { itemHashLookupMap = existingSystemManaged.ItemHashLookupMap; } catch { return; } NativeArray<PrefabGUID> val = default(NativeArray<PrefabGUID>); 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<ManagedItemData>(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<PrefabCollectionSystem>(); if (existingSystemManaged == null) { return; } Dictionary<string, PrefabGUID> spawnableNameToPrefabGuidDictionary = existingSystemManaged.SpawnableNameToPrefabGuidDictionary; if (spawnableNameToPrefabGuidDictionary == null) { return; } Enumerator<string, PrefabGUID> enumerator = spawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, PrefabGUID> 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<RectTransform>()); } 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<RectTransform>()); } } catch { } try { if ((Object)(object)warEventInfo.TimerText != (Object)null) { Acc(((Component)warEventInfo.TimerText).GetComponent<RectTransform>()); } } 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<RiftTrack> tracks = RiftReader.GetTracks(); if (tracks == null || tracks.Count == 0) { return false; } List<RiftTrack> list = new List<RiftTrack>(); 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<RiftTrack> 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<Vector3>.op_Implicit(array)); Canvas val = null; try { val = ((Component)rt).GetComponentInParent<Canvas>(); } 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