Exemple #1
0
 // Debug Purposes
 public void RegenerateAll()
 {
     foreach (Chunk c in Chunks.Values)
     {
         ChunkRenderer renderer = c.GetComponent <ChunkRenderer>();
         // Procedural Generation & Mesh
         ProceduralGeneration.AsyncGenerateChunk(c, () => renderer.RegenerateMesh());
     }
 }
Exemple #2
0
    private void CreateChunk(Vector3Int index)
    {
        // Create GameObject, Componentes, Position and Parent
        GameObject newChunk = new GameObject(index.ToString());
        Chunk      c        = newChunk.AddComponent <Chunk>();

        c.Index = index;
        ChunkRenderer renderer = newChunk.AddComponent <ChunkRenderer>();

        c.SetChunkRenderer(renderer);
        newChunk.transform.position = Vector3.Scale(Chunk.ChunkSize, index) + new Vector3(0.5f, 0.5f, 0.5f);
        newChunk.transform.SetParent(transform, true); // Chunk is a child of ChunkManager
                                                       // Add to Dictionary
        Chunks.Add(index, c);
        // Procedural Generation & Mesh
        ProceduralGeneration.AsyncGenerateChunk(c, () => renderer.RegenerateMesh());
        // Main Thread operations
        NotFinishedChunks.Add(c);
    }
Exemple #3
0
 public void SetBlock(int x, int y, int z, Block block)
 {
     Voxels[x, y, z] = block;
     ChunkRenderer.RegenerateMesh();
 }