Beispiel #1
0
        private void SetChunkNeighborhood(TerrainChunk chunk)
        {
            TerrainChunk xUp;
            TerrainChunk xDown;
            TerrainChunk zUp;
            TerrainChunk zDown;

            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X + 1, chunk.Position.Z), out xUp);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X - 1, chunk.Position.Z), out xDown);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X, chunk.Position.Z + 1), out zUp);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X, chunk.Position.Z - 1), out zDown);

            if (xUp != null)
            {
                chunk.SetNeighbors(xUp, TerrainNeighbor.XUp);
                xUp.SetNeighbors(chunk, TerrainNeighbor.XDown);
            }
            if (xDown != null)
            {
                chunk.SetNeighbors(xDown, TerrainNeighbor.XDown);
                xDown.SetNeighbors(chunk, TerrainNeighbor.XUp);
            }
            if (zUp != null)
            {
                chunk.SetNeighbors(zUp, TerrainNeighbor.ZUp);
                zUp.SetNeighbors(chunk, TerrainNeighbor.ZDown);
            }
            if (zDown != null)
            {
                chunk.SetNeighbors(zDown, TerrainNeighbor.ZDown);
                zDown.SetNeighbors(chunk, TerrainNeighbor.ZUp);
            }
        }
 private void GenerateChunk(int x, int z)
 {
     if (Cache.ChunkCanBeAdded(x, z))
     {
         var chunk = new TerrainChunk(Settings, NoiseProvider, x, z);
         Cache.AddNewChunk(chunk);
     }
 }
 private void GenerateChunk(int x, int z)
 {
     if (Cache.ChunkCanBeAdded(x, z))
     {
         var chunk = new TerrainChunk(Settings, NoiseProvider, x, z);
         Cache.AddNewChunk(chunk);
     }
 }
        public void addChunk(int x, int y)
        {
            TerrainChunk chunk = new TerrainChunk(Settings, NoiseProvider, x, y);

            chunk.GenerateHeightmap();
            chunks.Add(chunk);
            newestChunk = chunk;
        }
 private void GenerateChunk(int x, int z)
 {
     if (Cache.ChunkCanBeAdded(x, z))
     {
         NoiseProvider = new NoiseProvider(perlinHeight, perlinDamper);
         var chunk = new TerrainChunk(Settings, NoiseProvider, x, z);
         Cache.AddNewChunk(chunk);
     }
 }
Beispiel #6
0
 private void GenerateChunk(int x, int z)
 {
     //Debug.Log("TCG.GenerateChunk()  => " + "[" + x + "," + z +"]");
     if (Cache.ChunkCanBeAdded(x, z))
     {
         ChunkEdge edgetype = CheckChunkIsEdge(new Vector2i(x, z));
         var       chunk    = new TerrainChunk(Settings, WorldGenerator, edgetype, x, z);
         Cache.AddNewChunk(chunk);
     }
 }
Beispiel #7
0
 public void RemoveFromNeighborhood(TerrainChunk chunk)
 {
     if (Neighborhood.XDown == chunk)
     {
         Neighborhood.XDown = null;
     }
     if (Neighborhood.XUp == chunk)
     {
         Neighborhood.XUp = null;
     }
     if (Neighborhood.ZDown == chunk)
     {
         Neighborhood.ZDown = null;
     }
     if (Neighborhood.ZUp == chunk)
     {
         Neighborhood.ZUp = null;
     }
 }
Beispiel #8
0
        public void SetNeighbors(TerrainChunk chunk, TerrainNeighbor direction)
        {
            if (chunk != null)
            {
                switch (direction)
                {
                case TerrainNeighbor.XUp:
                    Neighborhood.XUp = chunk;
                    break;

                case TerrainNeighbor.XDown:
                    Neighborhood.XDown = chunk;
                    break;

                case TerrainNeighbor.ZUp:
                    Neighborhood.ZUp = chunk;
                    break;

                case TerrainNeighbor.ZDown:
                    Neighborhood.ZDown = chunk;
                    break;
                }
            }
        }
        public void SetNeighbors(TerrainChunk chunk, TerrainNeighbor direction)
        {
            if (chunk != null)
            {
                switch (direction)
                {
                    case TerrainNeighbor.XUp:
                        Neighborhood.XUp = chunk;
                        break;

                    case TerrainNeighbor.XDown:
                        Neighborhood.XDown = chunk;
                        break;

                    case TerrainNeighbor.ZUp:
                        Neighborhood.ZUp = chunk;
                        break;

                    case TerrainNeighbor.ZDown:
                        Neighborhood.ZDown = chunk;
                        break;
                }
            }
        }
 public void RemoveFromNeighborhood(TerrainChunk chunk)
 {
     if (Neighborhood.XDown == chunk)
         Neighborhood.XDown = null;
     if (Neighborhood.XUp == chunk)
         Neighborhood.XUp = null;
     if (Neighborhood.ZDown == chunk)
         Neighborhood.ZDown = null;
     if (Neighborhood.ZUp == chunk)
         Neighborhood.ZUp = null;
 }
Beispiel #11
0
 public void AddNewChunk(TerrainChunk chunk)
 {
     RequestedChunks.Add(chunk.Position, chunk);
     GenerateHeightmapForAvailableChunks();
 }
Beispiel #12
0
 public void AddNewChunk(TerrainChunk chunk)
 {
     RequestedChunks.Add(chunk.Position, chunk);
     GenerateHeightmapForAvailableChunks();
 }
Beispiel #13
0
        private void SetChunkNeighborhood(TerrainChunk chunk)
        {
            TerrainChunk xUp;
            TerrainChunk xDown;
            TerrainChunk zUp;
            TerrainChunk zDown;

            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X + 1, chunk.Position.Z), out xUp);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X - 1, chunk.Position.Z), out xDown);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X, chunk.Position.Z + 1), out zUp);
            LoadedChunks.TryGetValue(new Vector2i(chunk.Position.X, chunk.Position.Z - 1), out zDown);

            if (xUp != null)
            {
                chunk.SetNeighbors(xUp, TerrainNeighbor.XUp);
                xUp.SetNeighbors(chunk, TerrainNeighbor.XDown);
            }
            if (xDown != null)
            {
                chunk.SetNeighbors(xDown, TerrainNeighbor.XDown);
                xDown.SetNeighbors(chunk, TerrainNeighbor.XUp);
            }
            if (zUp != null)
            {
                chunk.SetNeighbors(zUp, TerrainNeighbor.ZUp);
                zUp.SetNeighbors(chunk, TerrainNeighbor.ZDown);
            }
            if (zDown != null)
            {
                chunk.SetNeighbors(zDown, TerrainNeighbor.ZDown);
                zDown.SetNeighbors(chunk, TerrainNeighbor.ZUp);
            }
        }