More work on the bindings.

This commit is contained in:
Relintai 2019-10-18 10:22:11 +02:00
parent 6c94bafc8e
commit b176ecc7bf
4 changed files with 488 additions and 10 deletions

View File

@ -1,5 +1,64 @@
#include "dungeon_data.h" #include "dungeon_data.h"
//Min Size
int DungeonData::get_min_sizex() {
return _min_sizex;
}
void DungeonData::set_min_sizex(int value) {
_min_sizex = value;
}
int DungeonData::get_min_sizey() {
return _min_sizey;
}
void DungeonData::set_min_sizey(int value) {
_min_sizey = value;
}
int DungeonData::get_min_sizez() {
return _min_sizez;
}
void DungeonData::set_min_sizez(int value) {
_min_sizez = value;
}
//Max Size
int DungeonData::get_max_sizex() {
return _max_sizex;
}
void DungeonData::set_max_sizex(int value) {
_max_sizex = value;
}
int DungeonData::get_max_sizey() {
return _max_sizey;
}
void DungeonData::set_max_sizey(int value) {
_max_sizey = value;
}
int DungeonData::get_max_sizez() {
return _max_sizez;
}
void DungeonData::set_max_sizez(int value) {
_max_sizez = value;
}
int DungeonData::get_min_room_count() {
return _min_room_count;
}
void DungeonData::set_min_room_count(int value) {
_min_room_count = value;
}
int DungeonData::get_max_room_count() {
return _max_room_count;
}
void DungeonData::set_max_room_count(int value) {
_max_room_count = value;
}
//Rooms
Ref<DungeonRoomData> DungeonData::get_dungeon_room_data(const int index) const { Ref<DungeonRoomData> DungeonData::get_dungeon_room_data(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_room_datas.size(), Ref<DungeonRoomData>()); ERR_FAIL_INDEX_V(index, _dungeon_room_datas.size(), Ref<DungeonRoomData>());
@ -39,6 +98,167 @@ void DungeonData::set_dungeon_room_datas(const Vector<Variant> &dungeon_room_dat
} }
} }
//Start Rooms
Ref<DungeonRoomData> DungeonData::get_dungeon_start_room_data(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_start_room_datas.size(), Ref<DungeonRoomData>());
return _dungeon_start_room_datas.get(index);
}
void DungeonData::set_dungeon_start_room_data(const int index, const Ref<DungeonRoomData> dungeon_start_room_data) {
ERR_FAIL_INDEX(index, _dungeon_start_room_datas.size());
_dungeon_start_room_datas.set(index, dungeon_start_room_data);
}
void DungeonData::add_dungeon_start_room_data(const Ref<DungeonRoomData> dungeon_start_room_data) {
_dungeon_start_room_datas.push_back(dungeon_start_room_data);
}
void DungeonData::remove_dungeon_start_room_data(const int index) {
ERR_FAIL_INDEX(index, _dungeon_start_room_datas.size());
_dungeon_start_room_datas.remove(index);
}
int DungeonData::get_dungeon_start_room_data_count() const {
return _dungeon_start_room_datas.size();
}
Vector<Variant> DungeonData::get_dungeon_start_room_datas() {
Vector<Variant> r;
for (int i = 0; i < _dungeon_start_room_datas.size(); i++) {
r.push_back(_dungeon_start_room_datas[i].get_ref_ptr());
}
return r;
}
void DungeonData::set_dungeon_start_room_datas(const Vector<Variant> &dungeon_start_room_datas) {
_dungeon_start_room_datas.clear();
for (int i = 0; i < dungeon_start_room_datas.size(); i++) {
Ref<DungeonRoomData> dungeon_start_room_data = Ref<DungeonRoomData>(dungeon_start_room_datas[i]);
_dungeon_start_room_datas.push_back(dungeon_start_room_data);
}
}
//End Rooms
Ref<DungeonRoomData> DungeonData::get_dungeon_end_room_data(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_end_room_datas.size(), Ref<DungeonRoomData>());
return _dungeon_end_room_datas.get(index);
}
void DungeonData::set_dungeon_end_room_data(const int index, const Ref<DungeonRoomData> dungeon_end_room_data) {
ERR_FAIL_INDEX(index, _dungeon_end_room_datas.size());
_dungeon_end_room_datas.set(index, dungeon_end_room_data);
}
void DungeonData::add_dungeon_end_room_data(const Ref<DungeonRoomData> dungeon_end_room_data) {
_dungeon_end_room_datas.push_back(dungeon_end_room_data);
}
void DungeonData::remove_dungeon_end_room_data(const int index) {
ERR_FAIL_INDEX(index, _dungeon_end_room_datas.size());
_dungeon_end_room_datas.remove(index);
}
int DungeonData::get_dungeon_end_room_data_count() const {
return _dungeon_end_room_datas.size();
}
Vector<Variant> DungeonData::get_dungeon_end_room_datas() {
Vector<Variant> r;
for (int i = 0; i < _dungeon_end_room_datas.size(); i++) {
r.push_back(_dungeon_end_room_datas[i].get_ref_ptr());
}
return r;
}
void DungeonData::set_dungeon_end_room_datas(const Vector<Variant> &dungeon_end_room_datas) {
_dungeon_end_room_datas.clear();
for (int i = 0; i < dungeon_end_room_datas.size(); i++) {
Ref<DungeonRoomData> dungeon_end_room_data = Ref<DungeonRoomData>(dungeon_end_room_datas[i]);
_dungeon_end_room_datas.push_back(dungeon_end_room_data);
}
}
//Corridors
Ref<DungeonRoomData> DungeonData::get_dungeon_corridor_data(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_corridor_datas.size(), Ref<DungeonRoomData>());
return _dungeon_corridor_datas.get(index);
}
void DungeonData::set_dungeon_corridor_data(const int index, const Ref<DungeonRoomData> dungeon_corridor_data) {
ERR_FAIL_INDEX(index, _dungeon_corridor_datas.size());
_dungeon_corridor_datas.set(index, dungeon_corridor_data);
}
void DungeonData::add_dungeon_corridor_data(const Ref<DungeonRoomData> dungeon_corridor_data) {
_dungeon_corridor_datas.push_back(dungeon_corridor_data);
}
void DungeonData::remove_dungeon_corridor_data(const int index) {
ERR_FAIL_INDEX(index, _dungeon_corridor_datas.size());
_dungeon_corridor_datas.remove(index);
}
int DungeonData::get_dungeon_corridor_data_count() const {
return _dungeon_corridor_datas.size();
}
Vector<Variant> DungeonData::get_dungeon_corridor_datas() {
Vector<Variant> r;
for (int i = 0; i < _dungeon_corridor_datas.size(); i++) {
r.push_back(_dungeon_corridor_datas[i].get_ref_ptr());
}
return r;
}
void DungeonData::set_dungeon_corridor_datas(const Vector<Variant> &dungeon_corridor_datas) {
_dungeon_corridor_datas.clear();
for (int i = 0; i < dungeon_corridor_datas.size(); i++) {
Ref<DungeonRoomData> dungeon_corridor_data = Ref<DungeonRoomData>(dungeon_corridor_datas[i]);
_dungeon_corridor_datas.push_back(dungeon_corridor_data);
}
}
//Entities
Ref<EntityData> DungeonData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void DungeonData::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void DungeonData::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void DungeonData::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int DungeonData::get_entity_data_count() const {
return _entity_datas.size();
}
Vector<Variant> DungeonData::get_entity_datas() {
Vector<Variant> r;
for (int i = 0; i < _entity_datas.size(); i++) {
r.push_back(_entity_datas[i].get_ref_ptr());
}
return r;
}
void DungeonData::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.clear();
for (int i = 0; i < entity_datas.size(); i++) {
Ref<EntityData> entity_data = Ref<EntityData>(entity_datas[i]);
_entity_datas.push_back(entity_data);
}
}
//Environments //Environments
Ref<EnvironmentData> DungeonData::get_environment_data(const int index) const { Ref<EnvironmentData> DungeonData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>()); ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
@ -78,19 +298,36 @@ void DungeonData::set_environment_datas(const Vector<Variant> &environment_datas
} }
} }
Ref<Dungeon> DungeonData::setup_dungeon(int seed) { Ref<Dungeon> DungeonData::setup_dungeon(int seed) {
if (has_method("_setup_dungeon")) { if (has_method("_setup_dungeon")) {
return call("_setup_dungeon", seed); return call("_setup_dungeon", seed);
} }
return Ref<Dungeon>(NULL); return Ref<Dungeon>();
} }
DungeonData::DungeonData() { DungeonData::DungeonData() {
_min_sizex = 0;
_min_sizey = 0;
_min_sizez = 0;
_max_sizex = 0;
_max_sizey = 0;
_max_sizez = 0;
_min_room_count = 0;
_max_room_count = 0;
} }
DungeonData::~DungeonData() { DungeonData::~DungeonData() {
_environment_datas.clear();
_dungeon_room_datas.clear();
_dungeon_start_room_datas.clear();
_dungeon_end_room_datas.clear();
_dungeon_corridor_datas.clear();
_entity_datas.clear();
} }
void DungeonData::_bind_methods() { void DungeonData::_bind_methods() {
@ -98,6 +335,42 @@ void DungeonData::_bind_methods() {
ClassDB::bind_method(D_METHOD("setup_dungeon", "seed"), &DungeonData::setup_dungeon); ClassDB::bind_method(D_METHOD("setup_dungeon", "seed"), &DungeonData::setup_dungeon);
//Min Size
ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonData::get_min_sizex);
ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonData::set_min_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex");
ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonData::get_min_sizey);
ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonData::set_min_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey");
ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonData::get_min_sizez);
ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonData::set_min_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez");
//Max Size
ClassDB::bind_method(D_METHOD("get_max_sizex"), &DungeonData::get_max_sizex);
ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonData::set_max_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex");
ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonData::get_max_sizey);
ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonData::set_max_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey");
ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonData::get_max_sizez);
ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonData::set_max_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez");
//Room Count
ClassDB::bind_method(D_METHOD("get_min_room_count"), &DungeonData::get_min_room_count);
ClassDB::bind_method(D_METHOD("set_min_room_count", "value"), &DungeonData::set_min_room_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_room_count"), "set_min_room_count", "get_min_room_count");
ClassDB::bind_method(D_METHOD("get_max_room_count"), &DungeonData::get_max_room_count);
ClassDB::bind_method(D_METHOD("set_max_room_count", "value"), &DungeonData::set_max_room_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_room_count"), "set_max_room_count", "get_max_room_count");
//Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_room_data", "index"), &DungeonData::get_dungeon_room_data); ClassDB::bind_method(D_METHOD("get_dungeon_room_data", "index"), &DungeonData::get_dungeon_room_data);
ClassDB::bind_method(D_METHOD("set_dungeon_room_data", "index", "data"), &DungeonData::set_dungeon_room_data); ClassDB::bind_method(D_METHOD("set_dungeon_room_data", "index", "data"), &DungeonData::set_dungeon_room_data);
ClassDB::bind_method(D_METHOD("add_dungeon_room_data", "dungeon_room_data"), &DungeonData::add_dungeon_room_data); ClassDB::bind_method(D_METHOD("add_dungeon_room_data", "dungeon_room_data"), &DungeonData::add_dungeon_room_data);
@ -109,6 +382,54 @@ void DungeonData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_dungeon_room_datas", "dungeon_room_datas"), &DungeonData::set_dungeon_room_datas); ClassDB::bind_method(D_METHOD("set_dungeon_room_datas", "dungeon_room_datas"), &DungeonData::set_dungeon_room_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_room_datas", "get_dungeon_room_datas"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_room_datas", "get_dungeon_room_datas");
//Start Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_start_room_data", "index"), &DungeonData::get_dungeon_start_room_data);
ClassDB::bind_method(D_METHOD("set_dungeon_start_room_data", "index", "data"), &DungeonData::set_dungeon_start_room_data);
ClassDB::bind_method(D_METHOD("add_dungeon_start_room_data", "dungeon_start_room_data"), &DungeonData::add_dungeon_start_room_data);
ClassDB::bind_method(D_METHOD("remove_dungeon_start_room_data", "index"), &DungeonData::remove_dungeon_start_room_data);
ClassDB::bind_method(D_METHOD("get_dungeon_start_room_data_count"), &DungeonData::get_dungeon_start_room_data_count);
ClassDB::bind_method(D_METHOD("get_dungeon_start_room_datas"), &DungeonData::get_dungeon_start_room_datas);
ClassDB::bind_method(D_METHOD("set_dungeon_start_room_datas", "dungeon_start_room_datas"), &DungeonData::set_dungeon_start_room_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_start_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_start_room_datas", "get_dungeon_start_room_datas");
//End Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_end_room_data", "index"), &DungeonData::get_dungeon_end_room_data);
ClassDB::bind_method(D_METHOD("set_dungeon_end_room_data", "index", "data"), &DungeonData::set_dungeon_end_room_data);
ClassDB::bind_method(D_METHOD("add_dungeon_end_room_data", "dungeon_end_room_data"), &DungeonData::add_dungeon_end_room_data);
ClassDB::bind_method(D_METHOD("remove_dungeon_end_room_data", "index"), &DungeonData::remove_dungeon_end_room_data);
ClassDB::bind_method(D_METHOD("get_dungeon_end_room_data_count"), &DungeonData::get_dungeon_end_room_data_count);
ClassDB::bind_method(D_METHOD("get_dungeon_end_room_datas"), &DungeonData::get_dungeon_end_room_datas);
ClassDB::bind_method(D_METHOD("set_dungeon_end_room_datas", "dungeon_end_room_datas"), &DungeonData::set_dungeon_end_room_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_end_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_end_room_datas", "get_dungeon_end_room_datas");
//Corridors
ClassDB::bind_method(D_METHOD("get_dungeon_corridor_data", "index"), &DungeonData::get_dungeon_corridor_data);
ClassDB::bind_method(D_METHOD("set_dungeon_corridor_data", "index", "data"), &DungeonData::set_dungeon_corridor_data);
ClassDB::bind_method(D_METHOD("add_dungeon_corridor_data", "dungeon_corridor_data"), &DungeonData::add_dungeon_corridor_data);
ClassDB::bind_method(D_METHOD("remove_dungeon_corridor_data", "index"), &DungeonData::remove_dungeon_corridor_data);
ClassDB::bind_method(D_METHOD("get_dungeon_corridor_data_count"), &DungeonData::get_dungeon_corridor_data_count);
ClassDB::bind_method(D_METHOD("get_dungeon_corridor_datas"), &DungeonData::get_dungeon_corridor_datas);
ClassDB::bind_method(D_METHOD("set_dungeon_corridor_datas", "dungeon_corridor_datas"), &DungeonData::set_dungeon_corridor_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridor_datas", PROPERTY_HINT_NONE, "17/17:DungeonCorridorData", PROPERTY_USAGE_DEFAULT, "DungeonCorridorData"), "set_dungeon_corridor_datas", "get_dungeon_corridor_datas");
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonData::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonData::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonData::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonData::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonData::get_entity_data_count);
ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonData::get_entity_datas);
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonData::set_entity_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
//Environments //Environments
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonData::get_environment_data); ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonData::get_environment_data);
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonData::set_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonData::set_environment_data);

