protected override void OnTarget(Mobile from, object targeted)
        {
            if (m_Request.Items.Count == 0)
            {
                m_Request.SendResponse(null);
            }

            ArrayList itemSerials = new ArrayList(m_Request.Items.Count);             // Used to store the serials of the created items

            IPoint3D p = targeted as IPoint3D;

            if (p != null)
            {
                if (p is Item)
                {
                    p = ((Item)p).GetWorldLocation();
                }

                for (int i = 0; i < m_Request.Items.Count; ++i)
                {
                    DesignItem designItem = m_Request.Items[i];

                    try
                    {
                        Point3D location = new Point3D(p.X + designItem.X, p.Y + designItem.Y, p.Z + designItem.Z);

                        Item item = CreateItem(designItem.ItemID);

                        #region MobileSaver
                        if (item.ItemID == 0x1)
                        {
                            Spawner spawner = MobileSaver.LoadMobile(item);

                            if (spawner != null)
                            {
                                itemSerials.Add(spawner.Serial.Value);
                            }

                            item.Delete();
                            continue;
                        }
                        #endregion

                        item.MoveToWorld(location, from.Map);
                        item.Hue = designItem.Hue;
                        itemSerials.Add(item.Serial.Value);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Unable to import item: " + e.Message);
                    }
                }
            }

            int[] serials = (int[])itemSerials.ToArray(typeof(int));

            m_Request.SendResponse(new BuildResponse(serials));             // send the serial list back to the client
        }
Beispiel #2
0
        private void ExtractItems()
        {
            foreach (Rect2D rect in _rects)
            {
                #region MobileSaver
                Rectangle2D realrectangle = new Rectangle2D(rect.TopX, rect.TopY, rect.Width, rect.Height);

                foreach (Mobile m in _map.GetMobilesInBounds(realrectangle))
                {
                    if (m != null && m is BaseCreature)
                    {
                        int saveflag = MobileSaver.GetSaveFlag(m);

                        if (saveflag > 0)
                        {
                            DesignItem designItem = new DesignItem();
                            designItem.ItemID = (short)0x1;
                            designItem.X      = m.X;
                            designItem.Y      = m.Y;
                            designItem.Z      = m.Z + saveflag;
                            designItem.Hue    = (short)m.Hue;
                        }
                    }
                }
                #endregion

                for (int x = 0; x <= rect.Width; ++x)
                {
                    for (int y = 0; y <= rect.Height; ++y)
                    {
                        int tileX = rect.TopX + x;
                        int tileY = rect.TopY + y;

                        Sector sector = _map.GetSector(tileX, tileY);

                        if (_args.NonStatic || _args.Static)
                        {
                            for (int i = 0; i < sector.Items.Count; ++i)
                            {
                                Item item = (Item)sector.Items[i];

                                if (!item.Visible)
                                {
                                    continue;
                                }
                                else if ((!_args.NonStatic) && !(item is Static))
                                {
                                    continue;
                                }
                                else if ((!_args.Static) && (item is Static))
                                {
                                    continue;
                                }
                                else if (_args.MinZSet && item.Z < _args.MinZ)
                                {
                                    continue;
                                }
                                else if (_args.MaxZSet && item.Z > _args.MaxZ)
                                {
                                    continue;
                                }

                                int hue = 0;

                                if (_args.ExtractHues)
                                {
                                    hue = item.Hue;
                                }

                                if (item.X == tileX && item.Y == tileY && !((item is BaseMulti) || (item is HouseSign)))
                                {
                                    DesignItem designItem = new DesignItem();
                                    designItem.ItemID = (short)item.ItemID;
                                    designItem.X      = item.X;
                                    designItem.Y      = item.Y;
                                    designItem.Z      = item.Z;
                                    designItem.Hue    = (short)hue;

                                    _items.Add(designItem);
                                }

                                // extract multi
                                if (item is HouseFoundation)
                                {
                                    HouseFoundation house = (HouseFoundation)item;

                                    if (_extractedMultiIds.IndexOf(house.Serial.Value) == -1)
                                    {
                                        ExtractCustomMulti(house);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            ExtractResponse response = new ExtractResponse(_items);

            if (_args.Frozen)
            {
                response.Rects = _rects;
                response.Map   = _map.Name;
            }

            // send response back to the UOAR tool
            SendResponse(response);
        }
        private void BoundingBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            Utility.FixPoints(ref start, ref end);
            Rectangle2D rect = new Rectangle2D(start, end);

            #region MobileSaver
            from.SendMessage("Extracting Mobiles");

            foreach (Mobile m in map.GetMobilesInBounds(rect))
            {
                if (m != null && m is BaseCreature)
                {
                    int saveflag = MobileSaver.GetSaveFlag(m);

                    if (saveflag > 0)
                    {
                        DesignItem designItem = new DesignItem();
                        designItem.ItemID = (short)0x1;
                        designItem.X      = m.X;
                        designItem.Y      = m.Y;
                        designItem.Z      = m.Z + saveflag;
                        designItem.Hue    = (short)m.Hue;
                    }
                }
            }
            #endregion

            for (int x = 0; x <= rect.Width; ++x)
            {
                for (int y = 0; y <= rect.Height; ++y)
                {
                    int tileX = rect.Start.X + x;
                    int tileY = rect.Start.Y + y;

                    Sector sector = map.GetSector(tileX, tileY);

                    for (int i = 0; i < sector.Items.Count; ++i)
                    {
                        Item item = (Item)sector.Items[i];

                        if (_args.UseMinZ && item.Z < _args.MinZ)
                        {
                            continue;
                        }
                        else if (_args.UseMaxZ && item.Z > _args.MaxZ)
                        {
                            continue;
                        }

                        if (item.Visible && item.X == tileX && item.Y == tileY && !((item is BaseMulti) || (item is HouseSign)))
                        {
                            _itemSerials.Add(item.Serial.Value);
                        }
                    }
                }
            }

            if (_itemSerials.Count > 0)
            {
                SendResponse(new SelectItemsResponse((int[])_itemSerials.ToArray(typeof(int))));
            }
            else
            {
                SendResponse(null);
            }
        }