More work on the bindings.

This commit is contained in:
Relintai 2019-10-18 09:43:45 +02:00
parent a6b538f0d0
commit 2abdb972e0
7 changed files with 138 additions and 8 deletions

5
SCsub
View File

@ -2,12 +2,13 @@ Import('env')
env.add_source_files(env.modules_sources,"register_types.cpp")
env.add_source_files(env.modules_sources,"main/dungeon_room.cpp")
env.add_source_files(env.modules_sources,"main/dungeon_room.cpp")
env.add_source_files(env.modules_sources,"main/dungeon_corridor.cpp")
env.add_source_files(env.modules_sources,"main/dungeon.cpp")
env.add_source_files(env.modules_sources,"main/biome.cpp")
env.add_source_files(env.modules_sources,"main/planet.cpp")
env.add_source_files(env.modules_sources,"data/dungeon_room_data.cpp")
env.add_source_files(env.modules_sources,"data/dungeon_room_data.cpp")
env.add_source_files(env.modules_sources,"data/dungeon_corridor_data.cpp")
env.add_source_files(env.modules_sources,"data/dungeon_data.cpp")
env.add_source_files(env.modules_sources,"data/biome_data.cpp")

View File

@ -7,7 +7,7 @@ void Dungeon::set_seed(int value) {
_seed = value;
}
//Position
int Dungeon::get_posx() {
return _posx;
}
@ -29,6 +29,7 @@ void Dungeon::set_posz(int value) {
_posz = value;
}
//Size
int Dungeon::get_sizex() {
return _sizex;
}
@ -179,6 +180,14 @@ Ref<Image> Dungeon::generate_map() {
Dungeon::Dungeon() {
_seed = 0;
_posx = 0;
_posy = 0;
_posz = 0;
_sizex = 0;
_sizey = 0;
_sizez = 0;
}
Dungeon::~Dungeon() {
_environment.unref();
@ -201,7 +210,6 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seed", "value"), &Dungeon::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
//Position
ClassDB::bind_method(D_METHOD("get_posx"), &Dungeon::get_posx);
ClassDB::bind_method(D_METHOD("set_posx", "value"), &Dungeon::set_posx);
@ -215,7 +223,6 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_posz", "value"), &Dungeon::set_posz);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz");
//Size
ClassDB::bind_method(D_METHOD("get_sizex"), &Dungeon::get_sizex);
ClassDB::bind_method(D_METHOD("set_sizex", "value"), &Dungeon::set_sizex);

View File

@ -31,10 +31,10 @@ int DungeonCorridor::get_dungeon_room_count() const {
return _dungeon_rooms.size();
}
DungeonRoom::DungeonRoom() {
DungeonCorridor::DungeonCorridor() {
_max_connections = 2;
}
DungeonRoom::~DungeonRoom() {
DungeonCorridor::~DungeonCorridor() {
_dungeon_rooms.clear();
}

View File

@ -27,7 +27,7 @@ protected:
private:
int _max_connections;
Vector<Ref<DungeonRoom> > _rooms;
Vector<Ref<DungeonRoom> > _dungeon_rooms;
};
#endif

View File

@ -1,5 +1,56 @@
#include "dungeon_room.h"
int DungeonRoom::get_seed() {
return _seed;
}
void DungeonRoom::set_seed(int value) {
_seed = value;
}
//Position
int DungeonRoom::get_posx() {
return _posx;
}
void DungeonRoom::set_posx(int value) {
_posx = value;
}
int DungeonRoom::get_posy() {
return _posy;
}
void DungeonRoom::set_posy(int value) {
_posy = value;
}
int DungeonRoom::get_posz() {
return _posz;
}
void DungeonRoom::set_posz(int value) {
_posz = value;
}
//Size
int DungeonRoom::get_sizex() {
return _sizex;
}
void DungeonRoom::set_sizex(int value) {
_sizex = value;
}
int DungeonRoom::get_sizey() {
return _sizey;
}
void DungeonRoom::set_sizey(int value) {
_sizey = value;
}
int DungeonRoom::get_sizez() {
return _sizez;
}
void DungeonRoom::set_sizez(int value) {
_sizez = value;
}
Ref<EnvironmentData> DungeonRoom::get_environment() {
return _environment;
}
@ -43,7 +94,15 @@ void DungeonRoom::generate_room(Ref<VoxelStructure> structure) {
}
DungeonRoom::DungeonRoom() {
_seed = 0;
_posx = 0;
_posy = 0;
_posz = 0;
_sizex = 0;
_sizey = 0;
_sizez = 0;
}
DungeonRoom::~DungeonRoom() {
_environment.unref();
@ -57,6 +116,36 @@ void DungeonRoom::_bind_methods() {
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_seed"), &DungeonRoom::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &DungeonRoom::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
//Position
ClassDB::bind_method(D_METHOD("get_posx"), &DungeonRoom::get_posx);
ClassDB::bind_method(D_METHOD("set_posx", "value"), &DungeonRoom::set_posx);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx");
ClassDB::bind_method(D_METHOD("get_posy"), &DungeonRoom::get_posy);
ClassDB::bind_method(D_METHOD("set_posy", "value"), &DungeonRoom::set_posy);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy");
ClassDB::bind_method(D_METHOD("get_posz"), &DungeonRoom::get_posz);
ClassDB::bind_method(D_METHOD("set_posz", "value"), &DungeonRoom::set_posz);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz");
//Size
ClassDB::bind_method(D_METHOD("get_sizex"), &DungeonRoom::get_sizex);
ClassDB::bind_method(D_METHOD("set_sizex", "value"), &DungeonRoom::set_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex");
ClassDB::bind_method(D_METHOD("get_sizey"), &DungeonRoom::get_sizey);
ClassDB::bind_method(D_METHOD("set_sizey", "value"), &DungeonRoom::set_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey");
ClassDB::bind_method(D_METHOD("get_sizez"), &DungeonRoom::get_sizez);
ClassDB::bind_method(D_METHOD("set_sizez", "value"), &DungeonRoom::set_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez");
ClassDB::bind_method(D_METHOD("get_environment"), &DungeonRoom::get_environment);
ClassDB::bind_method(D_METHOD("set_environment", "value"), &DungeonRoom::set_environment);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment");

View File

@ -13,6 +13,27 @@ class DungeonRoom : public Reference {
GDCLASS(DungeonRoom, Reference);
public:
int get_seed();
void set_seed(int value);
int get_posx();
void set_posx(int value);
int get_posy();
void set_posy(int value);
int get_posz();
void set_posz(int value);
int get_sizex();
void set_sizex(int value);
int get_sizey();
void set_sizey(int value);
int get_sizez();
void set_sizez(int value);
//Environment
Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
@ -34,6 +55,16 @@ protected:
static void _bind_methods();
private:
int _seed;
int _posx;
int _posy;
int _posz;
int _sizex;
int _sizey;
int _sizez;
Ref<EnvironmentData> _environment;
Vector<Ref<PropData> > _prop_datas;
};

View File

@ -8,6 +8,7 @@
#include "data/prop_data.h"
#include "main/dungeon_room.h"
#include "main/dungeon_corridor.h"
#include "main/dungeon.h"
#include "main/biome.h"
#include "main/planet.h"
@ -23,6 +24,7 @@ void register_world_generator_types() {
ClassDB::register_class<PropData>();
ClassDB::register_class<DungeonRoom>();
ClassDB::register_class<DungeonCorridor>();
ClassDB::register_class<Dungeon>();
ClassDB::register_class<Biome>();
ClassDB::register_class<Planet>();