Esempio n. 1
0
        //this is the actual withdrawal action.  it withdraws the item from the listentry and puts it in the backpack of the specified person
        public virtual void WithdrawItem(Mobile from, int index)
        {
            if (index < 0 || index >= ItemListEntries.Count)
            {
                from.SendMessage("Invalid withrawal selection");
                return;
            }

            Item item = WithdrawItem(index);

            if (item != null)
            {
                from.AddToBackpack(item);

                //resend the store gump after it's all done
                if (!ItemStoreGump.RefreshGump(from))
                {
                    //send a new store gump if there's no existing one up
                    from.SendGump(new ItemStoreGump(from, Store));
                }

                //resend the item list entry gump after it's all done
                if (!ListEntryGump.RefreshGump(from))
                {
                    //send a new list entry gump if there's no existing one up
                    from.SendGump(new ListEntryGump(from, this));
                }
            }
        }
Esempio n. 2
0
        //this performs an automatic sweep of all items in the user's backpack, and fills the the list entry with the items if it is possible
        public void FillFromBackpack(Mobile from)
        {
            if (from == null || from.Backpack == null)
            {
                return;
            }
            //generate a list of all items in the backpack
            List <Item> packitems = ItemStore.RecurseFindItemsInPack(from.Backpack);

            //go through backpack list, and try to add the items
            foreach (Item item in packitems)
            {
                AddItem(null, item);
            }

            //resend the store gump after it's all done
            if (!ItemStoreGump.RefreshGump(from))
            {
                //send a new store gump if there's no existing one up
                from.SendGump(new ItemStoreGump(from, Store));
            }

            //resend the item list entry gump after it's all done
            if (!ListEntryGump.RefreshGump(from))
            {
                //send a new list entry gump if there's no existing one up
                from.SendGump(new ListEntryGump(from, this));
            }
        }
Esempio n. 3
0
        //this performs the actual addition checks
        public void AddItem(Mobile from, object targeted)
        {
            if (!CanUse(from) || !(targeted is Item))
            {
                return;
            }

            if (!Add((Item)targeted))
            {
                return;
            }

            //resend the targeting cursor and refresh the gump
            if (from != null)
            {
                AddItem(from);

                //resend the store gump after it's all done
                if (!ItemStoreGump.RefreshGump(from))
                {
                    //send a new store gump if there's no existing one up
                    from.SendGump(new ItemStoreGump(from, Store));
                }

                //resend the item list entry gump after it's all done
                if (!ListEntryGump.RefreshGump(from))
                {
                    //send a new list entry gump if there's no existing one up
                    from.SendGump(new ListEntryGump(from, this));
                }
            }
        }
        //this checks if the person using this store has a gump open for it.
        public void RefreshParentGump()
        {
            //if the object containing this store is an item
            if (Owner != null && Owner is Item)
            {
                Item item = (Item)Owner;

                //if the item is being held by a mobile
                if (item.RootParent is Mobile)
                {
                    Mobile player = (Mobile)item.RootParent;

                    //perform a refresh operation on their gump if this store is being displayed
                    ItemStoreGump.RefreshGump(player, this);
                }
            }
        }
        public void FillFromBackpack(Mobile from, bool resendgump)
        {
            if (from == null || from.Backpack == null)
            {
                return;
            }

            FillFromContainer(from.Backpack);

            //resend the gump after it's all done.  Note that if the gump is already up, it will refresh
            if (!ItemStoreGump.RefreshGump(from) && resendgump)
            {
                //send a new gump if there's no existing one up and resendgump was set true
                from.SendGump(new ItemStoreGump(from, this));
            }

            //refresh the item list entry gump if one is up
            ListEntryGump.RefreshGump(from);
        }
        //code to finish adding an item - accessed by the add item target
        public void AddItem(Mobile from, object targeted)
        {
            if (from != null && !CanUse(from))
            {
                from.SendMessage("You no longer can use that");
                return;
            }

            //keep track of the item
            Item item = null;

            //keep track of the deed if it's a commodity deeds
            Item deed = null;

            int entryindex;

            if (!(targeted is Item))
            {
                if (from != null)
                {
                    from.SendMessage("this only works on items.");
                }
                return;
            }

            item = (Item)targeted;

            if (from != null && !item.IsChildOf(from.Backpack))
            {
                BankBox box = from.FindBankNoCreate();

                if (box == null || !item.IsChildOf(box))
                {
                    from.SendMessage("you can only add items from your backpack or bank box");
                    return;
                }
            }


            //Handle commodity deed insertion
            if (item is CommodityDeed)
            {
                if (((CommodityDeed)item).Commodity == null)
                {
                    if (from != null)
                    {
                        from.SendMessage("there is nothing to add in that commodity deed.");
                    }
                    return;
                }
                //store the deed reference
                deed = item;

                //reference the commodity within the deed
                item = ((CommodityDeed)item).Commodity;
            }

            //this uses the overloadable comparison for the appropriate store entries, so that custom store entries
            //can provide custom comparisons with items through their Match() methods
            entryindex = StoreEntry.IndexOfItem(_StoreEntries, item, true);

            if (entryindex == -1)
            {
                if (from != null)
                {
                    from.SendMessage("that cannot be stored in this.");
                }
                return;
            }

            //reference the item store entry
            StoreEntry entry = _StoreEntries[entryindex];

            if (!entry.Add(item))
            {
                if (from != null)
                {
                    from.SendMessage("that quantity cannot fit in this.");
                }
                return;
            }

            //don't delete items that are stuck in a stash list
            if (!(entry is StashEntry))
            {
                //delete the item after
                if (deed != null)
                {
                    deed.Delete();
                }
                else
                {
                    entry.AbsorbItem(item);
                }
            }



            //start next add and give another cursor
            if (from != null)
            {
                AddItem(from);

                //resend the gump after it's all done
                if (!ItemStoreGump.RefreshGump(from))
                {
                    //send a new gump if there's no existing one up
                    from.SendGump(new ItemStoreGump(from, this));
                }
            }
        }