add on_chunk_present and on_chunk_remove events
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user