public InventoryContainer(InventoryContainerOffset ict, InventoryContainerId cid) : this(new List <InventoryItem>(), ict, cid)
 {
 }
 public InventoryContainer(List <InventoryItem> items, InventoryContainerOffset ict, InventoryContainerId cid)
 {
     InventoryItems  = items;
     ContainerOffset = ict;
     ContainerId     = cid;
 }
示例#3
0
        private unsafe InventoryContainer GetInventoryItems(byte[] entry, InventoryContainerOffset type)
        {
            var offset = (int)type * 24;

            var cid              = (InventoryContainerId)BitConverter.ToInt16(entry, offset + 8);
            var container        = new InventoryContainer(type, cid);
            var containerAddress = ConvInt(entry, IntPtr.Size, offset);

            if (containerAddress == 0)
            {
                return(container);
            }

            int limit;

            switch (type)
            {
            case InventoryContainerOffset.COMPANY_1:
            case InventoryContainerOffset.COMPANY_2:
            case InventoryContainerOffset.COMPANY_3:
                limit = _szItemInfo * 50;
                break;

            case InventoryContainerOffset.CRYSTALS:
            case InventoryContainerOffset.HIRE_CRTSTALS:
            case InventoryContainerOffset.COMPANY_CRYSTALS:
                limit = _szItemInfo * 18;
                break;

            case InventoryContainerOffset.CURRENCIES:
            case InventoryContainerOffset.HIRE_CURRENCIES:
            case InventoryContainerOffset.COMPANY_CURRENCIES:
                limit = _szItemInfo * 11;
                break;

            case InventoryContainerOffset.HIRE_1:
            case InventoryContainerOffset.HIRE_2:
            case InventoryContainerOffset.HIRE_3:
            case InventoryContainerOffset.HIRE_4:
            case InventoryContainerOffset.HIRE_5:
                limit = _szItemInfo * 25;
                break;

            case InventoryContainerOffset.EQUIPPING:
            case InventoryContainerOffset.HIRE_EQUIP:
                limit = _szItemInfo * 14;
                break;

            case InventoryContainerOffset.HIRE_LISTING:
                limit = _szItemInfo * 20;
                break;

            case InventoryContainerOffset.AC_SOULS:
                limit = _szItemInfo * 19;
                break;

            default:
                limit = _szItemInfo * 35;
                break;
            }

            var buf = _gs.Reader.Read(new IntPtr(containerAddress), limit);

            for (var i = 0; i < limit; i += _szItemInfo)
            {
                fixed(byte *p = &buf[i])
                {
                    var item = *(MemoryInventoryItem *)p;

                    if (item.ItemId <= 0)
                    {
                        continue;
                    }
                    var mat1 = (item.Materia1Attr << 4) | item.Materia1Grade;
                    var mat2 = (item.Materia2Attr << 4) | item.Materia2Grade;
                    var mat3 = (item.Materia3Attr << 4) | item.Materia3Grade;
                    var mat4 = (item.Materia4Attr << 4) | item.Materia4Grade;
                    var mat5 = (item.Materia5Attr << 4) | item.Materia5Grade;

                    container.InventoryItems.Add(new InventoryItem(item.Amount, item.Durability, item.GlamourId,
                                                                   item.ItemId, item.IsHq, item.SpiritBond, item.Slot, item.ArtisanId, item.DyeId,
                                                                   (short)mat1, (short)mat2, (short)mat3, (short)mat4, (short)mat5));
                }
            }

            return(container);
        }