From 2abdb972e0fac50aa9ccf3fc8f6de92787e297e6 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 18 Oct 2019 09:43:45 +0200 Subject: [PATCH] More work on the bindings. --- SCsub | 5 ++- main/dungeon.cpp | 13 ++++-- main/dungeon_corridor.cpp | 4 +- main/dungeon_corridor.h | 2 +- main/dungeon_room.cpp | 89 +++++++++++++++++++++++++++++++++++++++ main/dungeon_room.h | 31 ++++++++++++++ register_types.cpp | 2 + 7 files changed, 138 insertions(+), 8 deletions(-) diff --git a/SCsub b/SCsub index 4deb13f..2f5706d 100644 --- a/SCsub +++ b/SCsub @@ -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") diff --git a/main/dungeon.cpp b/main/dungeon.cpp index ed72b72..e06231b 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -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 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); diff --git a/main/dungeon_corridor.cpp b/main/dungeon_corridor.cpp index ef7353a..afc269f 100644 --- a/main/dungeon_corridor.cpp +++ b/main/dungeon_corridor.cpp @@ -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(); } diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h index c342cfd..a8158a5 100644 --- a/main/dungeon_corridor.h +++ b/main/dungeon_corridor.h @@ -27,7 +27,7 @@ protected: private: int _max_connections; - Vector > _rooms; + Vector > _dungeon_rooms; }; #endif diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index 527470e..c20a17e 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -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 DungeonRoom::get_environment() { return _environment; } @@ -43,7 +94,15 @@ void DungeonRoom::generate_room(Ref 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"); diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 98ff2f0..d956748 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -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 get_environment(); void set_environment(Ref 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 _environment; Vector > _prop_datas; }; diff --git a/register_types.cpp b/register_types.cpp index 942bdd4..8fee9ca 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -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(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();