PsmFramework.Engines.DrawEngine2d.TiledTextures.GridIndex.BuildKeyList C# (CSharp) Méthode

BuildKeyList() private méthode

private BuildKeyList ( Int32 columns, Int32 rows ) : void
columns System.Int32
rows System.Int32
Résultat void
        private void BuildKeyList(Int32 columns, Int32 rows)
        {
            //At least 1
            if(columns < 1 || rows < 1)
                throw new ArgumentOutOfRangeException();

            //Can't be greater than number of pixels
            if(columns > TiledTexture.Texture.Width || rows > TiledTexture.Texture.Height)
                throw new ArgumentOutOfRangeException();

            //Must be evenly divisible
            if(TiledTexture.Texture.Width % columns != 0 || TiledTexture.Texture.Height % rows != 0)
                throw new ArgumentOutOfRangeException();

            Int32 tileWidth = TiledTexture.Texture.Width / columns;
            Int32 tileHeight = TiledTexture.Texture.Height / rows;

            for(Int32 r = 0; r < rows; r++)
            {
                for(Int32 c = 0; c < columns; c++)
                {
                    Int32 left = c * tileWidth;
                    Int32 right = left + tileWidth;

                    Int32 top = r * tileHeight;
                    Int32 bottom = top + tileHeight;

                    Texture2dArea area = new Texture2dArea(left, top, right, bottom, TiledTexture.Texture.Width, TiledTexture.Texture.Height);

                    GridLocation loc = new GridLocation(c, r);

                    GridKey key = new GridKey(this, c, r, area);
                    Keys.Add(loc, key);
                }
            }
        }