Esempio n. 1
0
        internal static bool CanUseItem(int parItemId, PrivateEnums.ItemCacheLookupType parType)
        {
            if (!ObjectManager.Instance.IsIngame)
            {
                return(false);
            }
            if (CanUseItemFunction == null)
            {
                CanUseItemFunction = Memory.Reader.RegisterDelegate <CanUseItemDelegate>(funcs.CanUseItem);
            }
            var ret = MainThread.Instance.Invoke(() =>
            {
                var ptr1 = ObjectManager.Instance.Player.Pointer;
                if (ptr1 == IntPtr.Zero)
                {
                    return(0);
                }
                var ptr2 = ObjectManager.Instance.LookupItemCachePtr(parItemId, parType);
                if (ptr2 == IntPtr.Zero)
                {
                    return(0);
                }
                var randomInt = 1;
                var result    = CanUseItemFunction(ptr1, ptr2, ref randomInt);
                return(result);
            });

            return(ret == 1);
        }
        internal IntPtr LookupItemCachePtr(int parItemId, PrivateEnums.ItemCacheLookupType parLookupType)
        {
            if (_itemCachePtrs.ContainsKey(parItemId))
            {
                return(_itemCachePtrs[parItemId]);
            }
            var res = Functions.ItemCacheGetRow(parItemId, parLookupType);

            if (res == IntPtr.Zero)
            {
                return(IntPtr.Zero);
            }
            _itemCachePtrs.Add(parItemId, res);
            return(_itemCachePtrs[parItemId]);
        }
        internal ItemCacheEntry?LookupItemCacheEntry(int parItemId, PrivateEnums.ItemCacheLookupType parLookupType)
        {
            if (_itemCachePtrs.ContainsKey(parItemId))
            {
                return(Memory.Reader.Read <ItemCacheEntry>(_itemCachePtrs[parItemId]));
            }
            var res = Functions.ItemCacheGetRow(parItemId, parLookupType);

            if (res == IntPtr.Zero)
            {
                return(null);
            }
            _itemCachePtrs.Add(parItemId, res);
            return(Memory.Reader.Read <ItemCacheEntry>(res));
        }
Esempio n. 4
0
        internal static IntPtr ItemCacheGetRow(int parItemId, PrivateEnums.ItemCacheLookupType parLookupType)
        {
            if (!ObjectManager.Instance.IsIngame)
            {
                return(IntPtr.Zero);
            }
            if (ItemCacheGetRowFunction == null)
            {
                ItemCacheGetRowFunction = Memory.Reader.RegisterDelegate <ItemCacheGetRowDelegate>(funcs.ItemCacheGetRow);
            }

            ulong val = 0;

            switch (parLookupType)
            {
            case PrivateEnums.ItemCacheLookupType.None:
                return
                    (MainThread.Instance.Invoke(
                         () =>
                         ItemCacheGetRowFunction(funcs.ItemCacheBasePtr, parItemId, ref val,
                                                 CacheCallbacks.Instance.ItemCallbackPtr,
                                                 0, 0x0)));

            case PrivateEnums.ItemCacheLookupType.Vendor:
                val = ObjectManager.Instance.Player.VendorGuid;
                return
                    (MainThread.Instance.Invoke(
                         () => ItemCacheGetRowFunction(funcs.ItemCacheBasePtr, parItemId, ref val,
                                                       CacheCallbacks.Instance.ItemCallbackPtr,
                                                       0, 0x0)));

            case PrivateEnums.ItemCacheLookupType.Quest:
                val = ObjectManager.Instance.Player.QuestNpcGuid;
                return
                    (MainThread.Instance.Invoke(
                         () => ItemCacheGetRowFunction(funcs.ItemCacheBasePtr, parItemId, ref val,
                                                       CacheCallbacks.Instance.ItemCallbackPtr,
                                                       0, 0x0)));

            default:
                return(IntPtr.Zero);
            }
        }