OpenRA.MapGrid.MapGrid C# (CSharp) Method

MapGrid() public method

public MapGrid ( MiniYaml yaml ) : System.Collections.Generic
yaml MiniYaml
return System.Collections.Generic
        public MapGrid(MiniYaml yaml)
        {
            FieldLoader.Load(this, yaml);

            // The default subcell index defaults to the middle entry
            var defaultSubCellIndex = (byte)DefaultSubCell;
            if (defaultSubCellIndex == byte.MaxValue)
                DefaultSubCell = (SubCell)(SubCellOffsets.Length / 2);
            else if (defaultSubCellIndex < (SubCellOffsets.Length > 1 ? 1 : 0) || defaultSubCellIndex >= SubCellOffsets.Length)
                throw new InvalidDataException("Subcell default index must be a valid index into the offset triples and must be greater than 0 for mods with subcells");

            var leftDelta = Type == MapGridType.RectangularIsometric ? new WVec(-512, 0, 0) : new WVec(-512, -512, 0);
            var topDelta = Type == MapGridType.RectangularIsometric ? new WVec(0, -512, 0) : new WVec(512, -512, 0);
            var rightDelta = Type == MapGridType.RectangularIsometric ? new WVec(512, 0, 0) : new WVec(512, 512, 0);
            var bottomDelta = Type == MapGridType.RectangularIsometric ? new WVec(0, 512, 0) : new WVec(-512, 512, 0);
            CellCorners = cellCornerHalfHeights.Select(ramp => new WVec[]
            {
                leftDelta + new WVec(0, 0, 512 * ramp[0]),
                topDelta + new WVec(0, 0, 512 * ramp[1]),
                rightDelta + new WVec(0, 0, 512 * ramp[2]),
                bottomDelta + new WVec(0, 0, 512 * ramp[3])
            }).ToArray();

            TilesByDistance = CreateTilesByDistance();
        }