View File

@ -6,22 +6,41 @@
#include "../main/dungeon.h" #include "../main/dungeon.h"
#include "dungeon_room_data.h" #include "dungeon_room_data.h"
#include "dungeon_corridor_data.h"
#include "../../voxelman/world/environment_data.h" #include "../../voxelman/world/environment_data.h"
#include "../../entity_spell_system/entities/data/entity_data.h"
class DungeonData : public Resource { class DungeonData : public Resource {
GDCLASS(DungeonData, Resource); GDCLASS(DungeonData, Resource);
public: public:
//Rooms //Min Size
Ref<DungeonRoomData> get_dungeon_room_data(const int index) const; int get_min_sizex();
void set_dungeon_room_data(const int index, const Ref<DungeonRoomData> dungeon_room_data); void set_min_sizex(int value);
void add_dungeon_room_data(const Ref<DungeonRoomData> dungeon_room_data);
void remove_dungeon_room_data(const int index);
int get_dungeon_room_data_count() const; int get_min_sizey();
void set_min_sizey(int value);
Vector<Variant> get_dungeon_room_datas(); int get_min_sizez();
void set_dungeon_room_datas(const Vector<Variant> &dungeon_room_datas); void set_min_sizez(int value);
//Max Size
int get_max_sizex();
void set_max_sizex(int value);
int get_max_sizey();
void set_max_sizey(int value);
int get_max_sizez();
void set_max_sizez(int value);
//Room Count
int get_min_room_count();
void set_min_room_count(int value);
int get_max_room_count();
void set_max_room_count(int value);
//Environments //Environments
Ref<EnvironmentData> get_environment_data(const int index) const; Ref<EnvironmentData> get_environment_data(const int index) const;
@ -34,6 +53,61 @@ public:
Vector<Variant> get_environment_datas(); Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas); void set_environment_datas(const Vector<Variant> &environment_datas);
//Rooms
Ref<DungeonRoomData> get_dungeon_room_data(const int index) const;
void set_dungeon_room_data(const int index, const Ref<DungeonRoomData> dungeon_room_data);
void add_dungeon_room_data(const Ref<DungeonRoomData> dungeon_room_data);
void remove_dungeon_room_data(const int index);
int get_dungeon_room_data_count() const;
Vector<Variant> get_dungeon_room_datas();
void set_dungeon_room_datas(const Vector<Variant> &dungeon_room_datas);
//Start Rooms
Ref<DungeonRoomData> get_dungeon_start_room_data(const int index) const;
void set_dungeon_start_room_data(const int index, const Ref<DungeonRoomData> dungeon_start_room_data);
void add_dungeon_start_room_data(const Ref<DungeonRoomData> dungeon_start_room_data);
void remove_dungeon_start_room_data(const int index);
int get_dungeon_start_room_data_count() const;
Vector<Variant> get_dungeon_start_room_datas();
void set_dungeon_start_room_datas(const Vector<Variant> &dungeon_start_room_datas);
//End Rooms
Ref<DungeonRoomData> get_dungeon_end_room_data(const int index) const;
void set_dungeon_end_room_data(const int index, const Ref<DungeonRoomData> dungeon_end_room_data);
void add_dungeon_end_room_data(const Ref<DungeonRoomData> dungeon_end_room_data);
void remove_dungeon_end_room_data(const int index);
int get_dungeon_end_room_data_count() const;
Vector<Variant> get_dungeon_end_room_datas();
void set_dungeon_end_room_datas(const Vector<Variant> &dungeon_end_room_datas);
//Corridors
Ref<DungeonRoomData> get_dungeon_corridor_data(const int index) const;
void set_dungeon_corridor_data(const int index, const Ref<DungeonRoomData> dungeon_corridor_data);
void add_dungeon_corridor_data(const Ref<DungeonRoomData> dungeon_corridor_data);
void remove_dungeon_corridor_data(const int index);
int get_dungeon_corridor_data_count() const;
Vector<Variant> get_dungeon_corridor_datas();
void set_dungeon_corridor_datas(const Vector<Variant> &dungeon_corridor_datas);
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
Ref<Dungeon> setup_dungeon(int seed); Ref<Dungeon> setup_dungeon(int seed);
DungeonData(); DungeonData();
@ -43,8 +117,24 @@ protected:
static void _bind_methods(); static void _bind_methods();
private: private:
Vector<Ref<DungeonRoomData> > _dungeon_room_datas; int _min_sizex;
int _min_sizey;
int _min_sizez;
int _max_sizex;
int _max_sizey;
int _max_sizez;
int _min_room_count;
int _max_room_count;
Vector<Ref<EnvironmentData> > _environment_datas; Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<DungeonRoomData> > _dungeon_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_start_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_end_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_corridor_datas;
Vector<Ref<EntityData> > _entity_datas;
}; };
#endif #endif

