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); }
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); } }
public void GenerateChunk() => ModifyMesh.CombineForAll(transform.gameObject);