public void TransferContents(Mobile from)
        {
            if (m_mate != null && !m_mate.Deleted)
            {
                if (Items.Count <= m_maxItems)
                {
                    if (m_currentCharge > 0)
                    {
                    Transfer:
                        int notTransferable = 0;
                        Items.ForEach(delegate(Item i)
                        {
                            if (i is Container || i is TransferChest)
                            {
                                from.SendMessage("You cannot send a container through the chest.");
                                notTransferable++;
                            }
                            else if (i is TransferKey)
                            {
                                from.SendMessage("You cannot send a transfer chest key through the chest.");
                                notTransferable++;
                            }
                            else if (i is TransferChestDeed)
                            {
                                from.SendMessage("You cannot send a transfer chest deed through the chest.");
                                notTransferable++;
                            }
                            else if (i.Weight > m_maxItemWeight)
                            {
                                string name;
                                if (i.Name == null)
                                    name = i.DefaultName;
                                else
                                    name = i.Name;
                                from.SendMessage("{0} is too heavy to send through this chest.", name);
                                notTransferable++;
                            }
                            else
                            {
                                m_mate.AddItem(i);
                                m_currentCharge -= 1;
                                if (m_currentCharge <= 0)
                                {
                                    if ((this.Mate.CurrentCharge <= 0) && (m_deleteOnNoCharge))
                                    {
                                        from.SendMessage("The chest ran out of charges during the transfer and will delete itself in 5 minutes.");
                                        TransferDeleteTimer timer = new TransferDeleteTimer(this);
                                        timer.Start();
                                        if (this.Mate.Items.Count <= 0)
                                        {
                                            this.Mate.Locked = true;
                                            this.Mate.KeyValue = 0;
                                            TransferDeleteTimer timerMate = new TransferDeleteTimer(this.Mate);
                                            timerMate.Start();
                                        }
                                    }
                                    else
                                    {
                                        from.SendMessage("The chest ran out of charges during the transfer.");
                                        this.Locked = false;
                                        return;
                                    }
                                }
                            }
                        });//end loop

                        if (Items.Count != notTransferable)
                        {
                            goto Transfer;//need this for some weird bug of transferring only half of the total items each iteration :(
                        }
                    }
                    else
                    {
                        if (this.Mate.CurrentCharge <= 0)
                        {
                            if (m_deleteOnNoCharge)
                            {
                                TransferDeleteTimer timer = new TransferDeleteTimer(this);
                                timer.Start();
                                if (this.Mate.Items.Count <= 0)
                                {
                                    this.Mate.Locked = true;
                                    this.Mate.KeyValue = 0;
                                    TransferDeleteTimer timerMate = new TransferDeleteTimer(this.Mate);
                                    timerMate.Start();
                                    from.SendMessage("Both this chest and its mate are out of charges, they will be deleted in 5 minutes.");
                                }
                                else
                                {
                                    from.SendMessage("Both this chest and its mate are out of charges, this one will be deleted in 5 minutes.");

                                }
                            }
                            else
                            {
                                from.SendMessage("Both this chest and its mate are out of charges.");
                            }
                        }
                        else
                        {
                            from.SendMessage("The chest is out of charges.");
                        }
                        this.Locked = false;//unlock it if the transfer didnt work

                    }
                }
                else
                {
                    from.SendMessage("There are too many items in this chest to send at one time.");
                    this.Locked = false;
                }
            }
            else
            {
                from.SendMessage("This chest will be destroyed in 5 minutes since it does not have a mate.");
                TransferDeleteTimer timer = new TransferDeleteTimer(this);
                timer.Start();
                this.Locked = false;
            }
        }
示例#2
0
        public void TransferContents(Mobile from)
        {
            if (m_mate != null && !m_mate.Deleted)
            {
                if (Items.Count <= m_maxItems)
                {
                    if (m_currentCharge > 0)
                    {
Transfer:
                        int notTransferable = 0;
                        Items.ForEach(delegate(Item i)
                        {
                            if (i is Container || i is TransferChest)
                            {
                                from.SendMessage("You cannot send a container through the chest.");
                                notTransferable++;
                            }
                            else if (i is TransferKey)
                            {
                                from.SendMessage("You cannot send a transfer chest key through the chest.");
                                notTransferable++;
                            }
                            else if (i is TransferChestDeed)
                            {
                                from.SendMessage("You cannot send a transfer chest deed through the chest.");
                                notTransferable++;
                            }
                            else if (i.Weight > m_maxItemWeight)
                            {
                                string name;
                                if (i.Name == null)
                                {
                                    name = i.DefaultName;
                                }
                                else
                                {
                                    name = i.Name;
                                }
                                from.SendMessage("{0} is too heavy to send through this chest.", name);
                                notTransferable++;
                            }
                            else
                            {
                                m_mate.AddItem(i);
                                m_currentCharge -= 1;
                                if (m_currentCharge <= 0)
                                {
                                    if ((this.Mate.CurrentCharge <= 0) && (m_deleteOnNoCharge))
                                    {
                                        from.SendMessage("The chest ran out of charges during the transfer and will delete itself in 5 minutes.");
                                        TransferDeleteTimer timer = new TransferDeleteTimer(this);
                                        timer.Start();
                                        if (this.Mate.Items.Count <= 0)
                                        {
                                            this.Mate.Locked              = true;
                                            this.Mate.KeyValue            = 0;
                                            TransferDeleteTimer timerMate = new TransferDeleteTimer(this.Mate);
                                            timerMate.Start();
                                        }
                                    }
                                    else
                                    {
                                        from.SendMessage("The chest ran out of charges during the transfer.");
                                        this.Locked = false;
                                        return;
                                    }
                                }
                            }
                        });//end loop

                        if (Items.Count != notTransferable)
                        {
                            goto Transfer;//need this for some weird bug of transferring only half of the total items each iteration :(
                        }
                    }
                    else
                    {
                        if (this.Mate.CurrentCharge <= 0)
                        {
                            if (m_deleteOnNoCharge)
                            {
                                TransferDeleteTimer timer = new TransferDeleteTimer(this);
                                timer.Start();
                                if (this.Mate.Items.Count <= 0)
                                {
                                    this.Mate.Locked   = true;
                                    this.Mate.KeyValue = 0;
                                    TransferDeleteTimer timerMate = new TransferDeleteTimer(this.Mate);
                                    timerMate.Start();
                                    from.SendMessage("Both this chest and its mate are out of charges, they will be deleted in 5 minutes.");
                                }
                                else
                                {
                                    from.SendMessage("Both this chest and its mate are out of charges, this one will be deleted in 5 minutes.");
                                }
                            }
                            else
                            {
                                from.SendMessage("Both this chest and its mate are out of charges.");
                            }
                        }
                        else
                        {
                            from.SendMessage("The chest is out of charges.");
                        }
                        this.Locked = false;//unlock it if the transfer didnt work
                    }
                }
                else
                {
                    from.SendMessage("There are too many items in this chest to send at one time.");
                    this.Locked = false;
                }
            }
            else
            {
                from.SendMessage("This chest will be destroyed in 5 minutes since it does not have a mate.");
                TransferDeleteTimer timer = new TransferDeleteTimer(this);
                timer.Start();
                this.Locked = false;
            }
        }