コード例 #1
0
ファイル: Inventory.cs プロジェクト: baburukiri/AOSharp
        public static unsafe List <Item> GetContainerItems(Identity identity)
        {
            List <Item> items = new List <Item>();

            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(items);
            }

            IntPtr pInvList = N3EngineClientAnarchy_t.GetContainerInventoryList(pEngine, &identity);

            if (pInvList == IntPtr.Zero)
            {
                return(items);
            }

            IntPtr pItems = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref identity);

            if (pItems == IntPtr.Zero)
            {
                return(items);
            }

            List <IntPtr> containerInvList = (*(StdObjList *)pInvList).ToList();

            int i = 0;

            foreach (IntPtr pItem in (*(StdStructVector *)pItems).ToList(sizeof(IntPtr)))
            {
                IntPtr pActualItem = *(IntPtr *)pItem;

                if (pActualItem != IntPtr.Zero)
                {
                    try
                    {
                        int      lowId          = (*(ItemMemStruct *)pActualItem).LowId;
                        int      highId         = (*(ItemMemStruct *)pActualItem).HighId;
                        int      ql             = (*(ItemMemStruct *)pActualItem).QualityLevel;
                        Identity unqiueIdentity = (*(ItemMemStruct *)pActualItem).UniqueIdentity;
                        Identity slot           = *((Identity *)(containerInvList[i] + 0x8));
                        items.Add(new Item(lowId, highId, ql, unqiueIdentity, slot));
                    } catch {}
                    i++;
                }
            }
            return(items);
        }