Dwarrowdelf.Client.GrowingTileGrid.DoGrow C# (CSharp) Method

DoGrow() private method

private DoGrow ( IntVector3 p ) : void
p IntVector3
return void
        void DoGrow(IntVector3 p)
        {
            int nw, nh, nd;

            if (p.X < 0 || p.Y < 0 || p.Z < 0)
                throw new Exception();

            nw = Align256(Math.Max(this.Size.Width, p.X + 1));
            nh = Align256(Math.Max(this.Size.Height, p.Y + 1));
            nd = Align16(Math.Max(this.Size.Depth, p.Z + 1));

            var newGrid = new TileData[nd, nh, nw];

            /* XXX Array.Copy will probably give better speed */
            foreach (var l in this.Size.Range())
            {
                var src = m_grid[l.Z, l.Y, l.X];
                newGrid[l.Z, l.Y, l.X] = src;
            }

            m_grid = newGrid;
            this.Size = new IntSize3(nw, nh, nd);

            Debug.Print("GrowingTileGrid.Grow({0})", this.Size);
        }