CNCMaps.Engine.Map.Map.FindCutoffHeight C# (CSharp) Method

FindCutoffHeight() public method

public FindCutoffHeight ( ) : int
return int
        public int FindCutoffHeight()
        {
            // searches in 10 rows, starting from the bottom up, for the first fully tiled row
            int y;

            #if DEBUG && FALSE
            // print map:
            var tileTouchGrid = _tiles.GridTouched;
            var sb = new System.Text.StringBuilder();
            for (y = 0; y < tileTouchGrid.GetLength(1); y++) {
                for (int x = 0; x < tileTouchGrid.GetLength(0); x++) {
                    if (tileTouchGrid[x, y] == TileLayer.TouchType.Untouched)
                        sb.Append(' ');
                    else if ((tileTouchGrid[x, y] & TileLayer.TouchType.ByExtraData) == TileLayer.TouchType.ByExtraData)
                        sb.Append('*');
                    else
                        sb.Append('o');
                }
                sb.AppendLine();
            }
            // File.WriteAllText("cutoffmap.txt", sb.ToString());
            #endif

            for (y = FullSize.Height - 1; y > FullSize.Height - 10; y--) {
                bool isRowFilled = true;
                for (int x = 1; x < FullSize.Width * 2 - 3; x++) {
                    if (_tiles.GridTouched[x, y] == TileLayer.TouchType.Untouched) {
                        isRowFilled = false;
                        break;
                    }
                }
                if (isRowFilled)
                    break;
            }
            Logger.Debug("Cutoff-height determined at {0}, cutting off {1} rows", y, FullSize.Height - y);
            return y;
        }