mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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
|
|
@ -14,6 +14,7 @@
|
|||
#include "scripting/scripting.hpp"
|
||||
#include "lighting/Lighting.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "world/LevelEvents.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
|
||||
|
|
@ -26,6 +27,14 @@ LevelController::LevelController(
|
|||
level(std::move(levelPtr)),
|
||||
chunks(std::make_unique<ChunksController>(*level)),
|
||||
playerTickClock(20, 3) {
|
||||
|
||||
level->events->listen(LevelEventType::CHUNK_PRESENT, [](auto, Chunk* chunk) {
|
||||
scripting::on_chunk_present(*chunk, chunk->flags.loaded);
|
||||
});
|
||||
level->events->listen(LevelEventType::CHUNK_UNLOAD, [](auto, Chunk* chunk) {
|
||||
scripting::on_chunk_remove(*chunk);
|
||||
});
|
||||
|
||||
if (clientPlayer) {
|
||||
chunks->lighting = std::make_unique<Lighting>(
|
||||
level->content, *clientPlayer->chunks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue