コード例 #1
0
ファイル: InventoryHandler.cs プロジェクト: Oshimada/Rhisis
        public static void OnMoveItem(WorldClient client, INetPacketStream packet)
        {
            var moveItemPacket = new MoveItemPacket(packet);
            var inventoryEvent = new InventoryMoveEventArgs(moveItemPacket.SourceSlot, moveItemPacket.DestinationSlot);

            client.Player.NotifySystem <InventorySystem>(inventoryEvent);
        }
コード例 #2
0
ファイル: InventorySystem.cs プロジェクト: Oshimada/Rhisis
        /// <summary>
        /// Move an item.
        /// </summary>
        /// <param name="player"></param>
        private void MoveItem(IPlayerEntity player, InventoryMoveEventArgs e)
        {
            var         sourceSlot      = e.SourceSlot;
            var         destinationSlot = e.DestinationSlot;
            List <Item> items           = player.Inventory.Items;

            if (sourceSlot >= MaxItems || destinationSlot >= MaxItems)
            {
                return;
            }

            if (items[sourceSlot].Id == -1 || items[sourceSlot].UniqueId == -1 || items[destinationSlot].UniqueId == -1)
            {
                return;
            }

            Item sourceItem = items[sourceSlot];
            Item destItem   = items[destinationSlot];

            Logger.Debug("Moving item from {0} to {1}", sourceSlot, destinationSlot);

            if (sourceItem.Id == destItem.Id && sourceItem.Data.IsStackable)
            {
                // TODO: stack items
            }
            else
            {
                sourceItem.Slot = destinationSlot;

                if (destItem.Slot != -1)
                {
                    destItem.Slot = sourceSlot;
                }

                items.Swap(sourceSlot, destinationSlot);
                WorldPacketFactory.SendItemMove(player, sourceSlot, destinationSlot);
            }
        }