예제 #1
0
        public override MoveItemsResult ClientTryTakeAllItems(
            ICharacter character,
            IItemsContainer fromContainer,
            bool showNotificationIfInventoryFull = true)
        {
            if (fromContainer.OccupiedSlotsCount == 0)
            {
                // no items to move
                return(new MoveItemsResult()
                {
                    AreAllItemMoved = true
                });
            }

            var privateState       = GetPrivateState(character);
            var containerHotbar    = privateState.ContainerHotbar;
            var containerInventory = privateState.ContainerInventory;

            // define a function for spawning item at specified container
            var clientItemsService = Client.Items;

            var result = new MoveItemsResult();

            bool TryMoveItemsTo(IItemsContainer toContainer, bool onlyToExistingStacks)
            {
                var movedItemResult = clientItemsService.TryMoveAllItems(
                    fromContainer,
                    toContainer,
                    onlyToExistingStacks);

                if (movedItemResult.MovedItems.Count == 0)
                {
                    // cannot move any item
                    return(false);
                }

                // something moved (perhaps all)
                result.MergeWith(movedItemResult, areAllItemsMoved: movedItemResult.AreAllItemMoved);
                return(movedItemResult.AreAllItemMoved);
            }

            // 1. Try to add to existing stacks in hotbar.
            // 3. Try to add to existing stacks or move to in inventory.
            // 3. Try to move to in hotbar.
            if (TryMoveItemsTo(containerHotbar, onlyToExistingStacks: true) ||
                TryMoveItemsTo(containerInventory, onlyToExistingStacks: false) ||
                TryMoveItemsTo(containerHotbar, onlyToExistingStacks: false))
            {
                // all items are moved!
            }

            if (result.MovedItems.Count > 0)
            {
                ItemsSoundPresets.ItemGeneric.PlaySound(ItemSound.Pick);
            }

            if (!result.AreAllItemMoved &&
                showNotificationIfInventoryFull)
            {
                NotificationSystem.ClientShowNotificationNoSpaceInInventory();
            }

            return(result);
        }
예제 #2
0
        public async Task <IActionResult> MoveItems(MoveItemsViewModel items)
        {
            MoveItemsResult Result = await _mediator.Send(new MoveItemsCommand(items.DestFolderId, items.SelectedFiles, items.SelectedFolders));

            return(HandleResult(Result));
        }