View File

@ -51,6 +51,13 @@ void Dungeon::set_sizez(int value) {
_sizez = value; _sizez = value;
} }
int Dungeon::get_room_count() {
return _room_count;
}
void Dungeon::set_room_count(int value) {
_room_count = value;
}
Ref<EnvironmentData> Dungeon::get_environment() { Ref<EnvironmentData> Dungeon::get_environment() {
return _environment; return _environment;
} }
@ -154,6 +161,31 @@ int Dungeon::get_dungeon_corridor_count() const {
return _dungeon_corridors.size(); return _dungeon_corridors.size();
} }
//Entities
Ref<DungeonCorridor> Dungeon::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<DungeonCorridor>());
return _entity_datas.get(index);
}
void Dungeon::set_entity_data(const int index, const Ref<DungeonCorridor> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void Dungeon::add_entity_data(const Ref<DungeonCorridor> entity_data) {
_entity_datas.push_back(entity_data);
}
void Dungeon::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int Dungeon::get_entity_data_count() const {
return _entity_datas.size();
}
void Dungeon::setup() { void Dungeon::setup() {
if (has_method("_setup")) { if (has_method("_setup")) {
call("_setup"); call("_setup");
@ -188,6 +220,8 @@ Dungeon::Dungeon() {
_sizex = 0; _sizex = 0;
_sizey = 0; _sizey = 0;
_sizez = 0; _sizez = 0;
_room_count = 0;
} }
Dungeon::~Dungeon() { Dungeon::~Dungeon() {
_environment.unref(); _environment.unref();
@ -195,6 +229,7 @@ Dungeon::~Dungeon() {
_dungeon_start_rooms.clear(); _dungeon_start_rooms.clear();
_dungeon_end_rooms.clear(); _dungeon_end_rooms.clear();
_dungeon_corridors.clear(); _dungeon_corridors.clear();
_entity_datas.clear();
} }
void Dungeon::_bind_methods() { void Dungeon::_bind_methods() {
@ -236,6 +271,11 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_sizez", "value"), &Dungeon::set_sizez); ClassDB::bind_method(D_METHOD("set_sizez", "value"), &Dungeon::set_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez");
//Room Count
ClassDB::bind_method(D_METHOD("get_room_count"), &Dungeon::get_room_count);
ClassDB::bind_method(D_METHOD("set_room_count", "value"), &Dungeon::set_room_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "room_count"), "set_room_count", "get_room_count");
//Environment //Environment
ClassDB::bind_method(D_METHOD("get_environment"), &Dungeon::get_environment); ClassDB::bind_method(D_METHOD("get_environment"), &Dungeon::get_environment);
ClassDB::bind_method(D_METHOD("set_environment", "value"), &Dungeon::set_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Dungeon::set_environment);
@ -273,6 +313,14 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_corridor_count"), &Dungeon::get_dungeon_corridor_count); ClassDB::bind_method(D_METHOD("get_dungeon_corridor_count"), &Dungeon::get_dungeon_corridor_count);
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Dungeon::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Dungeon::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Dungeon::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Dungeon::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Dungeon::get_entity_data_count);
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map"));
ClassDB::bind_method(D_METHOD("generate_map"), &Dungeon::generate_map); ClassDB::bind_method(D_METHOD("generate_map"), &Dungeon::generate_map);

View File

@ -10,6 +10,8 @@
#include "../../voxelman/world/voxel_structure.h" #include "../../voxelman/world/voxel_structure.h"
#include "../../voxelman/world/environment_data.h" #include "../../voxelman/world/environment_data.h"
#include "../../entity_spell_system/entities/data/entity_data.h"
class Dungeon : public Reference { class Dungeon : public Reference {
GDCLASS(Dungeon, Reference); GDCLASS(Dungeon, Reference);
@ -17,6 +19,7 @@ public:
int get_seed(); int get_seed();
void set_seed(int value); void set_seed(int value);
//Pos
int get_posx(); int get_posx();
void set_posx(int value); void set_posx(int value);
@ -26,6 +29,7 @@ public:
int get_posz(); int get_posz();
void set_posz(int value); void set_posz(int value);
//Size
int get_sizex(); int get_sizex();
void set_sizex(int value); void set_sizex(int value);
@ -35,6 +39,10 @@ public:
int get_sizez(); int get_sizez();
void set_sizez(int value); void set_sizez(int value);
//Room Count
int get_room_count();
void set_room_count(int value);
//Environment //Environment
Ref<EnvironmentData> get_environment(); Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value); void set_environment(Ref<EnvironmentData> value);
@ -71,6 +79,14 @@ public:
int get_dungeon_corridor_count() const; int get_dungeon_corridor_count() const;
//Entities
Ref<DungeonCorridor> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<DungeonCorridor> entity_datas);
void add_entity_data(const Ref<DungeonCorridor> entity_datas);
void remove_entity_data(const int index);
int get_entity_data_count() const;
void setup(); void setup();
void generate_chunk(Ref<VoxelChunk> chunk); void generate_chunk(Ref<VoxelChunk> chunk);
void generate_structure(Ref<VoxelStructure> structure); void generate_structure(Ref<VoxelStructure> structure);
@ -94,11 +110,14 @@ private:
int _sizey; int _sizey;
int _sizez; int _sizez;
int _room_count;
Ref<EnvironmentData> _environment; Ref<EnvironmentData> _environment;
Vector<Ref<DungeonRoom> > _dungeon_rooms; Vector<Ref<DungeonRoom> > _dungeon_rooms;
Vector<Ref<DungeonRoom> > _dungeon_start_rooms; Vector<Ref<DungeonRoom> > _dungeon_start_rooms;
Vector<Ref<DungeonRoom> > _dungeon_end_rooms; Vector<Ref<DungeonRoom> > _dungeon_end_rooms;
Vector<Ref<DungeonCorridor> > _dungeon_corridors; Vector<Ref<DungeonCorridor> > _dungeon_corridors;
Vector<Ref<EntityData> > _entity_datas;
}; };
#endif #endif