Example #1
0
        public static void CollectionBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            // Create rec and retrieve items within from bounding box callback
            // result
            Rectangle2D       rect    = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
            IPooledEnumerable eable   = map.GetObjectsInBounds(rect);
            Archive           archive = state as Archive;

            if (archive == null || archive.Deleted)
            {
                return;
            }

            // temp list for the items & Mobules we want to archive
            ArrayList temp = new ArrayList();

            // Loop through and add objects returned
            foreach (object obj in eable)
            {
                Item   item   = obj as Item;
                Mobile mobile = obj as Mobile;
                if (item == null && mobile == null)
                {
                    continue;
                }

                // no deleted items
                if (item != null && (item.Deleted))
                {
                    continue;
                }

                // no deleted items or players
                if (mobile != null && (mobile.Deleted || mobile is Server.Mobiles.PlayerMobile))
                {
                    continue;
                }

                // add the item to the temp storage
                temp.Add(obj);
            }
            eable.Free();

            // items this pass
            int mCount = 0, iCount = 0;

            foreach (object obj in temp)
            {
                Item   item   = obj as Item;
                Mobile mobile = obj as Mobile;

                if (item != null)
                {                       // move the item to the internal map at the original location
                    item.MoveItemToIntStorage(true);
                    // add the item to the archive
                    archive.AddItem(item);
                    iCount++;
                }

                else if (mobile != null)
                {                       // move the mobile to the internal map at the original location
                    mobile.MoveMobileToIntStorage(true);
                    // add the item to the archive
                    archive.AddMobile(mobile);
                    mCount++;
                }
            }

            from.SendMessage("{0} items and {1} mobiles added to this archive.", iCount, mCount);
            from.SendMessage("Archive now contains {0} objects total.", archive.ObjectCount);
        }