SetTileData() public method

public SetTileData ( IntVector3 p, TileData data ) : void
p IntVector3
data TileData
return void
Example #1
0
        public void AdjustRiver()
        {
            int minZ = m_riverPath.Min(p => m_terrain.GetSurfaceLevel(p));

            var pos = DirectionSet.Cardinal | DirectionSet.Exact;

            var coreLocs = new HashSet <IntVector2>(m_riverPath.SelectMany(p => pos.ToSurroundingPoints(p)));

            foreach (var pp in coreLocs)
            {
                if (m_terrain.Size.Plane.Contains(pp) == false)
                {
                    continue;
                }

                for (int z = m_terrain.Depth - 1; z >= minZ - 1; --z)
                {
                    var p = new IntVector3(pp.X, pp.Y, z);

                    var td = TileData.EmptyTileData;

                    if (z == minZ - 1)
                    {
                        td.WaterLevel = TileData.MaxWaterLevel;
                    }

                    m_terrain.SetTileData(p, td);
                }
            }
        }
Example #2
0
        public static void CreateSlopes(TerrainData data, int baseSeed)
        {
            var plane = data.Size.Plane;

            plane.Range().AsParallel().ForAll(p =>
            {
                int z = data.GetHeight(p);

                int count = 0;
                Direction dir = Direction.None;

                var r = new MWCRandom(p, baseSeed);

                int offset = r.Next(8);

                // Count the tiles around this tile which are higher. Create slope to a random direction, but skip
                // the slope if all 8 tiles are higher.
                // Count to 10. If 3 successive slopes, create one in the middle
                int successive = 0;
                for (int i = 0; i < 10; ++i)
                {
                    var d = DirectionExtensions.PlanarDirections[(i + offset) % 8];

                    var t = p + d;

                    if (plane.Contains(t) && data.GetHeight(t) > z)
                    {
                        if (i < 8)
                            count++;
                        successive++;

                        if (successive == 3)
                        {
                            dir = DirectionExtensions.PlanarDirections[((i - 1) + offset) % 8];
                        }
                        else if (dir == Direction.None)
                        {
                            dir = d;
                        }
                    }
                    else
                    {
                        successive = 0;
                    }
                }

                if (count > 0 && count < 8)
                {
                    var p3d = new IntPoint3(p, z);

                    var td = data.GetTileData(p3d);
                    td.TerrainID = dir.ToSlope();
                    data.SetTileData(p3d, td);
                }
            });
        }
Example #3
0
        public static void CreateSoil(TerrainData data, int soilLimit)
        {
            int w = data.Width;
            int h = data.Height;

            for (int y = 0; y < h; ++y)
            {
                for (int x = 0; x < w; ++x)
                {
                    int z = data.GetHeight(x, y);

                    var p = new IntPoint3(x, y, z);

                    if (z < soilLimit)
                    {
                        var td = data.GetTileData(p);

                        td.TerrainMaterialID = MaterialID.Loam;

                        data.SetTileData(p, td);
                    }
                }
            }
        }
 void SetTileData(IntVector3 p, TileData td)
 {
     m_data.SetTileData(p, td);
 }