Example #1
0
 public SpInventoryMove(MoveItemArgs args)
 {
     Args = args;
 }
Example #2
0
        public void ReplaceItem(Player player, Storage storage, MoveItemArgs Args, bool showStorage = true)
        {
            lock (storage.ItemsLock)
            {
                switch (Args.IsFromInventory)
                {
                    case 1: // Move item from inventory
                        storage.Items.TryGetValue(Args.FromSlot, out Args.ItemToMove);

                        switch (Args.IsToInventory)
                        {
                            case 1: // to inventory
                                {
                                    Args.ItemToReplace = player.Inventory.GetItem(Args.ToSlot);
                                    storage.Items.Remove(Args.FromSlot);
                                    if (Args.ItemToReplace != null)
                                    {
                                        storage.Items.Remove(Args.ToSlot);
                                        storage.Items.Add(Args.FromSlot, Args.ItemToReplace);
                                    }
                                    storage.Items.Add(Args.ToSlot, Args.ItemToMove);
                                }
                                break;

                            case 0: // to Equiped
                                {
                                    if (!CanDress(player, Args.ItemToMove) && !Global.Global.AdminEngine.IsDev(player))
                                        return;

                                    storage.EquipItems.TryGetValue(Args.ToSlot, out Args.ItemToReplace);
                                    storage.Items.Remove(Args.FromSlot);
                                    storage.EquipItems.Remove(Args.ToSlot);

                                    if (Args.ItemToReplace != null)
                                        storage.Items.Add(Args.FromSlot, Args.ItemToReplace);

                                    storage.EquipItems.Add(Args.ToSlot, Args.ItemToMove);
                                }
                                break;
                        }
                        break;

                    case 0: // Move item from Equiped
                        Args.ItemToMove = player.Inventory.GetEquipItem(Args.FromSlot);

                        switch (Args.IsToInventory)
                        {
                            case 1: // to inventory
                                {
                                    Args.ItemToReplace = player.Inventory.GetItem(Args.ToSlot);

                                    storage.EquipItems.Remove(Args.FromSlot);
                                    if (Args.ItemToReplace != null)
                                    {
                                        storage.Items.Remove(Args.ToSlot);
                                        //storage.EquipItems.Add(Args.FromSlot, Args.ItemToReplace);
                                    }
                                    storage.Items.Add(Args.ToSlot, Args.ItemToMove);
                                }
                                break;

                            case 0: // to Equiped
                                // this may be not use
                                break;
                        }
                        break;
                }

                switch (Args.ItemToMove.State)
                {
                    case ItemState.NEW:
                        Args.ItemToMove.State = ItemState.NEW;
                        break;
                    case ItemState.UPDATE:
                        Args.ItemToMove.State = ItemState.UPDATE;
                        break;
                    case ItemState.DELETE:
                        break;
                }
            }

            new SpInventoryMove(Args).Send(player.Connection);

            CreatureLogic.UpdateCreatureStats(player);

            if (showStorage)
            {
                Global.Global.VisibleService.Send(player, new SpEquipInfo(player));
                ShowPlayerStorage(player, storage.StorageType);
            }
        }