Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Hearthkeeper v1.0.1
Hearthkeeper.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Hearthkeeper")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.14.12")] [assembly: AssemblyInformationalVersion("0.1.14-Part1-LabelSurfaces-Fix1")] [assembly: AssemblyProduct("Hearthkeeper")] [assembly: AssemblyTitle("Hearthkeeper")] [assembly: AssemblyVersion("0.1.14.12")] [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 Hearthkeeper { internal static class AutoRefuelService { private const string DeviceDisabledKey = "MaddCatter365.Hearthkeeper.autoRefuelDisabled"; private static readonly List<Fireplace> Fireplaces = new List<Fireplace>(); private static readonly List<Smelter> Smelters = new List<Smelter>(); private static int _fireplaceCursor; private static int _smelterCursor; internal static void Register(Fireplace fireplace) { if ((Object)(object)fireplace != (Object)null && !Fireplaces.Contains(fireplace)) { Fireplaces.Add(fireplace); } } internal static void Register(Smelter smelter) { if ((Object)(object)smelter != (Object)null && !Smelters.Contains(smelter)) { Smelters.Add(smelter); } } internal static void Process(Player player) { if (!((Object)(object)player == (Object)null) && HearthkeeperPlugin.AutoRefuelEnabled.Value) { Cleanup(); int value = HearthkeeperPlugin.AutoRefuelMaximumDevicesPerCycle.Value; if (HearthkeeperPlugin.AutoRefuelFires.Value) { ProcessRotating<Fireplace>(Fireplaces, ref _fireplaceCursor, value, (Action<Fireplace>)ProcessFireplace); } if (HearthkeeperPlugin.AutoRefuelProcessingFuel.Value || HearthkeeperPlugin.AutoRefuelProcessingInputs.Value) { ProcessRotating<Smelter>(Smelters, ref _smelterCursor, value, (Action<Smelter>)ProcessSmelter); } } } internal static bool ToggleHoveredDevice(Player player) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } GameObject hoverObject = ((Humanoid)player).GetHoverObject(); if ((Object)(object)hoverObject == (Object)null) { return false; } Component componentInParent = (Component)(object)hoverObject.GetComponentInParent<Fireplace>(); if ((Object)(object)componentInParent == (Object)null) { componentInParent = (Component)(object)hoverObject.GetComponentInParent<Smelter>(); } if ((Object)(object)componentInParent == (Object)null) { return false; } ZNetView view = GetView(componentInParent); if ((Object)(object)view == (Object)null || !view.IsValid() || view.GetZDO() == null) { return false; } if (!PrivateArea.CheckAccess(componentInParent.transform.position, 0f, true, false)) { return true; } if (!view.IsOwner()) { view.ClaimOwnership(); } if (!view.IsOwner()) { ((Character)player).Message((MessageType)2, "Hearthkeeper could not change this device", 0, (Sprite)null, false); return true; } bool flag = view.GetZDO().GetBool("MaddCatter365.Hearthkeeper.autoRefuelDisabled", false); view.GetZDO().Set("MaddCatter365.Hearthkeeper.autoRefuelDisabled", !flag); ((Character)player).Message((MessageType)2, (!flag) ? "Hearthkeeper auto-refuel: DISABLED for this device" : "Hearthkeeper auto-refuel: ENABLED for this device", 0, (Sprite)null, false); return true; } internal unsafe static void AppendHoverText(Component device, ref string hoverText) { //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_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)device == (Object)null || string.IsNullOrEmpty(hoverText) || HearthkeeperPlugin.Enabled == null || !HearthkeeperPlugin.Enabled.Value || HearthkeeperPlugin.AutoRefuelEnabled == null || !HearthkeeperPlugin.AutoRefuelEnabled.Value || HearthkeeperPlugin.AutoRefuelDeviceToggleKey == null) { return; } KeyboardShortcut value = HearthkeeperPlugin.AutoRefuelDeviceToggleKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey == 0) { return; } Fireplace val = (Fireplace)(object)((device is Fireplace) ? device : null); Smelter val2 = (Smelter)(object)((device is Smelter) ? device : null); if ((Object)(object)val != (Object)null) { if (!HearthkeeperPlugin.AutoRefuelFires.Value || val.m_infiniteFuel || !val.m_canRefill || (Object)(object)val.m_fuelItem == (Object)null || val.m_maxFuel <= 0f) { return; } } else { if (!((Object)(object)val2 != (Object)null)) { return; } bool num = HearthkeeperPlugin.AutoRefuelProcessingFuel.Value && (Object)(object)val2.m_fuelItem != (Object)null && val2.m_maxFuel > 0; bool flag = HearthkeeperPlugin.AutoRefuelProcessingInputs.Value && val2.m_conversion != null && val2.m_conversion.Count > 0 && val2.m_maxOre > 0; if (!num && !flag) { return; } } if ((Object)(object)device.GetComponentInParent<Piece>() == (Object)null) { return; } ZNetView view = GetView(device); if (!((Object)(object)view == (Object)null) && view.IsValid() && view.GetZDO() != null) { bool flag2 = view.GetZDO().GetBool("MaddCatter365.Hearthkeeper.autoRefuelDisabled", false); string text = ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text)) { hoverText = hoverText + "\n[<color=yellow><b>" + text + "</b></color>] Toggle Auto-Refuel: " + (flag2 ? "OFF" : "ON"); } } } private static void ProcessFireplace(Fireplace fireplace) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fireplace == (Object)null || fireplace.m_infiniteFuel || !fireplace.m_canRefill || (Object)(object)fireplace.m_fuelItem == (Object)null || fireplace.m_maxFuel <= 0f) { return; } ZNetView view = GetView((Component)(object)fireplace); if (!CanAutomate((Component)(object)fireplace, view)) { return; } float num = view.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); float num2 = PercentOf(fireplace.m_maxFuel, HearthkeeperPlugin.AutoRefuelFireThresholdPercent.Value); if (num > num2) { return; } float num3 = PercentOf(fireplace.m_maxFuel, HearthkeeperPlugin.AutoRefuelFireTargetPercent.Value); num3 = Mathf.Clamp(Mathf.Max(num3, num2), 0f, fireplace.m_maxFuel); int num4 = Math.Min(HearthkeeperPlugin.AutoRefuelMaximumItemsPerDevice.Value, Mathf.CeilToInt(num3 - num)); if (num4 > 0) { string name = fireplace.m_fuelItem.m_itemData.m_shared.m_name; int num5 = TakeItems(((Component)fireplace).transform.position, name, num4, null); if (num5 > 0) { fireplace.AddFuel((float)num5); } } } private static void ProcessSmelter(Smelter smelter) { if ((Object)(object)smelter == (Object)null) { return; } ZNetView view = GetView((Component)(object)smelter); if (CanAutomate((Component)(object)smelter, view)) { int num = HearthkeeperPlugin.AutoRefuelMaximumItemsPerDevice.Value; if (HearthkeeperPlugin.AutoRefuelProcessingFuel.Value && num > 0) { num -= RefillProcessingFuel(smelter, view, num); } if (HearthkeeperPlugin.AutoRefuelProcessingInputs.Value && num > 0) { RefillProcessingInputs(smelter, view, num); } } } private static int RefillProcessingFuel(Smelter smelter, ZNetView view, int budget) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)smelter.m_fuelItem == (Object)null || smelter.m_maxFuel <= 0) { return 0; } float num = view.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); float num2 = PercentOf(smelter.m_maxFuel, HearthkeeperPlugin.AutoRefuelProcessingFuelThresholdPercent.Value); if (num > num2) { return 0; } float num3 = PercentOf(smelter.m_maxFuel, HearthkeeperPlugin.AutoRefuelProcessingFuelTargetPercent.Value); num3 = Mathf.Clamp(Mathf.Max(num3, num2), 0f, (float)smelter.m_maxFuel); int num4 = Math.Min(budget, Mathf.CeilToInt(num3 - num)); if (num4 <= 0) { return 0; } string name = smelter.m_fuelItem.m_itemData.m_shared.m_name; int num5 = TakeItems(((Component)smelter).transform.position, name, num4, null); for (int i = 0; i < num5; i++) { view.InvokeRPC("RPC_AddFuel", Array.Empty<object>()); } return num5; } private static int RefillProcessingInputs(Smelter smelter, ZNetView view, int budget) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (smelter.m_conversion == null || smelter.m_maxOre <= 0) { return 0; } int num = view.GetZDO().GetInt(ZDOVars.s_queued, 0); float num2 = PercentOf(smelter.m_maxOre, HearthkeeperPlugin.AutoRefuelProcessingInputThresholdPercent.Value); if ((float)num > num2) { return 0; } int num3 = Mathf.Clamp(Mathf.CeilToInt(Mathf.Max(PercentOf(smelter.m_maxOre, HearthkeeperPlugin.AutoRefuelProcessingInputTargetPercent.Value), num2)), 0, smelter.m_maxOre); int num4 = Math.Min(budget, num3 - num); if (num4 <= 0) { return 0; } for (int i = 0; i < smelter.m_conversion.Count; i++) { ItemConversion val = smelter.m_conversion[i]; if (val == null || (Object)(object)val.m_from == (Object)null || val.m_from.m_itemData == null) { continue; } string name = val.m_from.m_itemData.m_shared.m_name; List<ItemData> list = new List<ItemData>(); int num5 = TakeItems(((Component)smelter).transform.position, name, num4, list); if (num5 > 0) { string name2 = ((Object)((Component)val.m_from).gameObject).name; for (int j = 0; j < list.Count; j++) { view.InvokeRPC("RPC_AddOre", new object[2] { name2, list[j].m_cheated }); } return num5; } } return 0; } private static int TakeItems(Vector3 point, string sharedName, int requested, List<ItemData> taken) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (requested <= 0 || string.IsNullOrEmpty(sharedName)) { return 0; } List<Container> list = ContainerRegistry.Nearby(point, HearthkeeperPlugin.AutoRefuelRange.Value, requireAccept: false, allowInUse: false); int num = requested; for (int i = 0; i < list.Count; i++) { if (num <= 0) { break; } Container container = list[i]; if (!FuelChestLogic.IsFuelChest(container)) { continue; } Inventory val = ContainerRegistry.SafeInventory(container); if (val == null) { continue; } List<ItemData> list2 = new List<ItemData>(val.GetAllItems()); for (int j = 0; j < list2.Count; j++) { if (num <= 0) { break; } ItemData val2 = list2[j]; if (val2 == null || val2.m_shared == null || val2.m_shared.m_name != sharedName) { continue; } int val3 = InventoryTransfers.AvailableInContainer(container, sharedName, val2.m_quality); int num2 = Math.Min(num, Math.Min(val2.m_stack, val3)); if (num2 <= 0) { continue; } ItemData val4 = val2.Clone(); val4.m_stack = 1; if (!val.RemoveItem(val2, num2)) { continue; } if (taken != null) { for (int k = 0; k < num2; k++) { taken.Add(val4.Clone()); } } num -= num2; } } return requested - num; } private static bool CanAutomate(Component device, ZNetView view) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)device == (Object)null || (Object)(object)view == (Object)null || !view.IsValid() || !view.IsOwner() || view.GetZDO() == null) { return false; } if ((Object)(object)device.GetComponentInParent<Piece>() == (Object)null) { return false; } if (view.GetZDO().GetBool("MaddCatter365.Hearthkeeper.autoRefuelDisabled", false)) { return false; } return PrivateArea.CheckAccess(device.transform.position, 0f, false, true); } private static ZNetView GetView(Component component) { if ((Object)(object)component == (Object)null) { return null; } ZNetView component2 = component.GetComponent<ZNetView>(); if (!((Object)(object)component2 != (Object)null)) { return component.GetComponentInParent<ZNetView>(); } return component2; } private static float PercentOf(float maximum, float percent) { return maximum * Mathf.Clamp(percent, 0f, 100f) / 100f; } private static void ProcessRotating<T>(List<T> devices, ref int cursor, int budget, Action<T> process) where T : Object { if (devices.Count != 0 && budget > 0) { cursor = Mathf.Clamp(cursor, 0, devices.Count - 1); int num = Math.Min(budget, devices.Count); for (int i = 0; i < num; i++) { process(devices[(cursor + i) % devices.Count]); } cursor = (cursor + num) % devices.Count; } } private static void Cleanup() { for (int num = Fireplaces.Count - 1; num >= 0; num--) { if ((Object)(object)Fireplaces[num] == (Object)null) { Fireplaces.RemoveAt(num); } } for (int num2 = Smelters.Count - 1; num2 >= 0; num2--) { if ((Object)(object)Smelters[num2] == (Object)null) { Smelters.RemoveAt(num2); } } if (Fireplaces.Count == 0) { _fireplaceCursor = 0; } if (Smelters.Count == 0) { _smelterCursor = 0; } } } internal static class AuxiliaryHudPreview { private const int MaximumSlotCapacity = 8; private const float CellSize = 46f; private const float CellSpacing = 4f; private const float GuardianGap = 8f; private static Hud _hud; private static GameObject _root; private static RectTransform _rootRect; private static readonly GameObject[] Cells = (GameObject[])(object)new GameObject[8]; private static readonly RectTransform[] CellRects = (RectTransform[])(object)new RectTransform[8]; private static readonly Image[] Icons = (Image[])(object)new Image[8]; private static readonly TMP_Text[] Amounts = (TMP_Text[])(object)new TMP_Text[8]; private static readonly TMP_Text[] Bindings = (TMP_Text[])(object)new TMP_Text[8]; private static readonly ItemData[] LastItems = (ItemData[])(object)new ItemData[8]; private static readonly Sprite[] LastIcons = (Sprite[])(object)new Sprite[8]; private static readonly int[] LastStacks = new int[8]; private static readonly int[] LastMaximumStacks = new int[8]; private static int _lastSlotCount = -1; internal static void Update() { if (!HearthkeeperPlugin.Enabled.Value || !HearthkeeperPlugin.DedicatedSlotsActive) { SetVisible(visible: false); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { SetVisible(visible: false); return; } Hud instance = Hud.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_rootObject == (Object)null || (Object)(object)instance.m_gpRoot == (Object)null) { Clear(); return; } if ((Object)(object)_hud != (Object)(object)instance || (Object)(object)_root == (Object)null) { Clear(); if (!Create(instance)) { return; } } int num = ActiveSlotCount(); if (_lastSlotCount != num) { _lastSlotCount = num; Layout(num); ResetCachedItems(); } SetVisible(visible: true); DedicatedSlots.CreateInventory(); Inventory inventory = DedicatedSlots.Inventory; if (inventory == null) { HideAllCells(); return; } for (int i = 0; i < 8; i++) { if (i >= num) { SetCellVisible(i, visible: false); continue; } ItemData itemAt = inventory.GetItemAt(i, 1); RefreshCell(i, itemAt); } } internal static void Clear() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _hud = null; _root = null; _rootRect = null; _lastSlotCount = -1; for (int i = 0; i < 8; i++) { Cells[i] = null; CellRects[i] = null; Icons[i] = null; Amounts[i] = null; Bindings[i] = null; LastItems[i] = null; LastIcons[i] = null; LastStacks[i] = -1; LastMaximumStacks[i] = -1; } } private static bool Create(Hud hud) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_007f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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) Transform transform = hud.m_rootObject.transform; HotkeyBar componentInChildren = hud.m_rootObject.GetComponentInChildren<HotkeyBar>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.m_elementPrefab == (Object)null) { return false; } _hud = hud; _root = new GameObject("Hearthkeeper_AuxiliaryHudPreview", new Type[1] { typeof(RectTransform) }); Transform transform2 = _root.transform; _rootRect = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); ((Transform)_rootRect).SetParent(transform, false); _rootRect.anchorMin = Vector2.zero; _rootRect.anchorMax = Vector2.zero; _rootRect.pivot = new Vector2(0f, 1f); ((Transform)_rootRect).localScale = Vector3.one; int siblingIndex = ((Transform)hud.m_gpRoot).GetSiblingIndex(); ((Transform)_rootRect).SetSiblingIndex(Mathf.Min(siblingIndex + 1, transform.childCount - 1)); for (int i = 0; i < 8; i++) { GameObject val = Object.Instantiate<GameObject>(componentInChildren.m_elementPrefab, (Transform)(object)_rootRect, false); ((Object)val).name = "Hearthkeeper_AuxPreview_" + (i + 1); Cells[i] = val; Transform transform3 = val.transform; RectTransform val2 = (RectTransform)(object)((transform3 is RectTransform) ? transform3 : null); CellRects[i] = val2; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(46f, 46f); Transform val3 = val.transform.Find("icon"); if ((Object)(object)val3 != (Object)null) { Icons[i] = ((Component)val3).GetComponent<Image>(); } Transform val4 = val.transform.Find("amount"); if ((Object)(object)val4 != (Object)null) { Amounts[i] = ((Component)val4).GetComponent<TMP_Text>(); } Transform val5 = val.transform.Find("binding"); if ((Object)(object)val5 != (Object)null) { Bindings[i] = ((Component)val5).GetComponent<TMP_Text>(); } DisableInteraction(val); HideDecoration(val.transform, "durability"); HideDecoration(val.transform, "equiped"); HideDecoration(val.transform, "queued"); HideDecoration(val.transform, "selected"); ConfigureBinding(i); ApplyCellStyle(i); val.SetActive(false); } Layout(ActiveSlotCount()); ResetCachedItems(); return true; } private static void DisableInteraction(GameObject cell) { //IL_0026: 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) if ((Object)(object)cell == (Object)null) { return; } Selectable[] componentsInChildren = cell.GetComponentsInChildren<Selectable>(true); foreach (Selectable val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; val.navigation = navigation; ((Behaviour)val).enabled = false; } } Graphic[] componentsInChildren2 = cell.GetComponentsInChildren<Graphic>(true); foreach (Graphic val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { val2.raycastTarget = false; } } } private static void ConfigureBinding(int index) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_009f: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = Bindings[index]; if (!((Object)(object)val == (Object)null)) { val.text = HotkeyLabel(index); val.fontSize = 12f; val.enableAutoSizing = false; val.alignment = (TextAlignmentOptions)257; RectTransform rectTransform = val.rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.anchoredPosition = new Vector2(6f, -6f); rectTransform.sizeDelta = new Vector2(38f, 18f); ((Graphic)val).raycastTarget = false; } } private static void ApplyCellStyle(int index) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) GameObject val = Cells[index]; if ((Object)(object)val == (Object)null) { return; } Image val2 = Icons[index]; Image[] componentsInChildren = val.GetComponentsInChildren<Image>(true); foreach (Image val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { if ((Object)(object)val3 == (Object)(object)val2) { ((Graphic)val3).color = Color.white; } else { ((Graphic)val3).color = new Color(0.22f, 0.22f, 0.22f, 0.42f); } } } if ((Object)(object)Amounts[index] != (Object)null) { Amounts[index].fontSize = 10f; Amounts[index].enableAutoSizing = false; ((Graphic)Amounts[index]).color = new Color(1f, 1f, 1f, 0.92f); } if ((Object)(object)Bindings[index] != (Object)null) { ((Graphic)Bindings[index]).color = new Color(0.72f, 0.87f, 1f, 0.95f); } } private static void Layout(int slotCount) { //IL_0078: 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_00a1: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) if ((Object)(object)_rootRect == (Object)null || (Object)(object)_hud == (Object)null || (Object)(object)_hud.m_gpRoot == (Object)null) { return; } int num = ((slotCount > 6) ? 4 : 3); int num2 = Mathf.CeilToInt((float)slotCount / (float)num); float num3 = 50f; float num4 = (float)num * 46f + (float)(num - 1) * 4f; float num5 = (float)num2 * 46f + (float)(num2 - 1) * 4f; _rootRect.sizeDelta = new Vector2(num4, num5); RectTransform gpRoot = _hud.m_gpRoot; float x = gpRoot.anchoredPosition.x; float num6 = 1f - gpRoot.pivot.x; Rect rect = gpRoot.rect; float num7 = x + num6 * ((Rect)(ref rect)).width; float y = gpRoot.anchoredPosition.y; float y2 = gpRoot.pivot.y; rect = gpRoot.rect; float num8 = y - y2 * ((Rect)(ref rect)).height; _rootRect.anchoredPosition = new Vector2(num7 + 8f, num8 + num5); for (int i = 0; i < 8; i++) { RectTransform val = CellRects[i]; if ((Object)(object)val == (Object)null) { continue; } if (i >= slotCount) { GameObject obj = Cells[i]; if (obj != null) { obj.SetActive(false); } } else { int num9 = i % num; int num10 = i / num; val.anchoredPosition = new Vector2((float)num9 * num3, (float)(-num10) * num3); } } } private static void RefreshCell(int index, ItemData item) { if (index < 0 || index >= 8 || (Object)(object)Cells[index] == (Object)null) { return; } if (item == null) { if (Cells[index].activeSelf) { Cells[index].SetActive(false); } LastItems[index] = null; LastIcons[index] = null; LastStacks[index] = -1; LastMaximumStacks[index] = -1; return; } if (!Cells[index].activeSelf) { Cells[index].SetActive(true); } Sprite icon = item.GetIcon(); if ((Object)(object)Icons[index] != (Object)null && (LastItems[index] != item || (Object)(object)LastIcons[index] != (Object)(object)icon)) { Icons[index].sprite = icon; ((Component)Icons[index]).gameObject.SetActive((Object)(object)icon != (Object)null); } int num = ((item.m_shared == null) ? 1 : item.m_shared.m_maxStackSize); if ((Object)(object)Amounts[index] != (Object)null) { bool flag = num > 1; ((Component)Amounts[index]).gameObject.SetActive(flag); if (flag && (LastItems[index] != item || LastStacks[index] != item.m_stack || LastMaximumStacks[index] != num)) { Amounts[index].text = item.m_stack + " / " + num; } } LastItems[index] = item; LastIcons[index] = icon; LastStacks[index] = item.m_stack; LastMaximumStacks[index] = num; } private static void HideDecoration(Transform cell, string childName) { if (!((Object)(object)cell == (Object)null)) { Transform val = cell.Find(childName); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } } private static void HideAllCells() { for (int i = 0; i < 8; i++) { SetCellVisible(i, visible: false); } ResetCachedItems(); } private static void SetCellVisible(int index, bool visible) { if (index >= 0 && index < 8 && !((Object)(object)Cells[index] == (Object)null)) { Cells[index].SetActive(visible); } } private static void SetVisible(bool visible) { if ((Object)(object)_root != (Object)null) { _root.SetActive(visible); } } private static void ResetCachedItems() { for (int i = 0; i < 8; i++) { LastItems[i] = null; LastIcons[i] = null; LastStacks[i] = -1; LastMaximumStacks[i] = -1; } } private static int ActiveSlotCount() { return Mathf.Clamp(DedicatedSlots.AuxiliarySlotCount, 1, 8); } private static string HotkeyLabel(int auxiliaryIndex) { if (auxiliaryIndex < 0 || auxiliaryIndex >= 8) { return string.Empty; } return DedicatedSlotHotkeys.GetDisplayLabelForNumber(auxiliaryIndex + 3); } } internal sealed class AuxiliarySlotInteraction : IDisposable { private readonly InventoryGui _gui; private readonly InventoryGrid _displayGrid; private readonly InventoryGrid _proxyGrid; private readonly FieldInfo _gridInventoryField; internal AuxiliarySlotInteraction(InventoryGui gui, InventoryGrid displayGrid) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown _gui = gui ?? throw new ArgumentNullException("gui"); _displayGrid = displayGrid ?? throw new ArgumentNullException("displayGrid"); if ((Object)(object)_gui.m_playerGrid == (Object)null) { throw new InvalidOperationException("Valheim player inventory grid is unavailable."); } _gridInventoryField = typeof(InventoryGrid).GetField("m_inventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_gridInventoryField == null) { throw new InvalidOperationException("Valheim InventoryGrid inventory field is unavailable."); } GameObject val = new GameObject("Hearthkeeper_AuxiliaryInteractionProxy", new Type[1] { typeof(RectTransform) }); val.SetActive(false); val.transform.SetParent(((Component)_displayGrid).transform, false); _proxyGrid = val.AddComponent<InventoryGrid>(); _proxyGrid.m_uiGroup = _gui.m_playerGrid.m_uiGroup; _gridInventoryField.SetValue(_proxyGrid, DedicatedSlots.Inventory); _displayGrid.m_onSelected = OnSelected; _displayGrid.m_onReleased = delegate { }; _displayGrid.m_onRightClick = OnRightClick; _displayGrid.m_onEnter = null; _displayGrid.OnSetTouchSelection = null; _displayGrid.OnMoveToUpperInventoryGrid = null; _displayGrid.OnMoveToLowerInventoryGrid = null; _displayGrid.CanDropDragOntoItem = (ItemData item) => true; } private void OnRightClick(InventoryGrid grid, ItemData displayedItem, Vector2i displayPosition) { //IL_0028: 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_002e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_006c: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || ContainerNameService.IsRenaming()) { return; } Vector2i val = DedicatedSlotRules.Cell(auxiliary: true, displayPosition); if (!DedicatedSlots.IsAuxiliaryCell(val.x, val.y)) { return; } Inventory inventory = DedicatedSlots.Inventory; ItemData itemAt = inventory.GetItemAt(val.x, val.y); if (itemAt == null) { return; } if ((int)itemAt.m_shared.m_itemType == 2) { ((Humanoid)localPlayer).UseItem(inventory, itemAt, true); } else if (DedicatedAmmoBridge.IsSelectableDedicatedAmmo(itemAt)) { if (!DedicatedAmmoBridge.TryToggleSelectedAmmo(localPlayer, itemAt)) { ((Character)localPlayer).Message((MessageType)2, "Valheim could not select that ammunition.", 0, (Sprite)null, false); } } else if (WearableEquipBridge.CanEquipFromDedicatedSlot(itemAt) && !WearableEquipBridge.TryToggleWithNativePresentation(localPlayer, itemAt)) { ((Character)localPlayer).Message((MessageType)2, "Valheim could not equip that item.", 0, (Sprite)null, false); } } private void OnSelected(InventoryGrid grid, ItemData displayedItem, Vector2i displayPosition, Modifier modifier) { //IL_0028: 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_002e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || ContainerNameService.IsRenaming()) { return; } Vector2i val = DedicatedSlotRules.Cell(auxiliary: true, displayPosition); if (!DedicatedSlots.IsAuxiliaryCell(val.x, val.y)) { return; } Inventory inventory = DedicatedSlots.Inventory; ItemData itemAt = inventory.GetItemAt(val.x, val.y); if ((int)modifier == 2 && itemAt != null) { if (itemAt.m_shared.m_questItem) { return; } Inventory inventory2 = ((Humanoid)localPlayer).GetInventory(); if (inventory2 != null) { if (!inventory2.CanAddItem(itemAt, itemAt.m_stack)) { ((Character)localPlayer).Message((MessageType)2, "No room in your inventory.", 0, (Sprite)null, false); } else { inventory2.MoveItemToThis(inventory, itemAt); } } } else { _gridInventoryField.SetValue(_proxyGrid, inventory); _gui.m_playerGrid.m_onSelected?.Invoke(_proxyGrid, itemAt, val, modifier); } } public void Dispose() { if ((Object)(object)_proxyGrid != (Object)null) { Object.Destroy((Object)(object)((Component)_proxyGrid).gameObject); } } } [HarmonyPatch] internal static class CharacterPreviewBridge { [HarmonyPatch(typeof(FejdStartup), "SetupCharacterPreview")] [HarmonyPostfix] private static void AfterSetupCharacterPreview(FejdStartup __instance, PlayerProfile profile) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null || profile == null || HearthkeeperPlugin.Enabled == null || !HearthkeeperPlugin.Enabled.Value || !HearthkeeperPlugin.DedicatedSlotsActive) { return; } Player previewPlayer = __instance.GetPreviewPlayer(); if ((Object)(object)previewPlayer == (Object)null || previewPlayer.m_customData == null || !previewPlayer.m_customData.TryGetValue("MaddCatter365.Hearthkeeper.DedicatedSlots.v1", out var value) || string.IsNullOrEmpty(value)) { return; } try { byte[] array = Convert.FromBase64String(value); Inventory val = new Inventory("Hearthkeeper Character Preview", (Sprite)null, 8, 2); val.Load(new ZPackage(array)); VisEquipment component = ((Component)previewPlayer).GetComponent<VisEquipment>(); if ((Object)(object)component == (Object)null) { ManualLogSource log = HearthkeeperPlugin.Log; if (log != null) { log.LogWarning((object)"Character preview could not find VisEquipment."); } } else { Squirrel.LogCharacterPreviewApplied(ApplyWearableVisuals(val, component) + ApplyHandVisuals(val, ((Humanoid)previewPlayer).GetInventory(), component)); } } catch (Exception ex) { ManualLogSource log2 = HearthkeeperPlugin.Log; if (log2 != null) { log2.LogWarning((object)("Character preview could not read Hearthkeeper dedicated equipment: " + ex)); } } } private static int ApplyWearableVisuals(Inventory inventory, VisEquipment visEquipment) { int num = 0; ItemData itemAt = inventory.GetItemAt(0, 0); if (itemAt != null) { visEquipment.SetHelmetItem(GetItemHash(itemAt)); num++; } ItemData itemAt2 = inventory.GetItemAt(1, 0); if (itemAt2 != null) { visEquipment.SetShoulderItem(GetItemHash(itemAt2), itemAt2.m_variant, itemAt2.m_quality); num++; } ItemData itemAt3 = inventory.GetItemAt(2, 0); if (itemAt3 != null) { visEquipment.SetChestItem(GetItemHash(itemAt3)); num++; } ItemData itemAt4 = inventory.GetItemAt(3, 0); if (itemAt4 != null) { visEquipment.SetLegItem(GetItemHash(itemAt4)); num++; } ItemData itemAt5 = inventory.GetItemAt(4, 0); if (itemAt5 != null) { visEquipment.SetUtilityItem(GetItemHash(itemAt5)); num++; } ItemData itemAt6 = inventory.GetItemAt(5, 0); if (itemAt6 != null && (Object)(object)itemAt6.m_dropPrefab != (Object)null) { visEquipment.SetTrinketItem(((Object)itemAt6.m_dropPrefab).name); num++; } return num; } private static int ApplyHandVisuals(Inventory dedicatedInventory, Inventory playerInventory, VisEquipment visEquipment) { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Invalid comparison between Unknown and I4 if (dedicatedInventory == null || (Object)(object)visEquipment == (Object)null) { return 0; } ItemData rightItem = null; ItemData leftItem = null; ItemData torchItem = null; if (playerInventory != null) { foreach (ItemData allItem in playerInventory.GetAllItems()) { if (allItem != null && allItem.m_equipped && allItem.m_shared != null) { AssignHandCandidate(allItem, ref rightItem, ref leftItem, ref torchItem); } } } for (int i = 6; i < 8; i++) { ItemData itemAt = dedicatedInventory.GetItemAt(i, 0); if (itemAt != null && itemAt.m_equipped && itemAt.m_shared != null) { AssignHandCandidate(itemAt, ref rightItem, ref leftItem, ref torchItem); } } for (int j = 0; j < DedicatedSlots.AuxiliarySlotCount; j++) { ItemData itemAt2 = dedicatedInventory.GetItemAt(j, 1); if (itemAt2 != null && itemAt2.m_equipped && itemAt2.m_shared != null) { AssignHandCandidate(itemAt2, ref rightItem, ref leftItem, ref torchItem); string route = ((rightItem == itemAt2) ? "right" : ((leftItem == itemAt2) ? "left" : ((torchItem == itemAt2) ? "torch" : "ignored"))); Squirrel.LogCharacterPreviewAuxCandidate(j + 1, itemAt2, GetItemHash(itemAt2), route); } } if (torchItem != null) { if (rightItem != null && (int)rightItem.m_shared.m_itemType == 3 && leftItem == null) { leftItem = torchItem; } else { rightItem = torchItem; } } visEquipment.SetRightItem(GetItemHash(rightItem), rightItem?.m_quality ?? 0); visEquipment.SetLeftItem(GetItemHash(leftItem), leftItem?.m_variant ?? 0, leftItem?.m_quality ?? 0); int num = 0; if (rightItem != null) { num++; } if (leftItem != null) { num++; } return num; } private static void AssignHandCandidate(ItemData item, ref ItemData rightItem, ref ItemData leftItem, ref ItemData torchItem) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0011: 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_0025: Expected I4, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 ItemType itemType = item.m_shared.m_itemType; if ((int)itemType <= 14) { switch (itemType - 3) { default: if ((int)itemType == 14) { rightItem = item; leftItem = null; torchItem = null; } return; case 0: break; case 2: leftItem = item; return; case 1: leftItem = item; rightItem = null; torchItem = null; return; } } else { if ((int)itemType == 15) { torchItem = item; return; } if ((int)itemType != 19) { if ((int)itemType == 22) { leftItem = item; rightItem = null; torchItem = null; } return; } } rightItem = item; } private static int GetItemHash(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return 0; } return StringExtensionMethods.GetStableHashCode(((Object)item.m_dropPrefab).name); } } internal static class ChestActionVisuals { internal static Button Create(InventoryGui gui, Transform parent, string name, ActionIcon icon, Action clicked) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) Button val = CompactActionButtons.Create(gui, parent, name, icon, clicked); Graphic targetGraphic = ((Selectable)gui.m_stackAllButton).targetGraphic; Image val2 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sprite == (Object)null) { throw new InvalidOperationException("Native ash button background unavailable."); } Graphic[] componentsInChildren = ((Component)val).GetComponentsInChildren<Graphic>(true); foreach (Graphic obj in componentsInChildren) { obj.raycastTarget = false; Image val3 = (Image)(object)((obj is Image) ? obj : null); ((Behaviour)obj).enabled = val3 != null && IsFrame(val3); } Image val4 = ((Component)val).GetComponent<Image>() ?? ((Component)val).gameObject.AddComponent<Image>(); val4.sprite = val2.sprite; val4.overrideSprite = null; ((Graphic)val4).material = ((Graphic)val2).material; ((Graphic)val4).color = ((Graphic)val2).color; val4.type = val2.type; val4.pixelsPerUnitMultiplier = val2.pixelsPerUnitMultiplier; val4.preserveAspect = false; ((Graphic)val4).raycastTarget = true; ((Behaviour)val4).enabled = true; ((Selectable)val).targetGraphic = (Graphic)(object)val4; ((Selectable)val).transition = ((Selectable)gui.m_stackAllButton).transition; ((Selectable)val).colors = ((Selectable)gui.m_stackAllButton).colors; ((Selectable)val).spriteState = ((Selectable)gui.m_stackAllButton).spriteState; GameObject val5 = new GameObject("Hearthkeeper_GoldIcon", new Type[2] { typeof(RectTransform), typeof(GoldChestIcon) }); val5.transform.SetParent(((Component)val).transform, false); RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = new Vector2(7f, 7f); val6.offsetMax = new Vector2(-7f, -7f); val5.GetComponent<GoldChestIcon>().Initialize(icon); CompactButtonTooltips.Bind(gui, val); return val; } private static bool IsFrame(Image image) { if ((Object)(object)image.sprite == (Object)null) { return false; } string text = (((Object)image).name + " " + ((Object)image.sprite).name).ToLowerInvariant(); if (text.Contains("hammer") || text.Contains("repair") || text.Contains("icon") || text.Contains("glow")) { return false; } if (!text.Contains("frame") && !text.Contains("border") && !text.Contains("bkg")) { return text.Contains("background"); } return true; } } internal static class ChestGlowService { internal static void Pulse(Container container) { if (HearthkeeperPlugin.ReceivingGlowEnabled.Value && !((Object)(object)container == (Object)null)) { ChestLabelService.Pulse(container); } } internal static void Update() { } internal static void Clear() { } } internal static class ChestLabelGeometry { internal struct Surface { internal Vector3 Point; internal Vector3 Normal; internal Transform Parent; internal string Method; } internal static Quaternion TextRotation(Vector3 normal, Vector3 up, Vector3 correction) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0012: Unknown result type (might be due to invalid IL or missing references) return Quaternion.LookRotation(-normal, up) * Quaternion.Euler(correction); } internal static bool IsModelMesh(MeshFilter filter) { if (!((Component)filter).gameObject.activeInHierarchy || (Object)(object)filter.sharedMesh == (Object)null || (Object)(object)((Component)filter).GetComponent<TMP_Text>() != (Object)null) { return false; } MeshRenderer component = ((Component)filter).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { return ((Renderer)component).enabled; } return false; } internal static bool TrySurface(Transform model, Vector3 center, Vector3 outward, float reach, out Surface surface) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00de: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) surface = default(Surface); float num = float.MaxValue; Ray val = default(Ray); ((Ray)(ref val))..ctor(center + outward * reach, -outward); MeshFilter[] componentsInChildren = ((Component)model).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if (!IsModelMesh(val2)) { continue; } Mesh sharedMesh = val2.sharedMesh; Vector3 origin = ((Component)val2).transform.InverseTransformPoint(((Ray)(ref val)).origin); Vector3 direction = ((Component)val2).transform.InverseTransformVector(((Ray)(ref val)).direction); if (!BoundsHit(sharedMesh.bounds, origin, direction, out var distance, out var normal)) { continue; } float num2 = float.MaxValue; Vector3 val3 = Vector3.zero; string method; if (sharedMesh.isReadable) { Vector3[] vertices = sharedMesh.vertices; int[] triangles = sharedMesh.triangles; for (int j = 0; j + 2 < triangles.Length; j += 3) { if (TriangleHit(origin, direction, vertices[triangles[j]], vertices[triangles[j + 1]], vertices[triangles[j + 2]], out var distance2, out var normal2) && !(distance2 >= num2)) { Vector3 val4 = WorldNormal(((Component)val2).transform, normal2); if (!(Vector3.Dot(val4, outward) < 0.25f)) { num2 = distance2; val3 = val4; } } } method = "mesh triangles"; } else { num2 = distance; val3 = WorldNormal(((Component)val2).transform, normal); method = "mesh bounds fallback"; } if (!(num2 < 0f) && !(num2 > reach * 2f) && !(num2 >= num) && !(Vector3.Dot(val3, outward) < 0.25f)) { num = num2; surface = new Surface { Point = ((Ray)(ref val)).GetPoint(num2), Normal = val3, Parent = ((Component)val2).transform, Method = method }; } } return num < float.MaxValue; } private static Vector3 WorldNormal(Transform transform, Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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) Matrix4x4 val = transform.worldToLocalMatrix; val = ((Matrix4x4)(ref val)).transpose; Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyVector(normal); return ((Vector3)(ref val2)).normalized; } internal static bool TriangleHit(Vector3 origin, Vector3 direction, Vector3 a, Vector3 b, Vector3 c, out float distance, out Vector3 normal) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_004d: 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_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_0056: 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_0077: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) distance = 0f; normal = Vector3.zero; Vector3 val = b - a; Vector3 val2 = c - a; Vector3 val3 = Vector3.Cross(direction, val2); float num = Vector3.Dot(val, val3); if (Mathf.Abs(num) < 1E-06f) { return false; } float num2 = 1f / num; Vector3 val4 = origin - a; float num3 = Vector3.Dot(val4, val3) * num2; if (num3 < 0f || num3 > 1f) { return false; } Vector3 val5 = Vector3.Cross(val4, val); float num4 = Vector3.Dot(direction, val5) * num2; if (num4 < 0f || num3 + num4 > 1f) { return false; } distance = Vector3.Dot(val2, val5) * num2; Vector3 val6 = Vector3.Cross(val, val2); normal = ((Vector3)(ref val6)).normalized; return distance >= 0f; } internal static bool BoundsHit(Bounds bounds, Vector3 origin, Vector3 direction, out float distance, out Vector3 normal) { //IL_000e: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = float.NegativeInfinity; float num2 = float.PositiveInfinity; normal = Vector3.zero; distance = 0f; for (int i = 0; i < 3; i++) { Vector3 val; if (Mathf.Abs(((Vector3)(ref direction))[i]) < 1E-06f) { float num3 = ((Vector3)(ref origin))[i]; val = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val))[i])) { float num4 = ((Vector3)(ref origin))[i]; val = ((Bounds)(ref bounds)).max; if (!(num4 > ((Vector3)(ref val))[i])) { continue; } } return false; } val = ((Bounds)(ref bounds)).min; float num5 = (((Vector3)(ref val))[i] - ((Vector3)(ref origin))[i]) / ((Vector3)(ref direction))[i]; val = ((Bounds)(ref bounds)).max; float num6 = (((Vector3)(ref val))[i] - ((Vector3)(ref origin))[i]) / ((Vector3)(ref direction))[i]; Vector3 zero = Vector3.zero; ((Vector3)(ref zero))[i] = 0f - Mathf.Sign(((Vector3)(ref direction))[i]); if (num5 > num6) { float num7 = num5; num5 = num6; num6 = num7; } if (num5 > num) { num = num5; normal = zero; } num2 = Mathf.Min(num2, num6); if (num > num2) { return false; } } distance = num; if (num >= 0f) { return num2 >= num; } return false; } internal static Vector3 FrontPoint(Bounds bounds, ChestLabelProfile profile) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref bounds)).center; center.y = ((Bounds)(ref bounds)).min.y + ((Bounds)(ref bounds)).size.y * profile.FrontHeight; return center; } internal static Vector3 LidPoint(Bounds bounds, ChestLabelProfile profile) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) Vector3 val = Vector3.ProjectOnPlane(profile.FrontDirection, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Mathf.Abs(normalized.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(normalized.z) * ((Bounds)(ref bounds)).extents.z; return ((Bounds)(ref bounds)).center + normalized * num * (1f - 2f * profile.LidDepthFraction); } } internal sealed class ChestLabelProfile { internal Vector3 FrontDirection = Vector3.back; internal Vector3 FrontOffset = Vector3.zero; internal Vector3 FrontRotation = Vector3.zero; internal Vector3 LidOffset = Vector3.zero; internal Vector3 LidRotation = Vector3.zero; internal float FrontHeight; internal float WidthFraction; internal float HeightMetres; internal float LidDepthFraction; internal string LidPath = ""; internal float SurfaceClearance = 0.002f; internal ChestLabelProfile(float frontHeight, float widthFraction, float heightMetres, float lidDepthFraction = 0.5f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) FrontHeight = frontHeight; WidthFraction = widthFraction; HeightMetres = heightMetres; LidDepthFraction = lidDepthFraction; } } internal static class ChestLabelProfiles { private static readonly Dictionary<string, ChestLabelProfile> Profiles = new Dictionary<string, ChestLabelProfile> { ["piece_chest_wood"] = new ChestLabelProfile(0.43f, 0.65f, 0.12f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, 0f, 0.005f) }, ["piece_chest"] = new ChestLabelProfile(0.43f, 0.62f, 0.14f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, 0.01f, 0.005f) }, ["piece_chest_blackmetal"] = new ChestLabelProfile(0.4f, 0.6f, 0.14f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, 0f, 0.005f) }, ["piece_chest_private"] = new ChestLabelProfile(0.43f, 0.62f, 0.11f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, -0.01f, 0.005f) }, ["piece_chest_treasure"] = new ChestLabelProfile(0.4f, 0.58f, 0.13f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, 0f, 0.005f) }, ["piece_chest_ashwood"] = new ChestLabelProfile(0.4f, 0.6f, 0.14f) { FrontDirection = Vector3.forward, FrontOffset = new Vector3(0f, 0f, 0.005f) } }; private static readonly ChestLabelProfile Default = new ChestLabelProfile(0.43f, 0.6f, 0.12f); internal static ChestLabelProfile Get(string prefab) { if (!Profiles.TryGetValue(prefab, out var value)) { return Default; } return value; } internal static void RemoveLegacyConfiguration(ConfigFile config) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown if (!File.Exists(config.ConfigFilePath)) { return; } string text = ""; string[] array = File.ReadAllLines(config.ConfigFilePath); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.StartsWith("[") && text2.EndsWith("]")) { text = text2.Substring(1, text2.Length - 2); } else if (text.StartsWith("16 Chest Labels - ") && !text2.StartsWith("#")) { int num = text2.IndexOf('='); if (num > 0) { string text3 = text2.Substring(0, num).Trim(); config.Bind<string>(text, text3, "", "Retired internal geometry calibration."); config.Remove(new ConfigDefinition(text, text3)); } } } } } internal static class ChestLabelService { private sealed class LabelPair { internal TextMeshPro Front; internal TextMeshPro Lid; internal Material Material; internal GameObject FrontPulseLightObject; internal Light FrontPulseLight; internal GameObject LidPulseLightObject; internal Light LidPulseLight; internal void Destroy() { if ((Object)(object)Front != (Object)null) { Object.Destroy((Object)(object)((Component)Front).gameObject); } if ((Object)(object)Lid != (Object)null) { Object.Destroy((Object)(object)((Component)Lid).gameObject); } if ((Object)(object)FrontPulseLightObject != (Object)null) { Object.Destroy((Object)(object)FrontPulseLightObject); } if ((Object)(object)LidPulseLightObject != (Object)null) { Object.Destroy((Object)(object)LidPulseLightObject); } if ((Object)(object)Material != (Object)null) { Object.Destroy((Object)(object)Material); } } } private static readonly Dictionary<Container, LabelPair> Labels = new Dictionary<Container, LabelPair>(); private static readonly Dictionary<Container, float> PulseEnds = new Dictionary<Container, float>(); private static float _next; private static readonly HashSet<string> ReportedProfiles = new HashSet<string>(); private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32]; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; private static Color ResolveLabelColour(Container chest) { //IL_0007: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (Squirrel.ColourAuditionActive) { return Squirrel.ColourAuditionColour; } ContainerSettings settings = ContainerRegistry.GetSettings(chest); if (settings != null && settings.ColourOverride) { return ColourPaletteOptions.Resolve(settings.ColourKey); } return ColourPaletteOptions.Resolve("hearthkeeper_mist_blue"); } private static Color ResolvePulseColour(Container chest) { //IL_0017: 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) if (Squirrel.ColourAuditionActive) { return Squirrel.ColourAuditionColour; } return ColourPaletteOptions.Resolve(HearthkeeperPlugin.ReceivingGlowColourChoice.Value); } internal static void Clear() { foreach (LabelPair value in Labels.Values) { value.Destroy(); } Labels.Clear(); PulseEnds.Clear(); } internal static void Pulse(Container container) { if (!((Object)(object)container == (Object)null)) { PulseEnds[container] = Time.unscaledTime + HearthkeeperPlugin.ReceivingGlowDuration.Value; } } internal static void Update() { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) if (!HearthkeeperPlugin.Enabled.Value || !HearthkeeperPlugin.ChestNameLabelsEnabled.Value || (Object)(object)Player.m_localPlayer == (Object)null) { if (Labels.Count > 0) { Clear(); } } else { if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.15f; Camera main = Camera.main; TMP_FontAsset val = (((Object)(object)InventoryGui.instance != (Object)null) ? InventoryGui.instance.m_containerName.font : null); if ((Object)(object)main == (Object)null || (Object)(object)val == (Object)null) { return; } foreach (Container item in new List<Container>(Labels.Keys)) { if ((Object)(object)item == (Object)null) { Labels[item].Destroy(); Labels.Remove(item); continue; } bool num = !string.IsNullOrEmpty(ContainerNameService.GetCustomName(item)); float value; bool flag = PulseEnds.TryGetValue(item, out value) && value > Time.unscaledTime; if (!num && !flag) { Labels[item].Destroy(); Labels.Remove(item); PulseEnds.Remove(item); } } float num2 = Mathf.Max(1f, HearthkeeperPlugin.ChestNameLabelRange.Value); foreach (Container item2 in ContainerRegistry.All()) { if ((Object)(object)item2 == (Object)null) { continue; } string customName = ContainerNameService.GetCustomName(item2); bool flag2 = !string.IsNullOrEmpty(customName); bool flag3 = Vector3.Distance(((Component)main).transform.position, ((Component)item2).transform.position) <= num2; if (!Labels.TryGetValue(item2, out var value2)) { float value3; bool flag4 = PulseEnds.TryGetValue(item2, out value3) && value3 > Time.unscaledTime; if ((!flag3 && !flag4) || item2.IsInUse() || ((Object)(object)item2.m_closed != (Object)null && !item2.m_closed.activeInHierarchy)) { continue; } value2 = Create(item2, val); Labels[item2] = value2; } float intensity = GetPulseAmount(item2) * Mathf.Max(0f, HearthkeeperPlugin.ReceivingGlowIntensity.Value); Color val2 = ResolveLabelColour(item2); Color color = ResolvePulseColour(item2); if ((Object)(object)value2.Material != (Object)null) { if (value2.Material.HasProperty("_FaceColor")) { value2.Material.SetColor("_FaceColor", val2); } if (value2.Material.HasProperty("_GlowColor")) { value2.Material.SetColor("_GlowColor", new Color(val2.r, val2.g, val2.b, 0.35f)); } } if ((Object)(object)value2.FrontPulseLight != (Object)null) { value2.FrontPulseLight.color = color; value2.FrontPulseLight.intensity = intensity; } if ((Object)(object)value2.LidPulseLight != (Object)null) { value2.LidPulseLight.color = color; value2.LidPulseLight.intensity = intensity; } if (flag2) { Apply(value2.Front, customName, item2, main, num2, flag3); Apply(value2.Lid, customName, item2, main, num2, flag3); continue; } if ((Object)(object)value2.Front != (Object)null) { ((Component)value2.Front).gameObject.SetActive(false); } if ((Object)(object)value2.Lid != (Object)null) { ((Component)value2.Lid).gameObject.SetActive(false); } } } } private unsafe static LabelPair Create(Container chest, TMP_FontAsset font) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_0270: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) Color val = ResolveLabelColour(chest); Color color = ResolvePulseColour(chest); Bounds bounds = MeshBounds(((Component)chest).transform); ChestLabelProfile chestLabelProfile = ChestLabelProfiles.Get(ContainerRegistry.PrefabName(chest)); LabelPair labelPair = new LabelPair { Material = new Material(((TMP_Asset)font).material) }; ((Object)labelPair.Material).name = "Hearthkeeper_ChestInscription"; Shader val2 = Shader.Find("TextMeshPro/Distance Field"); if ((Object)(object)val2 != (Object)null) { labelPair.Material.shader = val2; } if (labelPair.Material.HasProperty("_ZTestMode")) { labelPair.Material.SetFloat("_ZTestMode", 4f); } if (labelPair.Material.HasProperty("_CullMode")) { labelPair.Material.SetFloat("_CullMode", 2f); } if (labelPair.Material.HasProperty("_FaceColor")) { labelPair.Material.SetColor("_FaceColor", val); } if (labelPair.Material.HasProperty("_GlowColor")) { labelPair.Material.EnableKeyword("GLOW_ON"); labelPair.Material.SetColor("_GlowColor", new Color(val.r, val.g, val.b, 0.35f)); labelPair.Material.SetFloat("_GlowPower", 0.15f); labelPair.Material.SetFloat("_GlowOuter", 0.04f); } float value = HearthkeeperPlugin.ChestNameLabelSize.Value; float width = Mathf.Clamp(((Bounds)(ref bounds)).size.x * chestLabelProfile.WidthFraction, 0.2f, 1.2f) * value; float height = chestLabelProfile.HeightMetres * value; Vector3 val3 = ((Component)chest).transform.TransformDirection(((Vector3)(ref chestLabelProfile.FrontDirection)).normalized); if (((Vector3)(ref val3)).sqrMagnitude < 0.5f) { val3 = -((Component)chest).transform.forward; } Vector3 val4 = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref val4)).magnitude; val4 = ((Component)chest).transform.lossyScale; float reach = magnitude * ((Vector3)(ref val4)).magnitude + 1f; Vector3 center = ((Component)chest).transform.TransformPoint(ChestLabelGeometry.FrontPoint(bounds, chestLabelProfile)); ChestLabelGeometry.Surface surface = Surface(((Component)chest).transform, center, val3, reach); labelPair.Front = Make(((Component)chest).transform, "Hearthkeeper_FrontName", font, labelPair.Material, surface.Point + surface.Normal * chestLabelProfile.SurfaceClearance + ((Component)chest).transform.TransformVector(chestLabelProfile.FrontOffset), surface.Normal, ((Component)chest).transform.up, width, height, chestLabelProfile.FrontRotation); if ((Object)(object)labelPair.Front != (Object)null) { labelPair.FrontPulseLightObject = new GameObject("Hearthkeeper_FrontPulseLight"); labelPair.FrontPulseLightObject.transform.SetParent(((Component)chest).transform, false); labelPair.FrontPulseLightObject.transform.position = surface.Point + surface.Normal * (chestLabelProfile.SurfaceClearance + 0.08f) + ((Component)chest).transform.TransformVector(chestLabelProfile.FrontOffset); labelPair.FrontPulseLight = labelPair.FrontPulseLightObject.AddComponent<Light>(); labelPair.FrontPulseLight.type = (LightType)2; labelPair.FrontPulseLight.shadows = (LightShadows)0; labelPair.FrontPulseLight.renderMode = (LightRenderMode)0; labelPair.FrontPulseLight.color = color; labelPair.FrontPulseLight.range = 0.55f; labelPair.FrontPulseLight.intensity = 0f; } Vector3 center2 = ((Component)chest).transform.TransformPoint(ChestLabelGeometry.LidPoint(bounds, chestLabelProfile)); Transform val5 = ((!string.IsNullOrEmpty(chestLabelProfile.LidPath)) ? ((Component)chest).transform.Find(chestLabelProfile.LidPath) : FindLid(((Component)chest).transform)); if (((Object)(object)val5 == (Object)null || !ChestLabelGeometry.TrySurface(val5, center2, ((Component)chest).transform.up, reach, out var surface2)) && !ChestLabelGeometry.TrySurface(((Object)(object)chest.m_closed != (Object)null) ? chest.m_closed.transform : ((Component)chest).transform, center2, ((Component)chest).transform.up, reach, out surface2)) { surface2 = Surface(((Component)chest).transform, center2, ((Component)chest).transform.up, reach); } val4 = Vector3.ProjectOnPlane(-val3, surface2.Normal); Vector3 normalized = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.5f) { val4 = Vector3.ProjectOnPlane(((Component)chest).transform.forward, surface2.Normal); normalized = ((Vector3)(ref val4)).normalized; } labelPair.Lid = Make(surface2.Parent, "Hearthkeeper_LidName", font, labelPair.Material, surface2.Point + surface2.Normal * chestLabelProfile.SurfaceClearance + surface2.Parent.TransformVector(chestLabelProfile.LidOffset), surface2.Normal, normalized, width, height, chestLabelProfile.LidRotation); if ((Object)(object)labelPair.Lid != (Object)null) { labelPair.LidPulseLightObject = new GameObject("Hearthkeeper_LidPulseLight"); labelPair.LidPulseLightObject.transform.SetParent(surface2.Parent, false); labelPair.LidPulseLightObject.transform.position = surface2.Point + surface2.Normal * (chestLabelProfile.SurfaceClearance + 0.04f) + surface2.Parent.TransformVector(chestLabelProfile.LidOffset); labelPair.LidPulseLight = labelPair.LidPulseLightObject.AddComponent<Light>(); labelPair.LidPulseLight.type = (LightType)2; labelPair.LidPulseLight.shadows = (LightShadows)0; labelPair.LidPulseLight.renderMode = (LightRenderMode)0; labelPair.LidPulseLight.color = color; labelPair.LidPulseLight.range = 0.35f; labelPair.LidPulseLight.intensity = 0f; } string text = ContainerRegistry.PrefabName(chest); if (ReportedProfiles.Add(text) && Squirrel.DiagnosticsEnabled(HearthkeeperPlugin.DiagnosticVisualInspector)) { ManualLogSource log = HearthkeeperPlugin.Log; string[] obj = new string[15] { "Chest label surfaces [", text, "]: front direction=", null, null, null, null, null, null, null, null, null, null, null, null }; val4 = chestLabelProfile.FrontDirection; obj[3] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj[4] = ", front="; obj[5] = surface.Method; obj[6] = " at "; val4 = ((Component)chest).transform.InverseTransformPoint(surface.Point); obj[7] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj[8] = ", lid="; obj[9] = surface2.Method; obj[10] = " at "; val4 = ((Component)chest).transform.InverseTransformPoint(surface2.Point); obj[11] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj[12] = ", lid parent="; obj[13] = TransformPath(((Component)chest).transform, surface2.Parent); obj[14] = "."; log.LogInfo((object)string.Concat(obj)); } return labelPair; } private static ChestLabelGeometry.Surface Surface(Transform model, Vector3 center, Vector3 outward, float reach) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_003f: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (ChestLabelGeometry.TrySurface(model, center, outward, reach, out var surface)) { return surface; } Bounds val = MeshBounds(model); Vector3 val2 = model.InverseTransformDirection(outward); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Mathf.Abs(normalized.x) * ((Bounds)(ref val)).extents.x + Mathf.Abs(normalized.y) * ((Bounds)(ref val)).extents.y + Mathf.Abs(normalized.z) * ((Bounds)(ref val)).extents.z; Vector3 val3 = model.InverseTransformPoint(center); return new ChestLabelGeometry.Surface { Point = model.TransformPoint(val3 + normalized * (num - Vector3.Dot(val3 - ((Bounds)(ref val)).center, normalized))), Normal = outward, Parent = model, Method = "model bounds fallback" }; } private static string TransformPath(Transform root, Transform child) { string text = ((Object)child).name; while ((Object)(object)child != (Object)(object)root && (Object)(object)child.parent != (Object)null) { child = child.parent; text = ((Object)child).name + "/" + text; } return text; } private static TextMeshPro Make(Transform parent, string name, TMP_FontAsset font, Material material, Vector3 position, Vector3 normal, Vector3 up, float width, float height, Vector3 rotation) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.SetActive(false); val.transform.SetParent(parent, false); val.transform.position = position; val.transform.rotation = ChestLabelGeometry.TextRotation(normal, up, rotation); TextMeshPro obj = val.AddComponent<TextMeshPro>(); ((TMP_Text)obj).font = font; ((TMP_Text)obj).fontSharedMaterial = material; ((TMP_Text)obj).fontSize = 2f; val.SetActive(true); ((TMP_Text)obj).richText = false; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).isOrthographic = false; ((TMP_Text)obj).autoSizeTextContainer = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)3; ((TMP_Text)obj).fontSize = 2f; ((TMP_Text)obj).fontSizeMin = 0.05f; ((TMP_Text)obj).fontSizeMax = 2.2f; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(width, height); val.transform.position = position; val.transform.rotation = ChestLabelGeometry.TextRotation(normal, up, rotation); val.transform.localScale = Vector3.one; Vector3 val2 = val.transform.TransformVector(Vector3.right); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = val.transform.TransformVector(Vector3.up); float magnitude2 = ((Vector3)(ref val2)).magnitude; val2 = val.transform.TransformVector(Vector3.forward); float magnitude3 = ((Vector3)(ref val2)).magnitude; val.transform.localScale = new Vector3(1f / Mathf.Max(0.0001f, magnitude), 1f / Mathf.Max(0.0001f, magnitude2), 1f / Mathf.Max(0.0001f, magnitude3)); ((Graphic)obj).color = Color.white; obj.renderer.shadowCastingMode = (ShadowCastingMode)0; obj.renderer.receiveShadows = false; return obj; } private static float GetPulseAmount(Container chest) { if ((Object)(object)chest == (Object)null) { return 0f; } if (!PulseEnds.TryGetValue(chest, out var value)) { return 0f; } float num = value - Time.unscaledTime; if (num <= 0f) { PulseEnds.Remove(chest); return 0f; } float num2 = Mathf.Max(0.1f, HearthkeeperPlugin.ReceivingGlowDuration.Value); return Mathf.Sin((1f - Mathf.Clamp01(num / num2)) * MathF.PI); } private static void Apply(TextMeshPro text, string name, Container chest, Camera camera, float range, bool nearby) { //IL_0010: 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_0020: 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_0043: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_00b3: 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) //IL_00c8: 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_00e5: 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_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)text == (Object)null)) { Vector3 val = ((Component)camera).transform.position - text.transform.position; float magnitude = ((Vector3)(ref val)).magnitude; float num = ((magnitude > 0.001f) ? Vector3.Dot(-text.transform.forward, val / magnitude) : 0f); bool flag = nearby && magnitude <= range && num > 0.3f; if (flag) { ((TMP_Text)text).rectTransform.GetWorldCorners(Corners); flag = ClearLine(((Component)camera).transform.position, text.transform.position) && ClearLine(((Component)camera).transform.position, Vector3.Lerp(text.transform.position, Corners[0], 0.65f)) && ClearLine(((Component)camera).transform.position, Vector3.Lerp(text.transform.position, Corners[2], 0.65f)); } ((Component)text).gameObject.SetActive(flag); if (flag) { ((TMP_Text)text).text = name; float num2 = Mathf.Clamp01((range - magnitude) / Mathf.Max(1f, range * 0.3f)) * Mathf.Clamp01((num - 0.3f) / 0.3f); ((Graphic)text).color = new Color(1f, 1f, 1f, num2); } } } private static bool ClearLine(Vector3 from, Vector3 target) { //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_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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or