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 ValheimLargerHud v1.3.0
BepInEx/plugins/ValheimLargerHUD/ValheimLargerHUD.dll
Decompiled 10 hours 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using ValheimLargerHUD.Readability; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Valheim Larger HUD")] [assembly: AssemblyFileVersion("0.3.10.0")] [assembly: AssemblyVersion("0.3.10.0")] namespace Lesly.ValheimLargerHUD { [BepInPlugin("lesly.valheim.largerhud", "Valheim Larger HUD", "0.3.10")] [BepInProcess("valheim.exe")] [DefaultExecutionOrder(1000)] public sealed class LargerHUD : BaseUnityPlugin { private sealed class BuildCategoryTextState { private readonly bool _autoSize; private readonly TextWrappingModes _wordWrapping; private readonly float _fontSize; private readonly float _minimum; private readonly float _maximum; private readonly TextOverflowModes _overflow; private float _lastMinimum; private float _lastMaximum; internal BuildCategoryTextState(TMP_Text text) { //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_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) _autoSize = text.enableAutoSizing; _wordWrapping = text.textWrappingMode; _fontSize = text.fontSize; _minimum = text.fontSizeMin; _maximum = text.fontSizeMax; _overflow = text.overflowMode; } internal bool Apply(TMP_Text text, float referenceSize) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 float num = referenceSize * 0.8f; int num2; if (text.enableAutoSizing && (int)text.textWrappingMode == 1 && Mathf.Approximately(text.fontSizeMin, num) && Mathf.Approximately(text.fontSizeMax, referenceSize)) { num2 = (((int)text.overflowMode != 1) ? 1 : 0); if (num2 == 0) { goto IL_006c; } } else { num2 = 1; } text.enableAutoSizing = true; text.fontSizeMin = num; text.fontSizeMax = referenceSize; text.textWrappingMode = (TextWrappingModes)1; text.overflowMode = (TextOverflowModes)1; goto IL_006c; IL_006c: _lastMinimum = num; _lastMaximum = referenceSize; return (byte)num2 != 0; } internal void Restore(TMP_Text text) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)text) && text.enableAutoSizing && Mathf.Approximately(text.fontSizeMin, _lastMinimum) && Mathf.Approximately(text.fontSizeMax, _lastMaximum)) { text.enableAutoSizing = _autoSize; text.fontSizeMin = _minimum; text.fontSizeMax = _maximum; text.fontSize = _fontSize; if ((int)text.textWrappingMode == 1) { text.textWrappingMode = _wordWrapping; } if ((int)text.overflowMode == 1) { text.overflowMode = _overflow; } } } } private sealed class StatTextState { internal string Original; internal string Output; internal Material OriginalMaterial; internal Material OwnedMaterial; } private sealed class ScaleGroup { private readonly List<ScaleTarget> _targets = new List<ScaleTarget>(); private readonly Transform _space; private readonly Vector2 _edge; private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4]; private Vector2 _screenShift; internal bool IsValid { get { if (!Object.op_Implicit((Object)(object)_space)) { return false; } foreach (ScaleTarget target in _targets) { if (!target.IsValid) { return false; } } return true; } } internal ScaleGroup(List<RectTransform> roots, Transform space, bool topRight) : this(roots, space, topRight ? Vector2.one : Vector2.zero) { }//IL_000d: 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) internal ScaleGroup(List<RectTransform> roots, Transform space, Vector2 edge, bool stableScale = false, bool stablePosition = false) { //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) _space = space; _edge = edge; foreach (RectTransform root in roots) { _targets.Add(new ScaleTarget(root, stableScale, stablePosition)); } } internal void Observe() { if (!IsValid) { return; } foreach (ScaleTarget target in _targets) { target.Observe(); } } internal Vector3 OriginalWorldPoint(RectTransform descendant, Vector3 currentWorldPoint) { //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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) foreach (ScaleTarget target in _targets) { if (Contains((Transform)(object)target.Rect, (Transform)(object)descendant)) { return target.OriginalWorldPoint(((Transform)target.Rect).InverseTransformPoint(currentWorldPoint)); } } return currentWorldPoint; } internal void Apply(float factor, bool keepScreenShift = false) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_01dd: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) if (!IsValid) { return; } if (!keepScreenShift) { _screenShift = Vector2.zero; } Observe(); if (factor == 1f && _screenShift == Vector2.zero) { foreach (ScaleTarget target in _targets) { target.ApplyOriginal(); } return; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(float.PositiveInfinity, float.PositiveInfinity); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(float.NegativeInfinity, float.NegativeInfinity); foreach (ScaleTarget target2 in _targets) { target2.Rect.GetLocalCorners(_corners); for (int i = 0; i < 4; i++) { Vector3 val3 = _space.InverseTransformPoint(target2.OriginalWorldPoint(_corners[i])); val.x = Mathf.Min(val.x, val3.x); val.y = Mathf.Min(val.y, val3.y); val2.x = Mathf.Max(val2.x, val3.x); val2.y = Mathf.Max(val2.y, val3.y); } } foreach (ScaleTarget target3 in _targets) { Vector3 val4 = _space.InverseTransformPoint(target3.OriginalWorldPoint(Vector3.zero)); val4.x += ScaleGeometry.Offset(val4.x, Mathf.Lerp(val.x, val2.x, _edge.x), factor); val4.y += ScaleGeometry.Offset(val4.y, Mathf.Lerp(val.y, val2.y, _edge.y), factor); target3.Apply(factor, _space.TransformPoint(val4), _screenShift); } } internal void Restore() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) foreach (ScaleTarget target in _targets) { target.Restore(); } _screenShift = Vector2.zero; } internal void ShiftScreen(Vector2 delta) { //IL_002c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!IsValid || ((Vector2)(ref delta)).sqrMagnitude < 0.0001f) { return; } foreach (ScaleTarget target in _targets) { target.ShiftScreen(delta); } _screenShift += delta; } internal string DescribePaths() { List<string> list = new List<string>(); foreach (ScaleTarget target in _targets) { list.Add(PathOf((Transform)(object)target.Rect)); } return string.Join("; ", list.ToArray()); } internal string Describe() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) StringBuilder stringBuilder = new StringBuilder(); foreach (ScaleTarget target in _targets) { if (Object.op_Implicit((Object)(object)target.Rect)) { stringBuilder.AppendLine(PathOf((Transform)(object)target.Rect) + " | rect=" + ((object)target.Rect.rect/*cast due to .constrained prefix*/).ToString() + " | anchored=" + ((object)target.Rect.anchoredPosition/*cast due to .constrained prefix*/).ToString() + " | scale=" + ((object)((Transform)target.Rect).localScale/*cast due to .constrained prefix*/).ToString() + " | rotation=" + ((object)((Transform)target.Rect).localEulerAngles/*cast due to .constrained prefix*/).ToString()); } } return stringBuilder.ToString(); } } private sealed class ScaleTarget { internal readonly RectTransform Rect; private readonly Transform _parent; private Vector3 _originalScale; private Vector2 _originalAnchor; private Vector3 _lastScale; private Vector2 _lastAnchor; private Vector3 _originalLocalPosition; private readonly bool _stableScale; private readonly bool _stablePosition; internal bool IsValid { get { if (Object.op_Implicit((Object)(object)Rect) && Object.op_Implicit((Object)(object)_parent)) { return (Object)(object)((Transform)Rect).parent == (Object)(object)_parent; } return false; } } internal ScaleTarget(RectTransform rect, bool stableScale, bool stablePosition) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Rect = rect; _parent = ((Transform)rect).parent; _stableScale = stableScale; _stablePosition = stablePosition; _originalScale = (_lastScale = ((Transform)rect).localScale); _originalAnchor = (_lastAnchor = rect.anchoredPosition); _originalLocalPosition = ((Transform)rect).localPosition; } internal void Observe() { //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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = ((Transform)Rect).localScale; Vector2 anchoredPosition = Rect.anchoredPosition; _originalScale.x = ScaleGeometry.TrackScale(_originalScale.x, localScale.x, _lastScale.x, _stableScale); _originalScale.y = ScaleGeometry.TrackScale(_originalScale.y, localScale.y, _lastScale.y, _stableScale); _originalScale.z = ScaleGeometry.TrackScale(_originalScale.z, localScale.z, _lastScale.z, _stableScale); _originalAnchor.x = ScaleGeometry.TrackScale(_originalAnchor.x, anchoredPosition.x, _lastAnchor.x, _stablePosition); _originalAnchor.y = ScaleGeometry.TrackScale(_originalAnchor.y, anchoredPosition.y, _lastAnchor.y, _stablePosition); _originalLocalPosition = ((Transform)Rect).localPosition + new Vector3(_originalAnchor.x - anchoredPosition.x, _originalAnchor.y - anchoredPosition.y, 0f); } internal Vector3 OriginalWorldPoint(Vector3 localPoint) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) return _parent.TransformPoint(_originalLocalPosition + ((Transform)Rect).localRotation * Vector3.Scale(_originalScale, localPoint)); } internal void Apply(float factor, Vector3 worldPivot, Vector2 screenShift) { //IL_0043: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (((Vector2)(ref screenShift)).sqrMagnitude > 0.0001f) { Camera val = ScreenCamera(Rect); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(val, worldPivot); Vector3 val3 = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(Rect, val2 + screenShift, val, ref val3)) { worldPivot = val3; } } Vector3 val4 = _parent.InverseTransformPoint(worldPivot); Vector2 anchor = _originalAnchor + new Vector2(val4.x - _originalLocalPosition.x, val4.y - _originalLocalPosition.y); Set(new Vector3(_originalScale.x * factor, _originalScale.y * factor, _originalScale.z), anchor); } internal void ApplyOriginal() { //IL_0002: 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) Set(_originalScale, _originalAnchor); } internal void ShiftScreen(Vector2 delta) { //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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Camera val = ScreenCamera(Rect); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(val, ((Transform)Rect).position); Vector3 val3 = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(Rect, val2 + delta, val, ref val3)) { Vector3 val4 = _parent.InverseTransformPoint(val3) - ((Transform)Rect).localPosition; Set(((Transform)Rect).localScale, Rect.anchoredPosition + new Vector2(val4.x, val4.y)); } } private void Set(Vector3 scale, Vector2 anchor) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!Close(((Transform)Rect).localScale, scale)) { ((Transform)Rect).localScale = scale; } if (!Close(Rect.anchoredPosition, anchor)) { Rect.anchoredPosition = anchor; } _lastScale = ((Transform)Rect).localScale; _lastAnchor = Rect.anchoredPosition; } internal void Restore() { if (IsValid) { Observe(); ApplyOriginal(); } } private static bool Close(Vector2 a, Vector2 b) { //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) Vector2 val = a - b; return ((Vector2)(ref val)).sqrMagnitude < 1E-07f; } private static bool Close(Vector3 a, Vector3 b) { //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) Vector3 val = a - b; return ((Vector3)(ref val)).sqrMagnitude < 1E-07f; } } public const string PluginId = "lesly.valheim.largerhud"; public const string PluginVersion = "0.3.10"; private ConfigEntry<bool> _enabled; private ConfigEntry<float> _minimapScale; private ConfigEntry<float> _healthScale; private ConfigEntry<KeyboardShortcut> _reloadKey; private ScaleGroup _minimapGroup; private ScaleGroup _healthGroup; private Minimap _map; private Hud _hud; private bool _ready; private bool _failed; private float _nextDiscovery; private float _nextReport; private bool _reportPending; private bool _mapWarned; private bool _hudWarned; private readonly List<string> _notes = new List<string>(); private static readonly HashSet<string> HealthFields = new HashSet<string>(StringComparer.Ordinal) { "m_healthPanel", "m_healthBarRoot", "m_healthBarFast", "m_healthBarSlow", "m_healthText", "m_foodBarRoot", "m_foodBaseBar", "m_foodBars", "m_foodIcons", "m_foodTime", "m_foodIcon", "m_foodText" }; private ConfigEntry<float> _toolbarScale; private ConfigEntry<float> _inventoryScale; private ConfigEntry<float> _rightScale; private ConfigEntry<float> _hintsScale; private ConfigEntry<float> _tooltipScale; private InventoryGui _inventory; private HotkeyBar _toolbar; private KeyHints _keyHints; private ScaleGroup _toolbarGroup; private ScaleGroup _playerGroup; private ScaleGroup _rightGroup; private ScaleGroup _containerGroup; private ScaleGroup _inventoryHintsGroup; private ScaleGroup _containerHintsGroup; private Graphic[] _toolbarGraphics; private Graphic[] _inventoryHintGraphics; private Graphic[] _containerHintGraphics; private readonly List<RectTransform> _playerBounds = new List<RectTransform>(); private readonly List<RectTransform> _rightBounds = new List<RectTransform>(); private readonly List<RectTransform> _containerBounds = new List<RectTransform>(); private readonly Vector3[] _layoutCorners = (Vector3[])(object)new Vector3[4]; private float _effectiveLeft = 1f; private float _effectiveRight = 1f; private float _effectiveHints = 1f; private Rect _lastTooltipSpace; private bool _inventoryWarned; private bool _inventoryFailed; private bool _inventoryWasVisible; private ConfigEntry<bool> _instantInventoryOpen; private ConfigEntry<bool> _instantInventoryClose; private CanvasGroup _inventoryCloseVisibility; private InventoryGui _openingGui; private Animator _openingAnimator; private bool _inventoryWantsOpen; private bool _finishInventoryOpening; private bool _openingAnimationFailed; private bool _inventoryCanvasSubscribed; private bool _inInventoryCanvasPass; private int _closedInventoryState; private int _lastFinishedInventoryState; private int _inventoryRenderFrame = -1; private int _inventoryLayoutReadyFrame = -1; private RectTransform _statusEffectRoot; private Transform _statusEffectParent; private Vector2 _statusEffectOriginalAnchor; private Vector2 _statusEffectLastAnchor; private bool _statusEffectLayoutFailed; private static readonly FieldInfo InventoryTooltipCurrentField = typeof(UITooltip).GetField("m_current", BindingFlags.Static | BindingFlags.NonPublic); private static readonly FieldInfo InventoryTooltipObjectField = typeof(UITooltip).GetField("m_tooltip", BindingFlags.Static | BindingFlags.NonPublic); private RectTransform _inventoryTooltipVisual; private Transform _inventoryTooltipVisualParent; private Canvas _inventoryTooltipCanvas; private Vector3 _inventoryTooltipBaseScale; private Vector3 _inventoryTooltipBasePosition; private Vector3 _inventoryTooltipNativeRootScale; private float _inventoryTooltipLearnedWidth; private GameObject _inventoryTooltipWidthPrefab; private bool _inventoryTooltipAdjusted; private bool _inventoryTooltipFitWarned; private bool _inventoryTooltipFieldsWarned; private readonly Vector3[] _inventoryTooltipCorners = (Vector3[])(object)new Vector3[4]; private TMP_Text[] _inventoryTooltipTexts; private Graphic[] _inventoryTooltipGraphics; private bool[] _inventoryTooltipRaycasts; private Canvas _inventoryTooltipOverlay; private bool _inventoryTooltipOwnsOverlay; private bool _inventoryTooltipOldOverride; private int _inventoryTooltipOldOrder; private int _inventoryTooltipOldLayer; private string[] _inventoryTooltipLastText; private bool _inventoryTooltipLayoutReady; private ConfigEntry<float> _buildMenuScale; private Hud _buildMenuHud; private BuildUi _buildMenuUi; private ScaleGroup _buildMenuGroup; private readonly List<RectTransform> _buildMenuBounds = new List<RectTransform>(); private RectTransform _buildMenuFrame; private Rect _lastBuildMenuBounds; private float _effectiveBuildMenuScale = 1f; private bool _buildMenuFailed; private bool _buildMenuWasVisible; private Transform _raisedBuildBranch; private Transform _raisedBuildParent; private int _originalBuildSibling; private int _lastBuildSibling; private static readonly string[] BuildMenuPanelFields = new string[5] { "m_tabContainer", "m_tagListContainer", "m_pieceView", "m_specialButtonsContainer", "m_searchField" }; private static readonly FieldInfo BuildTagPrefabField = typeof(BuildUi).GetField("m_tagButtonPrefab", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo BuildTagContentField = typeof(BuildUi).GetField("m_tagListScrollContent", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo BuildShowAllField = typeof(BuildUi).GetField("m_showAllTagsButton", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo BuildTagTextsField = typeof(BuildUiTagButton).GetField("m_textMeshes", BindingFlags.Instance | BindingFlags.NonPublic); private readonly Dictionary<TMP_Text, BuildCategoryTextState> _buildCategoryTexts = new Dictionary<TMP_Text, BuildCategoryTextState>(); private readonly List<TMP_Text> _deadBuildCategoryTexts = new List<TMP_Text>(); private ConfigEntry<bool> _improveStatContrast; private readonly Dictionary<TMP_Text, StatTextState> _statTextStates = new Dictionary<TMP_Text, StatTextState>(); private readonly List<TMP_Text> _deadStatTexts = new List<TMP_Text>(); private float _nextStatPrune; private static readonly int StatOutlineWidth = Shader.PropertyToID("_OutlineWidth"); private static readonly int StatOutlineColor = Shader.PropertyToID("_OutlineColor"); private static readonly FieldInfo InventoryHoveredField = typeof(UITooltip).GetField("m_hovered", BindingFlags.Static | BindingFlags.NonPublic); private static readonly FieldInfo InventoryElementsField = typeof(InventoryGrid).GetField("m_elements", BindingFlags.Instance | BindingFlags.NonPublic); private static LargerHUD _hoverPatchOwner; private Harmony _hoverHarmony; private bool _hoverPatchesReady; private bool _startingInventoryHover; private bool _inventoryMouseHoverActive; private ConfigEntry<float> _mouseTooltipDelay; private readonly List<RaycastResult> _inventoryHoverHits = new List<RaycastResult>(32); private EventSystem _inventoryHoverEvents; private PointerEventData _inventoryPointer; private readonly TooltipHoverState _inventoryHoverState = new TooltipHoverState(); private UITooltip _mouseHoverSource; private ItemData _mouseHoverItem; private float _nextHoverContentRefresh; private int _inventoryHoverRecoveries; private bool _closeCanvasOwned; private float _closeCanvasOriginalAlpha; private bool _closeCanvasOriginalRaycasts; private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!Application.isBatchMode) { _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the selected HUD and inventory size adjustments."); _minimapScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "MinimapScale", 1.35f, new ConfigDescription("Minimap size multiplier. 1 = original; 1.35 = 35% larger; 2 = double.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>())); _healthScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "HealthAndFoodScale", 1.35f, new ConfigDescription("Bottom-left health and food size multiplier. Stamina/eitr/adrenaline are separate and are not changed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>())); _reloadKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ReloadConfigKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Press after editing this configuration file. Also refreshes the UI diagnostic report. None disables the shortcut."); BindInventorySettings(); BindInventoryOpeningSettings(); BindBuildMenuSettings(); BindStatReadabilitySettings(); _ready = true; InstallInventoryHoverPatches(); SubscribeInventoryCanvas(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Larger HUD 0.3.10 loaded. Client UI only; no network hooks or server requirement."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Built against Steam build 25185596. Config: " + ((BaseUnityPlugin)this).Config.ConfigFilePath)); } } private void Update() { //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) if (!_ready) { return; } KeyboardShortcut value = _reloadKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { try { ((BaseUnityPlugin)this).Config.Reload(); _failed = false; _inventoryFailed = false; ReleaseGroups(); _hud = null; _map = null; _hudWarned = false; _mapWarned = false; _nextDiscovery = 0f; RequestReport(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Configuration reloaded. Minimap=" + _minimapScale.Value + "; health/food=" + _healthScale.Value)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not reload settings: " + ex.Message)); } } if (!_failed) { UpdateInventoryFeatures(discover: false, prepareOnly: true); UpdateBuildMenuFeatures(discover: false, prepareOnly: true); } } private void LateUpdate() { if (!_ready || _failed) { return; } Readability.Tick(_enabled.Value); try { bool flag = Time.unscaledTime >= _nextDiscovery; if (flag) { _nextDiscovery = Time.unscaledTime + 0.5f; Discover(); } float factor = (_enabled.Value ? ScaleGeometry.Sanitize(_minimapScale.Value) : 1f); float factor2 = (_enabled.Value ? ScaleGeometry.Sanitize(_healthScale.Value) : 1f); if (_minimapGroup != null) { _minimapGroup.Apply(factor); } UpdateStatusEffectLayout(); if (_healthGroup != null) { _healthGroup.Apply(factor2); } UpdateInventoryFeatures(flag, prepareOnly: true); UpdateBuildMenuFeatures(flag); _inventoryLayoutReadyFrame = Time.frameCount; if (_reportPending && Time.unscaledTime >= _nextReport) { WriteReport(); } } catch (Exception ex) { _failed = true; ReleaseGroups(); ((BaseUnityPlugin)this).Logger.LogError((object)("Larger HUD stopped and restored its tracked transforms: " + ex)); _notes.Add("Stopped: " + ex.GetType().Name + ": " + ex.Message); WriteReport(); } } private void Discover() { Minimap instance = Minimap.instance; Hud instance2 = Hud.instance; if ((Object)(object)_map != (Object)(object)instance || (_minimapGroup != null && !_minimapGroup.IsValid)) { if (_minimapGroup != null) { _minimapGroup.Restore(); } _minimapGroup = null; _map = instance; _mapWarned = false; RequestReport(); } if ((Object)(object)_hud != (Object)(object)instance2 || (_healthGroup != null && !_healthGroup.IsValid)) { if (_healthGroup != null) { _healthGroup.Restore(); } _healthGroup = null; _hud = instance2; _hudWarned = false; RequestReport(); } if (Object.op_Implicit((Object)(object)_map) && _minimapGroup == null && Object.op_Implicit((Object)(object)_map.m_smallRoot)) { Transform transform = _map.m_smallRoot.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy) { Transform val2 = (Object.op_Implicit((Object)(object)_map.m_largeRoot) ? _map.m_largeRoot.transform : null); if (Object.op_Implicit((Object)(object)((Transform)val).parent) && (!Object.op_Implicit((Object)(object)val2) || !Contains((Transform)(object)val, val2)) && (Object)(object)val != (Object)(object)((Component)_map).transform) { _minimapGroup = new ScaleGroup(new List<RectTransform> { val }, ((Transform)val).parent, topRight: true); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Minimap target: " + PathOf((Transform)(object)val))); RequestReport(); } else if (!_mapWarned) { _mapWarned = true; _notes.Add("Minimap target rejected because it could include the large map or a whole canvas."); ((BaseUnityPlugin)this).Logger.LogWarning((object)_notes[_notes.Count - 1]); RequestReport(); } } } if (Object.op_Implicit((Object)(object)_hud) && _healthGroup == null && Object.op_Implicit((Object)(object)_hud.m_rootObject) && _hud.m_rootObject.activeInHierarchy) { _healthGroup = ResolveHealthGroup(_hud, out var reason); if (_healthGroup != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Health/food targets: " + _healthGroup.DescribePaths())); RequestReport(); } else if (!_hudWarned) { _hudWarned = true; _notes.Add("Health/food scaling skipped: " + reason); ((BaseUnityPlugin)this).Logger.LogWarning((object)_notes[_notes.Count - 1]); RequestReport(); } } } private static ScaleGroup ResolveHealthGroup(Hud hud, out string reason) { reason = "No initialized health/food controls found."; List<RectTransform> list = new List<RectTransform>(); List<Transform> protectedControls = new List<Transform> { ((Component)hud).transform }; List<Transform> list2 = new List<Transform>(); FieldInfo[] fields = typeof(Hud).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { bool flag = HealthFields.Contains(fieldInfo.Name); if (fieldInfo.Name == "m_healthAnimator") { continue; } foreach (Transform item in TransformsIn(fieldInfo.GetValue(hud))) { if (flag) { RectTransform val = (RectTransform)(object)((item is RectTransform) ? item : null); if (Object.op_Implicit((Object)(object)val) && !list.Contains(val)) { list.Add(val); } if (fieldInfo.Name == "m_healthBarRoot" || fieldInfo.Name == "m_healthText" || fieldInfo.Name == "m_foodIcons" || fieldInfo.Name == "m_foodTime") { list2.Add(item); } } else { protectedControls.Add(item); } } } if (list2.Count == 0 || !Object.op_Implicit((Object)(object)hud.m_healthBarRoot)) { return null; } list.RemoveAll((RectTransform val2) => !Object.op_Implicit((Object)(object)((Transform)val2).parent) || protectedControls.Exists((Transform other) => Object.op_Implicit((Object)(object)other) && Contains((Transform)(object)val2, other))); List<RectTransform> list3 = new List<RectTransform>(); foreach (RectTransform candidate in list) { if (!list.Exists((RectTransform other) => (Object)(object)other != (Object)(object)candidate && Contains((Transform)(object)other, (Transform)(object)candidate))) { list3.Add(candidate); } } foreach (Transform control in list2) { if (!list3.Exists((RectTransform root) => Contains((Transform)(object)root, control))) { reason = "Cannot isolate required control " + PathOf(control) + " without including unrelated UI."; return null; } } if (list3.Count == 0) { return null; } Transform space = ((Transform)list3[0]).parent; while (Object.op_Implicit((Object)(object)space) && list3.Exists((RectTransform root) => !Contains(space, (Transform)(object)root))) { space = space.parent; } if (!Object.op_Implicit((Object)(object)space)) { reason = "Health and food do not share a UI coordinate space."; return null; } return new ScaleGroup(list3, space, topRight: false); } private static IEnumerable<Transform> TransformsIn(object value) { GameObject val = (GameObject)((value is GameObject) ? value : null); if (Object.op_Implicit((Object)(object)val)) { yield return val.transform; yield break; } Component val2 = (Component)((value is Component) ? value : null); if (Object.op_Implicit((Object)(object)val2)) { yield return val2.transform; } else { if (!(value is Array array)) { yield break; } foreach (object item in array) { GameObject val3 = (GameObject)((item is GameObject) ? item : null); if (Object.op_Implicit((Object)(object)val3)) { yield return val3.transform; } Component val4 = (Component)((item is Component) ? item : null); if (Object.op_Implicit((Object)(object)val4)) { yield return val4.transform; } } } } private static bool Contains(Transform root, Transform child) { if (!((Object)(object)root == (Object)(object)child)) { return child.IsChildOf(root); } return true; } private void RequestReport() { _reportPending = true; _nextReport = Time.unscaledTime + 0.2f; } private void WriteReport() { _reportPending = false; try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Valheim Larger HUD 0.3.10 - HUD diagnostics only"); stringBuilder.AppendLine("No player names, chat text, server addresses or world data are recorded here."); stringBuilder.AppendLine("Unity: " + Application.unityVersion + "; screen: " + Screen.width + " x " + Screen.height); stringBuilder.AppendLine("Configured factors: minimap=" + _minimapScale.Value.ToString(CultureInfo.InvariantCulture) + "; health/food=" + _healthScale.Value.ToString(CultureInfo.InvariantCulture) + "; enabled=" + _enabled.Value); stringBuilder.AppendLine("Minimap: " + ((_minimapGroup == null) ? "not attached" : _minimapGroup.Describe())); stringBuilder.AppendLine("Health/food: " + ((_healthGroup == null) ? "not attached" : _healthGroup.Describe())); DescribeInventory(stringBuilder); DescribeBuildMenu(stringBuilder); foreach (string note in _notes) { stringBuilder.AppendLine(note); } if (Object.op_Implicit((Object)(object)_hud)) { stringBuilder.AppendLine("Public HUD transform references:"); FieldInfo[] fields = typeof(Hud).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { foreach (Transform item in TransformsIn(fieldInfo.GetValue(_hud))) { stringBuilder.AppendLine(" " + fieldInfo.Name + " => " + PathOf(item)); } } } File.WriteAllText(Path.Combine(Paths.ConfigPath, "lesly.valheim.largerhud.diagnostics.txt"), stringBuilder.ToString()); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not write HUD diagnostics: " + ex.Message)); } } private static string PathOf(Transform transform) { if (!Object.op_Implicit((Object)(object)transform)) { return "<destroyed>"; } StringBuilder stringBuilder = new StringBuilder(((Object)transform).name); Transform parent = transform.parent; while (Object.op_Implicit((Object)(object)parent)) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } private void ReleaseGroups() { ReleaseInventory(); ReleaseStatusEffectLayout(); ReleaseBuildMenu(); RestoreStatReadability(); if (_minimapGroup != null) { _minimapGroup.Restore(); } if (_healthGroup != null) { _healthGroup.Restore(); } _minimapGroup = null; _healthGroup = null; } private void OnEnable() { if (_ready) { SubscribeInventoryCanvas(); } } private void OnDisable() { Readability.Restore(); UnsubscribeInventoryCanvas(); ReleaseGroups(); } private void OnDestroy() { Readability.Restore(); UnsubscribeInventoryCanvas(); ReleaseGroups(); RemoveInventoryHoverPatches(); } private void UpdateInventoryFeatures(bool discover, bool prepareOnly = false) { if (_inventoryFailed) { return; } try { if (discover || (Object)(object)_inventory != (Object)(object)InventoryGui.instance || (Object.op_Implicit((Object)(object)_inventory) && (_playerGroup == null || !_playerGroup.IsValid || _rightGroup == null || !_rightGroup.IsValid))) { DiscoverInventory(); } UpdateInventoryOpening(prepareOnly); if (!prepareOnly) { ApplyInventoryLayout(); } } catch (Exception ex) { _inventoryFailed = true; ReleaseInventory(); _notes.Add("Inventory layout stopped: " + ex.GetType().Name + ": " + ex.Message); ((BaseUnityPlugin)this).Logger.LogError((object)("Inventory layout stopped and restored its controls. The minimap and health/food remain active. " + ex)); RequestReport(); } } private void BindInventorySettings() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown _toolbarScale = BindSize("ToolbarScale", 1.25f, "Top-left gameplay toolbar multiplier."); _inventoryScale = BindSize("InventoryScale", 1.25f, "Player inventory multiplier, including its top toolbar row. Limited by screen space."); _rightScale = BindSize("RightPanelsScale", 1.25f, "Character buttons and crafting panel multiplier. Limited by screen space."); _hintsScale = BindSize("InventoryHintsScale", 1.15f, "Bottom inventory control hints multiplier. Automatically fits long hint rows to the screen."); _tooltipScale = ((BaseUnityPlugin)this).Config.Bind<float>("Inventory", "TooltipReadableScale", 1.1f, new ConfigDescription("Item tooltip size relative to native. 1.10 = 10% larger than the unmodified game; text fits within the gap between inventory panels when space is limited. Replaces the old TooltipScale key.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1.4f), Array.Empty<object>())); } private ConfigEntry<float> BindSize(string name, float value, string description) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<float>("Inventory", name, value, new ConfigDescription(description + " 1 = original; 1.25 = 25% larger.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1.5f), Array.Empty<object>())); } private void DiscoverInventory() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) Hud instance = Hud.instance; if (Object.op_Implicit((Object)(object)_toolbar) && (!Object.op_Implicit((Object)(object)instance) || !Contains(((Component)instance).transform, ((Component)_toolbar).transform))) { RestoreGroup(ref _toolbarGroup); _toolbar = null; } if (!Object.op_Implicit((Object)(object)_toolbar) && Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.m_rootObject)) { _toolbar = instance.m_rootObject.GetComponentInChildren<HotkeyBar>(true); } if (Object.op_Implicit((Object)(object)_toolbar)) { if (_toolbarGroup != null && !_toolbarGroup.IsValid) { RestoreGroup(ref _toolbarGroup); } if (_toolbarGroup == null) { _toolbarGroup = MakeGroup(new Vector2(0f, 1f), (RectTransform)/*isinst with value type is only supported in some contexts*/); } _toolbarGraphics = ((Component)_toolbar).GetComponentsInChildren<Graphic>(true); } InventoryGui instance2 = InventoryGui.instance; if ((Object)(object)_inventory != (Object)(object)instance2 || (_playerGroup != null && !_playerGroup.IsValid) || (_rightGroup != null && !_rightGroup.IsValid)) { ReleasePanels(); _inventory = instance2; _inventoryWarned = false; RequestReport(); } if (Object.op_Implicit((Object)(object)_inventory) && _playerGroup == null) { RectTransform player = _inventory.m_player; RectTransform info = _inventory.m_info; RectTransform crafting = _inventory.m_crafting; if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)info) && Object.op_Implicit((Object)(object)crafting) && Object.op_Implicit((Object)(object)((Transform)player).parent) && Object.op_Implicit((Object)(object)((Transform)info).parent) && Object.op_Implicit((Object)(object)((Transform)crafting).parent) && !Contains((Transform)(object)player, (Transform)(object)info) && !Contains((Transform)(object)player, (Transform)(object)crafting) && !Contains((Transform)(object)info, (Transform)(object)player) && !Contains((Transform)(object)crafting, (Transform)(object)player) && (Object)(object)player != (Object)(object)_inventory.m_inventoryRoot && (Object)(object)info != (Object)(object)_inventory.m_inventoryRoot && (Object)(object)crafting != (Object)(object)_inventory.m_inventoryRoot) { _playerGroup = MakeInventoryGroup(new Vector2(0f, 1f), player); _rightGroup = MakeInventoryGroup(Vector2.one, info, crafting); _playerBounds.Add(player); AddDecorationBounds(_playerBounds, player, (Component)(object)_inventory.m_armor); AddDecorationBounds(_playerBounds, player, (Component)(object)_inventory.m_weight); _rightBounds.Add(info); _rightBounds.Add(crafting); AddRightDecoration((Component)(object)_inventory.m_repairPanel); AddRightDecoration((Component)(object)_inventory.m_repairButton); AddRightDecoration((Component)(object)_inventory.m_craftingStationLevelRoot); RectTransform container = _inventory.m_container; if (Object.op_Implicit((Object)(object)container) && !Contains((Transform)(object)player, (Transform)(object)container) && !Contains((Transform)(object)container, (Transform)(object)player) && !Contains((Transform)(object)crafting, (Transform)(object)container) && !Contains((Transform)(object)info, (Transform)(object)container)) { _containerGroup = MakeInventoryGroup(new Vector2(0f, 1f), container); _containerBounds.Add(container); AddDecorationBounds(_containerBounds, container, (Component)(object)_inventory.m_containerWeight); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Inventory targets: " + _playerGroup.DescribePaths() + "; " + _rightGroup.DescribePaths())); RequestReport(); } else if (!_inventoryWarned) { _inventoryWarned = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Inventory roots not yet isolated; retaining native inventory layout."); } } if ((Object)(object)_keyHints != (Object)(object)KeyHints.instance) { RestoreGroup(ref _inventoryHintsGroup); RestoreGroup(ref _containerHintsGroup); _keyHints = KeyHints.instance; } if (Object.op_Implicit((Object)(object)_keyHints)) { DiscoverHints(_keyHints.m_inventoryHints, ref _inventoryHintsGroup, ref _inventoryHintGraphics); DiscoverHints(_keyHints.m_inventoryWithContainerHints, ref _containerHintsGroup, ref _containerHintGraphics); } } private static ScaleGroup MakeGroup(Vector2 edge, params RectTransform[] candidates) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return MakeGroupCore(edge, stablePosition: false, candidates); } private static ScaleGroup MakeInventoryGroup(Vector2 edge, params RectTransform[] candidates) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return MakeGroupCore(edge, stablePosition: true, candidates); } private static ScaleGroup MakeGroupCore(Vector2 edge, bool stablePosition, params RectTransform[] candidates) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) List<RectTransform> roots = new List<RectTransform>(); foreach (RectTransform val in candidates) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Transform)val).parent) && !roots.Contains(val)) { roots.Add(val); } } List<RectTransform> list = roots.FindAll((RectTransform candidate) => !roots.Exists((RectTransform other) => (Object)(object)other != (Object)(object)candidate && Contains((Transform)(object)other, (Transform)(object)candidate))); if (list.Count == 0) { return null; } Transform space = ((Transform)list[0]).parent; while (Object.op_Implicit((Object)(object)space) && list.Exists((RectTransform root) => !Contains(space, (Transform)(object)root))) { space = space.parent; } if (!Object.op_Implicit((Object)(object)space)) { return null; } return new ScaleGroup(list, space, edge, stableScale: true, stablePosition); } private static void DiscoverHints(GameObject root, ref ScaleGroup group, ref Graphic[] graphics) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (group != null && !group.IsValid) { RestoreGroup(ref group); } if (Object.op_Implicit((Object)(object)root)) { if (group == null) { group = MakeGroup(new Vector2(0.5f, 0f), (RectTransform)/*isinst with value type is only supported in some contexts*/); } graphics = root.GetComponentsInChildren<Graphic>(true); } } private static void AddDecorationBounds(List<RectTransform> bounds, RectTransform root, Component label) { if (Object.op_Implicit((Object)(object)label) && Contains((Transform)(object)root, label.transform)) { Transform parent = label.transform.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (Object.op_Implicit((Object)(object)val) && !bounds.Contains(val)) { bounds.Add(val); } } } private void AddRightDecoration(Component decoration) { if (Object.op_Implicit((Object)(object)decoration) && Object.op_Implicit((Object)(object)_inventory)) { Transform transform = decoration.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (Object.op_Implicit((Object)(object)val) && (Contains((Transform)(object)_inventory.m_crafting, (Transform)(object)val) || Contains((Transform)(object)_inventory.m_info, (Transform)(object)val)) && !_rightBounds.Contains(val)) { _rightBounds.Add(val); } } } private void ApplyInventoryLayout() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) bool value = _enabled.Value; bool flag = Object.op_Implicit((Object)(object)Hud.instance) && Hud.instance.IsVisible(); if (_toolbarGroup != null) { _toolbarGroup.Observe(); if (value && flag && TryGraphicsBounds(_toolbarGraphics, out var bounds, _toolbarGroup)) { float factor = LayoutGeometry.Setting(_toolbarScale.Value, 1.25f, 1f, 1.5f); _toolbarGroup.Apply(factor, keepScreenShift: true); if (TryGraphicsBounds(_toolbarGraphics, out var bounds2)) { _toolbarGroup.ShiftScreen(new Vector2(((Rect)(ref bounds)).xMin - ((Rect)(ref bounds2)).xMin, ((Rect)(ref bounds)).yMax - ((Rect)(ref bounds2)).yMax)); } } else { _toolbarGroup.Apply(1f); } } if (!value || !flag || !Object.op_Implicit((Object)(object)_inventory) || !_inventoryWantsOpen) { if (!value) { ApplyNativePanels(); } _inventoryWasVisible = false; ClearInventoryHover(); RestoreInventoryTooltip(); if (Object.op_Implicit((Object)(object)_inventory)) { RestoreStatReadability(_inventory.m_recipeDecription); } return; } if (_playerGroup == null || _rightGroup == null) { RestoreInventoryTooltip(); return; } if (!_inventoryWasVisible) { RebuildOpeningInventory(); _inventoryWasVisible = true; } _playerGroup.Observe(); _rightGroup.Observe(); if (_containerGroup != null) { _containerGroup.Observe(); } float num = Mathf.Max(10f, (float)Screen.height * 0.01f); float num2 = InventoryLayoutPolicy.HintTop(Screen.height, num); _effectiveHints = 1f; ApplyHints(_inventoryHintsGroup, _inventoryHintGraphics, num); ApplyHints(_containerHintsGroup, _containerHintGraphics, num); if (!TryBounds(_playerBounds, out var bounds3, _playerGroup, includeInactive: true) || !TryBounds(_rightBounds, out var bounds4, _rightGroup, includeInactive: true)) { RestoreInventoryTooltip(); return; } float num3 = (float)Screen.height - num - num2 - num; float availableHeight = num3; float num4 = ((Rect)(ref bounds3)).width; bool flag2 = InventoryOpeningPolicy.IncludeContainer(_inventory.IsContainerOpen(), Object.op_Implicit((Object)(object)_inventory.m_container) && ((Component)_inventory.m_container).gameObject.activeInHierarchy); if (flag2 && _containerGroup != null && TryBounds(_containerBounds, out var bounds5, _containerGroup)) { availableHeight = Mathf.Max(1f, num3 - ((Rect)(ref bounds5)).height - num); num4 = Mathf.Max(num4, ((Rect)(ref bounds5)).width); } float leftScale = LayoutGeometry.FitScale(LayoutGeometry.Setting(_inventoryScale.Value, 1.25f, 1f, 1.5f), ((Rect)(ref bounds3)).width, ((Rect)(ref bounds3)).height, (float)Screen.width - num * 2f, availableHeight); float rightScale = LayoutGeometry.FitScale(LayoutGeometry.Setting(_rightScale.Value, 1.25f, 1f, 1.5f), ((Rect)(ref bounds4)).width, ((Rect)(ref bounds4)).height, (float)Screen.width - num * 2f, num3); float middle = InventoryLayoutPolicy.MiddleReservation(InventoryTooltipNativeWidth(), DesiredInventoryTooltipScale(), Screen.width, num) + 24f; float num5 = num; float num6 = (float)Screen.width - num; LayoutGeometry.ReserveMiddle(num4, ((Rect)(ref bounds4)).width, num6 - num5, middle, ref leftScale, ref rightScale); _effectiveLeft = leftScale; _effectiveRight = rightScale; _playerGroup.Apply(leftScale, keepScreenShift: true); _rightGroup.Apply(rightScale, keepScreenShift: true); if (!TryBounds(_playerBounds, out var bounds6, null, includeInactive: true) || !TryBounds(_rightBounds, out var bounds7, null, includeInactive: true)) { return; } _playerGroup.ShiftScreen(new Vector2(num5 - ((Rect)(ref bounds6)).xMin, LayoutGeometry.DockTopTranslation(((Rect)(ref bounds6)).yMax, Screen.height, num))); _rightGroup.ShiftScreen(new Vector2(num6 - ((Rect)(ref bounds7)).xMax, LayoutGeometry.DockTopTranslation(((Rect)(ref bounds7)).yMax, Screen.height, num))); TryBounds(_playerBounds, out bounds6, null, includeInactive: true); TryBounds(_rightBounds, out bounds7, null, includeInactive: true); if (flag2 && _containerGroup != null && TryBounds(_containerBounds, out var bounds8, _containerGroup)) { float num7 = Mathf.Min(0f, ((Rect)(ref bounds6)).yMin - num - ((Rect)(ref bounds8)).yMax); _containerGroup.Apply(1f, keepScreenShift: true); if (TryBounds(_containerBounds, out var bounds9)) { _containerGroup.ShiftScreen(new Vector2(((Rect)(ref bounds6)).xMin - ((Rect)(ref bounds9)).xMin, ((Rect)(ref bounds8)).yMin + num7 - ((Rect)(ref bounds9)).yMin)); } TryBounds(_containerBounds, out bounds8); ((Rect)(ref bounds6)).xMax = Mathf.Max(((Rect)(ref bounds6)).xMax, ((Rect)(ref bounds8)).xMax); } _lastTooltipSpace = Rect.MinMaxRect(((Rect)(ref bounds6)).xMax + num, num2 + num, ((Rect)(ref bounds7)).xMin - num, (float)Screen.height - num); RecoverInventoryHover(); ApplyInventoryTooltip(_lastTooltipSpace); ApplyStatReadability(_inventory.m_recipeDecription); } private float ApplyHints(ScaleGroup group, Graphic[] graphics, float margin) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (group == null) { return margin; } group.Observe(); if (!TryGraphicsBounds(graphics, out var bounds, group)) { group.Apply(1f); return margin; } if (((Rect)(ref bounds)).height > (float)Screen.height * 0.2f) { group.Apply(1f); return margin; } float num = LayoutGeometry.FitScale(LayoutGeometry.Setting(_hintsScale.Value, 1.15f, 1f, 1.5f), ((Rect)(ref bounds)).width, ((Rect)(ref bounds)).height, (float)Screen.width - margin * 2f, (float)Screen.height * 0.2f); group.Apply(num, keepScreenShift: true); if (!TryGraphicsBounds(graphics, out var bounds2)) { return margin; } float num2 = ((Rect)(ref bounds)).center.x - ((Rect)(ref bounds2)).width * 0.5f; float yMin = ((Rect)(ref bounds)).yMin; float num3 = num2 - ((Rect)(ref bounds2)).xMin + LayoutGeometry.ClampTranslation(num2, num2 + ((Rect)(ref bounds2)).width, margin, (float)Screen.width - margin); float num4 = yMin - ((Rect)(ref bounds2)).yMin + LayoutGeometry.ClampTranslation(yMin, yMin + ((Rect)(ref bounds2)).height, margin, (float)Screen.height - margin); group.ShiftScreen(new Vector2(num3, num4)); TryGraphicsBounds(graphics, out bounds2); _effectiveHints = num; return ((Rect)(ref bounds2)).yMax; } private void RebuildOpeningInventory() { Transform inventoryRoot = _inventory.m_inventoryRoot; RectTransform val = (RectTransform)(object)((inventoryRoot is RectTransform) ? inventoryRoot : null); if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy) { LayoutRebuilder.ForceRebuildLayoutImmediate(val); } if (Object.op_Implicit((Object)(object)_keyHints)) { GameObject inventoryHints = _keyHints.m_inventoryHints; if (Object.op_Implicit((Object)(object)inventoryHints) && inventoryHints.activeInHierarchy) { Transform transform = inventoryHints.transform; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null)); } inventoryHints = _keyHints.m_inventoryWithContainerHints; if (Object.op_Implicit((Object)(object)inventoryHints) && inventoryHints.activeInHierarchy) { Transform transform2 = inventoryHints.transform; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform2 is RectTransform) ? transform2 : null)); } } } private static Camera ScreenCamera(RectTransform rect) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) Canvas val = ((Component)rect).GetComponentInParent<Canvas>(); if (Object.op_Implicit((Object)(object)val)) { val = val.rootCanvas; } if (!Object.op_Implicit((Object)(object)val) || (int)val.renderMode == 0) { return null; } return val.worldCamera; } private bool TryRectBounds(RectTransform rect, out Rect bounds, ScaleGroup native = null, bool includeInactive = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0089: 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_008c: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) bounds = default(Rect); if (!Object.op_Implicit((Object)(object)rect) || (!includeInactive && !((Component)rect).gameObject.activeInHierarchy)) { return false; } Camera val = ScreenCamera(rect); rect.GetWorldCorners(_layoutCorners); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(float.PositiveInfinity, float.PositiveInfinity); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(float.NegativeInfinity, float.NegativeInfinity); for (int i = 0; i < 4; i++) { Vector3 val4 = native?.OriginalWorldPoint(rect, _layoutCorners[i]) ?? _layoutCorners[i]; Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val, val4); val2 = Vector2.Min(val2, val5); val3 = Vector2.Max(val3, val5); } if (!InventoryTooltipFinite(val2.x) || !InventoryTooltipFinite(val2.y) || !InventoryTooltipFinite(val3.x) || !InventoryTooltipFinite(val3.y)) { return false; } bounds = Rect.MinMaxRect(val2.x, val2.y, val3.x, val3.y); if (((Rect)(ref bounds)).width > 0.01f) { return ((Rect)(ref bounds)).height > 0.01f; } return false; } private bool TryBounds(List<RectTransform> rects, out Rect bounds, ScaleGroup native = null, bool includeInactive = false) { //IL_0001: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) bounds = default(Rect); bool flag = false; foreach (RectTransform rect in rects) { if (TryRectBounds(rect, out var bounds2, native, includeInactive)) { bounds = (flag ? Union(bounds, bounds2) : bounds2); flag = true; } } return flag; } private bool TryGraphicsBounds(Graphic[] graphics, out Rect bounds, ScaleGroup native = null) { //IL_0001: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0061: Unknown result type (might be due to invalid IL or missing references) bounds = default(Rect); bool flag = false; if (graphics == null) { return false; } foreach (Graphic val in graphics) { if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).isActiveAndEnabled && !(val.color.a <= 0.001f) && TryRectBounds(val.rectTransform, out var bounds2, native)) { bounds = (flag ? Union(bounds, bounds2) : bounds2); flag = true; } } return flag; } private static Rect Union(Rect a, Rect b) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) return Rect.MinMaxRect(Mathf.Min(((Rect)(ref a)).xMin, ((Rect)(ref b)).xMin), Mathf.Min(((Rect)(ref a)).yMin, ((Rect)(ref b)).yMin), Mathf.Max(((Rect)(ref a)).xMax, ((Rect)(ref b)).xMax), Mathf.Max(((Rect)(ref a)).yMax, ((Rect)(ref b)).yMax)); } private void ApplyNativePanels() { if (_playerGroup != null) { _playerGroup.Apply(1f); } if (_rightGroup != null) { _rightGroup.Apply(1f); } if (_containerGroup != null) { _containerGroup.Apply(1f); } if (_inventoryHintsGroup != null) { _inventoryHintsGroup.Apply(1f); } if (_containerHintsGroup != null) { _containerHintsGroup.Apply(1f); } } private static void RestoreGroup(ref ScaleGroup group) { if (group != null) { group.Restore(); } group = null; } private void ReleasePanels() { _inventoryWasVisible = false; ReleaseInventoryOpening(); _inventoryTooltipLearnedWidth = 0f; _inventoryTooltipWidthPrefab = null; ClearInventoryHover(); if (Object.op_Implicit((Object)(object)_inventory)) { RestoreStatReadability(_inventory.m_recipeDecription); } RestoreGroup(ref _playerGroup); RestoreGroup(ref _rightGroup); RestoreGroup(ref _containerGroup); RestoreInventoryTooltip(); _playerBounds.Clear(); _rightBounds.Clear(); _containerBounds.Clear(); } private void ReleaseInventory() { ReleasePanels(); RestoreGroup(ref _toolbarGroup); RestoreGroup(ref _inventoryHintsGroup); RestoreGroup(ref _containerHintsGroup); _toolbar = null; _inventory = null; _keyHints = null; _toolbarGraphics = (_inventoryHintGraphics = (_containerHintGraphics = null)); } private unsafe void DescribeInventory(StringBuilder report) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) report.AppendLine("Toolbar: " + ((_toolbarGroup == null) ? "not attached" : _toolbarGroup.Describe())); report.AppendLine("Player inventory: " + ((_playerGroup == null) ? "not attached; open inventory and press F8" : _playerGroup.Describe())); report.AppendLine("Right panels: " + ((_rightGroup == null) ? "not attached" : _rightGroup.Describe())); report.AppendLine("Effective inventory factors: left=" + _effectiveLeft + "; right=" + _effectiveRight + "; hints=" + _effectiveHints); Rect lastTooltipSpace = _lastTooltipSpace; report.AppendLine("Tooltip available screen rectangle: " + ((object)(*(Rect*)(&lastTooltipSpace))/*cast due to .constrained prefix*/).ToString()); report.AppendLine("Layout: single Canvas pass; fixed menu anchors and hint band; prefab-only tooltip reservation."); report.AppendLine("Hover recoveries=" + _inventoryHoverRecoveries + "; tooltip tracked=" + ((Object)(object)_inventoryTooltipVisual != (Object)null) + "; tooltip active=" + (Object.op_Implicit((Object)(object)_inventoryTooltipVisual) && ((Component)_inventoryTooltipVisual).gameObject.activeInHierarchy) + "; tooltip overlay=" + ((Object)(object)_inventoryTooltipOverlay != (Object)null)); report.AppendLine("Inventory feature stopped after error: " + _inventoryFailed); report.AppendLine("Instant inventory open=" + _instantInventoryOpen.Value + "; requested open=" + _inventoryWantsOpen + "; last finished animation state=" + _lastFinishedInventoryState + "; animation completion failed=" + _openingAnimationFailed); report.AppendLine("Requested toolbar=" + _toolbarScale.Value + "; inventory=" + _inventoryScale.Value + "; right=" + _rightScale.Value + "; hints=" + _hintsScale.Value + "; tooltip=" + _tooltipScale.Value); } private void BindInventoryOpeningSettings() { _instantInventoryOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "InstantInventoryOpen", true, "Finish the inventory's opening animation before sizing its panels, so the enlarged view opens at its settled size."); _instantInventoryClose = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "InstantInventoryClose", true, "Hide inventory panels immediately on close, preventing the brief native shrinking animation. Game close logic still runs normally."); } private void UpdateInventoryOpening(bool prepareOnly) { //IL_0107: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_openingGui != (Object)(object)_inventory) { ReleaseInventoryOpening(); _openingGui = _inventory; _openingAnimator = (Object.op_Implicit((Object)(object)_inventory) ? ((Component)_inventory).GetComponent<Animator>() : null); } bool flag = Object.op_Implicit((Object)(object)_openingAnimator) && Object.op_Implicit((Object)(object)_openingAnimator.runtimeAnimatorController) && ((Behaviour)_openingAnimator).isActiveAndEnabled && _openingAnimator.isInitialized && _openingAnimator.layerCount > 0; bool flag2 = Object.op_Implicit((Object)(object)_inventory) && (Object.op_Implicit((Object)(object)_openingAnimator) ? _openingAnimator.GetBool("visible") : InventoryGui.IsVisible()); AnimatorStateInfo val; if (!flag2) { _inventoryWasVisible = false; _finishInventoryOpening = false; if (_closedInventoryState == 0 && !prepareOnly && !InventoryGui.IsVisible() && flag && !_openingAnimator.IsInTransition(0)) { val = _openingAnimator.GetCurrentAnimatorStateInfo(0); _closedInventoryState = ((AnimatorStateInfo)(ref val)).fullPathHash; } } else if (!_inventoryWantsOpen) { _inventoryWasVisible = false; _finishInventoryOpening = true; } _inventoryWantsOpen = flag2; UpdateInventoryCloseVisibility(flag2); if (prepareOnly || !_finishInventoryOpening || !flag || !_enabled.Value || !_instantInventoryOpen.Value || _openingAnimationFailed) { return; } try { _openingAnimator.Update(0f); for (int i = 0; i < 2; i++) { bool flag3 = _openingAnimator.IsInTransition(0); AnimatorStateInfo currentAnimatorStateInfo = _openingAnimator.GetCurrentAnimatorStateInfo(0); AnimatorStateInfo val2; if (!flag3) { val = default(AnimatorStateInfo); val2 = val; } else { val2 = _openingAnimator.GetNextAnimatorStateInfo(0); } AnimatorStateInfo val3 = val2; int num = InventoryOpeningPolicy.StateToFinish(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash, ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).loop, flag3, ((AnimatorStateInfo)(ref val3)).fullPathHash, _closedInventoryState); if (num == 0) { if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash != _closedInventoryState && _closedInventoryState != 0 && !flag3) { _finishInventoryOpening = false; } break; } bool flag4 = (flag3 ? ((AnimatorStateInfo)(ref val3)).loop : ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).loop); _openingAnimator.Play(num, 0, flag4 ? 0f : 1f); _openingAnimator.Update(0f); _lastFinishedInventoryState = num; if (!_openingAnimator.IsInTransition(0)) { _finishInventoryOpening = false; break; } } } catch (Exception ex) { _openingAnimationFailed = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not finish the inventory opening animation; retaining native animation. " + ex.Message)); RequestReport(); } } private void SubscribeInventoryCanvas() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!_inventoryCanvasSubscribed) { CanvasUpdateRegistry.IsRebuildingLayout(); Canvas.preWillRenderCanvases += new WillRenderCanvases(InventoryBeforeCanvasRender); _inventoryCanvasSubscribed = true; } } private void UnsubscribeInventoryCanvas() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (_inventoryCanvasSubscribed) { Canvas.preWillRenderCanvases -= new WillRenderCanvases(InventoryBeforeCanvasRender); _inventoryCanvasSubscribed = false; } } private void InventoryBeforeCanvasRender() { if (!_ready || !((Behaviour)this).isActiveAndEnabled || _failed || _inventoryFailed || _inInventoryCanvasPass || _inventoryRenderFrame == Time.frameCount || _inventoryLayoutReadyFrame != Time.frameCount || CanvasUpdateRegistry.IsRebuildingLayout() || CanvasUpdateRegistry.IsRebuildingGraphics()) { return; } _inInventoryCanvasPass = true; _inventoryRenderFrame = Time.frameCount; try { UpdateInventoryFeatures(discover: false); } finally { _inventoryRenderFrame = Time.frameCount; _inInventoryCanvasPass = false; } } private void ReleaseInventoryOpening() { ReleaseCloseCanvas(); _inventoryCloseVisibility = null; _openingGui = null; _openingAnimator = null; _inventoryWantsOpen = (_finishInventoryOpening = false); _openingAnimationFailed = false; _closedInventoryState = (_lastFinishedInventoryState = 0); _inventoryRenderFrame = -1; } private void UpdateInventoryCloseVisibility(bool wantsOpen) { bool flag = _enabled.Value && _instantInventoryClose.Value && Object.op_Implicit((Object)(object)_inventory) && Object.op_Implicit((Object)(object)_inventory.m_inventoryRoot); if (!Object.op_Implicit((Object)(object)_inventoryCloseVisibility) && flag) { _inventoryCloseVisibility = AcquireCloseCanvas(((Component)_inventory.m_inventoryRoot).gameObject); } if (Object.op_Implicit((Object)(object)_inventoryCloseVisibility)) { bool flag2 = flag && !wantsOpen; _inventoryCloseVisibility.alpha = (flag2 ? 0f : _closeCanvasOriginalAlpha); _inventoryCloseVisibility.blocksRaycasts = !flag2 & _closeCanvasOriginalRaycasts; } } private void UpdateStatusEffectLayout() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020e: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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) if (_statusEffectLayoutFailed) { return; } try { Hud instance = Hud.instance; RectTransform val = (Object.op_Implicit((Object)(object)instance) ? instance.m_statusEffectListRoot : null); if ((Object)(object)_statusEffectRoot != (Object)(object)val || (Object.op_Implicit((Object)(object)val) && (Object)(object)((Transform)val).parent != (Object)(object)_statusEffectParent)) { ReleaseStatusEffectLayout(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Transform)val).parent)) { _statusEffectRoot = val; _statusEffectParent = ((Transform)val).parent; _statusEffectOriginalAnchor = (_statusEffectLastAnchor = val.anchoredPosition); } } if (!Object.op_Implicit((Object)(object)_statusEffectRoot) || !Object.op_Implicit((Object)(object)_statusEffectParent)) { return; } ObserveStatusEffectAnchor(); Minimap instance2 = Minimap.instance; RectTransform val2 = (RectTransform)((Object.op_Implicit((Object)(object)instance2) && Object.op_Implicit((Object)(object)instance2.m_smallRoot)) ? /*isinst with value type is only supported in some contexts*/: null); if (!_enabled.Value || (Object)(object)instance2 != (Object)(object)_map || !Object.op_Implicit((Object)(object)val2) || _minimapGroup == null || !_minimapGroup.IsValid || !((Component)_statusEffectRoot).gameObject.activeInHierarchy || Contains((Transform)(object)val2, (Transform)(object)_statusEffectRoot) || Contains((Transform)(object)_statusEffectRoot, (Transform)(object)val2) || !TryRectBounds(val2, out var bounds, _minimapGroup) || !TryRectBounds(val2, out var bounds2)) { SetStatusEffectAnchor(_statusEffectOriginalAnchor); return; } float num = ((Rect)(ref bounds2)).xMin - ((Rect)(ref bounds)).xMin; if (Mathf.Abs(num) < 0.01f) { SetStatusEffectAnchor(_statusEffectOriginalAnchor); return; } Vector2 anchoredPosition = _statusEffectRoot.anchoredPosition; Vector3 val3 = ((Transform)_statusEffectRoot).localPosition + new Vector3(_statusEffectOriginalAnchor.x - anchoredPosition.x, _statusEffectOriginalAnchor.y - anchoredPosition.y, 0f); Camera val4 = ScreenCamera(_statusEffectRoot); Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val4, _statusEffectParent.TransformPoint(val3)); Vector3 val6 = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(_statusEffectRoot, val5 + new Vector2(num, 0f), val4, ref val6)) { Vector3 val7 = _statusEffectParent.InverseTransformPoint(val6) - val3; SetStatusEffectAnchor(_statusEffectOriginalAnchor + new Vector2(val7.x, val7.y)); } } catch (Exception ex) { ReleaseStatusEffectLayout(); _statusEffectLayoutFailed = true; _notes.Add("Status effect positioning stopped: " + ex.GetType().Name + ": " + ex.Message); ((BaseUnityPlugin)this).Logger.LogError((object)("Status effect positioning stopped and restored its layout. " + ex)); RequestReport(); } } private void ObserveStatusEffectAnchor() { //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_001d: 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) Vector2 anchoredPosition = _statusEffectRoot.anchoredPosition; _statusEffectOriginalAnchor.x = ScaleGeometry.TrackOriginal(_statusEffectOriginalAnchor.x, anchoredPosition.x, _statusEffectLastAnchor.x); _statusEffectOriginalAnchor.y = ScaleGeometry.TrackOriginal(_statusEffectOriginalAnchor.y, anchoredPosition.y, _statusEffectLastAnchor.y); } private void SetStatusEffectAnchor(Vector2 anchor) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Vector2 val = _statusEffectRoot.anchoredPosition - anchor; if (((Vector2)(ref val)).sqrMagnitude > 1E-07f) { _statusEffectRoot.anchoredPosition = anchor; } _statusEffectLastAnchor = _statusEffectRoot.anchoredPosition; } private void ReleaseStatusEffectLayout() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_statusEffectRoot) && Object.op_Implicit((Object)(object)_statusEffectParent) && (Object)(object)((Transform)_statusEffectRoot).parent == (Object)(object)_statusEffectParent) { ObserveStatusEffectAnchor(); SetStatusEffectAnchor(_statusEffectOriginalAnchor); } _statusEffectRoot = null; _statusEffectParent = null; _statusEffectLayoutFailed = false; } private float DesiredInventoryTooltipScale() { return LayoutGeometry.Setting((_tooltipScale == null) ? 1.1f : _tooltipScale.Value, 1.1f, 1f, 1.4f); } private void ApplyInventoryTooltip(Rect availablePixels) { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0198: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) availablePixels = Readability.TooltipArea(availablePixels); if (!InventoryTooltipTryCurrent(out var source, out var visual, out var canvas)) { RestoreInventoryTooltip(); return; } InventoryTooltipTrack(source, visual, canvas); PrepareInventoryTooltipPresentation(); if (_inventoryTooltipTexts != null) { TMP_Text[] inventoryTooltipTexts = _inventoryTooltipTexts; foreach (TMP_Text text in inventoryTooltipTexts) { ApplyStatReadability(text); } } SettleInventoryTooltipLayout(); Vector3 val = InventoryTooltipNativeLocalScale(); Rect val2 = InventoryTooltipBounds(visual, canvas, val, _inventoryTooltipBasePosition); if (InventoryTooltipUsable(val2)) { float desired = DesiredInventoryTooltipScale(); Rect val3 = InventoryTooltipScreenRect(); Rect area = Rect.MinMaxRect(Mathf.Max(((Rect)(ref val3)).xMin, ((Rect)(ref availablePixels)).xMin), Mathf.Max(((Rect)(ref val3)).yMin, ((Rect)(ref availablePixels)).yMin), Mathf.Min(((Rect)(ref val3)).xMax, ((Rect)(ref availablePixels)).xMax), Mathf.Min(((Rect)(ref val3)).yMax, ((Rect)(ref availablePixels)).yMax)); float num = Readability.TooltipScale(desired, val2, area); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(val.x * num, val.y * num, val.z); Rect val5 = InventoryTooltipBounds(visual, canvas, val4, _inventoryTooltipBasePosition); float num2 = ((Rect)(ref area)).center.x - ((Rect)(ref val5)).center.x; float num3 = 0f; if (((Rect)(ref val5)).height > ((Rect)(ref area)).height) { num3 = ((Rect)(ref area)).center.y - ((Rect)(ref val5)).center.y; } else if (((Rect)(ref val5)).yMax > ((Rect)(ref area)).yMax) { num3 = ((Rect)(ref area)).yMax - ((Rect)(ref val5)).yMax; } else if (((Rect)(ref val5)).yMin < ((Rect)(ref area)).yMin) { num3 = ((Rect)(ref area)).yMin - ((Rect)(ref val5)).yMin; } Vector3 val6 = InventoryTooltipShiftedLocalPosition(visual, canvas, _inventoryTooltipBasePosition, new Vector2(num2, num3)); Vector3 val7 = ((Transform)visual).localScale - val4; if (((Vector3)(ref val7)).sqrMagnitude > 1E-07f) { ((Transform)visual).localScale = val4; } val7 = ((Transform)visual).localPosition - val6; if (((Vector3)(ref val7)).sqrMagnitude > 1E-07f) { ((Transform)visual).localPosition = val6; } _inventoryTooltipAdjusted = true; } } private void RestoreInventoryTooltip() { //IL_0063: 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) RestoreInventoryTooltipPresentation(); if (_inventoryTooltipTexts != null) { TMP_Text[] inventoryTooltipTexts = _inventoryTooltipTexts; foreach (TMP_Text text in inventoryTooltipTexts) { RestoreStatReadability(text); } } if (_inventoryTooltipAdjusted) { if (Object.op_Implicit((Object)(object)_inventoryTooltipVisual) && (Object)(object)((Transform)_inventoryTooltipVisual).parent == (Object)(object)_inventoryTooltipVisualParent) { ((Transform)_inventoryTooltipVisual).localScale = InventoryTooltipNativeLocalScale(); ((Transform)_inventoryTooltipVisual).localPosition = _inventoryTooltipBasePosition; InventoryTooltipClampScreen(_inventoryTooltipVisual, _inventoryTooltipCanvas); } _inventoryTooltipAdjusted = false; } } private float InventoryTooltipNativeWidth() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.m_playerGrid)) { return 0f; } Canvas componentInParent = ((Component)instance.m_playerGrid).GetComponentInParent<Canvas>(); if (!Object.op_Implicit((Object)(object)componentInParent)) { return 0f; } GameObject elementPrefab = instance.m_playerGrid.m_elementPrefab; UITooltip val = (Object.op_Implicit((Object)(object)elementPrefab) ? elementPrefab.GetComponent<UITooltip>() : null); GameObject val2 = (Object.op_Implicit((Object)(object)val) ? val.m_tooltipPrefab : null); if ((Object)(object)_inventoryTooltipWidthPrefab == (Object)(object)val2 && _inventoryTooltipLearnedWidth > 0f) { return _inventoryTooltipLearnedWidth * InventoryTooltipCanvasScale(componentInParent); } _inventoryTooltipWidthPrefab = val2; _inventoryTooltipLearnedWidth = 0f; if (Object.op_Implicit((Object)(object)val2) && val2.transform.childCount > 0) { Transform child = val2.transform.GetChild(0); RectTransform val3 = (RectTransform)(object)((child is RectTransform) ? child : null); if (Object.op_Implicit((Object)(object)val3)) { Transform transform = val2.transform; Matrix4x4 matrix = ((Component)componentInParent).transform.localToWorldMatrix * Matrix4x4.TRS(transform.localPosition, transform.localRotation, transform.localScale) * Matrix4x4.TRS(((Transform)val3).localPosition, ((Transform)val3).localRotation, ((Transform)val3).localScale); Rect rectangle = InventoryTooltipBounds(val3, componentInParent, matrix); if (InventoryTooltipUsable(rectangle)) { InventoryTooltipRememberWidth(((Rect)(ref rectangle)).width, componentInParent); } } } return _inventoryTooltipLearnedWidth * InventoryTooltipCanvasScale(componentInParent); } private bool InventoryTooltipTryCurrent(out UITooltip source, out RectTransform visual, out Canvas canvas) { source = null; visual = null; canvas = null; if (InventoryTooltipCurrentField == null || InventoryTooltipObjectField == null) { if (!_inventoryTooltipFieldsWarned) { _inventoryTooltipFieldsWarned = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"This Valheim build has different tooltip fields; tooltip fitting is unavailable."); } return false; } _ = InventoryGui.instance; if (!InventoryTooltipScopeOpen()) { return false; } object? value = InventoryTooltipCurrentField.GetValue(null); source = (UITooltip)((value is UITooltip) ? value : null); object? value2 = InventoryTooltipObjectField.GetValue(null); GameObject val = (GameObject)((value2 is GameObject) ? value2 : null); if (!Object.op_Implicit((Object)(object)source) || !((Behaviour)source).isActiveAndEnabled || !Object.op_Implicit((Object)(object)val) || val.transform.childCount == 0) { return false; } if (!InventoryTooltipSourceInScope(source)) { return false; } Transform child = val.transform.GetChild(0); visual = (RectTransform)(object)((child is RectTransform) ? child : null); canvas = ((Component)source).GetComponentInParent<Canvas>(); if (Object.op_Implicit((Object)(object)visual) && Object.op_Implicit((Object)(object)((Transform)visual).parent)) { return Object.op_Implicit((Object)(object)canvas); } return false; } private static bool InventoryTooltipInside(RectTransfor