mirror of
https://github.com/Relintai/world_generator.git
synced 2025-04-19 21:43:15 +02:00
Improved the bindings and the design a bit.
This commit is contained in:
parent
e60f95da9a
commit
c702f039c9
@ -50,13 +50,13 @@ int Biome::get_dungeon_count() const {
|
||||
|
||||
|
||||
void Biome::generate_chunk(Ref<VoxelChunk> chunk) {
|
||||
if (has_method("_generate")) {
|
||||
call("_generate", chunk);
|
||||
if (has_method("_generate_chunk")) {
|
||||
call("_generate_chunk", chunk);
|
||||
}
|
||||
}
|
||||
void Biome::generate_stack(Ref<VoxelChunk> chunk, int x, int z) {
|
||||
if (has_method("_generate")) {
|
||||
call("_generate", chunk, x, z);
|
||||
if (has_method("_generate_stack")) {
|
||||
call("_generate_stack", chunk, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,15 @@ int Dungeon::get_dungeon_room_count() const {
|
||||
return _dungeon_rooms.size();
|
||||
}
|
||||
|
||||
void Dungeon::generate(Ref<VoxelStructure> structure) {
|
||||
if (has_method("_generate")) {
|
||||
call("_generate", structure);
|
||||
void Dungeon::generate_chunk(Ref<VoxelChunk> chunk) {
|
||||
if (has_method("_generate_chunk")) {
|
||||
call("_generate_chunk", chunk);
|
||||
}
|
||||
}
|
||||
|
||||
void Dungeon::generate_structure(Ref<VoxelStructure> structure) {
|
||||
if (has_method("_generate_structure")) {
|
||||
call("_generate_structure", structure);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,9 +43,11 @@ Dungeon::~Dungeon() {
|
||||
}
|
||||
|
||||
void Dungeon::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_generate", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure")));
|
||||
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")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("generate", "structure"), &Dungeon::generate);
|
||||
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("get_dungeon_room", "index"), &Dungeon::get_dungeon_room);
|
||||
ClassDB::bind_method(D_METHOD("set_dungeon_room", "index", "data"), &Dungeon::set_dungeon_room);
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "dungeon_room.h"
|
||||
|
||||
#include "../../voxelman/world/voxel_chunk.h"
|
||||
#include "../../voxelman/world/voxel_structure.h"
|
||||
|
||||
class Dungeon : public Reference {
|
||||
@ -17,7 +19,8 @@ public:
|
||||
|
||||
int get_dungeon_room_count() const;
|
||||
|
||||
void generate(Ref<VoxelStructure> structure);
|
||||
void generate_chunk(Ref<VoxelChunk> chunk);
|
||||
void generate_structure(Ref<VoxelStructure> structure);
|
||||
|
||||
Dungeon();
|
||||
~Dungeon();
|
||||
|
@ -23,6 +23,12 @@ int DungeonRoom::get_prop_data_count() const {
|
||||
return _prop_datas.size();
|
||||
}
|
||||
|
||||
void DungeonRoom::generate_chunk(Ref<VoxelChunk> chunk) {
|
||||
if (has_method("_generate_chunk")) {
|
||||
call("_generate_chunk", chunk);
|
||||
}
|
||||
}
|
||||
|
||||
void DungeonRoom::generate_room(Ref<VoxelStructure> structure) {
|
||||
if (has_method("_generate_room")) {
|
||||
call("_generate_room", structure);
|
||||
@ -38,7 +44,9 @@ DungeonRoom::~DungeonRoom() {
|
||||
|
||||
void DungeonRoom::_bind_methods() {
|
||||
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")));
|
||||
|
||||
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("get_prop_data", "index"), &DungeonRoom::get_prop_data);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "../../voxelman/world/voxel_chunk.h"
|
||||
#include "../../voxelman/world/voxel_structure.h"
|
||||
#include "../data/prop_data.h"
|
||||
|
||||
@ -18,6 +19,7 @@ public:
|
||||
|
||||
int get_prop_data_count() const;
|
||||
|
||||
void generate_chunk(Ref<VoxelChunk> chunk);
|
||||
void generate_room(Ref<VoxelStructure> structure);
|
||||
|
||||
DungeonRoom();
|
||||
|
Loading…
Reference in New Issue
Block a user