Esempio n. 1
0
        public void HandleNetworkItemInfo(NetworkMessageHeader header, IResult message)
        {
            if (_retainerCountdown <= 0)
            {
                return;
            }

            var dat = (NetworkItemInfo)message;

            if (!_irBuffer.ContainsKey(dat.ContainerId))
            {
                _irBuffer[dat.ContainerId] =
                    new InventoryContainer(InventoryContainerTypeConverter.ToOffset(dat.ContainerId), (InventoryContainerId)dat.ContainerId);
            }

            var item = new InventoryItem(dat.Quantity, dat.Condition, dat.GlamourItemId, dat.ItemId,
                                         dat.IsHq, dat.SpiritBond, dat.ContainerSlot, dat.ArtisanId, dat.DyeId,
                                         dat.Materia1, dat.Materia2, dat.Materia3, dat.Materia4, dat.Materia5);

            if (_ipBuffer.ContainsKey(dat.ContainerId * PrimeForInventorySlot + dat.ContainerSlot)) // max slot is 240, also 241 is a prime
            {
                item.UnitPrice = _ipBuffer[dat.ContainerId * PrimeForInventorySlot + dat.ContainerSlot];
            }

            _irBuffer[dat.ContainerId].InventoryItems.Add(item);
        }
Esempio n. 2
0
        internal InventoryResult GetInventory(InventoryContainerId containerType)
        {
            var type   = InventoryContainerTypeConverter.ToOffset((int)containerType);
            var result = new InventoryResult(new List <InventoryContainer>(), -1);

            _szItemInfo          = Signature.PointerLib[PointerType.Inventory].DtStep;
            _inventoryPointerMap = _gs.GetPointer(PointerType.Inventory);

            const int offset = (int)InventoryContainerOffset.LAST_AVAILABLE * 24;
            var       arr    = _gs.Reader.Read(_inventoryPointerMap, offset + 10);

            result.InventoryContainers.Add(GetInventoryItems(arr, type));

            return(result);
        }
Esempio n. 3
0
        public void HandleInventoryModify(NetworkMessageHeader header, IResult message)
        {
            if (message == null)
            {
                return;
            }

            var msg = (NetworkInventoryModify)message;

            if (msg.FromContainer == InventoryContainerId.HIRE_LISTING)
            {
                if (_irBuffer.TryGetValue((int)msg.FromContainer, out var items))
                {
                    items.InventoryItems.RemoveAll(x => x.Slot == msg.FromSlot);
                }

                var dat = new RetainerUpdateItem();
                dat.ContainerId   = InventoryContainerId.HIRE_LISTING;
                dat.ContainerSlot = msg.FromSlot;
                dat.IsRemove      = true;

                OnDataReady?.Invoke(new PackedResult(PackedResultType.RetainerUpdate,
                                                     new RetainerUpdateResult {
                    UpdateItems = new List <RetainerUpdateItem> {
                        dat
                    }
                }));                                                                                   // delete
            }
            else if (msg.ToContainer == InventoryContainerId.HIRE_LISTING)
            {
                var result = OnRequestScan?.Invoke(InventoryContainerId.HIRE_LISTING);
                if (result == null)
                {
                    return;
                }
                if (!_irBuffer.TryGetValue((int)msg.ToContainer, out var items))
                {
                    _irBuffer[(int)msg.ToContainer] = new InventoryContainer(
                        InventoryContainerTypeConverter.ToOffset((int)InventoryContainerId.HIRE_LISTING),
                        InventoryContainerId.HIRE_LISTING);
                }

                items.InventoryItems.AddRange(result.InventoryContainers.First().InventoryItems.Where(x => x.Slot == msg.ToSlot));
                // always a ClientTrigger follows add operation, so we do not need to forge request here.
            }
        }