diff --git a/main/biome.cpp b/main/biome.cpp index 365333e..b707f13 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -150,6 +150,8 @@ void Biome::generate_stack(Ref chunk, int x, int z, bool spawn_mobs) } void Biome::setup_library(Ref library) { + ERR_FAIL_COND(!library.is_valid()); + if (!_data.is_valid()) return; @@ -167,6 +169,14 @@ void Biome::_setup_library(Ref library) { } } + for (int i = 0; i < get_dungeon_count(); ++i) { + Ref d = get_dungeon(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } + #ifdef PROPS_PRESENT for (int i = 0; i < _data->get_prop_data_count(); ++i) { Ref s = _data->get_prop_data(i); diff --git a/main/dungeon.cpp b/main/dungeon.cpp index 18c5d52..293272a 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -250,6 +250,38 @@ void Dungeon::_setup_library(Ref library) { library->add_voxel_surface(s); } } + + for (int i = 0; i < get_dungeon_corridor_count(); ++i) { + Ref d = get_dungeon_corridor(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } + + for (int i = 0; i < get_dungeon_end_room_count(); ++i) { + Ref d = get_dungeon_end_room(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } + + for (int i = 0; i < get_dungeon_room_count(); ++i) { + Ref d = get_dungeon_room(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } + + for (int i = 0; i < get_dungeon_start_room_count(); ++i) { + Ref d = get_dungeon_start_room(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } } void Dungeon::generate_chunk(Ref chunk, bool spawn_mobs) { diff --git a/main/planet.cpp b/main/planet.cpp index 02988cf..78f18c8 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -109,6 +109,8 @@ void Planet::setup() { #ifdef VOXELMAN_PRESENT void Planet::setup_library(Ref library) { + ERR_FAIL_COND(!library.is_valid()); + if (!_data.is_valid()) return; @@ -125,6 +127,22 @@ void Planet::_setup_library(Ref library) { library->add_voxel_surface(s); } } + + for (int i = 0; i < get_biome_count(); ++i) { + Ref s = get_biome(i); + + if (s.is_valid()) { + s->setup_library(library); + } + } + + for (int i = 0; i < get_dungeon_count(); ++i) { + Ref d = get_dungeon(i); + + if (d.is_valid()) { + d->setup_library(library); + } + } } void Planet::generate_chunk(Ref chunk, bool spawn_mobs) {