示例#1
0
    public void RemoveBlock(GameObject currentChunk, Block block)
    {
        ChunkDictionary.Remove(block.Position);
        //Ich entferne erst den Block auf dem Chunk
        IChunk chunk = currentChunk.GetComponent <IChunk>();

        chunk.RemoveBlock(block);
        // Und erstelle anschließend mit den restlichen Blöcken den Chunk
        ModifyMesh.RemoveBlockFromMesh(currentChunk.transform, block);

        DeleteChunkIfNotNeeded(chunk);
    }
示例#2
0
    public void AddBlock(Block block)
    {
        Vector3 centeredCubePosition = block.Position;

        ChunkDictionary.Add(block.Position, block.Position);

        (IChunk chunk, GameObject parent, bool hasCreatedNewChunk) = GenerateOrGetChunkGameObject(centeredCubePosition);
        chunk.AddBlock(block);


        if (!hasCreatedNewChunk)
        {
            ModifyMesh.Combine(block, parent);
        }
        else
        {
            ModifyMesh.CombineForAll(parent);
        }
    }
示例#3
0
 public void GenerateChunk() => ModifyMesh.CombineForAll(transform.gameObject);