public void SetBlockAndRecompute(BlockData block, Vector3i pos) { SetBlock(block, pos); Build(Chunk.ToChunkPosition(pos)); foreach (Vector3i dir in Vector3i.directions) { Build(Chunk.ToChunkPosition(pos + dir)); } LightComputer.RecomputeLightAtPosition(this, pos); }
public void SetBlockAndRecompute(BlockData block, Vector3i pos) { SetBlock(block, pos); Vector3i chunkPos = Chunk.ToChunkPosition(pos); Vector3i localPos = Chunk.ToLocalPosition(pos); SetDirty(chunkPos); if (localPos.x == 0) { SetDirty(chunkPos - Vector3i.right); } if (localPos.y == 0) { SetDirty(chunkPos - Vector3i.up); } if (localPos.z == 0) { SetDirty(chunkPos - Vector3i.forward); } if (localPos.x == Chunk.SIZE_X - 1) { SetDirty(chunkPos + Vector3i.right); } if (localPos.y == Chunk.SIZE_Y - 1) { SetDirty(chunkPos + Vector3i.up); } if (localPos.z == Chunk.SIZE_Z - 1) { SetDirty(chunkPos + Vector3i.forward); } SunLightComputer.RecomputeLightAtPosition(this, pos); LightComputer.RecomputeLightAtPosition(this, pos); UpdateMeshColliderAfterBlockChange(); }