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 InventoryActions v1.1.0
InventoryActions.dll
Decompiled 4 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using InventoryActions.LocalizationManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("InventoryActions")] [assembly: AssemblyDescription("Standalone inventory actions for Valheim")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InventoryActions")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1FBE0C8C-42DE-4C9A-9C7F-74280DC0B9AB")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace InventoryActions { [BepInPlugin("sighsorry.InventoryActions", "InventoryActions", "1.1.0")] [BepInIncompatibility("sighsorry.InventorySlots")] [BepInIncompatibility("goldenrevolver.quick_stack_store")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class InventoryActionsPlugin : BaseUnityPlugin { private enum RestockMode { CurrentContainerMatchingStacks, AreaFavoriteRestock } private enum AreaOwnershipFailure { None, InvalidRequest, NotOwner, Unsupported, Busy, InUse, NoAccess, OutOfRange, Unavailable } private sealed class AreaContainerTransferSession { public Player Player; public Inventory PlayerInventory; public Container Anchor; public ZDOID AnchorId; public AreaContainerActionKind Action; public List<Container> Targets; public int NextTargetIndex; public Container? PendingTarget; public AreaOwnershipRequestIdentity PendingIdentity; public long PendingGrantToken; public AreaOwnershipHandoffDecision PendingDecision; public uint GrantDataRevision; public ushort GrantOwnerRevision; public long GrantExpiresAt; public int TotalMoved; public bool PlayerInventoryChanged; public int ChangedContainerVfxCount; public int VfxLimit; public bool AllowOpenQuickStackAnchor; } private sealed class ButtonPositionOffsetEditorState { public string LastEntryValue { get; set; } = ""; public string X { get; set; } = "0"; public string Y { get; set; } = "0"; } private sealed class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } private sealed class ConfigurationManagerAttributes { public bool? Browsable { get; set; } public int? Order { get; set; } public Action<ConfigEntryBase>? CustomDrawer { get; set; } } public enum Toggle { Off, On } private sealed class RestockTargetLimitEditorRow { public string Item { get; set; } public string Amount { get; set; } public RestockRuleMode Mode { get; set; } public RestockTargetLimitEditorRow(string item, string amount, RestockRuleMode mode = RestockRuleMode.Existing) { Item = item; Amount = amount; Mode = mode; } } private static class FavoriteMemoryAccess { internal static readonly FieldRef<Player, bool> IsLoading = AccessTools.FieldRefAccess<Player, bool>("m_isLoading"); } private enum InventorySlideButton { Trash, Restock, Exclude } private sealed class InventoryButtonSlide : MonoBehaviour, ICanvasRaycastFilter { private const float Peek = 7f; private const float Duration = 0.15f; private const float CloseDelay = 0.3f; internal InventoryGui Owner; internal RectTransform Content; private InventorySlideButton _kind; private RectTransform _clip; private CanvasGroup _input; private Animator? _animator; private Camera? _camera; private EventSystem? _eventSystem; private PointerEventData? _pointer; private readonly List<RaycastResult> _hits = new List<RaycastResult>(); private float _progress; private float _size; private float _lastInside = float.NegativeInfinity; private bool _wasOpen; private bool _hasButtons; internal bool PointerOver { get; private set; } internal Camera? Camera => _camera; private bool ButtonEnabled { get { if (_kind != InventorySlideButton.Trash) { return IsItemRuleButtonEnabled(_kind == InventorySlideButton.Restock); } return IsInventoryTrashButtonEnabled(); } } private InventoryButtonMode Mode => ((_kind == InventorySlideButton.Trash) ? _trashButtonMode : ((_kind == InventorySlideButton.Restock) ? _restockButtonMode : _autoPickupButtonMode))?.Value ?? InventoryButtonMode.Auto; private float VisibleHeight => Mathf.Lerp(7f, _size, _progress); internal void Initialize(InventoryGui gui, InventorySlideButton kind) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0066: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) Owner = gui; _kind = kind; _animator = ((Component)gui).GetComponent<Animator>(); Canvas componentInParent = ((Component)gui).GetComponentInParent<Canvas>(); _camera = ((componentInParent != null) ? componentInParent.worldCamera : null); _clip = (RectTransform)((Component)this).transform; RectTransform clip = _clip; RectTransform clip2 = _clip; RectTransform clip3 = _clip; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); clip3.pivot = val; Vector2 anchorMin = (clip2.anchorMax = val); clip.anchorMin = anchorMin; _input = ((Component)this).gameObject.AddComponent<CanvasGroup>(); GameObject val3 = new GameObject("Buttons", new Type[1] { typeof(RectTransform) }); Content = (RectTransform)val3.transform; ((Transform)Content).SetParent(((Component)this).transform, false); RectTransform content = Content; RectTransform content2 = Content; RectTransform content3 = Content; ((Vector2)(ref val))..ctor(0f, 1f); content3.pivot = val; anchorMin = (content2.anchorMax = val); content.anchorMin = anchorMin; Content.sizeDelta = Vector2.zero; } internal void Layout(Vector3 origin, int rows) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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) InventoryGrid playerGrid = Owner.m_playerGrid; float num = Mathf.Max(1f, playerGrid.m_elementSpace); _size = Mathf.Clamp(num * 0.72f, 42f, 58f); int columns = Mathf.Max(1, (playerGrid.m_inventory != null) ? playerGrid.m_inventory.GetWidth() : 8); _hasButtons = ButtonEnabled; int columnsFromRight = ((_kind != InventorySlideButton.Trash) ? GetItemRuleColumnsFromRight(_kind == InventorySlideButton.Restock) : 0); Vector3 localPosition = origin + CalculateInventoryBottomButtonPosition(columns, rows, num, _size, columnsFromRight); ((Transform)_clip).localPosition = localPosition; _clip.sizeDelta = new Vector2(_size, _size); ApplyOffset(); } public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); if (_hasButtons && RectTransformUtility.ScreenPointToLocalPointInRectangle(_clip, screenPoint, eventCamera, ref val) && val.x >= 0f) { float x = val.x; Rect rect = _clip.rect; if (x <= ((Rect)(ref rect)).width && val.y <= 0f) { return val.y >= 0f - VisibleHeight; } } return false; } private void ApplyOffset() { //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_0016: 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) ((Transform)Content).localPosition = -((Transform)_clip).localPosition + Vector3.up * (_size - VisibleHeight); } private bool HitVisibleStrip() { //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_005d: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //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) if (!IsRaycastLocationValid(Vector2.op_Implicit(Input.mousePosition), _camera)) { return false; } EventSystem current = EventSystem.current; if ((Object)(object)current == (Object)null) { return false; } if ((Object)(object)_eventSystem != (Object)(object)current) { _eventSystem = current; _pointer = new PointerEventData(current); } ((AbstractEventData)_pointer).Reset(); _pointer.position = Vector2.op_Implicit(Input.mousePosition); _hits.Clear(); current.RaycastAll(_pointer, _hits); if (_hits.Count > 0) { RaycastResult val = _hits[0]; return ((RaycastResult)(ref val)).gameObject.transform.IsChildOf(((Component)this).transform); } return false; } private void LateUpdate() { if ((Object)(object)Owner == (Object)null || (Object)(object)_instance == (Object)null) { return; } bool flag = InventoryGui.IsVisible() && ((Object)(object)_animator == (Object)null || _animator.GetBool("visible")); bool flag2 = ((Behaviour)_instance).isActiveAndEnabled && (Object)(object)Player.m_localPlayer != (Object)null && !Player.m_localPlayer.m_isLoading && CanShowItemRules(Owner); _hasButtons = ButtonEnabled; _input.blocksRaycasts = flag && flag2 && _hasButtons; if (!flag || !flag2) { PointerOver = false; _wasOpen = false; return; } if (!_wasOpen) { _progress = 0f; _lastInside = float.NegativeInfinity; ApplyOffset(); } _wasOpen = true; PointerOver = HitVisibleStrip(); bool flag3 = _kind != InventorySlideButton.Trash && (Object)(object)_itemRuleEditor != (Object)null && _itemRuleEditor.IsPopupOpenFor(_kind == InventorySlideButton.Restock); int num; if (!(PointerOver || flag3)) { num = (ZInput.IsGamepadActive() ? 1 : 0); if (num == 0) { goto IL_0139; } } else { num = 1; } _lastInside = Time.unscaledTime; goto IL_0139; IL_0139: float num2 = ((num != 0 || Time.unscaledTime - _lastInside < 0.3f) ? 1 : 0); _progress = ((Mode == InventoryButtonMode.On) ? 1f : Mathf.MoveTowards(_progress, num2, Time.unscaledDeltaTime / 0.15f)); ApplyOffset(); if (flag3) { _itemRuleEditor.PositionPopup(); } } private void OnDisable() { PointerOver = false; _wasOpen = false; } private void OnDestroy() { if (InventoryButtonSlides[(int)_kind] == this) { InventoryButtonSlides[(int)_kind] = null; } } } private enum InventoryButtonMode { Off, Auto, On } private sealed class ItemRuleEditor : MonoBehaviour { private const float RowHeight = 38f; private const float PopupWidth = 300f; private const float PopupChromeHeight = 116f; internal InventoryGui Owner; private RectTransform _root; private RectTransform _toolbar; private RectTransform _popup; private RectTransform _content; private RectTransform _viewport; private Button _restockButton; private Button _excludeButton; private Button _backdrop; private Sprite _restockIcon; private Sprite _excludeIcon; private Sprite? _ruleButtonSprite; private int _visibleRowCount = 1; private TMP_Text _title; private TMP_Text _scope; private TMP_Text _status; private TMP_FontAsset _font; private Material _fontMaterial; private readonly List<Button> _rowButtons = new List<Button>(); private readonly List<TMP_InputField> _fields = new List<TMP_InputField>(); private readonly List<Sprite> _ownedIcons = new List<Sprite>(); private readonly Dictionary<string, ItemData?> _resolved = new Dictionary<string, ItemData>(StringComparer.Ordinal); private List<ItemRuleConfigCore.Entry> _entries = new List<ItemRuleConfigCore.Entry>(); private ItemRuleConfigCore.Entry? _registration; private string _snapshot = ""; private bool _restock = true; private int _registrationMax; private float _hoverStarted = -1f; private float _outsideStarted = -1f; private bool? _hoverMode; private Camera? _camera; internal Animator? _animator; private static readonly int VisibleParameter = Animator.StringToHash("visible"); private ScrollRect _scroll; private readonly Color _text = new Color(1f, 0.94f, 0.8f); private readonly Color _gold = new Color(1f, 0.8f, 0.36f); internal bool Pinned { get; private set; } private ConfigEntry<string> Setting { get { if (!_restock) { return _autoPickupExcludedItemsConfig; } return _restockTargetStackLimitsConfig; } } private bool Open { get { if ((Object)(object)_popup != (Object)null) { return ((Component)_popup).gameObject.activeSelf; } return false; } } private bool CanShow { get { if ((Object)(object)_instance != (Object)null && ((Behaviour)_instance).isActiveAndEnabled && (Object)(object)Owner != (Object)null && InventoryGui.IsVisible() && ((Object)(object)_animator == (Object)null || _animator.GetBool(VisibleParameter)) && !Menu.IsVisible() && !Console.IsVisible()) { return CanShowItemRules(Owner); } return false; } } private bool HasBlockingDialog { get { if (!IsDialogActive((Component?)(object)Owner.m_splitDialog) && !IsDialogActive((Component?)(object)Owner.m_variantDialog) && !IsDialogActive((Component?)(object)Owner.m_skillsDialog) && !IsDialogActive((Component?)(object)Owner.m_textsDialog) && !IsDialogActive((Component?)(object)Owner.m_achievementsPanel) && (!((Object)(object)Owner.m_trophiesPanel != (Object)null) || !Owner.m_trophiesPanel.activeInHierarchy)) { if ((Object)(object)Runtime.TrashConfirmDialog != (Object)null) { return Runtime.TrashConfirmDialog.activeInHierarchy; } return false; } return true; } } internal bool OwnsPointer { get { if (Open) { return Contains(_popup); } return false; } } private static ColorBlock InputColors { get { //IL_0002: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) ColorBlock result = default(ColorBlock); ((ColorBlock)(ref result)).normalColor = new Color(0.132f, 0.132f, 0.132f, 0.502f); ((ColorBlock)(ref result)).highlightedColor = new Color(0.39f, 0.4f, 0.4f, 0.502f); ((ColorBlock)(ref result)).selectedColor = new Color(0.39f, 0.4f, 0.4f, 0.502f); ((ColorBlock)(ref result)).pressedColor = new Color(0.132f, 0.132f, 0.132f, 0.65f); ((ColorBlock)(ref result)).disabledColor = new Color(0.132f, 0.132f, 0.132f, 0.35f); ((ColorBlock)(ref result)).colorMultiplier = 1f; ((ColorBlock)(ref result)).fadeDuration = 0.08f; return result; } } internal bool IsPopupOpenFor(bool restock) { if (Open) { return _restock == restock; } return false; } private static bool IsDialogActive(Component? dialog) { if ((Object)(object)dialog != (Object)null) { return dialog.gameObject.activeInHierarchy; } return false; } private string L(string key, string fallback) { return LocalizeUi("$" + "InventoryActions".ToLowerInvariant() + "_rules_" + key, fallback); } internal bool Initialize(InventoryGui gui) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_01a3: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) Owner = gui; _animator = ((Component)gui).GetComponent<Animator>(); _root = (RectTransform)((Component)this).transform; Canvas componentInParent = ((Component)gui).GetComponentInParent<Canvas>(); _camera = ((componentInParent != null) ? componentInParent.worldCamera : null); TMP_Text val = ((Component)gui.m_takeAllButton).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)val == (Object)null || (Object)(object)val.font == (Object)null) { val = ((IEnumerable<TMP_Text>)((Component)gui).GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text text) => (Object)(object)text.font != (Object)null)); } if ((Object)(object)val == (Object)null) { return false; } _font = val.font; _fontMaterial = ((val != null) ? val.fontSharedMaterial : null) ?? ((TMP_Asset)_font).material; _toolbar = Rect("Toolbar", (Transform)(object)gui.m_playerGrid.m_gridRoot, Vector2.zero, Vector2.zero); _restockButton = RuleButton("InventoryActions_RestockRules", restock: true); _excludeButton = RuleButton("InventoryActions_AutoPickupRules", restock: false); _ruleButtonSprite = ((Selectable)_restockButton).image.sprite; ((Component)_restockButton).gameObject.AddComponent<UIDragHandler>().m_onReleasedOn = delegate { ClickTool(restock: true); }; ((Component)_excludeButton).gameObject.AddComponent<UIDragHandler>().m_onReleasedOn = delegate { ClickTool(restock: false); }; _restockIcon = CreateRuleIcon(restock: true); _excludeIcon = CreateRuleIcon(restock: false); _backdrop = Button((Transform)(object)_root, "Outside", "", new UnityAction(Close)); Stretch((RectTransform)((Component)_backdrop).transform); ((Graphic)((Component)_backdrop).GetComponent<Image>()).color = Color.clear; ((Component)_backdrop).gameObject.SetActive(false); _popup = Rect("Popup", (Transform)(object)_root, new Vector2(300f, 160f), Vector2.zero); Image val2 = ((Component)_popup).gameObject.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.15f, 0.13f, 0.14f, 0.99f); ApplyWoodenPanelStyle(val2); _title = Text((Transform)(object)_popup, "Title", "", 19f); Frame(_title.rectTransform, 12f, -10f, 276f, 28f); _scope = Text((Transform)(object)_popup, "Scope", "", 13f); Frame(_scope.rectTransform, 12f, -39f, 276f, 34f); _viewport = Rect("Viewport", (Transform)(object)_popup, new Vector2(276f, 38f), new Vector2(12f, -78f)); ((Graphic)((Component)_viewport).gameObject.AddComponent<Image>()).color = Color.clear; ((Component)_viewport).gameObject.AddComponent<RectMask2D>(); _content = Rect("Content", (Transform)(object)_viewport, new Vector2(276f, 38f), Vector2.zero); _scroll = ((Component)_viewport).gameObject.AddComponent<ScrollRect>(); _scroll.viewport = _viewport; _scroll.content = _content; _scroll.horizontal = false; _scroll.vertical = true; _scroll.movementType = (MovementType)2; _scroll.inertia = false; _scroll.scrollSensitivity = 30f; _status = Text((Transform)(object)_popup, "Status", "", 12f); ((Component)_popup).gameObject.SetActive(false); return true; } internal void PositionToolbar(Vector3 gridOrigin, int visibleRows) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (!CanShow) { EndInteraction(); return; } if (Open && (!IsItemRuleButtonEnabled(_restock) || HasBlockingDialog)) { Close(); } InventoryGrid grid = Owner.m_playerGrid; RectTransform gridRoot = grid.m_gridRoot; if ((Object)(object)((Transform)_toolbar).parent != (Object)(object)gridRoot) { ((Transform)_toolbar).SetParent((Transform)(object)gridRoot, false); } float size = Mathf.Clamp(Mathf.Max(1f, grid.m_elementSpace) * 0.72f, 42f, 58f); ((Transform)_toolbar).localPosition = Vector3.zero; Place(_restockButton, restock: true); Place(_excludeButton, restock: false); ConfigureInventoryActionIcon(_restockButton, size, _restockIcon); ConfigureInventoryActionIcon(_excludeButton, size, _excludeIcon); bool acceptsHeldItem = CanRegisterHeldItem(); UpdateRuleButtonVisual(_restockButton, acceptsHeldItem); UpdateRuleButtonVisual(_excludeButton, acceptsHeldItem); ((Component)_toolbar).gameObject.SetActive(true); if (Open) { PositionPopup(); } void Place(Button button, bool restock) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) bool flag = IsItemRuleButtonEnabled(restock); ((Component)button).gameObject.SetActive(flag); if (flag) { InventorySlideButton kind = (restock ? InventorySlideButton.Restock : InventorySlideButton.Exclude); RectTransform val = EnsureInventoryButtonSlide(Owner, gridOrigin, visibleRows, kind, (Transform?)(object)_toolbar); if ((Object)(object)((Component)button).transform.parent != (Object)(object)val) { ((Component)button).transform.SetParent((Transform)(object)val, false); } Frame((RectTransform)((Component)button).transform, 0f, 0f, size, size); int columns = Mathf.Max(1, (grid.m_inventory != null) ? grid.m_inventory.GetWidth() : 8); Vector3 localPosition = gridOrigin + CalculateInventoryBottomButtonPosition(columns, visibleRows, Mathf.Max(1f, grid.m_elementSpace), size, GetItemRuleColumnsFromRight(restock)); ((Component)button).transform.localPosition = localPosition; } } } internal void PositionPopup() { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) Rect rect = _root.rect; RectTransform val = (RectTransform)((Component)(_restock ? _restockButton : _excludeButton)).transform; RectTransform root = _root; Rect rect2 = val.rect; float xMax = ((Rect)(ref rect2)).xMax; rect2 = val.rect; Vector3 val2 = ((Transform)root).InverseTransformPoint(((Transform)val).TransformPoint(new Vector3(xMax, ((Rect)(ref rect2)).yMin))); float x = val2.x; rect2 = _popup.rect; float num = x - ((Rect)(ref rect2)).width; float num2 = val2.y - 6f; float num3 = num2 - ((Rect)(ref rect)).yMin - 8f; float height = Mathf.Min((float)Mathf.Min(6, _visibleRowCount) * 38f, Mathf.Max(38f, num3 - 116f)); ResizePopupViewport(height); float num4 = num; float num5 = ((Rect)(ref rect)).xMin + 8f; float num6 = ((Rect)(ref rect)).xMin + 8f; float xMax2 = ((Rect)(ref rect)).xMax; rect2 = _popup.rect; num = Mathf.Clamp(num4, num5, Mathf.Max(num6, xMax2 - ((Rect)(ref rect2)).width - 8f)); float num7 = num2; float yMin = ((Rect)(ref rect)).yMin; rect2 = _popup.rect; float num8 = yMin + ((Rect)(ref rect2)).height + 8f; float yMin2 = ((Rect)(ref rect)).yMin; rect2 = _popup.rect; num2 = Mathf.Clamp(num7, num8, Mathf.Max(yMin2 + ((Rect)(ref rect2)).height + 8f, ((Rect)(ref rect)).yMax - 8f)); ((Transform)_popup).localPosition = new Vector3(num, num2, 0f); } private void ResizePopupViewport(float height) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005c: 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_00ad: 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) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) Rect rect = _viewport.rect; if (!(Mathf.Abs(((Rect)(ref rect)).height - height) < 0.1f)) { rect = _popup.rect; float width = ((Rect)(ref rect)).width - 24f; RectTransform popup = _popup; rect = _popup.rect; popup.sizeDelta = new Vector2(((Rect)(ref rect)).width, 116f + height); Frame(_viewport, 12f, -78f, width, height); Frame(_status.rectTransform, 12f, -82f - height, width, 30f); Vector2 anchoredPosition = _content.anchoredPosition; float y = anchoredPosition.y; rect = _content.rect; anchoredPosition.y = Mathf.Clamp(y, 0f, Mathf.Max(0f, ((Rect)(ref rect)).height - height)); _content.anchoredPosition = anchoredPosition; } } private bool CanRegisterHeldItem() { Player localPlayer = Player.m_localPlayer; ItemData dragItem = Owner.m_dragItem; if (HasHeldTrashCandidate(Owner) && (Object)(object)localPlayer != (Object)null && dragItem?.m_shared != null && (Object)(object)dragItem.m_dropPrefab != (Object)null && Owner.m_dragInventory == ((Humanoid)localPlayer).GetInventory() && Owner.m_dragInventory.ContainsItem(dragItem)) { if (!((Object)(object)Owner.m_splitDialog == (Object)null)) { return !Owner.m_splitDialog.IsActive; } return true; } return false; } private void UpdateRuleButtonVisual(Button button, bool acceptsHeldItem) { //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_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) SetInventoryActionIconVisual(button, acceptsHeldItem); Image image = ((Selectable)button).image; Sprite? obj; if (!acceptsHeldItem) { SpriteState spriteState = ((Selectable)button).spriteState; if ((Object)(object)((SpriteState)(ref spriteState)).disabledSprite != (Object)null) { spriteState = ((Selectable)button).spriteState; obj = ((SpriteState)(ref spriteState)).disabledSprite; goto IL_003d; } } obj = _ruleButtonSprite; goto IL_003d; IL_003d: Sprite val = obj; if ((Object)(object)image.sprite != (Object)(object)val) { image.sprite = val; } } private Button RuleButton(string name, bool restock) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown Button val = EnsureActionButton(_toolbar, Owner.m_takeAllButton, name, "", (UnityAction)delegate { ClickTool(restock); }); val.onClick = new ButtonClickedEvent(); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { ClickTool(restock); }); ((Selectable)val).interactable = true; UIGamePad[] componentsInChildren = ((Component)val).GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val2 in componentsInChildren) { ((Behaviour)val2).enabled = false; if ((Object)(object)val2.m_hint != (Object)null && val2.m_hint.transform.IsChildOf(((Component)val).transform)) { val2.m_hint.SetActive(false); } } UITooltip component = ((Component)val).GetComponent<UITooltip>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } return val; } private void ApplyWoodenPanelStyle(Image target) { //IL_0101: 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) object obj; if (!((Object)(object)Owner.m_splitDialog != (Object)null)) { obj = null; } else { Transform obj2 = ((Component)Owner.m_splitDialog).transform.Find("win_bkg/border (1)"); obj = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); } Image val = (Image)obj; if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null) { object obj3; if (!((Object)(object)Owner.m_player != (Object)null)) { obj3 = null; } else { Transform obj4 = ((Transform)Owner.m_player).Find("Bkg"); obj3 = ((obj4 != null) ? ((Component)obj4).GetComponent<Image>() : null); } val = (Image)obj3; } if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null) { object obj5; if (!((Object)(object)Owner.m_crafting != (Object)null)) { obj5 = null; } else { Transform obj6 = ((Transform)Owner.m_crafting).Find("Bkg"); obj5 = ((obj6 != null) ? ((Component)obj6).GetComponent<Image>() : null); } val = (Image)obj5; } if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sprite == (Object)null)) { target.sprite = val.sprite; target.type = val.type; ((Graphic)target).material = ((Graphic)val).material; ((Graphic)target).color = ((Graphic)val).color; target.pixelsPerUnitMultiplier = val.pixelsPerUnitMultiplier; target.fillCenter = val.fillCenter; target.preserveAspect = val.preserveAspect; } } private bool Contains(RectTransform rect) { //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) return RectTransformUtility.RectangleContainsScreenPoint(rect, Vector2.op_Implicit(Input.mousePosition), _camera); } private void Update() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown if (!CanShow || (Object)(object)Player.m_localPlayer == (Object)null || Player.m_localPlayer.m_isLoading) { EndInteraction(); return; } if (Open && !IsItemRuleButtonEnabled(_restock)) { Close(); } if (!IsItemRuleButtonEnabled(restock: true) && !IsItemRuleButtonEnabled(restock: false)) { Hide(); return; } if (HasBlockingDialog) { Close(); return; } if (Open && Pinned && (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("JoyButtonB"))) { Close(); return; } if (Open && !string.Equals(_snapshot, Setting.Value, StringComparison.Ordinal) && !_fields.Any((TMP_InputField field) => field.isFocused)) { LoadList(_restock, Pinned); } bool? flag = ((IsPointerOverSlide(InventorySlideButton.Restock) && IsItemRuleButtonEnabled(restock: true) && ((Component)_restockButton).gameObject.activeInHierarchy && Contains((RectTransform)((Component)_restockButton).transform)) ? new bool?(true) : ((IsPointerOverSlide(InventorySlideButton.Exclude) && IsItemRuleButtonEnabled(restock: false) && ((Component)_excludeButton).gameObject.activeInHierarchy && Contains((RectTransform)((Component)_excludeButton).transform)) ? new bool?(false) : ((bool?)null))); if (Pinned) { return; } if (HasHeldTrashCandidate(Owner)) { if (Open) { Close(); } return; } if (flag != _hoverMode) { _hoverMode = flag; _hoverStarted = Time.unscaledTime; } if (flag.HasValue) { _outsideStarted = -1f; if (Time.unscaledTime - _hoverStarted >= 0.3f && (!Open || _restock != flag.Value)) { LoadList(flag.Value, pin: false); } } else if (Open && Contains(_popup)) { _outsideStarted = -1f; } else if (Open) { if (_outsideStarted < 0f) { _outsideStarted = Time.unscaledTime; } if (Time.unscaledTime - _outsideStarted >= 0.25f) { Close(); } } } private void ClickTool(bool restock) { if (CanShow && !HasBlockingDialog && IsItemRuleButtonEnabled(restock)) { if (HasHeldTrashCandidate(Owner)) { RegisterHeldItem(restock); } else { LoadList(restock, pin: true); } } } private void LoadList(bool restock, bool pin) { if (CanShow && !HasBlockingDialog && IsItemRuleButtonEnabled(restock)) { CloseInventoryTrashConfirmDialog(); _restock = restock; _snapshot = Setting.Value; _entries = ItemRuleConfigCore.Read(_snapshot, restock); _resolved.Clear(); _registration = null; Pinned = pin; ((Component)_popup).gameObject.SetActive(true); ((Component)_backdrop).gameObject.SetActive(pin); Render(); } } private void RegisterHeldItem(bool restock) { Player localPlayer = Player.m_localPlayer; ItemData dragItem = Owner.m_dragItem; if (!CanRegisterHeldItem() || (Object)(object)localPlayer == (Object)null || dragItem?.m_shared == null || (Object)(object)dragItem.m_dropPrefab == (Object)null) { return; } string key = ItemRuleConfigCore.PrefabKey(((Object)dragItem.m_dropPrefab).name); if (key.Length == 0) { return; } LoadList(restock, pin: true); ItemRuleConfigCore.Entry entry = _entries.LastOrDefault((ItemRuleConfigCore.Entry e) => (!restock) ? string.Equals(ItemRuleConfigCore.PrefabKey(e.Key), key, StringComparison.OrdinalIgnoreCase) : (RestockTargetLimitCore.NormalizeResourceToken(e.Key) == RestockTargetLimitCore.NormalizeResourceToken(key))); bool flag = entry == null; if (entry == null) { ItemRuleConfigCore.Entry entry2 = null; if (restock) { foreach (string restockTargetLookupToken in GetRestockTargetLookupTokens(dragItem)) { string normalized = RestockTargetLimitCore.NormalizeResourceToken(restockTargetLookupToken); entry2 = _entries.LastOrDefault((ItemRuleConfigCore.Entry e) => RestockTargetLimitCore.NormalizeResourceToken(e.Key) == normalized); if (entry2 != null) { break; } } } entry = new ItemRuleConfigCore.Entry { Start = -1, Key = key, Mode = (entry2?.Mode ?? RestockRuleMode.Existing), Amount = RestockTargetLimitCore.ClampAmountForEditor(entry2?.Amount ?? dragItem.m_shared.m_maxStackSize.ToString(CultureInfo.InvariantCulture), dragItem.m_shared.m_maxStackSize) }; _entries.Add(entry); } _resolved[entry.Key] = dragItem; Owner.SetupDragItem((ItemData)null, (Inventory)null, 0); if (flag && !Save()) { _entries.Remove(entry); } else if (restock) { _registration = entry; _registrationMax = Mathf.Max(1, dragItem.m_shared.m_maxStackSize); Pin(); Render(); if (_fields.Count > 0) { ((Selectable)_fields[0]).Select(); _fields[0].ActivateInputField(); } } else { Render(); _status.text = L("registered", "Registered") + ": " + GetLocalizedItemName(dragItem); ScrollTo(entry.Key); } } private void Pin() { Pinned = true; ((Component)_backdrop).gameObject.SetActive(true); } private bool Save() { if (!string.Equals(Setting.Value, _snapshot, StringComparison.Ordinal)) { _status.text = L("conflict", "Config changed. Finish editing to reload."); return false; } string text = ItemRuleConfigCore.Write(_snapshot, _entries, _restock); List<ItemRuleConfigCore.Entry> list = ItemRuleConfigCore.Read(text, _restock); if (!(from entry in _entries where !entry.Removed select entry.Key).SequenceEqual(list.Select((ItemRuleConfigCore.Entry entry) => entry.Key))) { _status.text = L("save_failed", "Could not save config."); return false; } try { if (text != _snapshot && !ItemRuleConfigStore.Save(Setting, _snapshot, text)) { _status.text = L("conflict", "Config changed. Finish editing to reload."); return false; } } catch (Exception ex) { Log.LogWarning((object)("Could not save item rules: " + ex.Message)); _status.text = L("save_failed", "Could not save config."); return false; } ItemRuleConfigCore.AcceptSaved(_entries, list); _snapshot = text; _status.text = L("saved", "Saved"); return true; } private void ScrollTo(string key) { int num = _entries.FindLastIndex((ItemRuleConfigCore.Entry e) => e.Key == key); if (num >= 0) { _scroll.verticalNormalizedPosition = ((_entries.Count <= 1) ? 1f : (1f - (float)num / (float)(_entries.Count - 1))); } } private ItemData? Resolve(string key) { if (_resolved.TryGetValue(key, out ItemData value)) { return value; } if ((Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(ItemRuleConfigCore.PrefabKey(key)); value = ((!((Object)(object)itemPrefab != (Object)null)) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData); if (value == null && _restock) { string normalized = RestockTargetLimitCore.NormalizeResourceToken(key); foreach (GameObject item in ObjectDB.instance.m_items) { ItemData val = ((!((Object)(object)item != (Object)null)) ? null : item.GetComponent<ItemDrop>()?.m_itemData); if (val?.m_shared != null && GetRestockTargetLookupTokens(val).Any((string k) => RestockTargetLimitCore.NormalizeResourceToken(k) == normalized)) { value = val; break; } } } } _resolved[key] = value; return value; } private void ClearRows() { if ((Object)(object)_content == (Object)null) { _fields.Clear(); _rowButtons.Clear(); return; } if ((Object)(object)EventSystem.current != (Object)null && (Object)(object)EventSystem.current.currentSelectedGameObject != (Object)null && EventSystem.current.currentSelectedGameObject.transform.IsChildOf((Transform)(object)_content)) { EventSystem.current.SetSelectedGameObject((GameObject)null); } foreach (TMP_InputField field in _fields) { if (!((Object)(object)field == (Object)null)) { ((UnityEventBase)field.onValueChanged).RemoveAllListeners(); ((UnityEventBase)field.onSelect).RemoveAllListeners(); ((UnityEventBase)field.onEndEdit).RemoveAllListeners(); field.DeactivateInputField(false); } } foreach (Button rowButton in _rowButtons) { if ((Object)(object)rowButton != (Object)null) { ((UnityEventBase)rowButton.onClick).RemoveAllListeners(); } } _fields.Clear(); _rowButtons.Clear(); for (int num = ((Transform)_content).childCount - 1; num >= 0; num--) { GameObject gameObject = ((Component)((Transform)_content).GetChild(num)).gameObject; gameObject.SetActive(false); Object.Destroy((Object)(object)gameObject); } } private void Render() { //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_00bd: 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_01f6: 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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Expected O, but got Unknown //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Expected O, but got Unknown //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Expected O, but got Unknown ClearRows(); Rect rect = _root.rect; float num = Mathf.Clamp(((Rect)(ref rect)).width - 16f, 260f, 300f); float num2 = num - 24f; List<ItemRuleConfigCore.Entry> list = ((_registration != null) ? new List<ItemRuleConfigCore.Entry> { _registration } : _entries.Where((ItemRuleConfigCore.Entry e) => !e.Removed).ToList()); _visibleRowCount = Mathf.Max(1, list.Count); float num3 = (float)Mathf.Max(1, Mathf.Min(6, list.Count)) * 38f; _popup.sizeDelta = new Vector2(num, 116f + num3); Frame(_title.rectTransform, 12f, -10f, num2, 28f); Frame(_scope.rectTransform, 12f, -39f, num2, 34f); _title.text = (_restock ? L("restock_title", "Restock targets") : L("exclude_title", "Auto pickup exclusions")); ((Graphic)_title).color = _gold; _scope.text = ((_registration != null) ? (L("quantity", "Target quantity") + " (1–" + _registrationMax + ")") : (_restock ? L("restock_scope", "{key} · mode and target per favorite stack").Replace("{key}", GetContainerRestockKeyDisplayText()) : L("exclude_scope", "Manual E pickup is still available"))); Frame(_viewport, 12f, -78f, num2, num3); _content.sizeDelta = new Vector2(num2, (float)Mathf.Max(1, list.Count) * 38f); _content.anchoredPosition = Vector2.zero; Frame(_status.rectTransform, 12f, -82f - num3, num2, 30f); _status.text = ""; if (list.Count == 0) { Frame(Text((Transform)(object)_content, "Empty", L("empty", "No registered items"), 16f).rectTransform, 0f, 0f, num2, 38f); } for (int num4 = 0; num4 < list.Count; num4++) { ItemRuleConfigCore.Entry entry = list[num4]; RectTransform val = Rect("Row", (Transform)(object)_content, new Vector2(num2, 38f), new Vector2(0f, (float)(-num4) * 38f)); ((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = Color.clear; float num5 = num2 - (float)((_registration != null) ? 58 : 94); float num6 = num5 - 38f; float num7 = (_restock ? (num6 - 6f) : (num2 - 74f)); RectTransform val2 = Rect("ItemInfo", (Transform)(object)val, new Vector2(num7, 38f), Vector2.zero); ((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = Color.clear; ItemData val3 = Resolve(entry.Key); Image obj = ((Component)Rect("Icon", (Transform)(object)val2, new Vector2(26f, 26f), new Vector2(0f, -5f))).gameObject.AddComponent<Image>(); ((Graphic)obj).raycastTarget = false; obj.sprite = ((val3 != null) ? val3.GetIcon() : null); ((Behaviour)obj).enabled = (Object)(object)obj.sprite != (Object)null; obj.preserveAspect = true; TMP_Text obj2 = Text((Transform)(object)val2, "Name", (val3 == null) ? entry.Key : GetLocalizedItemName(val3), 16f); obj2.textWrappingMode = (TextWrappingModes)0; obj2.overflowMode = (TextOverflowModes)1; Frame(obj2.rectTransform, 32f, -2f, num7 - 32f, 32f); UITooltip obj3 = ((Component)val2).gameObject.AddComponent<UITooltip>(); EnsureTooltipPrefab(obj3); ((Behaviour)obj3).enabled = (Object)(object)obj3.m_tooltipPrefab != (Object)null; obj3.m_topic = ((val3 == null) ? entry.Key : GetLocalizedItemName(val3)); obj3.m_text = entry.Key; Image modeIcon; UITooltip modeTip; if (_restock) { Frame((RectTransform)((Component)NumberField(val, entry, val3)).transform, num5, -2f, 58f, 32f); modeIcon = null; modeTip = null; Button val4 = Button((Transform)(object)val, "RestockMode", "", (UnityAction)delegate { Pin(); RestockRuleMode mode = entry.Mode; entry.Mode = RestockTargetLimitCore.NextMode(entry.Mode); if (!Save()) { entry.Mode = mode; } RefreshMode(); }); ApplyCraftButtonStyle(val4); Frame((RectTransform)((Component)val4).transform, num6, -2f, 32f, 32f); modeIcon = ((Component)Rect("ModeIcon", ((Component)val4).transform, new Vector2(28f, 28f), new Vector2(2f, -2f))).gameObject.AddComponent<Image>(); ((Graphic)modeIcon).raycastTarget = false; modeTip = ((Component)val4).gameObject.AddComponent<UITooltip>(); EnsureTooltipPrefab(modeTip); ((Behaviour)modeTip).enabled = (Object)(object)modeTip.m_tooltipPrefab != (Object)null; RefreshMode(); _rowButtons.Add(val4); } if (_registration != null) { continue; } Button val5 = Button((Transform)(object)val, "Remove", _restock ? "×" : L("remove", "Remove"), (UnityAction)delegate { Pin(); entry.Removed = true; if (Save()) { Render(); } else { entry.Removed = false; } }); Frame((RectTransform)((Component)val5).transform, num2 - (float)(_restock ? 30 : 68), -2f, _restock ? 30 : 68, 32f); _rowButtons.Add(val5); void RefreshMode() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) modeIcon.sprite = GetRestockModeIcon(entry.Mode); if (((Behaviour)modeTip).enabled) { modeTip.Set(GetRestockModeTitle(entry.Mode), GetRestockModeHelp(entry.Mode), (RectTransform)null, default(Vector2)); } } } PositionPopup(); } private TMP_InputField NumberField(RectTransform parent, ItemRuleConfigCore.Entry entry, ItemData? item) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) int? maximumAmount = ((item?.m_shared != null) ? new int?(Mathf.Max(1, item.m_shared.m_maxStackSize)) : ((int?)null)); RectTransform val = Rect("Quantity", (Transform)(object)parent, new Vector2(58f, 32f), Vector2.zero); ((Component)val).gameObject.SetActive(false); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); Image component = Owner.m_playerGrid.m_elementPrefab.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { CopyImageStyle(component, val2); } RectTransform val3 = Rect("TextArea", (Transform)(object)val, Vector2.zero, Vector2.zero); Stretch(val3); val3.offsetMin = new Vector2(4f, 2f); val3.offsetMax = new Vector2(-4f, -2f); ((Component)val3).gameObject.AddComponent<RectMask2D>(); TMP_Text val4 = Text((Transform)(object)val3, "Text", entry.Amount, 17f); Stretch(val4.rectTransform); val4.alignment = (TextAlignmentOptions)4100; TMP_InputField input = ((Component)val).gameObject.AddComponent<TMP_InputField>(); ((Selectable)input).targetGraphic = (Graphic)(object)val2; input.textViewport = val3; input.textComponent = val4; TMP_InputField obj = input; Button component2 = Owner.m_playerGrid.m_elementPrefab.GetComponent<Button>(); ((Selectable)obj).colors = ((component2 != null) ? ((Selectable)component2).colors : InputColors); input.contentType = (ContentType)2; input.characterLimit = 10; input.lineType = (LineType)0; input.restoreOriginalTextOnEscape = false; input.text = entry.Amount; input.customCaretColor = true; input.caretColor = _text; input.selectionColor = new Color(0.3f, 0.48f, 0.62f, 0.55f); ((UnityEvent<string>)(object)input.onSelect).AddListener((UnityAction<string>)delegate { Pin(); }); ((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { Pin(); if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result < 1 || (maximumAmount.HasValue && result > maximumAmount.Value)) { _status.text = L("invalid", "Enter a quantity from 1 to the item's maximum stack."); } else { string amount = entry.Amount; entry.Amount = text; if (!Save()) { entry.Amount = amount; input.SetTextWithoutNotify(amount); } } }); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string text) { string text2 = (maximumAmount.HasValue ? RestockTargetLimitCore.ClampAmountForEditor(text, maximumAmount.Value) : RestockTargetLimitCore.NormalizeAmountForEditor(text)); if (text2.Length == 0) { input.SetTextWithoutNotify(entry.Amount); _status.text = L("restored", "Last saved quantity restored"); } else if (text2 == entry.Amount) { input.SetTextWithoutNotify(text2); } else { string amount = entry.Amount; entry.Amount = text2; if (Save()) { input.SetTextWithoutNotify(text2); } else { entry.Amount = amount; input.SetTextWithoutNotify(amount); } } }); _fields.Add(input); ((Component)val).gameObject.SetActive(true); return input; } internal void Close() { if (Pinned) { _itemRuleInputClosedFrame = Time.frameCount; } Pinned = false; _registration = null; _hoverMode = null; _hoverStarted = (_outsideStarted = -1f); if (!((Object)(object)_popup == (Object)null)) { ClearRows(); _entries.Clear(); _resolved.Clear(); ((Component)_popup).gameObject.SetActive(false); ((Component)_backdrop).gameObject.SetActive(false); } } internal void Hide() { if (Open) { Close(); } _hoverMode = null; _hoverStarted = (_outsideStarted = -1f); if ((Object)(object)_toolbar != (Object)null) { ((Component)_toolbar).gameObject.SetActive(false); } } private void EndInteraction() { if (IsInventoryPanelClosing(Owner)) { Close(); } else { Hide(); } } private void OnDisable() { Close(); if ((Object)(object)_toolbar != (Object)null) { ((Component)_toolbar).gameObject.SetActive(false); } } private void OnDestroy() { Close(); RemoveUiListeners(((Component)this).transform); if ((Object)(object)_toolbar != (Object)null && !((Transform)_toolbar).IsChildOf(((Component)this).transform)) { RemoveUiListeners((Transform)(object)_toolbar); Object.Destroy((Object)(object)((Component)_toolbar).gameObject); } foreach (Sprite ownedIcon in _ownedIcons) { if ((Object)(object)ownedIcon != (Object)null) { Object.Destroy((Object)(object)ownedIcon.texture); Object.Destroy((Object)(object)ownedIcon); } } _ownedIcons.Clear(); if (_itemRuleEditor == this) { _itemRuleEditor = null; } } private static void RemoveUiListeners(Transform owner) { Button[] componentsInChildren = ((Component)owner).GetComponentsInChildren<Button>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((UnityEventBase)componentsInChildren[i].onClick).RemoveAllListeners(); } UIDragHandler[] componentsInChildren2 = ((Component)owner).GetComponentsInChildren<UIDragHandler>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].m_onReleasedOn = null; } } private RectTransform Rect(string name, Transform parent, Vector2 size, Vector2 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0056: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject("InventoryActions_Rules_" + name, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent, false); Frame(val, position.x, position.y, size.x, size.y); return val; } private static void Frame(RectTransform rect, float x, float y, float width, float height) { //IL_0013: 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_002a: 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_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rect.anchorMax = val; rect.anchorMin = val; rect.pivot = new Vector2(0f, 1f); rect.sizeDelta = new Vector2(width, height); rect.anchoredPosition = new Vector2(x, y); } private static void Stretch(RectTransform rect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; Vector2 offsetMin = (rect.offsetMax = Vector2.zero); rect.offsetMin = offsetMin; } private TMP_Text Text(Transform parent, string name, string value, float size) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(name, parent, Vector2.zero, Vector2.zero); ((Component)val).gameObject.SetActive(false); TextMeshProUGUI obj = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = _font; ((TMP_Text)obj).fontSharedMaterial = _fontMaterial; ((TMP_Text)obj).fontSize = size; ((Graphic)obj).color = _text; ((TMP_Text)obj).text = value; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).alignment = (TextAlignmentOptions)4097; ((Component)val).gameObject.SetActive(true); return (TMP_Text)(object)obj; } private Button Button(Transform parent, string name, string text, UnityAction action) { //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_00c0: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(name, parent, new Vector2(80f, 32f), Vector2.zero); Image targetGraphic = ((Component)val).gameObject.AddComponent<Image>(); Button val2 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)val2).targetGraphic = (Graphic)(object)targetGraphic; ((UnityEvent)val2.onClick).AddListener(action); if (text.Length > 0) { Button obj = ApplyCraftButtonStyle(val2); TMP_Text val3 = Text((Transform)(object)val, "Label", text, 16f); Stretch(val3.rectTransform); val3.alignment = (TextAlignmentOptions)514; TMP_Text componentInChildren = ((Component)obj).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.font != (Object)null) { val3.font = componentInChildren.font; val3.fontSharedMaterial = componentInChildren.fontSharedMaterial; val3.fontStyle = componentInChildren.fontStyle; } } return val2; } private Button ApplyCraftButtonStyle(Button button) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Button val = (((Object)(object)Owner.m_craftButton != (Object)null) ? Owner.m_craftButton : Owner.m_takeAllButton); if ((Object)(object)((Selectable)val).image != (Object)null) { CopyImageStyle(((Selectable)val).image, ((Selectable)button).image); } ((Selectable)button).spriteState = ((Selectable)val).spriteState; ((Selectable)button).colors = ((Selectable)val).colors; ((Selectable)button).transition = ((Selectable)val).transition; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)button).navigation = navigation; return val; } private static void CopyImageStyle(Image source, Image target) { //IL_000e: 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) target.sprite = source.sprite; target.type = source.type; ((Graphic)target).material = ((Graphic)source).material; ((Graphic)target).color = ((Graphic)source).color; target.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier; target.fillCenter = source.fillCenter; target.preserveAspect = source.preserveAspect; } private Sprite CreateRuleIcon(bool restock) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown Color[] pixels = (Color[])(object)new Color[4096]; if (restock) { DrawRestockSymbol(pixels, Color.white, includeParcel: true); } else { DrawTrashLine(pixels, 64, 16, 35, 16, 48, 2, Color.white); DrawTrashLine(pixels, 64, 16, 48, 46, 48, 2, Color.white); DrawTrashLine(pixels, 64, 46, 48, 46, 35, 2, Color.white); DrawTrashLine(pixels, 64, 28, 40, 28, 17, 2, Color.white); DrawTrashLine(pixels, 64, 20, 25, 28, 17, 2, Color.white); DrawTrashLine(pixels, 64, 28, 17, 36, 25, 2, Color.white); DrawTrashLine(pixels, 64, 13, 53, 51, 15, 3, Color.clear); DrawTrashLine(pixels, 64, 13, 53, 51, 15, 1, Color.white); } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = (restock ? "InventoryActions_RestockIcon" : "InventoryActions_ExcludeIcon"), filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val.SetPixels(pixels); val.Apply(false, true); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); _ownedIcons.Add(val2); return val2; } } [CompilerGenerated] private static class <>O { public static Action<ConfigEntryBase> <0>__DrawButtonPositionOffsetConfig; public static Action<ConfigEntryBase> <1>__DrawRestockTargetStackLimitsConfig; public static EventHandler <2>__RefreshAutoPickupExclusions; public static Func<KeyCode, string> <3>__GetShortcutKeyDisplayText; public static EventHandler<SettingChangedEventArgs> <4>__HandleAzuEpiSettingChanged; public static Func<char, bool> <5>__IsDigit; public static UnityAction <6>__TryClickInventoryTrashPanel; public static Action <7>__ConfirmInventoryTrashDelete; public static Action <8>__CloseInventoryTrashConfirmDialog; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<ItemData, bool> <>9__5_0; public static Func<ItemData, int> <>9__5_1; public static Func<ItemData, int> <>9__5_2; public static Comparison<ItemData> <>9__9_1; public static Func<ItemData, bool> <>9__10_0; public static Func<ItemData, string> <>9__10_1; public static Comparison<ItemData> <>9__11_1; public static Comparison<ItemData> <>9__21_1; public static Func<ItemData, bool> <>9__26_0; public static Func<ItemData, ItemData> <>9__28_0; public static Func<ItemData, bool> <>9__29_0; public static Func<ItemData, <>f__AnonymousType0<string, int, int, bool>> <>9__29_1; public static Func<IGrouping<<>f__AnonymousType0<string, int, int, bool>, ItemData>, List<ItemData>> <>9__29_2; public static Func<ItemData, int> <>9__29_3; public static Comparison<(Container Container, float DistanceSq)> <>9__45_0; public static Func<MonoBehaviour, bool> <>9__50_0; public static Func<ItemData, int> <>9__63_1; public static Func<ItemData, int> <>9__63_2; public static EventHandler <>9__149_0; public static Func<char, bool> <>9__158_0; public static Func<char, bool> <>9__175_0; public static Func<string, bool> <>9__184_0; public static Func<Vector2i, int> <>9__192_0; public static Func<Vector2i, int> <>9__192_1; public static Func<Vector2i, string> <>9__192_2; public static Func<RestockTargetLimitEditorRow, bool> <>9__313_0; public static Func<RestockTargetLimitEditorRow, bool> <>9__314_0; public static Func<RestockTargetLimitEditorRow, string> <>9__314_1; public static UnityAction <>9__326_0; public static UnityAction <>9__326_1; public static UnityAction <>9__328_0; public static UnityAction <>9__337_0; public static Func<Vector2i, int> <>9__380_0; public static Func<Vector2i, int> <>9__380_1; public static Func<ItemData, bool> <>9__428_0; public static Func<ItemData, int> <>9__429_0; public static Func<ItemData, int> <>9__429_1; internal bool <SafeTakeAllItems>b__5_0(ItemData item) { return item?.m_shared != null; } internal int <SafeTakeAllItems>b__5_1(ItemData item) { return item.m_gridPos.y; } internal int <SafeTakeAllItems>b__5_2(ItemData item) { return item.m_gridPos.x; } internal int <GetQuickStackCandidates>b__9_1(ItemData a, ItemData b) { //IL_0001: 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) return -CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal bool <QuickStackItemsIntoContainer>b__10_0(ItemData item) { return item?.m_shared != null; } internal string <QuickStackItemsIntoContainer>b__10_1(ItemData item) { return item.m_shared.m_name; } internal int <StoreAllToCurrentContainer>b__11_1(ItemData a, ItemData b) { //IL_0001: 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) return CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal int <GetRestockTargets>b__21_1(ItemData a, ItemData b) { //IL_0001: 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) return -CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal bool <SortContainerInventory>b__26_0(ItemData item) { return item?.m_shared != null; } internal ItemData <SortInventoryInternal>b__28_0(ItemData item) { return item; } internal bool <MergeSortableStacks>b__29_0(ItemData item) { if (item?.m_shared != null && item.m_stack < item.m_shared.m_maxStackSize) { return CanUseContainerActionStacking(item); } return false; } internal <>f__AnonymousType0<string, int, int, bool> <MergeSortableStacks>b__29_1(ItemData item) { return new { item.m_shared.m_name, item.m_quality, item.m_worldLevel, item.m_cheated }; } internal List<ItemData> <MergeSortableStacks>b__29_2(IGrouping<<>f__AnonymousType0<string, int, int, bool>, ItemData> grouping) { return grouping.ToList(); } internal int <MergeSortableStacks>b__29_3(ItemData item) { return item.m_stack; } internal int <GetActionContainers>b__45_0((Container Container, float DistanceSq) left, (Container Container, float DistanceSq) right) { return left.DistanceSq.CompareTo(right.DistanceSq); } internal bool <IsExternalMultiUserChestTransferContainer>b__50_0(MonoBehaviour component) { if ((Object)(object)component != (Object)null) { return string.Equals(((object)component).GetType().FullName, "OdinShip.ShipContainer", StringComparison.Ordinal); } return false; } internal int <MoveItemToInventoryTopFirst>b__63_1(ItemData target) { return target.m_gridPos.y; } internal int <MoveItemToInventoryTopFirst>b__63_2(ItemData target) { return target.m_gridPos.x; } internal void <BindConfigs>b__149_0(object _, EventArgs _) { RefreshRestockTargetStackLimits(); } internal bool <FilterSignedFloatText>b__158_0(char c) { if (!char.IsDigit(c) && c != '-' && c != '+') { return c == '.'; } return true; } internal bool <GetFavoriteFilePath>b__175_0(char ch) { bool flag = char.IsLetterOrDigit(ch); if (!flag) { bool flag2 = ((ch == '-' || ch == '_') ? true : false); flag = flag2; } return flag; } internal bool <GetShortcutDisplayText>b__184_0(string part) { return !string.IsNullOrWhiteSpace(part); } internal int <SaveFavorites>b__192_0(Vector2i slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return slot.y; } internal int <SaveFavorites>b__192_1(Vector2i slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return slot.x; } internal string <SaveFavorites>b__192_2(Vector2i slot) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) string value; return FavoriteSlotMemoryCore.WriteLine(slot.x, slot.y, FavoriteSlotItems.TryGetValue(slot, out value) ? value : ""); } internal bool <UpdateRestockTargetStackLimitsConfigEntry>b__313_0(RestockTargetLimitEditorRow row) { if (!string.IsNullOrWhiteSpace(row.Item)) { if (int.TryParse(row.Amount, out var result)) { return result < 1; } return true; } return false; } internal bool <SerializeRestockTargetLimitEditorRows>b__314_0(RestockTargetLimitEditorRow row) { return !string.IsNullOrWhiteSpace(row.Item); } internal string <SerializeRestockTargetLimitEditorRows>b__314_1(RestockTargetLimitEditorRow row) { return row.Item.Trim() + ": " + RestockTargetLimitCore.FormatRuleValue(row.Amount.Trim(), row.Mode); } internal void <UpdateContainerActionButtons>b__326_0() { StoreAllToCurrentContainer(Player.m_localPlayer); } internal void <UpdateContainerActionButtons>b__326_1() { RestockFromCurrentContainer(Player.m_localPlayer); } internal void <UpdatePlayerActionPanel>b__328_0() { SortPlayerInventory(Player.m_localPlayer); } internal void <EnsureContainerSortButton>b__337_0() { SortCurrentContainer(Player.m_localPlayer); } internal int <TryFindEmptyFavoriteRestockCell>b__380_0(Vector2i pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return pos.y; } internal int <TryFindEmptyFavoriteRestockCell>b__380_1(Vector2i pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return pos.x; } internal bool <FillFavoriteStacks>b__428_0(ItemData item) { return item.m_stack == 0; } internal int <FillFavoriteStackAmounts>b__429_0(ItemData item) { return item.m_gridPos.y; } internal int <FillFavoriteStackAmounts>b__429_1(ItemData item) { return item.m_gridPos.x; } } private const string AreaOwnershipRequestRpc = "InventoryActions_AreaOwnershipRequestV1"; private const string AreaOwnershipResponseRpc = "InventoryActions_AreaOwnershipResponseV1"; private const string AreaOwnershipLeaseRequesterKey = "InventoryActions_AreaLeaseRequester"; private const string AreaOwnershipLeaseRequestIdKey = "InventoryActions_AreaLeaseRequestId"; private const string AreaOwnershipLeaseActionKey = "InventoryActions_AreaLeaseAction"; private const string AreaOwnershipLeaseExpiryKey = "InventoryActions_AreaLeaseExpiry"; private const string AreaOwnershipLeaseTokenKey = "InventoryActions_AreaLeaseToken"; private const int AreaOwnershipProtocolVersion = 1; private const int AreaOwnershipMaximumPackageBytes = 256; private const float AreaOwnershipResponseTimeout = 2.5f; private const float AreaOwnershipPropagationTimeout = 3f; private const float AreaOwnershipMaximumAnchorDistance = 8f; private static readonly long AreaOwnershipLeaseDurationTicks = TimeSpan.FromSeconds(8.0).Ticks; private static readonly AreaOwnershipHandoffCore AreaOwnershipHandoff = new AreaOwnershipHandoffCore(); private static AreaContainerTransferSession? _areaContainerTransfer; private static int _nextAreaOwnershipRequestId = 1; private static readonly Action<Inventory, bool, bool> InventoryChanged = AccessTools.MethodDelegate<Action<Inventory, bool, bool>>(AccessTools.DeclaredMethod(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null), (object)null, true); private static readonly ConfigSync ConfigSync = new ConfigSync("sighsorry.InventoryActions") { DisplayName = "InventoryActions", CurrentVersion = "1.1.0", MinimumRequiredVersion = "1.1.0", ModRequired = true }; private static ConfigEntry<Toggle> _serverConfigLocked = null; private static ConfigEntry<Toggle> _enableInventoryTrashPanel = null; private static ConfigEntry<float> _areaQuickStackRange = null; private static ConfigEntry<float> _areaRestockRange = null; private static ConfigEntry<Toggle> _containerActionSuccessFx = null; private static ConfigEntry<KeyboardShortcut> _favoriteModifierKey = null; private static ConfigEntry<KeyboardShortcut> _containerRestockKey = null; private static ConfigEntry<string> _sortButtonPositionOffset = null; private static ConfigEntry<Toggle> _showFeatureGuide = null; private static ConfigEntry<Toggle> _featureGuideCollapsed = null; private static string? _cachedSortButtonPositionOffsetText; private static Vector2 _cachedSortButtonPositionOffset; private static ConfigEntry<string> _restockTargetStackLimitsConfig = null; private static ConfigEntry<Toggle> _restockLeaveOneItem = null; private static ConfigEntry<string> _autoPickupExcludedItemsConfig = null; private static readonly Color FavoriteBorderColor = new Color(0.1f, 0.55f, 1f, 0.95f); private static readonly char[] ButtonPositionOffsetSeparators = new char[12] { ' ', '\t', '\r', '\n', ':', '=', ',', ';', '(', ')', '[', ']' }; private static readonly Dictionary<string, ButtonPositionOffsetEditorState> ButtonPositionOffsetEditorStates = new Dictionary<string, ButtonPositionOffsetEditorState>(StringComparer.Ordinal); private const string FeatureGuideRootName = "InventoryActions_FeatureGuideHudHint"; private const float FeatureGuideMaximumContentWidth = 500f; private const float FeatureGuideMinimumSideContentWidth = 320f; private const float FeatureGuideFallbackContentHeight = 176f; private const float FeatureGuideGap = 12f; private const float FeatureGuideHorizontalPadding = 10f; private const float FeatureGuideVerticalPadding = 8f; private const float FeatureGuideToggleSize = 24f; private static readonly Color FeatureGuideBackgroundColor = new Color(0.055f, 0.035f, 0.025f, 0.64f); private static readonly Color FeatureGuideTextColor = new Color(0.78f, 0.88f, 0.94f, 0.92f); private static readonly Color FeatureGuideToggleColor = new Color(1f, 0.663f, 0.302f, 0.92f); private static readonly Vector3[] FeatureGuideHotbarCorners = (Vector3[])(object)new Vector3[4]; private static readonly UnityAction FeatureGuideToggleAction = new UnityAction(ToggleFeatureGuideCollapsed); private static RectTransform? _featureGuideRoot; private static TMP_Text? _featureGuideText; private static RectTransform? _featureGuideToggle; private static TMP_Text? _featureGuideToggleArrow; private static Button? _featureGuideToggleButton; private static Canvas? _featureGuideToggleCanvas; private static GraphicRaycaster? _featureGuideToggleRaycaster; private static TMP_FontAsset? _featureGuideFont; private static Material? _featureGuideFontMaterial; private static string _featureGuideExpandedText = ""; private static string _featureGuideTitle = ""; private static string _featureGuideMeasuredText = ""; private static int _featureGuideMeasuredFontId; private static float _featureGuideMeasuredWidth = -1f; private static Vector2 _featureGuideMeasuredSize = new Vector2(500f, 176f); private static float _featureGuideNaturalContentWidth = 500f; private static float _featureGuideTitleWidth = 180f; private static float _nextFeatureGuideTextRefreshTime; private static float _nextFeatureGuideFontLookupTime; internal const string ModName = "InventoryActions"; internal const string ModVersion = "1.1.0"; internal const string Author = "sighsorry"; internal const string ModGUID = "sighsorry.InventoryActions"; private const string ExternalMultiUserChestGuid = "com.maxsch.valheim.MultiUserChest"; private const string ExtraSlotsGuid = "shudnal.ExtraSlots"; private const string EquipmentAndQuickSlotsGuid = "randyknapp.mods.equipmentandquickslots"; private const string AzuExtendedPlayerInventoryGuid = "Azumatt.AzuExtendedPlayerInventory"; private static readonly ConfigDefinition AzuEpiSeparatePanelConfig = new ConfigDefinition("2 - Inventory", "Display Equipment in Separate Panel"); private static BaseUnityPlugin? _extraSlotsPlugin; private static Func<int>? _extraSlotsPlayerRows; private static Func<int>? _equipmentAndQuickSlotsVisibleRows; private static Func<Inventory, int, int>? _azuEpiGetSlotGridLinearIndex; private static ConfigFile? _azuEpiConfig; private static ConfigEntryBase? _azuEpiSeparatePanelEntry; private static bool? _azuEpiDisplaysEquipmentInSeparatePanel; private const int PlayerInventoryWidth = 8; private const int VanillaPlayerRows = 4; private const string FavoriteBorderName = "InventoryActions_FavoriteBorder"; private const float FavoriteBorderThickness = 2f; private const string ClientConfigSection = "2 - Client"; private const string InventoryButtonsConfigSection = "3 - Inventory Buttons"; private const string GeneralConfigSection = "1 - General"; private const float ContainerHoverHoldDuration = 0.5f; private const string ContainerActionSuccessFxPrefabName = "fx_HildirChest_Unlock"; private const string ContainerActionSuccessFxRpc = "InventoryActions_ContainerActionTransientFxV1"; private const int ContainerActionSuccessVfxKind = 1; private const int ContainerActionSuccessSfxKind = 2; private const int ContainerActionSuccessVfxLimit = 10; private const float ContainerActionSuccessFxLifetime = 5f; private const float ContainerActionSuccessFxReceiveRange = 64f; private const int ContainerActionSuccessFxReceiveLimit = 32; private const float ContainerActionSuccessFxReceiveWindow = 1f; internal static readonly ManualLogSource Log = Logger.CreateLogSource("InventoryActions"); private readonly Harmony _harmony = new Harmony("sighsorry.InventoryActions"); private static InventoryActionsPlugin _instance = null; private static readonly InventoryActionRuntimeState Runtime = new InventoryActionRuntimeState(); private static readonly System.Version MinimumSupportedExternalMultiUserChestVersion = new System.Version(0, 6, 1); private static float _containerActionSuccessFxReceiveWindowStartedAt = -1f; private static int _containerActionSuccessFxReceivedInWindow; private static readonly List<RestockTargetLimitEditorRow> RestockTargetLimitEditorRows = new List<RestockTargetLimitEditorRow>(); private static string _restockTargetLimitEditorLastValue = ""; private const float SortButtonOutsideGap = 1f; private const float TrashPanelGap = 8f; private static readonly Vector2 InventorySortButtonFixedOffset = new Vector2(2f, 2f); private const string PlayerActionPanelName = "InventoryActions_PlayerActionPanel"; private const string TrashPanelName = "InventoryActions_TrashPanel"; private const string TrashButtonName = "InventoryActions_TrashButton"; private const string TrashIconName = "InventoryActions_TrashIcon"; private const string TrashConfirmDialogName = "InventoryActions_TrashConfirmDialog"; private static readonly FieldRef<SplitDialog, Button> TrashSplitOkButton = AccessTools.FieldRefAccess<SplitDialog, Button>("m_splitOkButton"); private static readonly FieldRef<SplitDialog, Button> TrashSplitCancelButton = AccessTools.FieldRefAccess<SplitDialog, Button>("m_splitCancelButton"); private static HashSet<string> _autoPickupExcludedItems = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static List<string> _emptyFavoriteRestockKeys = new List<string>(); private static readonly Dictionary<Vector2i, string> FavoriteSlotItems = new Dictionary<Vector2i, string>(); private static Inventory? _favoriteMemoryInventory; private static bool _favoriteMemoryPending = true; private static bool _favoriteMemorySavePending; private static float _favoriteMemorySaveRetryAt; private static readonly InventoryButtonSlide?[] InventoryButtonSlides = new InventoryButtonSlide[3]; private static ConfigEntry<InventoryButtonMode> _restockButtonMode = null; private static ConfigEntry<InventoryButtonMode> _autoPickupButtonMode = null; private static ConfigEntry<InventoryButtonMode> _trashButtonMode = null; private const string RuleButtonModeDescription = "Client-only display mode. Off hides the button without disabling saved rules. Auto shows its bottom edge and slides out only on hover; holding an item alone does not expand it. An open editor keeps its button expanded. Gamepad use expands Auto buttons. On always shows the full button. Changes apply immediately."; private const string TrashButtonModeDescription = "Client-only display mode. Off hides the trash button. Auto shows its bottom edge and slides out only on hover; holding an item alone does not expand it. Gamepad use expands Auto buttons. On always shows the full button. The server's Enable Inventory Trash Panel setting must also be On. Changes apply immediately."; private static ItemRuleEditor? _itemRuleEditor; private static int _itemRuleInputClosedFrame = -1; private static readonly Sprite?[] RestockRuleModeIcons = (Sprite?[])(object)new Sprite[3]; internal static bool IsDedicatedServer { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4) { if (Application.isBatchMode) { return string.Equals(Paths.ProcessName, "valheim_server", StringComparison.OrdinalIgnoreCase); } return false; } return true; } } private static bool HasExternalMultiUserChestActive { get { if (Chainloader.PluginInfos.TryGetValue("com.maxsch.valheim.MultiUserChest", out var value)) { return (Object)(object)value.Instance != (Object)null; } return false; } } private static bool HasSupportedExternalMultiUserChestActive { get { if (Chainloader.PluginInfos.TryGetValue("com.maxsch.valheim.MultiUserChest", out var value) && (Object)(object)value.Instance != (Object)null) { return value.Metadata.Version.CompareTo(MinimumSupportedExternalMultiUserChestVersion) >= 0; } return false; } } private static ISet<Vector2i> RememberedFavoriteCells => Runtime.FavoriteSlots; internal static bool TryHandleVanillaPlaceStacks(InventoryGui gui) { if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_currentContainer == (Object)null) { return false; } if (!CanMutateContainerDirectly(gui.m_currentContainer, allowLocalWithoutZNetView: true)) { return false; } QuickStackCurrentContainer(Player.m_localPlayer); return true; } internal static bool TryHandleContainerStackAll(Container container) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || (Object)(object)container == (Object)null || container.m_inventory == null) { return false; } if (!CanMutateContainerDirectly(container, allowLocalWithoutZNetView: true)) { return false; } Inventory playerInventory = GetPlayerInventory(localPlayer); if (playerInventory == null) { return false; } return QuickStackIntoContainers(localPlayer, playerInventory, container, includeArea: true); } internal static bool TryHandleSafeTakeAll(InventoryGui gui) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || (Object)(object)gui == (Object)null || (Object)(object)gui.m_currentContainer == (Object)null || gui.m_currentContainer.m_inventory == null) { return false; } Container currentContainer = gui.m_currentContainer; if (!CanMutateContainerDirectly(currentContainer, allowLocalWithoutZNetView: true)) { if (CanDelegateTakeAllToExternalMultiUserChest(localPlayer, currentContainer)) { return false; } ((Character)localPlayer).Message((MessageType)2, LocalizeUi("$inventoryactions_container_not_ready", "Container is not ready."), 0, (Sprite)null, false); return true; } Inventory playerInventory = GetPlayerInventory(localPlayer); Inventory inventory = currentContainer.m_inventory; if (playerInventory == null || inventory == null) { return false; } TombStone component = ((Component)currentContainer).GetComponent<TombStone>(); gui.SetupDragItem((ItemData)null, (Inventory)null, 0); if (SafeTakeAllItems(localPlayer, playerInventory, inventory) > 0) { NotifyInventoryChanged(playerInventory); NotifyInventoryChanged(inventory); } if ((Object)(object)component != (Object)null && inventory.NrOfItems() == 0) { component.OnTakeAllSuccess(); } return true; } internal static bool TryHandleTopFirstMoveSelectedItem(InventoryGui gui, InventoryGrid grid, ItemData item, Modifier mod) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0103: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui == (Object)null || (Object)(object)grid == (Object)null || item?.m_shared == null || (int)mod != 2 || item.m_shared.m_questItem || (Object)(object)gui.m_dragGo != (Object)null) { return false; } Player localPlayer = Player.m_localPlayer; Container currentContainer = gui.m_currentContainer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsTeleporting() || (Object)(object)currentContainer == (Object)null || currentContainer.m_inventory == null || !CanMutateContainerDirectly(currentContainer, allowLocalWithoutZNetView: true)) { return false; } Inventory playerInventory = GetPlayerInventory(localPlayer); Inventory inventory = grid.GetInventory(); Inventory inventory2 = currentContainer.m_inventory; if (playerInventory == null || inventory == null) { return false; } Inventory val = null; if (inventory == inventory2) { val = playerInventory; } else if (inventory == playerInventory) { val = inventory2; } if (val == null) { return false; } if (!CanMoveItemToInventoryTopFirst(inventory, val, item)) { return true; } if (inventory == playerInventory && ((Humanoid)localPlayer).IsItemEquiped(item)) { ((Humanoid)localPlayer).RemoveEquipAction(item); ((Humanoid)localPlayer).UnequipItem(item, false); } if (MoveItemToInventoryTopFirst(inventory, val, item) > 0) { NotifyInventoryChanged(playerInventory); NotifyInventoryChanged(inventory2); gui.m_moveItemEffects.Create(((Component)gui).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } return true; } private static int SafeTakeAllItems(Player player, Inventory playerInventory, Inventory containerInventory) { HashSet<Vector2i> allowedSlots = new HashSet<Vector2i>(GetPlayerActionSlots(player, playerInventory)); List<ItemData> list = (from item in containerInventory.m_inventory where item?.m_shared != null orderby item.m_gridPos.y, item.m_gridPos.x select item).ToList(); int num = 0; foreach (ItemData item in list) { if (containerInventory.m_inventory.Contains(item)) { int stack = item.m_stack; if (MoveItemToInventoryTopFirst(containerInventory, playerInventory, item, allowedSlots) > 0 && (!containerInventory.m_inventory.Contains(item) || item.m_stack < stack)) { num++; } } } return num; } private static void QuickStackCurrentContainer(Player? player) { if (TryGetActionContext(player, out Player localPlayer, out Inventory playerInventory, out Container container, out Inventory _)) { QuickStackIntoContainers(localPlayer, playerInventory, container, includeArea: false); } } private static bool QuickStackIntoContainers(Player localPlayer, Inventory playerInventory, Container container, bool includeArea) { if (includeArea) { return TryStartAreaContainerTransfer(localPlayer, playerInventory, container, AreaContainerActionKind.QuickStack); } List<ItemData> quickStackCandidates = GetQuickStackCandidates(localPlayer, playerInventory); InventoryGui instance = InventoryGui.instance; if (instance != null) { instance.SetupDragItem((ItemData)null, (Inventory)null, 0); } int num = ((!IsUnityNull((Object?)(object)container) && container.m_inventory != null) ? QuickStackItemsIntoContainer(playerInventory, container.m_inventory, quickStackCandidates) : 0); if (num > 0) { NotifyInventoryChanged(playerInventory); } ShowContainerActionResult(localPlayer, "$inventoryactions_action_stack", "Stack", num); return true; } private static bool ShouldQuickStackItem(Player player, Inventory inventory, ItemData item) { if (item?.m_shared != null && item.m_shared.m_maxStackSize > 1 && IsRegularActionItem(inventory, item) && !IsFavoriteProtected(player, inventory, item)) { return CanUseContainerActionStacking(item); } return false; } private static List<ItemData> GetQuickStackCandidates(Player player, Inventory playerInventory) { if ((Object)(object)player == (Object)null || playerInventory == null) { return new List<ItemData>(); } List<ItemData> list = playerInventory.m_inventory.Where((ItemData item) => ShouldQuickStackI