Update for Voxelman's changes.

This commit is contained in:
Relintai 2019-11-06 03:38:02 +01:00
parent 2956e67f60
commit 72fdb52731
9 changed files with 52 additions and 26 deletions

View File

@ -87,16 +87,26 @@ int Biome::get_dungeon_count() const {
} }
void Biome::generate_chunk(Ref<VoxelChunk> 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")) { if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs); call("_generate_chunk", chunk, spawn_mobs);
} }
} }
void Biome::generate_stack(Ref<VoxelChunk> chunk, int x, int z, bool spawn_mobs) { void Biome::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(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")) { if (has_method("_generate_stack")) {
call("_generate_stack", chunk, x, z, spawn_mobs); 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<VoxelChunk>(chunk), x, z, spawn_mobs);
}
Biome::Biome() { Biome::Biome() {
@ -109,11 +119,11 @@ Biome::~Biome() {
} }
void Biome::_bind_methods() { 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_chunk", PropertyInfo(Variant::OBJECT, "chunk", 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_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_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk_bind);
ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack); 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("get_level_range"), &Biome::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range); ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range);

View File

@ -44,8 +44,10 @@ public:
int get_dungeon_count() const; int get_dungeon_count() const;
void generate_chunk(Ref<VoxelChunk> chunk, bool spawn_mobs); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs);
void generate_stack(Ref<VoxelChunk> chunk, int x, int z, 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();
~Biome(); ~Biome();

View File

@ -199,11 +199,16 @@ void Dungeon::setup() {
} }
} }
void Dungeon::generate_chunk(Ref<VoxelChunk> 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")) { if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs); call("_generate_chunk", chunk, spawn_mobs);
} }
} }
void Dungeon::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
void Dungeon::generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs) { void Dungeon::generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs) {
if (has_method("_generate_structure")) { if (has_method("_generate_structure")) {
@ -242,10 +247,10 @@ Dungeon::~Dungeon() {
void Dungeon::_bind_methods() { void Dungeon::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup")); 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_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("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("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure);
ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed); ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed);

View File

@ -91,7 +91,8 @@ public:
int get_entity_data_count() const; int get_entity_data_count() const;
void setup(); void setup();
void generate_chunk(Ref<VoxelChunk> 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<VoxelStructure> structure, bool spawn_mobs); void generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs);
Ref<Image> generate_map(); Ref<Image> generate_map();

View File

@ -19,12 +19,6 @@ public:
int get_dungeon_room_count() const; 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();
~DungeonCorridor(); ~DungeonCorridor();

View File

@ -127,12 +127,18 @@ void DungeonRoom::setup() {
} }
} }
void DungeonRoom::generate_chunk(Ref<VoxelChunk> 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")) { if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs); call("_generate_chunk", chunk, spawn_mobs);
} }
} }
void DungeonRoom::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
void DungeonRoom::generate_room(Ref<VoxelStructure> structure, bool spawn_mobs) { void DungeonRoom::generate_room(Ref<VoxelStructure> structure, bool spawn_mobs) {
if (has_method("_generate_room")) { if (has_method("_generate_room")) {
call("_generate_room", structure, spawn_mobs); call("_generate_room", structure, spawn_mobs);
@ -159,10 +165,10 @@ DungeonRoom::~DungeonRoom() {
void DungeonRoom::_bind_methods() { void DungeonRoom::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup")); 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_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("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("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room);
ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed); ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed);

View File

@ -65,7 +65,8 @@ public:
int get_entity_data_count() const; int get_entity_data_count() const;
void setup(); void setup();
void generate_chunk(Ref<VoxelChunk> 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<VoxelStructure> structure, bool spawn_mobs); void generate_room(Ref<VoxelStructure> structure, bool spawn_mobs);
DungeonRoom(); DungeonRoom();

View File

@ -50,12 +50,18 @@ void Planet::setup() {
} }
} }
void Planet::generate_chunk(Ref<VoxelChunk> 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")) { if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs); call("_generate_chunk", chunk, spawn_mobs);
} }
} }
void Planet::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
Ref<Image> Planet::generate_map() { Ref<Image> Planet::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>()); ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
@ -72,9 +78,9 @@ Planet::~Planet() {
void Planet::_bind_methods() { void Planet::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup")); 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("setup"), &Planet::setup);
ClassDB::bind_method(D_METHOD("get_seed"), &Planet::get_seed); ClassDB::bind_method(D_METHOD("get_seed"), &Planet::get_seed);

View File

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