diff --git a/main/biome.cpp b/main/biome.cpp index 5278e9d..ae33883 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -80,14 +80,14 @@ int Biome::get_dungeon_count() const { } -void Biome::generate_chunk(Ref chunk) { +void Biome::generate_chunk(Ref chunk, bool spawn_mobs) { if (has_method("_generate_chunk")) { - call("_generate_chunk", chunk); + call("_generate_chunk", chunk, spawn_mobs); } } -void Biome::generate_stack(Ref chunk, int x, int z) { +void Biome::generate_stack(Ref chunk, int x, int z, bool spawn_mobs) { if (has_method("_generate_stack")) { - call("_generate_stack", chunk, x, z); + call("_generate_stack", chunk, x, z, spawn_mobs); } } @@ -102,11 +102,11 @@ Biome::~Biome() { } void Biome::_bind_methods() { - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"))); + 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"))); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Biome::generate_chunk); - ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z"), &Biome::generate_stack); + 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("get_environment"), &Biome::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Biome::set_environment); diff --git a/main/biome.h b/main/biome.h index 46c7734..919ed8a 100644 --- a/main/biome.h +++ b/main/biome.h @@ -41,8 +41,8 @@ public: int get_dungeon_count() const; - void generate_chunk(Ref chunk); - void generate_stack(Ref chunk, int x, int z); + void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_stack(Ref chunk, int x, int z, bool spawn_mobs); Biome(); ~Biome(); diff --git a/main/dungeon.cpp b/main/dungeon.cpp index 92dd171..5db94f7 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -192,15 +192,15 @@ void Dungeon::setup() { } } -void Dungeon::generate_chunk(Ref chunk) { +void Dungeon::generate_chunk(Ref chunk, bool spawn_mobs) { if (has_method("_generate_chunk")) { - call("_generate_chunk", chunk); + call("_generate_chunk", chunk, spawn_mobs); } } -void Dungeon::generate_structure(Ref structure) { +void Dungeon::generate_structure(Ref structure, bool spawn_mobs) { if (has_method("_generate_structure")) { - call("_generate_structure", structure); + call("_generate_structure", structure, spawn_mobs); } } @@ -234,12 +234,12 @@ Dungeon::~Dungeon() { void Dungeon::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - BIND_VMETHOD(MethodInfo("_generate_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + 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"))); ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Dungeon::generate_chunk); - ClassDB::bind_method(D_METHOD("generate_structure", "structure"), &Dungeon::generate_structure); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure); ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed); ClassDB::bind_method(D_METHOD("set_seed", "value"), &Dungeon::set_seed); diff --git a/main/dungeon.h b/main/dungeon.h index 52e1e71..6adbeee 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -88,8 +88,8 @@ public: int get_entity_data_count() const; void setup(); - void generate_chunk(Ref chunk); - void generate_structure(Ref structure); + void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_structure(Ref structure, bool spawn_mobs); Ref generate_map(); diff --git a/main/dungeon_corridor.cpp b/main/dungeon_corridor.cpp index 9be640b..c68eab8 100644 --- a/main/dungeon_corridor.cpp +++ b/main/dungeon_corridor.cpp @@ -31,6 +31,30 @@ int DungeonCorridor::get_dungeon_room_count() const { return _dungeon_rooms.size(); } +void DungeonCorridor::setup() { + if (has_method("_setup")) { + call("_setup"); + } +} + +void DungeonCorridor::generate_chunk(Ref chunk, bool spawn_mobs) { + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk, spawn_mobs); + } +} + +void DungeonCorridor::generate_structure(Ref structure, bool spawn_mobs) { + if (has_method("_generate_structure")) { + call("_generate_structure", structure, spawn_mobs); + } +} + +Ref DungeonCorridor::generate_map() { + ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); + + return call("_generate_map"); +} + DungeonCorridor::DungeonCorridor() { _max_connections = 2; } @@ -39,6 +63,14 @@ DungeonCorridor::~DungeonCorridor() { } void DungeonCorridor::_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"))); + + ClassDB::bind_method(D_METHOD("setup"), &DungeonCorridor::setup); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonCorridor::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &DungeonCorridor::generate_structure); + ClassDB::bind_method(D_METHOD("get_max_connections"), &DungeonCorridor::get_max_connections); ClassDB::bind_method(D_METHOD("set_max_connections", "value"), &DungeonCorridor::set_max_connections); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_connections"), "set_max_connections", "get_max_connections"); @@ -50,4 +82,8 @@ void DungeonCorridor::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &DungeonCorridor::remove_dungeon_room); ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &DungeonCorridor::get_dungeon_room_count); + + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); + + ClassDB::bind_method(D_METHOD("generate_map"), &DungeonCorridor::generate_map); } diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h index a8158a5..b89a06b 100644 --- a/main/dungeon_corridor.h +++ b/main/dungeon_corridor.h @@ -19,6 +19,12 @@ 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 fab3210..c669fec 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -120,15 +120,15 @@ void DungeonRoom::setup() { } } -void DungeonRoom::generate_chunk(Ref chunk) { +void DungeonRoom::generate_chunk(Ref chunk, bool spawn_mobs) { if (has_method("_generate_chunk")) { - call("_generate_chunk", chunk); + call("_generate_chunk", chunk, spawn_mobs); } } -void DungeonRoom::generate_room(Ref structure) { +void DungeonRoom::generate_room(Ref structure, bool spawn_mobs) { if (has_method("_generate_room")) { - call("_generate_room", structure); + call("_generate_room", structure, spawn_mobs); } } @@ -151,12 +151,12 @@ DungeonRoom::~DungeonRoom() { void DungeonRoom::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + 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"))); ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &DungeonRoom::generate_chunk); - ClassDB::bind_method(D_METHOD("generate_room", "structure"), &DungeonRoom::generate_room); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room); ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed); ClassDB::bind_method(D_METHOD("set_seed", "value"), &DungeonRoom::set_seed); diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 731cd90..98c928b 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -62,8 +62,8 @@ public: int get_entity_data_count() const; void setup(); - void generate_chunk(Ref chunk); - void generate_room(Ref structure); + void generate_chunk(Ref chunk, bool spawn_mobs); + void generate_room(Ref structure, bool spawn_mobs); DungeonRoom(); ~DungeonRoom(); diff --git a/main/planet.cpp b/main/planet.cpp index 4316a73..c34ed28 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -43,9 +43,9 @@ void Planet::setup() { } } -void Planet::generate_chunk(Ref chunk) { +void Planet::generate_chunk(Ref chunk, bool spawn_mobs) { if (has_method("_generate_chunk")) { - call("_generate_chunk", chunk); + call("_generate_chunk", chunk, spawn_mobs); } } @@ -65,7 +65,7 @@ Planet::~Planet() { void Planet::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", 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("setup"), &Planet::setup); diff --git a/main/planet.h b/main/planet.h index 7b7f686..976d73c 100644 --- a/main/planet.h +++ b/main/planet.h @@ -27,7 +27,7 @@ public: int get_biome_count() const; void setup(); - void generate_chunk(Ref chunk); + void generate_chunk(Ref chunk, bool spawn_mobs); Ref generate_map(); Planet();