Dwarrowdelf.TerrainGen.TerrainData.GetSurfaceLevel C# (CSharp) Method

GetSurfaceLevel() public method

public GetSurfaceLevel ( int x, int y ) : int
x int
y int
return int
        public int GetSurfaceLevel(int x, int y)
        {
            return m_levelMap[y, x];
        }

Same methods

TerrainData::GetSurfaceLevel ( IntVector2 p ) : int

Usage Example

Example #1
0
        IntVector3 FindStartLoc(Random r, SideEdge edge)
        {
            int side = m_terrain.Width;

            int yo = r.Next(0, side);
            int zo = m_terrain.GetSurfaceLevel(MapCoord(yo, edge));

            int yu = yo;
            int zu = zo;

            for (int y = yo - 1; y >= 0; --y)
            {
                int z = m_terrain.GetSurfaceLevel(MapCoord(y, edge));
                if (z < zu)
                {
                    zu = z;
                    yu = y;
                }

                if (z - 2 > zu)
                {
                    break;
                }
            }

            int yd = yo;
            int zd = zo;

            for (int y = yo + 1; y < side; ++y)
            {
                int z = m_terrain.GetSurfaceLevel(MapCoord(y, edge));
                if (z < zd)
                {
                    zd = z;
                    yd = y;
                }

                if (z - 2 > zd)
                {
                    break;
                }
            }

            int yf = zd < zu ? yd : yu;
            var p2 = MapCoord(yf, edge);

            return(m_terrain.GetSurfaceLocation(p2));
        }
All Usage Examples Of Dwarrowdelf.TerrainGen.TerrainData::GetSurfaceLevel