diff --git a/SCsub b/SCsub index 68a922d..ee64884 100644 --- a/SCsub +++ b/SCsub @@ -1,16 +1,17 @@ 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.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_data.cpp") -env.add_source_files(env.modules_sources,"data/biome_data.cpp") -env.add_source_files(env.modules_sources,"data/planet_data.cpp") - -env.add_source_files(env.modules_sources,"world_generator.cpp") +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.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_data.cpp") +env.add_source_files(env.modules_sources,"data/biome_data.cpp") +env.add_source_files(env.modules_sources,"data/planet_data.cpp") +env.add_source_files(env.modules_sources,"data/prop_data.cpp") + +env.add_source_files(env.modules_sources,"world_generator.cpp") diff --git a/data/biome_data.cpp b/data/biome_data.cpp index d48c545..809ee9e 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -1,5 +1,101 @@ #include "biome_data.h" +Vector2 BiomeData::get_humidity_range() { + return _humidity_range; +} +void BiomeData::set_humidity_range(Vector2 range) { + _humidity_range = range; +} + +Vector2 BiomeData::get_temperature_range() { + return _temperature_range; +} +void BiomeData::set_temperature_range(Vector2 range) { + _temperature_range = range; +} + +//// DungeonData //// + +Ref BiomeData::get_dungeon_data(const int index) const { + ERR_FAIL_INDEX_V(index, _dungeon_datas.size(), Ref()); + + return _dungeon_datas.get(index); +} +void BiomeData::set_dungeon_data(const int index, const Ref dungeon_data) { + ERR_FAIL_INDEX(index, _dungeon_datas.size()); + + _dungeon_datas.set(index, dungeon_data); +} +void BiomeData::add_dungeon_data(const Ref dungeon_data) { + _dungeon_datas.push_back(dungeon_data); +} +void BiomeData::remove_dungeon_data(const int index) { + ERR_FAIL_INDEX(index, _dungeon_datas.size()); + + _dungeon_datas.remove(index); +} + +int BiomeData::get_dungeon_data_count() const { + return _dungeon_datas.size(); +} + +Vector BiomeData::get_dungeon_datas() { + Vector r; + for (int i = 0; i < _dungeon_datas.size(); i++) { + r.push_back(_dungeon_datas[i].get_ref_ptr()); + } + return r; +} +void BiomeData::set_dungeon_datas(const Vector &dungeon_datas) { + _dungeon_datas.clear(); + for (int i = 0; i < dungeon_datas.size(); i++) { + Ref dungeon_data = Ref(dungeon_datas[i]); + + _dungeon_datas.push_back(dungeon_data); + } +} + +//// PROP DATA //// + +Ref BiomeData::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); + + return _prop_datas.get(index); +} +void BiomeData::set_prop_data(const int index, const Ref prop_data) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.set(index, prop_data); +} +void BiomeData::add_prop_data(const Ref prop_data) { + _prop_datas.push_back(prop_data); +} +void BiomeData::remove_prop_data(const int index) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.remove(index); +} + +int BiomeData::get_prop_data_count() const { + return _prop_datas.size(); +} + +Vector BiomeData::get_prop_datas() { + Vector r; + for (int i = 0; i < _prop_datas.size(); i++) { + r.push_back(_prop_datas[i].get_ref_ptr()); + } + return r; +} +void BiomeData::set_prop_datas(const Vector &prop_datas) { + _prop_datas.clear(); + for (int i = 0; i < prop_datas.size(); i++) { + Ref prop_data = Ref(prop_datas[i]); + + _prop_datas.push_back(prop_data); + } +} + Ref BiomeData::setup_biome(int seed) { if (has_method("_setup_biome")) { return call("_setup_biome", seed); @@ -12,11 +108,44 @@ BiomeData::BiomeData() { } BiomeData::~BiomeData() { - + _dungeon_datas.clear(); + _prop_datas.clear(); } void BiomeData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "Biome"), "_setup_biome", PropertyInfo(Variant::INT, "seed"))); ClassDB::bind_method(D_METHOD("setup_biome", "seed"), &BiomeData::setup_biome); + + ClassDB::bind_method(D_METHOD("get_humidity_range"), &BiomeData::get_humidity_range); + ClassDB::bind_method(D_METHOD("set_humidity_range", "value"), &BiomeData::set_humidity_range); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "humidity_range"), "set_humidity_range", "get_humidity_range"); + + ClassDB::bind_method(D_METHOD("get_temperature_range"), &BiomeData::get_temperature_range); + ClassDB::bind_method(D_METHOD("set_temperature_range", "value"), &BiomeData::set_temperature_range); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "temperature_range"), "set_temperature_range", "get_temperature_range"); + + //DungeonDatas + ClassDB::bind_method(D_METHOD("get_dungeon_data", "index"), &BiomeData::get_dungeon_data); + ClassDB::bind_method(D_METHOD("set_dungeon_data", "index", "data"), &BiomeData::set_dungeon_data); + ClassDB::bind_method(D_METHOD("add_dungeon_data", "dungeon_data"), &BiomeData::add_dungeon_data); + ClassDB::bind_method(D_METHOD("remove_dungeon_data", "index"), &BiomeData::remove_dungeon_data); + + ClassDB::bind_method(D_METHOD("get_dungeon_data_count"), &BiomeData::get_dungeon_data_count); + + ClassDB::bind_method(D_METHOD("get_dungeon_datas"), &BiomeData::get_dungeon_datas); + ClassDB::bind_method(D_METHOD("set_dungeon_datas", "dungeon_datas"), &BiomeData::set_dungeon_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_datas", PROPERTY_HINT_NONE, "17/17:DungeonData", PROPERTY_USAGE_DEFAULT, "DungeonData"), "set_dungeon_datas", "get_dungeon_datas"); + + //PropData + ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &BiomeData::get_prop_data); + ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &BiomeData::set_prop_data); + ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &BiomeData::add_prop_data); + ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &BiomeData::remove_prop_data); + + ClassDB::bind_method(D_METHOD("get_prop_data_count"), &BiomeData::get_prop_data_count); + + ClassDB::bind_method(D_METHOD("get_prop_datas"), &BiomeData::get_prop_datas); + 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"); } diff --git a/data/biome_data.h b/data/biome_data.h index ee2b6e1..c16eceb 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -1,14 +1,45 @@ -#ifndef BIOME_DATA_H -#define BIOME_DATA_H +#ifndef dungeon_data_H +#define dungeon_data_H #include "core/resource.h" +#include "core/vector.h" +#include "core/math/vector2.h" #include "../main/biome.h" +#include "dungeon_data.h" +#include "prop_data.h" class BiomeData : public Resource { GDCLASS(BiomeData, Resource); public: + Vector2 get_humidity_range(); + void set_humidity_range(Vector2 range); + + Vector2 get_temperature_range(); + void set_temperature_range(Vector2 range); + + //DungeonData + Ref get_dungeon_data(const int index) const; + void set_dungeon_data(const int index, const Ref dungeon_data); + void add_dungeon_data(const Ref dungeon_data); + void remove_dungeon_data(const int index); + + int get_dungeon_data_count() const; + + Vector get_dungeon_datas(); + void set_dungeon_datas(const Vector &dungeon_datas); + + //PropData + Ref get_prop_data(const int index) const; + void set_prop_data(const int index, const Ref prop_data); + void add_prop_data(const Ref prop_data); + void remove_prop_data(const int index); + + int get_prop_data_count() const; + + Vector get_prop_datas(); + void set_prop_datas(const Vector &prop_datas); Ref setup_biome(int seed); @@ -20,10 +51,10 @@ protected: private: - //Vector2 _humidity_range; - //Vector2 _temperature_range; - //Vector _dungeon_datas; - //Vector > _props; + Vector2 _humidity_range; + Vector2 _temperature_range; + Vector > _dungeon_datas; + Vector > _prop_datas; }; #endif diff --git a/data/dungeon_data.cpp b/data/dungeon_data.cpp index 19a28cf..9cc78ac 100644 --- a/data/dungeon_data.cpp +++ b/data/dungeon_data.cpp @@ -1,5 +1,44 @@ #include "dungeon_data.h" +Ref DungeonData::get_dungeon_room_data(const int index) const { + ERR_FAIL_INDEX_V(index, _dungeon_room_datas.size(), Ref()); + + return _dungeon_room_datas.get(index); +} +void DungeonData::set_dungeon_room_data(const int index, const Ref dungeon_room_data) { + ERR_FAIL_INDEX(index, _dungeon_room_datas.size()); + + _dungeon_room_datas.set(index, dungeon_room_data); +} +void DungeonData::add_dungeon_room_data(const Ref dungeon_room_data) { + _dungeon_room_datas.push_back(dungeon_room_data); +} +void DungeonData::remove_dungeon_room_data(const int index) { + ERR_FAIL_INDEX(index, _dungeon_room_datas.size()); + + _dungeon_room_datas.remove(index); +} + +int DungeonData::get_dungeon_room_data_count() const { + return _dungeon_room_datas.size(); +} + +Vector DungeonData::get_dungeon_room_datas() { + Vector r; + for (int i = 0; i < _dungeon_room_datas.size(); i++) { + r.push_back(_dungeon_room_datas[i].get_ref_ptr()); + } + return r; +} +void DungeonData::set_dungeon_room_datas(const Vector &dungeon_room_datas) { + _dungeon_room_datas.clear(); + for (int i = 0; i < dungeon_room_datas.size(); i++) { + Ref dungeon_room_data = Ref(dungeon_room_datas[i]); + + _dungeon_room_datas.push_back(dungeon_room_data); + } +} + Ref DungeonData::setup_dungeon(int seed) { if (has_method("_setup_dungeon")) { return call("_setup_dungeon", seed); @@ -19,4 +58,15 @@ void DungeonData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "Dungeon"), "_setup_dungeon", PropertyInfo(Variant::INT, "seed"))); ClassDB::bind_method(D_METHOD("setup_dungeon", "seed"), &DungeonData::setup_dungeon); + + 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("add_dungeon_room_data", "dungeon_room_data"), &DungeonData::add_dungeon_room_data); + ClassDB::bind_method(D_METHOD("remove_dungeon_room_data", "index"), &DungeonData::remove_dungeon_room_data); + + ClassDB::bind_method(D_METHOD("get_dungeon_room_data_count"), &DungeonData::get_dungeon_room_data_count); + + ClassDB::bind_method(D_METHOD("get_dungeon_room_datas"), &DungeonData::get_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"); } diff --git a/data/dungeon_data.h b/data/dungeon_data.h index 7172f6e..c6bfdec 100644 --- a/data/dungeon_data.h +++ b/data/dungeon_data.h @@ -2,13 +2,25 @@ #define DUNGEON_DATA_H #include "core/resource.h" +#include "core/vector.h" #include "../main/dungeon.h" +#include "dungeon_room_data.h" class DungeonData : public Resource { GDCLASS(DungeonData, Resource); public: + Ref get_dungeon_room_data(const int index) const; + void set_dungeon_room_data(const int index, const Ref dungeon_room_data); + void add_dungeon_room_data(const Ref dungeon_room_data); + void remove_dungeon_room_data(const int index); + + int get_dungeon_room_data_count() const; + + Vector get_dungeon_room_datas(); + void set_dungeon_room_datas(const Vector &dungeon_room_datas); + Ref setup_dungeon(int seed); DungeonData(); @@ -18,7 +30,7 @@ protected: static void _bind_methods(); private: - //Vector > _rooms; + Vector > _dungeon_room_datas; }; #endif diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp index 731f1ee..971bf22 100644 --- a/data/dungeon_room_data.cpp +++ b/data/dungeon_room_data.cpp @@ -1,5 +1,44 @@ #include "dungeon_room_data.h" +Ref DungeonRoomData::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); + + return _prop_datas.get(index); +} +void DungeonRoomData::set_prop_data(const int index, const Ref prop_data) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.set(index, prop_data); +} +void DungeonRoomData::add_prop_data(const Ref prop_data) { + _prop_datas.push_back(prop_data); +} +void DungeonRoomData::remove_prop_data(const int index) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.remove(index); +} + +int DungeonRoomData::get_prop_data_count() const { + return _prop_datas.size(); +} + +Vector DungeonRoomData::get_prop_datas() { + Vector r; + for (int i = 0; i < _prop_datas.size(); i++) { + r.push_back(_prop_datas[i].get_ref_ptr()); + } + return r; +} +void DungeonRoomData::set_prop_datas(const Vector &prop_datas) { + _prop_datas.clear(); + for (int i = 0; i < prop_datas.size(); i++) { + Ref prop_data = Ref(prop_datas[i]); + + _prop_datas.push_back(prop_data); + } +} + Ref DungeonRoomData::setup_room(int seed) { if (has_method("_setup_room")) { return call("_setup_room", seed); @@ -19,4 +58,15 @@ void DungeonRoomData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"), "_setup_room", PropertyInfo(Variant::INT, "seed"))); ClassDB::bind_method(D_METHOD("setup_room", "seed"), &DungeonRoomData::setup_room); + + 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); + ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoomData::add_prop_data); + ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoomData::remove_prop_data); + + ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoomData::get_prop_data_count); + + ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoomData::get_prop_datas); + 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"); } diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index 536fdd0..34ba7c8 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -4,11 +4,21 @@ #include "core/resource.h" #include "../main/dungeon_room.h" +#include "prop_data.h" class DungeonRoomData : public Resource { GDCLASS(DungeonRoomData, Resource); public: + Ref get_prop_data(const int index) const; + void set_prop_data(const int index, const Ref prop_data); + void add_prop_data(const Ref prop_data); + void remove_prop_data(const int index); + + int get_prop_data_count() const; + + Vector get_prop_datas(); + void set_prop_datas(const Vector &prop_datas); Ref setup_room(int seed); @@ -19,7 +29,7 @@ protected: static void _bind_methods(); private: - //Vector _props; + Vector > _prop_datas; }; #endif diff --git a/data/planet_data.cpp b/data/planet_data.cpp index 6d30330..8851fb5 100644 --- a/data/planet_data.cpp +++ b/data/planet_data.cpp @@ -1,5 +1,65 @@ #include "planet_data.h" +int PlanetData::get_id() const { + return _id; +} +void PlanetData::set_id(const int value) { + _id = value; +} + +Ref PlanetData::get_humidity_noise_params() { + return _humidity_noise_params; +} +void PlanetData::set_humidity_noise_params(Ref value) { + _humidity_noise_params = value; +} + +Ref PlanetData::get_temperature_noise_params() { + return _temperature_noise_params; +} +void PlanetData::set_temperature_noise_params(Ref value) { + _temperature_noise_params = value; +} + +Ref PlanetData::get_biome_data(const int index) const { + ERR_FAIL_INDEX_V(index, _biome_datas.size(), Ref()); + + return _biome_datas.get(index); +} +void PlanetData::set_biome_data(const int index, const Ref biome_data) { + ERR_FAIL_INDEX(index, _biome_datas.size()); + + _biome_datas.set(index, biome_data); +} +void PlanetData::add_biome_data(const Ref biome_data) { + _biome_datas.push_back(biome_data); +} +void PlanetData::remove_biome_data(const int index) { + ERR_FAIL_INDEX(index, _biome_datas.size()); + + _biome_datas.remove(index); +} + +int PlanetData::get_biome_data_count() const { + return _biome_datas.size(); +} + +Vector PlanetData::get_biome_datas() { + Vector r; + for (int i = 0; i < _biome_datas.size(); i++) { + r.push_back(_biome_datas[i].get_ref_ptr()); + } + return r; +} +void PlanetData::set_biome_datas(const Vector &biome_datas) { + _biome_datas.clear(); + for (int i = 0; i < biome_datas.size(); i++) { + Ref biome_data = Ref(biome_datas[i]); + + _biome_datas.push_back(biome_data); + } +} + Ref PlanetData::setup_planet(int seed) { if (has_method("_setup_planet")) { return call("_setup_planet", seed); @@ -9,14 +69,39 @@ Ref PlanetData::setup_planet(int seed) { } PlanetData::PlanetData() { - + _id = 0; } PlanetData::~PlanetData() { - + _biome_datas.clear(); } void PlanetData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "biome", PROPERTY_HINT_RESOURCE_TYPE, "Planet"), "_setup_planet", PropertyInfo(Variant::INT, "seed"))); ClassDB::bind_method(D_METHOD("setup_planet", "seed"), &PlanetData::setup_planet); + + + ClassDB::bind_method(D_METHOD("get_id"), &PlanetData::get_id); + ClassDB::bind_method(D_METHOD("set_id", "value"), &PlanetData::set_id); + ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); + + ClassDB::bind_method(D_METHOD("get_humidity_noise_params"), &PlanetData::get_humidity_noise_params); + ClassDB::bind_method(D_METHOD("set_humidity_noise_params", "value"), &PlanetData::set_humidity_noise_params); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "humidity_noise_params", PROPERTY_HINT_RESOURCE_TYPE, "FastnoiseNoiseParams"), "set_humidity_noise_params", "get_humidity_noise_params"); + + ClassDB::bind_method(D_METHOD("get_temperature_noise_params"), &PlanetData::get_temperature_noise_params); + ClassDB::bind_method(D_METHOD("set_temperature_noise_params", "value"), &PlanetData::set_temperature_noise_params); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "temperature_noise_params", PROPERTY_HINT_RESOURCE_TYPE, "FastnoiseNoiseParams"), "set_temperature_noise_params", "get_temperature_noise_params"); + + + ClassDB::bind_method(D_METHOD("get_biome_data", "index"), &PlanetData::get_biome_data); + ClassDB::bind_method(D_METHOD("set_biome_data", "index", "data"), &PlanetData::set_biome_data); + ClassDB::bind_method(D_METHOD("add_biome_data", "biome_data"), &PlanetData::add_biome_data); + ClassDB::bind_method(D_METHOD("remove_biome_data", "index"), &PlanetData::remove_biome_data); + + ClassDB::bind_method(D_METHOD("get_biome_data_count"), &PlanetData::get_biome_data_count); + + ClassDB::bind_method(D_METHOD("get_biome_datas"), &PlanetData::get_biome_datas); + ClassDB::bind_method(D_METHOD("set_biome_datas", "biome_datas"), &PlanetData::set_biome_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "biome_datas", PROPERTY_HINT_NONE, "17/17:BiomeData", PROPERTY_USAGE_DEFAULT, "BiomeData"), "set_biome_datas", "get_biome_datas"); } diff --git a/data/planet_data.h b/data/planet_data.h index 4ca0093..d6ad50c 100644 --- a/data/planet_data.h +++ b/data/planet_data.h @@ -1,25 +1,35 @@ -#ifndef PLANET_DATA_H -#define PLANET_DATA_H +#ifndef biome_data_H +#define biome_data_H #include "core/resource.h" +#include "../../fastnoise/fastnoise_noise_params.h" + #include "../main/planet.h" +#include "../data/biome_data.h" class PlanetData : public Resource { GDCLASS(PlanetData, Resource); public: - /* - Ref get_planet_data(const int index) const; - void set_planet_data(const int index, const Ref planet_data); - void add_planet_data(const Ref planet_data); - void remove_planet_data(const int index); + int get_id() const; + void set_id(const int value); - int get_planet_data_count() const; + Ref get_humidity_noise_params(); + void set_humidity_noise_params(Ref value); - Vector get_planet_datas(); - void set_planet_datas(const Vector &planet_datas); - */ + Ref get_temperature_noise_params(); + void set_temperature_noise_params(Ref value); + + Ref get_biome_data(const int index) const; + void set_biome_data(const int index, const Ref biome_data); + void add_biome_data(const Ref biome_data); + void remove_biome_data(const int index); + + int get_biome_data_count() const; + + Vector get_biome_datas(); + void set_biome_datas(const Vector &biome_datas); Ref setup_planet(int seed); @@ -31,10 +41,10 @@ protected: private: - //int _id; - //Vector _biome_datas; - //Ref _humidity_noise_params; - //Ref _temperature_noise_params; + int _id; + Ref _humidity_noise_params; + Ref _temperature_noise_params; + Vector > _biome_datas; }; #endif diff --git a/data/prop_data.cpp b/data/prop_data.cpp new file mode 100644 index 0000000..774558e --- /dev/null +++ b/data/prop_data.cpp @@ -0,0 +1,32 @@ +#include "prop_data.h" + +bool PropData::can_spawn(int seed) { + if (has_method("_can_spawn")) { + return call("_can_spawn", seed); + } + + return false; +} + +Ref PropData::get_prop(int seed) { + if (has_method("_get_prop")) { + return call("_get_prop", seed); + } + + return Ref(NULL); +} + +PropData::PropData() { + +} +PropData::~PropData() { + +} + +void PropData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanProp"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + + ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &PropData::can_spawn); + ClassDB::bind_method(D_METHOD("get_prop", "seed"), &PropData::get_prop); +} diff --git a/data/prop_data.h b/data/prop_data.h new file mode 100644 index 0000000..2152085 --- /dev/null +++ b/data/prop_data.h @@ -0,0 +1,24 @@ +#ifndef PROP_DATA_H +#define PROP_DATA_H + +#include "core/resource.h" + +#include "../../voxelman/props/voxelman_prop.h" + +class PropData : public Resource { + GDCLASS(PropData, Resource); + +public: + + bool can_spawn(int seed); + Ref get_prop(int seed); + + PropData(); + ~PropData(); + +protected: + static void _bind_methods(); + +}; + +#endif diff --git a/main/biome.cpp b/main/biome.cpp index c06537f..4891d4d 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -1,5 +1,54 @@ #include "biome.h" +//// Prop Data //// +Ref Biome::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); + + return _prop_datas.get(index); +} +void Biome::set_prop_data(const int index, const Ref prop_data) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.set(index, prop_data); +} +void Biome::add_prop_data(const Ref prop_data) { + _prop_datas.push_back(prop_data); +} +void Biome::remove_prop_data(const int index) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.remove(index); +} + +int Biome::get_prop_data_count() const { + return _prop_datas.size(); +} + +//// Dungeons //// +Ref Biome::get_dungeon(const int index) const { + ERR_FAIL_INDEX_V(index, _dungeons.size(), Ref()); + + return _dungeons.get(index); +} +void Biome::set_dungeon(const int index, const Ref dungeon) { + ERR_FAIL_INDEX(index, _dungeons.size()); + + _dungeons.set(index, dungeon); +} +void Biome::add_dungeon(const Ref dungeon) { + _dungeons.push_back(dungeon); +} +void Biome::remove_dungeon(const int index) { + ERR_FAIL_INDEX(index, _dungeons.size()); + + _dungeons.remove(index); +} + +int Biome::get_dungeon_count() const { + return _dungeons.size(); +} + + void Biome::generate_chunk(Ref chunk) { if (has_method("_generate")) { call("_generate", chunk); @@ -24,4 +73,19 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Biome::generate_chunk); ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z"), &Biome::generate_stack); + + + 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); + ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &Biome::remove_prop_data); + + ClassDB::bind_method(D_METHOD("get_prop_data_count"), &Biome::get_prop_data_count); + + 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); + ClassDB::bind_method(D_METHOD("remove_dungeon", "index"), &Biome::remove_dungeon); + + ClassDB::bind_method(D_METHOD("get_dungeon_count"), &Biome::get_dungeon_count); } diff --git a/main/biome.h b/main/biome.h index 948b97a..861cf31 100644 --- a/main/biome.h +++ b/main/biome.h @@ -4,11 +4,30 @@ #include "core/resource.h" #include "../../voxelman/world/voxel_chunk.h" +#include "../data/prop_data.h" +#include "dungeon.h" + class Biome : public Resource { GDCLASS(Biome, Resource); public: + //PropData + Ref get_prop_data(const int index) const; + void set_prop_data(const int index, const Ref prop_data); + void add_prop_data(const Ref prop_data); + void remove_prop_data(const int index); + + int get_prop_data_count() const; + + //Dungeons + Ref get_dungeon(const int index) const; + void set_dungeon(const int index, const Ref dungeon); + void add_dungeon(const Ref dungeon); + void remove_dungeon(const int index); + + int get_dungeon_count() const; + void generate_chunk(Ref chunk); void generate_stack(Ref chunk, int x, int z); @@ -19,8 +38,8 @@ protected: static void _bind_methods(); private: - //Vector > _props; - //Vector > _dungeons; + Vector > _prop_datas; + Vector > _dungeons; }; #endif diff --git a/main/dungeon.cpp b/main/dungeon.cpp index 3245dca..dc7c6f4 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -1,5 +1,28 @@ #include "dungeon.h" +Ref Dungeon::get_dungeon_room(const int index) const { + ERR_FAIL_INDEX_V(index, _dungeon_rooms.size(), Ref()); + + return _dungeon_rooms.get(index); +} +void Dungeon::set_dungeon_room(const int index, const Ref dungeon_room) { + ERR_FAIL_INDEX(index, _dungeon_rooms.size()); + + _dungeon_rooms.set(index, dungeon_room); +} +void Dungeon::add_dungeon_room(const Ref dungeon_room) { + _dungeon_rooms.push_back(dungeon_room); +} +void Dungeon::remove_dungeon_room(const int index) { + ERR_FAIL_INDEX(index, _dungeon_rooms.size()); + + _dungeon_rooms.remove(index); +} + +int Dungeon::get_dungeon_room_count() const { + return _dungeon_rooms.size(); +} + void Dungeon::generate(Ref structure) { if (has_method("_generate")) { call("_generate", structure); @@ -17,4 +40,11 @@ void Dungeon::_bind_methods() { BIND_VMETHOD(MethodInfo("_generate", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); ClassDB::bind_method(D_METHOD("generate", "structure"), &Dungeon::generate); + + 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); + ClassDB::bind_method(D_METHOD("add_dungeon_room", "dungeon_room"), &Dungeon::add_dungeon_room); + ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &Dungeon::remove_dungeon_room); + + ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &Dungeon::get_dungeon_room_count); } diff --git a/main/dungeon.h b/main/dungeon.h index 5037c43..381d898 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -3,12 +3,19 @@ #include "core/resource.h" +#include "dungeon_room.h" #include "../../voxelman/world/voxel_structure.h" class Dungeon : public Reference { GDCLASS(Dungeon, Reference); public: + Ref get_dungeon_room(const int index) const; + void set_dungeon_room(const int index, const Ref dungeon_room); + void add_dungeon_room(const Ref dungeon_room); + void remove_dungeon_room(const int index); + + int get_dungeon_room_count() const; void generate(Ref structure); @@ -20,7 +27,7 @@ protected: private: - //Vector > _rooms; + Vector > _dungeon_rooms; }; #endif diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index bbd604e..4eeaf06 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -1,5 +1,28 @@ #include "dungeon_room.h" +Ref DungeonRoom::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); + + return _prop_datas.get(index); +} +void DungeonRoom::set_prop_data(const int index, const Ref prop_data) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.set(index, prop_data); +} +void DungeonRoom::add_prop_data(const Ref prop_data) { + _prop_datas.push_back(prop_data); +} +void DungeonRoom::remove_prop_data(const int index) { + ERR_FAIL_INDEX(index, _prop_datas.size()); + + _prop_datas.remove(index); +} + +int DungeonRoom::get_prop_data_count() const { + return _prop_datas.size(); +} + void DungeonRoom::generate_room(Ref structure) { if (has_method("_generate_room")) { call("_generate_room", structure); @@ -17,4 +40,11 @@ void DungeonRoom::_bind_methods() { BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); ClassDB::bind_method(D_METHOD("generate_room", "structure"), &DungeonRoom::generate_room); + + 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); } diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 0d3207b..349fb5f 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -2,13 +2,21 @@ #define DUNGEON_ROOM_H #include "core/reference.h" +#include "core/vector.h" #include "../../voxelman/world/voxel_structure.h" +#include "../data/prop_data.h" class DungeonRoom : public Reference { GDCLASS(DungeonRoom, Reference); public: + Ref get_prop_data(const int index) const; + void set_prop_data(const int index, const Ref prop_data); + void add_prop_data(const Ref prop_data); + void remove_prop_data(const int index); + + int get_prop_data_count() const; void generate_room(Ref structure); @@ -20,7 +28,7 @@ protected: private: - //Vector > _props; + Vector > _prop_datas; }; #endif diff --git a/main/planet.cpp b/main/planet.cpp index 4c549f0..a9cf85f 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -1,5 +1,28 @@ #include "planet.h" +Ref Planet::get_biome(const int index) const { + ERR_FAIL_INDEX_V(index, _biomes.size(), Ref()); + + return _biomes.get(index); +} +void Planet::set_biome(const int index, const Ref biome) { + ERR_FAIL_INDEX(index, _biomes.size()); + + _biomes.set(index, biome); +} +void Planet::add_biome(const Ref biome) { + _biomes.push_back(biome); +} +void Planet::remove_biome(const int index) { + ERR_FAIL_INDEX(index, _biomes.size()); + + _biomes.remove(index); +} + +int Planet::get_biome_count() const { + return _biomes.size(); +} + void Planet::generate_chunk(Ref chunk) { if (has_method("_generate_chunk")) { call("_generate_chunk", chunk); @@ -17,4 +40,11 @@ void Planet::_bind_methods() { BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk); + + ClassDB::bind_method(D_METHOD("get_biome", "index"), &Planet::get_biome); + ClassDB::bind_method(D_METHOD("set_biome", "index", "data"), &Planet::set_biome); + ClassDB::bind_method(D_METHOD("add_biome", "biome"), &Planet::add_biome); + ClassDB::bind_method(D_METHOD("remove_biome", "index"), &Planet::remove_biome); + + ClassDB::bind_method(D_METHOD("get_biome_count"), &Planet::get_biome_count); } diff --git a/main/planet.h b/main/planet.h index 5c67388..9240dd0 100644 --- a/main/planet.h +++ b/main/planet.h @@ -4,11 +4,19 @@ #include "core/resource.h" #include "../../voxelman/world/voxel_chunk.h" +#include "biome.h" class Planet : public Resource { GDCLASS(Planet, Resource); public: + Ref get_biome(const int index) const; + void set_biome(const int index, const Ref biome); + void add_biome(const Ref biome); + void remove_biome(const int index); + + int get_biome_count() const; + void generate_chunk(Ref chunk); Planet(); @@ -18,7 +26,7 @@ protected: static void _bind_methods(); private: - //Vector > _biomes; + Vector > _biomes; }; #endif diff --git a/register_types.cpp b/register_types.cpp index d0ccca5..9f1bac7 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -4,6 +4,7 @@ #include "data/dungeon_data.h" #include "data/biome_data.h" #include "data/planet_data.h" +#include "data/prop_data.h" #include "main/dungeon_room.h" #include "main/dungeon.h" @@ -17,6 +18,7 @@ void register_world_generator_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();