mirror of
https://github.com/Relintai/world_generator.git
synced 2024-11-12 10:15:07 +01:00
More work on the bindings.
This commit is contained in:
parent
b176ecc7bf
commit
a1aa09ab6d
@ -96,6 +96,47 @@ void BiomeData::set_prop_datas(const Vector<Variant> &prop_datas) {
|
||||
}
|
||||
}
|
||||
|
||||
//Entities
|
||||
|
||||
Ref<EntityData> BiomeData::get_entity_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
void BiomeData::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 BiomeData::add_entity_data(const Ref<EntityData> entity_data) {
|
||||
_entity_datas.push_back(entity_data);
|
||||
}
|
||||
void BiomeData::remove_entity_data(const int index) {
|
||||
ERR_FAIL_INDEX(index, _entity_datas.size());
|
||||
|
||||
_entity_datas.remove(index);
|
||||
}
|
||||
|
||||
int BiomeData::get_entity_data_count() const {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
|
||||
Vector<Variant> BiomeData::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 BiomeData::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
|
||||
Ref<EnvironmentData> BiomeData::get_environment_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
|
||||
@ -149,6 +190,7 @@ BiomeData::BiomeData() {
|
||||
BiomeData::~BiomeData() {
|
||||
_dungeon_datas.clear();
|
||||
_prop_datas.clear();
|
||||
_entity_datas.clear();
|
||||
}
|
||||
|
||||
void BiomeData::_bind_methods() {
|
||||
@ -188,6 +230,18 @@ void BiomeData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &BiomeData::set_prop_datas);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_prop_datas", "get_prop_datas");
|
||||
|
||||
//Entities
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &BiomeData::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &BiomeData::set_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &BiomeData::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &BiomeData::remove_entity_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &BiomeData::get_entity_data_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_datas"), &BiomeData::get_entity_datas);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &BiomeData::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
|
||||
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &BiomeData::get_environment_data);
|
||||
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &BiomeData::set_environment_data);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "dungeon_data.h"
|
||||
#include "prop_data.h"
|
||||
#include "../../voxelman/world/environment_data.h"
|
||||
#include "../../entity_spell_system/entities/data/entity_data.h"
|
||||
|
||||
class BiomeData : public Resource {
|
||||
GDCLASS(BiomeData, Resource);
|
||||
@ -42,6 +43,17 @@ public:
|
||||
Vector<Variant> get_prop_datas();
|
||||
void set_prop_datas(const Vector<Variant> &prop_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);
|
||||
|
||||
//Environments
|
||||
Ref<EnvironmentData> get_environment_data(const int index) const;
|
||||
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
|
||||
@ -67,6 +79,7 @@ private:
|
||||
Vector2 _temperature_range;
|
||||
Vector<Ref<DungeonData> > _dungeon_datas;
|
||||
Vector<Ref<PropData> > _prop_datas;
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
Vector<Ref<EnvironmentData> > _environment_datas;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,49 @@
|
||||
#include "dungeon_room_data.h"
|
||||
|
||||
//Min Size
|
||||
int DungeonRoomData::get_min_sizex() {
|
||||
return _min_sizex;
|
||||
}
|
||||
void DungeonRoomData::set_min_sizex(int value) {
|
||||
_min_sizex = value;
|
||||
}
|
||||
|
||||
int DungeonRoomData::get_min_sizey() {
|
||||
return _min_sizey;
|
||||
}
|
||||
void DungeonRoomData::set_min_sizey(int value) {
|
||||
_min_sizey = value;
|
||||
}
|
||||
|
||||
int DungeonRoomData::get_min_sizez() {
|
||||
return _min_sizez;
|
||||
}
|
||||
void DungeonRoomData::set_min_sizez(int value) {
|
||||
_min_sizez = value;
|
||||
}
|
||||
|
||||
//Max Size
|
||||
int DungeonRoomData::get_max_sizex() {
|
||||
return _max_sizex;
|
||||
}
|
||||
void DungeonRoomData::set_max_sizex(int value) {
|
||||
_max_sizex = value;
|
||||
}
|
||||
|
||||
int DungeonRoomData::get_max_sizey() {
|
||||
return _max_sizey;
|
||||
}
|
||||
void DungeonRoomData::set_max_sizey(int value) {
|
||||
_max_sizey = value;
|
||||
}
|
||||
|
||||
int DungeonRoomData::get_max_sizez() {
|
||||
return _max_sizez;
|
||||
}
|
||||
void DungeonRoomData::set_max_sizez(int value) {
|
||||
_max_sizez = value;
|
||||
}
|
||||
|
||||
//Props
|
||||
Ref<PropData> DungeonRoomData::get_prop_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<PropData>());
|
||||
@ -78,6 +122,45 @@ void DungeonRoomData::set_environment_datas(const Vector<Variant> &environment_d
|
||||
}
|
||||
}
|
||||
|
||||
//Entities
|
||||
Ref<EntityData> DungeonRoomData::get_entity_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
void DungeonRoomData::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 DungeonRoomData::add_entity_data(const Ref<EntityData> entity_data) {
|
||||
_entity_datas.push_back(entity_data);
|
||||
}
|
||||
void DungeonRoomData::remove_entity_data(const int index) {
|
||||
ERR_FAIL_INDEX(index, _entity_datas.size());
|
||||
|
||||
_entity_datas.remove(index);
|
||||
}
|
||||
int DungeonRoomData::get_entity_data_count() const {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
|
||||
Vector<Variant> DungeonRoomData::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 DungeonRoomData::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);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<DungeonRoom> DungeonRoomData::setup_room(int seed) {
|
||||
if (has_method("_setup_room")) {
|
||||
return call("_setup_room", seed);
|
||||
@ -87,7 +170,13 @@ Ref<DungeonRoom> DungeonRoomData::setup_room(int seed) {
|
||||
}
|
||||
|
||||
DungeonRoomData::DungeonRoomData() {
|
||||
_min_sizex = 0;
|
||||
_min_sizey = 0;
|
||||
_min_sizez = 0;
|
||||
|
||||
_max_sizex = 0;
|
||||
_max_sizey = 0;
|
||||
_max_sizez = 0;
|
||||
}
|
||||
DungeonRoomData::~DungeonRoomData() {
|
||||
|
||||
@ -98,6 +187,32 @@ void DungeonRoomData::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("setup_room", "seed"), &DungeonRoomData::setup_room);
|
||||
|
||||
//Min Size
|
||||
ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonRoomData::get_min_sizex);
|
||||
ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonRoomData::set_min_sizex);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonRoomData::get_min_sizey);
|
||||
ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonRoomData::set_min_sizey);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonRoomData::get_min_sizez);
|
||||
ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonRoomData::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"), &DungeonRoomData::get_max_sizex);
|
||||
ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonRoomData::set_max_sizex);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonRoomData::get_max_sizey);
|
||||
ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonRoomData::set_max_sizey);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonRoomData::get_max_sizez);
|
||||
ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonRoomData::set_max_sizez);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez");
|
||||
|
||||
//Props
|
||||
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoomData::get_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoomData::set_prop_data);
|
||||
@ -110,6 +225,18 @@ void DungeonRoomData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoomData::set_prop_datas);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_prop_datas", "get_prop_datas");
|
||||
|
||||
//Entities
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoomData::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoomData::set_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoomData::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoomData::remove_entity_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoomData::get_entity_data_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoomData::get_entity_datas);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoomData::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
|
||||
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonRoomData::get_environment_data);
|
||||
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonRoomData::set_environment_data);
|
||||
|
@ -7,10 +7,32 @@
|
||||
#include "prop_data.h"
|
||||
#include "../../voxelman/world/environment_data.h"
|
||||
|
||||
#include "../../entity_spell_system/entities/data/entity_data.h"
|
||||
|
||||
class DungeonRoomData : public Resource {
|
||||
GDCLASS(DungeonRoomData, Resource);
|
||||
|
||||
public:
|
||||
//Min Size
|
||||
int get_min_sizex();
|
||||
void set_min_sizex(int value);
|
||||
|
||||
int get_min_sizey();
|
||||
void set_min_sizey(int value);
|
||||
|
||||
int get_min_sizez();
|
||||
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);
|
||||
|
||||
//Prop Data
|
||||
Ref<PropData> get_prop_data(const int index) const;
|
||||
void set_prop_data(const int index, const Ref<PropData> prop_data);
|
||||
@ -35,6 +57,17 @@ public:
|
||||
|
||||
Ref<DungeonRoom> setup_room(int seed);
|
||||
|
||||
//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);
|
||||
|
||||
DungeonRoomData();
|
||||
~DungeonRoomData();
|
||||
|
||||
@ -42,7 +75,16 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _min_sizex;
|
||||
int _min_sizey;
|
||||
int _min_sizez;
|
||||
|
||||
int _max_sizex;
|
||||
int _max_sizey;
|
||||
int _max_sizez;
|
||||
|
||||
Vector<Ref<PropData> > _prop_datas;
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
Vector<Ref<EnvironmentData> > _environment_datas;
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,30 @@ int Biome::get_prop_data_count() const {
|
||||
return _prop_datas.size();
|
||||
}
|
||||
|
||||
//Entities
|
||||
Ref<EntityData> Biome::get_entity_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
void Biome::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 Biome::add_entity_data(const Ref<EntityData> entity_data) {
|
||||
_entity_datas.push_back(entity_data);
|
||||
}
|
||||
void Biome::remove_entity_data(const int index) {
|
||||
ERR_FAIL_INDEX(index, _entity_datas.size());
|
||||
|
||||
_entity_datas.remove(index);
|
||||
}
|
||||
|
||||
int Biome::get_entity_data_count() const {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
|
||||
//// Dungeons ////
|
||||
Ref<Dungeon> Biome::get_dungeon(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _dungeons.size(), Ref<Dungeon>());
|
||||
@ -73,6 +97,7 @@ Biome::Biome() {
|
||||
Biome::~Biome() {
|
||||
_environment.unref();
|
||||
_prop_datas.clear();
|
||||
_entity_datas.clear();
|
||||
_dungeons.clear();
|
||||
}
|
||||
|
||||
@ -87,6 +112,7 @@ void Biome::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_environment", "value"), &Biome::set_environment);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment");
|
||||
|
||||
//Props
|
||||
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &Biome::get_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &Biome::set_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &Biome::add_prop_data);
|
||||
@ -94,6 +120,15 @@ void Biome::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &Biome::get_prop_data_count);
|
||||
|
||||
//Entities
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Biome::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Biome::set_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Biome::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Biome::remove_entity_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Biome::get_entity_data_count);
|
||||
|
||||
//Dungeons
|
||||
ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Biome::get_dungeon);
|
||||
ClassDB::bind_method(D_METHOD("set_dungeon", "index", "data"), &Biome::set_dungeon);
|
||||
ClassDB::bind_method(D_METHOD("add_dungeon", "dungeon"), &Biome::add_dungeon);
|
||||
|
10
main/biome.h
10
main/biome.h
@ -7,6 +7,7 @@
|
||||
#include "../data/prop_data.h"
|
||||
#include "dungeon.h"
|
||||
#include "../../voxelman/world/environment_data.h"
|
||||
#include "../../entity_spell_system/entities/data/entity_data.h"
|
||||
|
||||
class Biome : public Reference {
|
||||
GDCLASS(Biome, Reference);
|
||||
@ -24,6 +25,14 @@ public:
|
||||
|
||||
int get_prop_data_count() const;
|
||||
|
||||
//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;
|
||||
|
||||
//Dungeons
|
||||
Ref<Dungeon> get_dungeon(const int index) const;
|
||||
void set_dungeon(const int index, const Ref<Dungeon> dungeon);
|
||||
@ -44,6 +53,7 @@ protected:
|
||||
private:
|
||||
Ref<EnvironmentData> _environment;
|
||||
Vector<Ref<PropData> > _prop_datas;
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
Vector<Ref<Dungeon> > _dungeons;
|
||||
};
|
||||
|
||||
|
@ -162,17 +162,17 @@ int Dungeon::get_dungeon_corridor_count() const {
|
||||
}
|
||||
|
||||
//Entities
|
||||
Ref<DungeonCorridor> Dungeon::get_entity_data(const int index) const {
|
||||
Ref<EntityData> 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) {
|
||||
void Dungeon::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 Dungeon::add_entity_data(const Ref<DungeonCorridor> entity_data) {
|
||||
void Dungeon::add_entity_data(const Ref<EntityData> entity_data) {
|
||||
_entity_datas.push_back(entity_data);
|
||||
}
|
||||
void Dungeon::remove_entity_data(const int index) {
|
||||
|
@ -80,9 +80,9 @@ public:
|
||||
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);
|
||||
Ref<EntityData> get_entity_data(const int index) const;
|
||||
void set_entity_data(const int index, const Ref<EntityData> entity_datas);
|
||||
void add_entity_data(const Ref<EntityData> entity_datas);
|
||||
void remove_entity_data(const int index);
|
||||
|
||||
int get_entity_data_count() const;
|
||||
|
@ -58,6 +58,14 @@ void DungeonRoom::set_environment(Ref<EnvironmentData> value) {
|
||||
_environment = value;
|
||||
}
|
||||
|
||||
Ref<VoxelStructure> DungeonRoom::get_structure() {
|
||||
return _structure;
|
||||
}
|
||||
void DungeonRoom::set_structure(Ref<VoxelStructure> structure) {
|
||||
_structure = structure;
|
||||
}
|
||||
|
||||
//Props
|
||||
Ref<PropData> DungeonRoom::get_prop_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<PropData>());
|
||||
|
||||
@ -81,6 +89,37 @@ int DungeonRoom::get_prop_data_count() const {
|
||||
return _prop_datas.size();
|
||||
}
|
||||
|
||||
//Entities
|
||||
Ref<EntityData> DungeonRoom::get_entity_data(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
void DungeonRoom::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 DungeonRoom::add_entity_data(const Ref<EntityData> entity_data) {
|
||||
_entity_datas.push_back(entity_data);
|
||||
}
|
||||
void DungeonRoom::remove_entity_data(const int index) {
|
||||
ERR_FAIL_INDEX(index, _entity_datas.size());
|
||||
|
||||
_entity_datas.remove(index);
|
||||
}
|
||||
|
||||
int DungeonRoom::get_entity_data_count() const {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
|
||||
|
||||
void DungeonRoom::setup() {
|
||||
if (has_method("_setup")) {
|
||||
call("_setup");
|
||||
}
|
||||
}
|
||||
|
||||
void DungeonRoom::generate_chunk(Ref<VoxelChunk> chunk) {
|
||||
if (has_method("_generate_chunk")) {
|
||||
call("_generate_chunk", chunk);
|
||||
@ -107,12 +146,15 @@ DungeonRoom::DungeonRoom() {
|
||||
DungeonRoom::~DungeonRoom() {
|
||||
_environment.unref();
|
||||
_prop_datas.clear();
|
||||
_entity_datas.clear();
|
||||
}
|
||||
|
||||
void DungeonRoom::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_setup"));
|
||||
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("setup"), &DungeonRoom::setup);
|
||||
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &DungeonRoom::generate_chunk);
|
||||
ClassDB::bind_method(D_METHOD("generate_room", "structure"), &DungeonRoom::generate_room);
|
||||
|
||||
@ -150,10 +192,23 @@ void DungeonRoom::_bind_methods() {
|
||||
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");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_structure"), &DungeonRoom::get_structure);
|
||||
ClassDB::bind_method(D_METHOD("set_structure", "value"), &DungeonRoom::set_structure);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), "set_structure", "get_structure");
|
||||
|
||||
//Props
|
||||
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoom::get_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoom::set_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoom::add_prop_data);
|
||||
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoom::remove_prop_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoom::get_prop_data_count);
|
||||
|
||||
//Entities
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoom::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoom::set_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoom::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoom::remove_entity_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoom::get_entity_data_count);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "../../voxelman/world/voxel_structure.h"
|
||||
#include "../data/prop_data.h"
|
||||
#include "../../voxelman/world/environment_data.h"
|
||||
#include "../../entity_spell_system/entities/data/entity_data.h"
|
||||
|
||||
class DungeonRoom : public Reference {
|
||||
GDCLASS(DungeonRoom, Reference);
|
||||
@ -16,6 +17,7 @@ public:
|
||||
int get_seed();
|
||||
void set_seed(int value);
|
||||
|
||||
//Pos
|
||||
int get_posx();
|
||||
void set_posx(int value);
|
||||
|
||||
@ -25,6 +27,7 @@ public:
|
||||
int get_posz();
|
||||
void set_posz(int value);
|
||||
|
||||
//Size
|
||||
int get_sizex();
|
||||
void set_sizex(int value);
|
||||
|
||||
@ -38,6 +41,11 @@ public:
|
||||
Ref<EnvironmentData> get_environment();
|
||||
void set_environment(Ref<EnvironmentData> value);
|
||||
|
||||
//Structure
|
||||
Ref<VoxelStructure> get_structure();
|
||||
void set_structure(Ref<VoxelStructure> structure);
|
||||
|
||||
//Props
|
||||
Ref<PropData> get_prop_data(const int index) const;
|
||||
void set_prop_data(const int index, const Ref<PropData> prop_data);
|
||||
void add_prop_data(const Ref<PropData> prop_data);
|
||||
@ -45,6 +53,15 @@ public:
|
||||
|
||||
int get_prop_data_count() const;
|
||||
|
||||
//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;
|
||||
|
||||
void setup();
|
||||
void generate_chunk(Ref<VoxelChunk> chunk);
|
||||
void generate_room(Ref<VoxelStructure> structure);
|
||||
|
||||
@ -66,7 +83,9 @@ private:
|
||||
int _sizez;
|
||||
|
||||
Ref<EnvironmentData> _environment;
|
||||
Ref<VoxelStructure> _structure;
|
||||
Vector<Ref<PropData> > _prop_datas;
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user