diff --git a/main/biome.cpp b/main/biome.cpp index 59cde3d..23934a1 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -87,16 +87,26 @@ int Biome::get_dungeon_count() const { } -void Biome::generate_chunk(Ref chunk, bool spawn_mobs) { +void Biome::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + if (has_method("_generate_chunk")) { call("_generate_chunk", chunk, spawn_mobs); } } -void Biome::generate_stack(Ref chunk, int x, int z, bool spawn_mobs) { +void Biome::generate_chunk_bind(Node *chunk, bool spawn_mobs) { + generate_chunk(Object::cast_to(chunk), spawn_mobs); +} +void Biome::generate_stack(VoxelChunk *chunk, int x, int z, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + if (has_method("_generate_stack")) { call("_generate_stack", chunk, x, z, spawn_mobs); } } +void Biome::generate_stack_bind(Node *chunk, int x, int z, bool spawn_mobs) { + generate_stack(Object::cast_to(chunk), x, z, spawn_mobs); +} Biome::Biome() { @@ -109,11 +119,11 @@ Biome::~Biome() { } void Biome::_bind_methods() { - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk); - ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk_bind); + ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack_bind); ClassDB::bind_method(D_METHOD("get_level_range"), &Biome::get_level_range); ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range); diff --git a/main/biome.h b/main/biome.h index 5e6eed4..1725058 100644 --- a/main/biome.h +++ b/main/biome.h @@ -44,8 +44,10 @@ public: int get_dungeon_count() const; - void generate_chunk(Ref chunk, bool spawn_mobs); - void generate_stack(Ref chunk, int x, int z, bool spawn_mobs); + void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); + void generate_chunk_bind(Node *chunk, bool spawn_mobs); + void generate_stack(VoxelChunk *chunk, int x, int z, bool spawn_mobs); + void generate_stack_bind(Node *chunk, int x, int z, bool spawn_mobs); Biome(); ~Biome(); diff --git a/main/dungeon.cpp b/main/dungeon.cpp index df2a488..ab17df9 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -199,11 +199,16 @@ void Dungeon::setup() { } } -void Dungeon::generate_chunk(Ref chunk, bool spawn_mobs) { +void Dungeon::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + if (has_method("_generate_chunk")) { call("_generate_chunk", chunk, spawn_mobs); } } +void Dungeon::generate_chunk_bind(Node *chunk, bool spawn_mobs) { + generate_chunk(Object::cast_to(chunk), spawn_mobs); +} void Dungeon::generate_structure(Ref structure, bool spawn_mobs) { if (has_method("_generate_structure")) { @@ -242,10 +247,10 @@ Dungeon::~Dungeon() { void Dungeon::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); BIND_VMETHOD(MethodInfo("_generate_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure); ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed); diff --git a/main/dungeon.h b/main/dungeon.h index f692331..f23ec6f 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -91,7 +91,8 @@ public: int get_entity_data_count() const; void setup(); - void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); + void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_structure(Ref structure, bool spawn_mobs); Ref generate_map(); diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h index b89a06b..a8158a5 100644 --- a/main/dungeon_corridor.h +++ b/main/dungeon_corridor.h @@ -19,12 +19,6 @@ public: int get_dungeon_room_count() const; - void setup(); - void generate_chunk(Ref chunk, bool spawn_mobs); - void generate_structure(Ref structure, bool spawn_mobs); - - Ref generate_map(); - DungeonCorridor(); ~DungeonCorridor(); diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index b07acb4..b69a959 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -127,12 +127,18 @@ void DungeonRoom::setup() { } } -void DungeonRoom::generate_chunk(Ref chunk, bool spawn_mobs) { +void DungeonRoom::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + if (has_method("_generate_chunk")) { call("_generate_chunk", chunk, spawn_mobs); } } +void DungeonRoom::generate_chunk_bind(Node *chunk, bool spawn_mobs) { + generate_chunk(Object::cast_to(chunk), spawn_mobs); +} + void DungeonRoom::generate_room(Ref structure, bool spawn_mobs) { if (has_method("_generate_room")) { call("_generate_room", structure, spawn_mobs); @@ -159,10 +165,10 @@ DungeonRoom::~DungeonRoom() { void DungeonRoom::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room); ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed); diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 77ce196..5c5e90c 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -65,7 +65,8 @@ public: int get_entity_data_count() const; void setup(); - void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); + void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_room(Ref structure, bool spawn_mobs); DungeonRoom(); diff --git a/main/planet.cpp b/main/planet.cpp index 6f6f6eb..28ee17a 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -50,12 +50,18 @@ void Planet::setup() { } } -void Planet::generate_chunk(Ref chunk, bool spawn_mobs) { +void Planet::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + if (has_method("_generate_chunk")) { call("_generate_chunk", chunk, spawn_mobs); } } +void Planet::generate_chunk_bind(Node *chunk, bool spawn_mobs) { + generate_chunk(Object::cast_to(chunk), spawn_mobs); +} + Ref Planet::generate_map() { ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); @@ -72,9 +78,9 @@ Planet::~Planet() { void Planet::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk_bind); ClassDB::bind_method(D_METHOD("setup"), &Planet::setup); ClassDB::bind_method(D_METHOD("get_seed"), &Planet::get_seed); diff --git a/main/planet.h b/main/planet.h index d15cc50..7857279 100644 --- a/main/planet.h +++ b/main/planet.h @@ -30,7 +30,8 @@ public: int get_biome_count() const; void setup(); - void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); + void generate_chunk_bind(Node *chunk, bool spawn_mobs); Ref generate_map(); Planet();