Esempio n. 1
0
    /// <summary>
    /// Add a chunk at selected chunk coordinates
    /// </summary>
    private VoxelChunk AddChunk(int X, int Z)
    {
        VoxelChunk chunk = null;

        if (mChunkPool.Count != 0)
        {
            chunk = mChunkPool.Dequeue();
        }
        else
        {
            chunk = VoxelChunk.NewPoolObj(this);
            Debug.LogWarning("Chunk pool was empty, so had to create a new object");
        }

        chunk.Construct(X, Z);
        mActiveChunks[new ChunkID(X, Z)] = chunk;
        return(chunk);
    }
Esempio n. 2
0
    /// <summary>
    /// Creates voxel terrain object
    /// </summary>
    public static VoxelTerrain New(int Y)
    {
        GameObject obj = new GameObject("Layer " + Y);

        obj.isStatic           = true;
        obj.transform.position = new Vector3(0, VoxelChunk.ChunkHeight * Y, 0) * WorldManager.VoxelToUnitScale;


        VoxelTerrain terrain = obj.AddComponent <VoxelTerrain>();

        terrain.Y = Y;
        terrain.mTerrainGenerator = new TerrainGen_Overworld(123);


        // Create chunk pool
        for (int i = 0; i < 30; ++i)
        {
            terrain.mChunkPool.Enqueue(VoxelChunk.NewPoolObj(terrain));
        }


        return(terrain);
    }