mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
add on_chunk_present and on_chunk_remove events
This commit is contained in:
parent
cfa6b5e578
commit
22c7cb8398
9 changed files with 65 additions and 9 deletions
|
|
@ -34,7 +34,7 @@ Chunks::Chunks(
|
|||
areaMap(w, d) {
|
||||
areaMap.setCenter(ox-w/2, oz-d/2);
|
||||
areaMap.setOutCallback([this](int, int, const auto& chunk) {
|
||||
this->events->trigger(EVT_CHUNK_HIDDEN, chunk.get());
|
||||
this->events->trigger(LevelEventType::CHUNK_HIDDEN, chunk.get());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ void Chunks::resize(uint32_t newW, uint32_t newD) {
|
|||
bool Chunks::putChunk(const std::shared_ptr<Chunk>& chunk) {
|
||||
if (areaMap.set(chunk->x, chunk->z, chunk)) {
|
||||
if (events) {
|
||||
events->trigger(LevelEventType::EVT_CHUNK_SHOWN, chunk.get());
|
||||
events->trigger(LevelEventType::CHUNK_SHOWN, chunk.get());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "objects/Entities.hpp"
|
||||
#include "voxels/blocks_agent.hpp"
|
||||
#include "typedefs.hpp"
|
||||
#include "world/LevelEvents.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "Block.hpp"
|
||||
|
|
@ -125,6 +126,8 @@ std::shared_ptr<Chunk> GlobalChunks::create(int x, int z) {
|
|||
chunk->flags.loadedLights = true;
|
||||
}
|
||||
chunk->blocksMetadata = regions.getBlocksData(chunk->x, chunk->z);
|
||||
|
||||
level.events->trigger(LevelEventType::CHUNK_PRESENT, chunk.get());
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue