示例#1
0
    public void CreateChunk(int x, int y, int z)
    {
        Vector3Int worldPos = new Vector3Int(x, y, z);

        var chunkObject = Instantiate(ChunkPrefab, new Vector3(x, y, z), Quaternion.Euler(Vector3.zero), transform) as GameObject;

        Chunk newChunk = chunkObject.GetComponent <Chunk>();

        newChunk.pos   = worldPos;
        newChunk.world = this;
        newChunk.name  = $"{worldPos.x}_{worldPos.y}_{worldPos.z}";

        chunks.Add(worldPos, newChunk);

        bool loaded = Serialization.Load(newChunk);

        if (loaded)
        {
            return;
        }

        var terrainGenerationMethod = new TerrainGeneration(BlocsDefinition);

        newChunk = terrainGenerationMethod.GenerateChunk3D(newChunk);
    }