コード例 #1
0
 /// <summary>
 /// Forwards the call to MapFileChild.
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 /// <param name="levs"></param>
 /// <param name="zType"></param>
 /// <returns>a bitwise int of changes
 ///          0x0 - no changes
 ///          0x1 - Map changed
 ///          0x2 - Routes changed</returns>
 public virtual int MapResize(
     int rows,
     int cols,
     int levs,
     MapResizeService.MapResizeZtype zType)
 {
     return(0x0);
 }
コード例 #2
0
        /// <summary>
        /// Resizes the current Map.
        /// </summary>
        /// <param name="rows">total rows in the new Map</param>
        /// <param name="cols">total columns in the new Map</param>
        /// <param name="levs">total levels in the new Map</param>
        /// <param name="zType">MRZT_TOP to add or subtract delta-levels
        /// starting at the top level, MRZT_BOT to add or subtract delta-levels
        /// starting at the ground level - but only if a height difference is
        /// found for either case</param>
        /// <returns>a bitwise int of changes
        ///          0x0 - no changes
        ///          0x1 - Map changed
        ///          0x2 - Routes changed</returns>
        public override int MapResize(
            int rows,
            int cols,
            int levs,
            MapResizeService.MapResizeZtype zType)
        {
            int bit = 0x0;

            var tileList = MapResizeService.GetResizedTileList(
                rows, cols, levs,
                MapSize,
                MapTiles,
                zType);

            if (tileList != null)
            {
                bit |= 0x1;

                int
                    preRows = MapSize.Rows,
                    preCols = MapSize.Cols,
                    preLevs = MapSize.Levs;

                if (zType == MapResizeService.MapResizeZtype.MRZT_TOP &&              // adjust route-nodes ->
                    Routes.Any())
                {
                    bit |= 0x2;

                    int delta = (levs - preLevs);                       // NOTE: map levels are inverted so adding or subtracting levels
                    // to the top needs to push any existing node-levels down or up.
                    foreach (RouteNode node in Routes)
                    {
                        if (node.Lev < 128)                         // allow nodes that are OoB to come back into view
                        {
                            if ((node.Lev += delta) < 0)            // NOTE: node x/y/z are stored as bytes.
                            {
                                node.Lev += 256;                    // -> ie. level -1 = level 255
                            }
                        }
                        else
                        {
                            if ((node.Lev += delta - 256) < 0)                                  // nodes above the highest Maplevel maintain
                            {
                                node.Lev += 256;                                                // their relative z-level
                            }
                        }
                    }
                }

                MapSize  = new MapSize(rows, cols, levs);
                MapTiles = tileList;

                if (RouteCheckService.CheckNodeBounds(this))
                {
                    bit |= 0x2;
                }

                ClearRouteNodes();
                SetupRouteNodes();

                Level = 0;                 // fires a LevelChangedEvent.
            }
            return(bit);
        }