Added a spawn_mobs bool To the genetarion methods, also work on bindings.

This commit is contained in:
Relintai 2019-10-31 01:50:26 +01:00
parent a1aa09ab6d
commit c110bea4c5
10 changed files with 76 additions and 34 deletions

View File

@ -80,14 +80,14 @@ int Biome::get_dungeon_count() const {
}
void Biome::generate_chunk(Ref<VoxelChunk> chunk) {
void Biome::generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs) {
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk);
call("_generate_chunk", chunk, spawn_mobs);
}
}
void Biome::generate_stack(Ref<VoxelChunk> chunk, int x, int z) {
void Biome::generate_stack(Ref<VoxelChunk> 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);

View File

@ -41,8 +41,8 @@ public:
int get_dungeon_count() const;
void generate_chunk(Ref<VoxelChunk> chunk);
void generate_stack(Ref<VoxelChunk> chunk, int x, int z);
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs);
void generate_stack(Ref<VoxelChunk> chunk, int x, int z, bool spawn_mobs);
Biome();
~Biome();

View File

@ -192,15 +192,15 @@ void Dungeon::setup() {
}
}
void Dungeon::generate_chunk(Ref<VoxelChunk> chunk) {
void Dungeon::generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs) {
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk);
call("_generate_chunk", chunk, spawn_mobs);
}
}
void Dungeon::generate_structure(Ref<VoxelStructure> structure) {
void Dungeon::generate_structure(Ref<VoxelStructure> 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);

View File

@ -88,8 +88,8 @@ public:
int get_entity_data_count() const;
void setup();
void generate_chunk(Ref<VoxelChunk> chunk);
void generate_structure(Ref<VoxelStructure> structure);
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs);
void generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs);
Ref<Image> generate_map();

View File

@ -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<VoxelChunk> chunk, bool spawn_mobs) {
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs);
}
}
void DungeonCorridor::generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs) {
if (has_method("_generate_structure")) {
call("_generate_structure", structure, spawn_mobs);
}
}
Ref<Image> DungeonCorridor::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
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);
}

View File

@ -19,6 +19,12 @@ public:
int get_dungeon_room_count() const;
void setup();
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs);
void generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs);
Ref<Image> generate_map();
DungeonCorridor();
~DungeonCorridor();

View File

@ -120,15 +120,15 @@ void DungeonRoom::setup() {
}
}
void DungeonRoom::generate_chunk(Ref<VoxelChunk> chunk) {
void DungeonRoom::generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs) {
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk);
call("_generate_chunk", chunk, spawn_mobs);
}
}
void DungeonRoom::generate_room(Ref<VoxelStructure> structure) {
void DungeonRoom::generate_room(Ref<VoxelStructure> 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);

View File

@ -62,8 +62,8 @@ public:
int get_entity_data_count() const;
void setup();
void generate_chunk(Ref<VoxelChunk> chunk);
void generate_room(Ref<VoxelStructure> structure);
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs);
void generate_room(Ref<VoxelStructure> structure, bool spawn_mobs);
DungeonRoom();
~DungeonRoom();

View File

@ -43,9 +43,9 @@ void Planet::setup() {
}
}
void Planet::generate_chunk(Ref<VoxelChunk> chunk) {
void Planet::generate_chunk(Ref<VoxelChunk> 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);

View File

@ -27,7 +27,7 @@ public:
int get_biome_count() const;
void setup();
void generate_chunk(Ref<VoxelChunk> chunk);
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs);
Ref<Image> generate_map();
Planet();