diff --git a/SCsub b/SCsub index 4fa9ab7..623ab9d 100644 --- a/SCsub +++ b/SCsub @@ -1,8 +1,18 @@ Import('env') +import os + +if os.path.isdir('../entity_spell_system'): + print("ESS FOUND") + env.Append(CPPDEFINES=['ESS_PRESENT']) + +if os.path.isdir('../voxelman'): + print("VOXELMAN FOUND") + env.Append(CPPDEFINES=['VOXELMAN_PRESENT']) + 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") diff --git a/data/biome_data.cpp b/data/biome_data.cpp index 56bded9..a0ff792 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -117,8 +117,8 @@ void BiomeData::set_prop_datas(const Vector &prop_datas) { } } +#ifdef ESS_PRESENT //Entities - Ref BiomeData::get_entity_data(const int index) const { ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); @@ -158,6 +158,9 @@ void BiomeData::set_entity_datas(const Vector &entity_datas) { } } +#endif + +#ifdef VOXELMAN_PRESENT //Environments Ref BiomeData::get_environment_data(const int index) const { ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref()); @@ -275,17 +278,24 @@ void BiomeData::set_liquid_voxel_surfaces(const Vector &voxel_surfaces) } } +#endif + BiomeData::BiomeData() { } BiomeData::~BiomeData() { _dungeon_datas.clear(); _prop_datas.clear(); - _entity_datas.clear(); + #ifdef ESS_PRESENT + _entity_datas.clear(); + #endif + + #ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); + #endif } void BiomeData::_bind_methods() { @@ -331,6 +341,7 @@ 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:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); + #ifdef ESS_PRESENT //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); @@ -341,7 +352,9 @@ void BiomeData::_bind_methods() { 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"); + #endif + #ifdef VOXELMAN_PRESENT //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); @@ -374,4 +387,5 @@ void BiomeData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &BiomeData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &BiomeData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); + #endif } diff --git a/data/biome_data.h b/data/biome_data.h index fdcf418..b729f53 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -11,10 +11,14 @@ #include "dungeon_data.h" #include "world_generator_prop_data.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#endif +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" +#endif class BiomeData : public Resource { GDCLASS(BiomeData, Resource); @@ -56,6 +60,7 @@ public: Vector get_prop_datas(); void set_prop_datas(const Vector &prop_datas); + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); @@ -65,7 +70,9 @@ public: Vector get_entity_datas(); void set_entity_datas(const Vector &entity_datas); + #endif + #ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -95,6 +102,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); + #endif BiomeData(); ~BiomeData(); @@ -113,10 +121,16 @@ private: Vector > _dungeon_datas; Vector > _prop_datas; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif + + #ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; + #endif }; #endif diff --git a/data/dungeon_data.cpp b/data/dungeon_data.cpp index be8ebf0..0c6bc10 100644 --- a/data/dungeon_data.cpp +++ b/data/dungeon_data.cpp @@ -239,6 +239,7 @@ void DungeonData::set_dungeon_corridor_datas(const Vector &dungeon_corr } } +#ifdef ESS_PRESENT //Entities Ref DungeonData::get_entity_data(const int index) const { ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); @@ -277,7 +278,9 @@ void DungeonData::set_entity_datas(const Vector &entity_datas) { _entity_datas.push_back(entity_data); } } +#endif +#ifdef VOXELMAN_PRESENT //// Surfaces //// Ref DungeonData::get_voxel_surface(const int index) const { ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); @@ -394,6 +397,7 @@ void DungeonData::set_environment_datas(const Vector &environment_datas _environment_datas.push_back(environment_data); } } +#endif DungeonData::DungeonData() { _min_sizex = 0; @@ -408,17 +412,24 @@ DungeonData::DungeonData() { _max_room_count = 0; } DungeonData::~DungeonData() { + #ifdef VOXELMAN_PRESENT _environment_datas.clear(); + #endif _dungeon_room_datas.clear(); _dungeon_start_room_datas.clear(); _dungeon_end_room_datas.clear(); _dungeon_corridor_datas.clear(); - _entity_datas.clear(); + #ifdef ESS_PRESENT + _entity_datas.clear(); + #endif + + #ifdef VOXELMAN_PRESENT _entity_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); + #endif } void DungeonData::_bind_methods() { @@ -513,6 +524,7 @@ void DungeonData::_bind_methods() { 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"); + #ifdef ESS_PRESENT //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); @@ -523,7 +535,9 @@ void DungeonData::_bind_methods() { 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"); + #endif + #ifdef VOXELMAN_PRESENT //Environments 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); @@ -556,4 +570,5 @@ void DungeonData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &DungeonData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &DungeonData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); + #endif } diff --git a/data/dungeon_data.h b/data/dungeon_data.h index f3d2c1c..6d0dbfa 100644 --- a/data/dungeon_data.h +++ b/data/dungeon_data.h @@ -10,11 +10,14 @@ #include "dungeon_room_data.h" #include "dungeon_corridor_data.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#endif +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" - +#endif class DungeonData : public Resource { GDCLASS(DungeonData, Resource); @@ -56,6 +59,7 @@ public: int get_max_room_count(); void set_max_room_count(int value); + #ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -65,6 +69,7 @@ public: Vector get_environment_datas(); void set_environment_datas(const Vector &environment_datas); + #endif //Rooms Ref get_dungeon_room_data(const int index) const; @@ -106,6 +111,7 @@ public: Vector get_dungeon_corridor_datas(); void set_dungeon_corridor_datas(const Vector &dungeon_corridor_datas); + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); @@ -115,7 +121,9 @@ public: Vector get_entity_datas(); void set_entity_datas(const Vector &entity_datas); + #endif + #ifdef VOXELMAN_PRESENT //Surfaces Ref get_voxel_surface(const int index) const; void set_voxel_surface(const int index, const Ref voxel_surface); @@ -135,6 +143,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); + #endif DungeonData(); ~DungeonData(); @@ -159,15 +168,23 @@ private: int _min_room_count; int _max_room_count; + #ifdef VOXELMAN_PRESENT Vector > _environment_datas; + #endif Vector > _dungeon_room_datas; Vector > _dungeon_start_room_datas; Vector > _dungeon_end_room_datas; Vector > _dungeon_corridor_datas; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif + + #ifdef VOXELMAN_PRESENT Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; + #endif }; #endif diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp index 1495d97..f516eb6 100644 --- a/data/dungeon_room_data.cpp +++ b/data/dungeon_room_data.cpp @@ -104,6 +104,7 @@ void DungeonRoomData::set_prop_datas(const Vector &prop_datas) { } } +#ifdef VOXELMAN_PRESENT //Environments Ref DungeonRoomData::get_environment_data(const int index) const { ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref()); @@ -143,45 +144,6 @@ void DungeonRoomData::set_environment_datas(const Vector &environment_d } } -//Entities -Ref DungeonRoomData::get_entity_data(const int index) const { - ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); - - return _entity_datas.get(index); -} -void DungeonRoomData::set_entity_data(const int index, const Ref entity_data) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.set(index, entity_data); -} -void DungeonRoomData::add_entity_data(const Ref 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 DungeonRoomData::get_entity_datas() { - Vector 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 &entity_datas) { - _entity_datas.clear(); - for (int i = 0; i < entity_datas.size(); i++) { - Ref entity_data = Ref(entity_datas[i]); - - _entity_datas.push_back(entity_data); - } -} - //// Surfaces //// Ref DungeonRoomData::get_voxel_surface(const int index) const { ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); @@ -260,6 +222,51 @@ void DungeonRoomData::set_liquid_voxel_surfaces(const Vector &voxel_sur } } +#endif + +#ifdef ESS_PRESENT + +//Entities +Ref DungeonRoomData::get_entity_data(const int index) const { + ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); + + return _entity_datas.get(index); +} +void DungeonRoomData::set_entity_data(const int index, const Ref entity_data) { + ERR_FAIL_INDEX(index, _entity_datas.size()); + + _entity_datas.set(index, entity_data); +} +void DungeonRoomData::add_entity_data(const Ref 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 DungeonRoomData::get_entity_datas() { + Vector 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 &entity_datas) { + _entity_datas.clear(); + for (int i = 0; i < entity_datas.size(); i++) { + Ref entity_data = Ref(entity_datas[i]); + + _entity_datas.push_back(entity_data); + } +} + +#endif + DungeonRoomData::DungeonRoomData() { _min_sizex = 0; _min_sizey = 0; @@ -271,10 +278,16 @@ DungeonRoomData::DungeonRoomData() { } DungeonRoomData::~DungeonRoomData() { _prop_datas.clear(); + + #ifdef ESS_PRESENT _entity_datas.clear(); + #endif + + #ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); + #endif } void DungeonRoomData::_bind_methods() { @@ -327,6 +340,7 @@ 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:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); + #ifdef ESS_PRESENT //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); @@ -337,7 +351,9 @@ void DungeonRoomData::_bind_methods() { 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"); + #endif + #ifdef VOXELMAN_PRESENT //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); @@ -370,4 +386,5 @@ void DungeonRoomData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &DungeonRoomData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &DungeonRoomData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); + #endif } diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index 17e8d30..9af681b 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -5,14 +5,17 @@ #include "core/ustring.h" #include "core/script_language.h" -#include "../../voxelman/world/environment_data.h" -#include "../../voxelman/library/voxel_surface.h" - #include "../main/dungeon_room.h" #include "world_generator_prop_data.h" +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" +#endif +#ifdef VOXELMAN_PRESENT +#include "../../voxelman/world/environment_data.h" +#include "../../voxelman/library/voxel_surface.h" +#endif class DungeonRoomData : public Resource { GDCLASS(DungeonRoomData, Resource); @@ -57,6 +60,9 @@ public: Vector get_prop_datas(); void set_prop_datas(const Vector &prop_datas); + #ifdef VOXELMAN_PRESENT + //TOO: Environments are useful for every game, this should be decoupled from voxelman. + //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -67,16 +73,6 @@ public: Vector get_environment_datas(); void set_environment_datas(const Vector &environment_datas); - //Entities - Ref get_entity_data(const int index) const; - void set_entity_data(const int index, const Ref entity_data); - void add_entity_data(const Ref entity_data); - void remove_entity_data(const int index); - int get_entity_data_count() const; - - Vector get_entity_datas(); - void set_entity_datas(const Vector &entity_datas); - //Surfaces Ref get_voxel_surface(const int index) const; void set_voxel_surface(const int index, const Ref voxel_surface); @@ -96,6 +92,21 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); + #else + //TODO Create generic binds + #endif + + #ifdef ESS_PRESENT + //Entities + Ref get_entity_data(const int index) const; + void set_entity_data(const int index, const Ref entity_data); + void add_entity_data(const Ref entity_data); + void remove_entity_data(const int index); + int get_entity_data_count() const; + + Vector get_entity_datas(); + void set_entity_datas(const Vector &entity_datas); + #endif DungeonRoomData(); ~DungeonRoomData(); @@ -118,10 +129,16 @@ private: int _max_sizez; Vector > _prop_datas; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif + + #ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; + #endif }; #endif diff --git a/data/planet_data.cpp b/data/planet_data.cpp index ba79b1c..eee4a62 100644 --- a/data/planet_data.cpp +++ b/data/planet_data.cpp @@ -81,6 +81,7 @@ void PlanetData::set_biome_datas(const Vector &biome_datas) { } } +#ifdef VOXELMAN_PRESENT //Environments Ref PlanetData::get_environment_data(const int index) const { ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref()); @@ -198,6 +199,7 @@ void PlanetData::set_liquid_voxel_surfaces(const Vector &voxel_surfaces _liquid_voxel_surfaces.push_back(voxel_surface); } } +#endif PlanetData::PlanetData() { _id = 0; @@ -207,9 +209,12 @@ PlanetData::~PlanetData() { _temperature_noise_params.unref(); _biome_datas.clear(); + + #ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); + #endif } void PlanetData::_bind_methods() { @@ -248,6 +253,7 @@ void PlanetData::_bind_methods() { 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"); + #ifdef VOXELMAN_PRESENT //Environments ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &PlanetData::get_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &PlanetData::set_environment_data); @@ -280,4 +286,5 @@ void PlanetData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &PlanetData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &PlanetData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); + #endif } diff --git a/data/planet_data.h b/data/planet_data.h index c53e8b8..82eb51d 100644 --- a/data/planet_data.h +++ b/data/planet_data.h @@ -10,8 +10,10 @@ #include "../main/planet.h" #include "../data/biome_data.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#endif class PlanetData : public Resource { GDCLASS(PlanetData, Resource); @@ -45,6 +47,7 @@ public: Vector get_biome_datas(); void set_biome_datas(const Vector &biome_datas); + #ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -74,6 +77,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); + #endif PlanetData(); ~PlanetData(); @@ -92,9 +96,12 @@ private: Ref _humidity_noise_params; Ref _temperature_noise_params; Vector > _biome_datas; + + #ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; + #endif }; #endif diff --git a/data/world_generator_prop_data.cpp b/data/world_generator_prop_data.cpp index 6f229d4..6f4327b 100644 --- a/data/world_generator_prop_data.cpp +++ b/data/world_generator_prop_data.cpp @@ -8,6 +8,7 @@ bool WorldGeneratorPropData::can_spawn(int seed) { return false; } +#ifdef VOXELMAN_PRESENT Ref WorldGeneratorPropData::get_prop(int seed) { if (has_method("_get_prop")) { return call("_get_prop", seed); @@ -15,6 +16,15 @@ Ref WorldGeneratorPropData::get_prop(int seed) { return Ref(NULL); } +#else +Ref WorldGeneratorPropData::get_prop(int seed) { + if (has_method("_get_prop")) { + return call("_get_prop", seed); + } + + return Ref(NULL); +} +#endif WorldGeneratorPropData::WorldGeneratorPropData() { @@ -25,7 +35,12 @@ WorldGeneratorPropData::~WorldGeneratorPropData() { void WorldGeneratorPropData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); + + #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + #else + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + #endif ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &WorldGeneratorPropData::can_spawn); ClassDB::bind_method(D_METHOD("get_prop", "seed"), &WorldGeneratorPropData::get_prop); diff --git a/data/world_generator_prop_data.h b/data/world_generator_prop_data.h index eb21d5b..7301086 100644 --- a/data/world_generator_prop_data.h +++ b/data/world_generator_prop_data.h @@ -3,7 +3,9 @@ #include "core/resource.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/props/prop_data.h" +#endif class WorldGeneratorPropData : public Resource { GDCLASS(WorldGeneratorPropData, Resource); @@ -11,7 +13,12 @@ class WorldGeneratorPropData : public Resource { public: bool can_spawn(int seed); + + #ifdef VOXELMAN_PRESENT Ref get_prop(int seed); + #else + Ref get_prop(int seed); + #endif WorldGeneratorPropData(); ~WorldGeneratorPropData(); diff --git a/main/biome.cpp b/main/biome.cpp index 18a9a8f..1041af1 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -14,12 +14,14 @@ void Biome::set_level_range(Vector2 value) { _level_range = value; } +#ifdef VOXELMAN_PRESENT Ref Biome::get_environment() { return _environment; } void Biome::set_environment(Ref value) { _environment = value; } +#endif Ref Biome::get_data() { return _data; @@ -54,6 +56,7 @@ int Biome::get_prop_data_count() const { return _prop_datas.size(); } +#ifdef ESS_PRESENT //Entities Ref Biome::get_entity_data(const int index) const { ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); @@ -76,6 +79,7 @@ void Biome::remove_entity_data(const int index) { int Biome::get_entity_data_count() const { return _entity_datas.size(); } +#endif //// Dungeons //// Ref Biome::get_dungeon(const int index) const { @@ -100,6 +104,16 @@ int Biome::get_dungeon_count() const { return _dungeons.size(); } +void Biome::setup() { + if (!_data.is_valid()) + return; + + if (has_method("_setup")) { + call("_setup"); + } +} + +#ifdef VOXELMAN_PRESENT void Biome::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); @@ -121,15 +135,6 @@ void Biome::generate_stack_bind(Node *chunk, int x, int z, bool spawn_mobs) { generate_stack(Object::cast_to(chunk), x, z, spawn_mobs); } -void Biome::setup() { - if (!_data.is_valid()) - return; - - if (has_method("_setup")) { - call("_setup"); - } -} - void Biome::setup_library(Ref library) { if (!_data.is_valid()) return; @@ -156,30 +161,66 @@ void Biome::_setup_library(Ref library) { } } } +#else +void Biome::setup_library(Ref library) { + if (!_data.is_valid()) + return; + + if (has_method("_setup_library")) { + call("_setup_library", library); + } +} + +void Biome::generate_chunk(Node *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk, spawn_mobs); + } +} +#endif Biome::Biome() { _current_seed = 0; } Biome::~Biome() { + #ifdef VOXELMAN_PRESENT _environment.unref(); + #endif + _data.unref(); _prop_datas.clear(); + + #ifdef ESS_PRESENT _entity_datas.clear(); + #endif + _dungeons.clear(); } void Biome::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); + + #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #else + BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #endif ClassDB::bind_method(D_METHOD("setup"), &Biome::setup); ClassDB::bind_method(D_METHOD("setup_library", "library"), &Biome::setup_library); + + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Biome::_setup_library); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack_bind); + #else + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk); + #endif ClassDB::bind_method(D_METHOD("get_current_seed"), &Biome::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Biome::set_current_seed); @@ -189,9 +230,11 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &Biome::get_environment); 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"); + #endif ClassDB::bind_method(D_METHOD("get_data"), &Biome::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Biome::set_data); @@ -204,12 +247,14 @@ void Biome::_bind_methods() { 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); + #ifdef ESS_PRESENT //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); + #endif //Dungeons ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Biome::get_dungeon); diff --git a/main/biome.h b/main/biome.h index c382a01..8bf8f37 100644 --- a/main/biome.h +++ b/main/biome.h @@ -8,11 +8,15 @@ #include "../data/biome_data.h" #include "../data/world_generator_prop_data.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxelman_library.h" #include "../../voxelman/world/voxel_chunk.h" +#endif +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" +#endif class BiomeData; @@ -26,9 +30,11 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); + #ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); + #endif Ref get_data(); void set_data(Ref value); @@ -41,12 +47,14 @@ public: int get_prop_data_count() const; + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); void add_entity_data(const Ref entity_data); void remove_entity_data(const int index); int get_entity_data_count() const; + #endif //Dungeons Ref get_dungeon(const int index) const; @@ -55,14 +63,21 @@ public: void remove_dungeon(const int index); int get_dungeon_count() const; + void setup(); + + #ifdef VOXELMAN_PRESENT void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_stack(VoxelChunk *chunk, int x, int z, bool spawn_mobs); void generate_stack_bind(Node *chunk, int x, int z, bool spawn_mobs); - void setup(); void setup_library(Ref library); void _setup_library(Ref library); + #else + void generate_chunk(Node *chunk, bool spawn_mobs); + + void setup_library(Ref library); + #endif Biome(); ~Biome(); @@ -75,10 +90,17 @@ private: Vector2 _level_range; + #ifdef VOXELMAN_PRESENT Ref _environment; + #endif + Ref _data; Vector > _prop_datas; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif + Vector > _dungeons; }; diff --git a/main/dungeon.cpp b/main/dungeon.cpp index 54c4183..ca1cfed 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -65,12 +65,14 @@ void Dungeon::set_room_count(int value) { _room_count = value; } +#ifdef VOXELMAN_PRESENT Ref Dungeon::get_environment() { return _environment; } void Dungeon::set_environment(Ref value) { _environment = value; } +#endif Ref Dungeon::get_data() { return _data; @@ -176,6 +178,7 @@ int Dungeon::get_dungeon_corridor_count() const { return _dungeon_corridors.size(); } +#ifdef ESS_PRESENT //Entities Ref Dungeon::get_entity_data(const int index) const { ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); @@ -198,6 +201,7 @@ void Dungeon::remove_entity_data(const int index) { int Dungeon::get_entity_data_count() const { return _entity_datas.size(); } +#endif void Dungeon::setup() { if (!_data.is_valid()) @@ -208,6 +212,7 @@ void Dungeon::setup() { } } +#ifdef VOXELMAN_PRESENT void Dungeon::setup_library(Ref library) { if (!_data.is_valid()) return; @@ -251,6 +256,24 @@ void Dungeon::generate_structure(Ref structure, bool spawn_mobs) call("_generate_structure", structure, spawn_mobs); } } +#else +void Dungeon::setup_library(Ref library) { + if (!_data.is_valid()) + return; + + if (has_method("_setup_library")) { + call("_setup_library", library); + } +} + +void Dungeon::generate_chunk(Node *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk, spawn_mobs); + } +} +#endif Ref Dungeon::generate_map() { ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); @@ -272,27 +295,45 @@ Dungeon::Dungeon() { _room_count = 0; } Dungeon::~Dungeon() { + #ifdef VOXELMAN_PRESENT _environment.unref(); + #endif + _data.unref(); _dungeon_rooms.clear(); _dungeon_start_rooms.clear(); _dungeon_end_rooms.clear(); _dungeon_corridors.clear(); + + #ifdef ESS_PRESENT _entity_datas.clear(); + #endif } void Dungeon::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); + + #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #else + BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #endif ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup); + + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("setup_library", "library"), &Dungeon::setup_library); ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Dungeon::_setup_library); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure); + #else + ClassDB::bind_method(D_METHOD("setup_library", "library"), &Dungeon::setup_library); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk); + #endif ClassDB::bind_method(D_METHOD("get_current_seed"), &Dungeon::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Dungeon::set_current_seed); @@ -333,10 +374,12 @@ void Dungeon::_bind_methods() { 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"); + #ifdef VOXELMAN_PRESENT //Environment ClassDB::bind_method(D_METHOD("get_environment"), &Dungeon::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Dungeon::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); + #endif ClassDB::bind_method(D_METHOD("get_data"), &Dungeon::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Dungeon::set_data); @@ -372,12 +415,14 @@ void Dungeon::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_dungeon_corridor", "index"), &Dungeon::remove_dungeon_corridor); ClassDB::bind_method(D_METHOD("get_dungeon_corridor_count"), &Dungeon::get_dungeon_corridor_count); + #ifdef ESS_PRESENT //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); + #endif BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); diff --git a/main/dungeon.h b/main/dungeon.h index 62b8074..cf89a32 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -6,14 +6,20 @@ #include "dungeon_room.h" #include "dungeon_corridor.h" +#include "../data/dungeon_data.h" + +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/voxel_structure.h" #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxelman_library.h" +#else +#include "scene/main/node.h" +#endif +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" - -#include "../data/dungeon_data.h" +#endif class DungeonData; @@ -51,9 +57,11 @@ public: int get_room_count(); void set_room_count(int value); + #ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); + #endif Ref get_data(); void set_data(Ref value); @@ -86,20 +94,28 @@ public: void remove_dungeon_corridor(const int index); int get_dungeon_corridor_count() const; + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_datas); void add_entity_data(const Ref entity_datas); void remove_entity_data(const int index); int get_entity_data_count() const; + #endif void setup(); + + #ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_structure(Ref structure, bool spawn_mobs); + #else + void setup_library(Ref library); + void generate_chunk(Node *chunk, bool spawn_mobs); + #endif Ref generate_map(); @@ -124,13 +140,19 @@ private: int _room_count; + #ifdef VOXELMAN_PRESENT Ref _environment; + #endif + Ref _data; Vector > _dungeon_rooms; Vector > _dungeon_start_rooms; Vector > _dungeon_end_rooms; Vector > _dungeon_corridors; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif }; #endif diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h index a8158a5..f0885e3 100644 --- a/main/dungeon_corridor.h +++ b/main/dungeon_corridor.h @@ -3,7 +3,6 @@ #include "dungeon_room.h" - class DungeonCorridor : public DungeonRoom { GDCLASS(DungeonCorridor, DungeonRoom); diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index f0bfa77..7a65682 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -58,12 +58,14 @@ void DungeonRoom::set_sizez(int value) { _sizez = value; } +#ifdef VOXELMAN_PRESENT Ref DungeonRoom::get_environment() { return _environment; } void DungeonRoom::set_environment(Ref value) { _environment = value; } +#endif Ref DungeonRoom::get_data() { return _data; @@ -74,12 +76,14 @@ void DungeonRoom::set_data(Ref value) { setup(); } +#ifdef VOXELMAN_PRESENT Ref DungeonRoom::get_structure() { return _structure; } void DungeonRoom::set_structure(Ref structure) { _structure = structure; } +#endif //Props Ref DungeonRoom::get_prop_data(const int index) const { @@ -104,6 +108,7 @@ int DungeonRoom::get_prop_data_count() const { return _prop_datas.size(); } +#ifdef ESS_PRESENT //Entities Ref DungeonRoom::get_entity_data(const int index) const { ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); @@ -126,6 +131,7 @@ void DungeonRoom::remove_entity_data(const int index) { int DungeonRoom::get_entity_data_count() const { return _entity_datas.size(); } +#endif void DungeonRoom::setup() { if (!_data.is_valid()) @@ -136,6 +142,7 @@ void DungeonRoom::setup() { } } +#ifdef VOXELMAN_PRESENT void DungeonRoom::setup_library(Ref library) { if (!_data.is_valid()) return; @@ -180,6 +187,26 @@ void DungeonRoom::generate_room(Ref structure, bool spawn_mobs) call("_generate_room", structure, spawn_mobs); } } +#else + +void DungeonRoom::setup_library(Ref library) { + if (!_data.is_valid()) + return; + + if (has_method("_setup_library")) { + call("_setup_library", library); + } +} + +void DungeonRoom::generate_chunk(Node *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk, spawn_mobs); + } +} + +#endif DungeonRoom::DungeonRoom() { _current_seed = 0; @@ -193,25 +220,44 @@ DungeonRoom::DungeonRoom() { _sizez = 0; } DungeonRoom::~DungeonRoom() { - _environment.unref(); _data.unref(); - _structure.unref(); _prop_datas.clear(); + + #ifdef VOXELMAN_PRESENT + _environment.unref(); + _structure.unref(); + #endif + + #ifdef ESS_PRESENT _entity_datas.clear(); + #endif } void DungeonRoom::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); + + #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #else + BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #endif ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup); ClassDB::bind_method(D_METHOD("setup_library", "library"), &DungeonRoom::setup_library); - ClassDB::bind_method(D_METHOD("_setup_library", "library"), &DungeonRoom::_setup_library); + #ifdef VOXELMAN_PRESENT + ClassDB::bind_method(D_METHOD("_setup_library", "library"), &DungeonRoom::_setup_library); + #endif + + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room); + #else + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk); + #endif ClassDB::bind_method(D_METHOD("get_current_seed"), &DungeonRoom::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &DungeonRoom::set_current_seed); @@ -247,17 +293,21 @@ void DungeonRoom::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sizez", "value"), &DungeonRoom::set_sizez); ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); + #ifdef VOXELMAN_PRESENT 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"); + #endif ClassDB::bind_method(D_METHOD("get_data"), &DungeonRoom::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &DungeonRoom::set_data); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PlanetData"), "set_data", "get_data"); + #ifdef VOXELMAN_PRESENT 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"); + #endif //Props ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoom::get_prop_data); @@ -266,10 +316,12 @@ void DungeonRoom::_bind_methods() { 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); + #ifdef ESS_PRESENT //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); + #endif } diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 6cabad2..5123e25 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -4,15 +4,21 @@ #include "core/reference.h" #include "core/vector.h" +#include "../data/world_generator_prop_data.h" +#include "../data/dungeon_room_data.h" + +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/voxel_structure.h" #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxelman_library.h" +#else +#include "scene/main/node.h" +#endif -#include "../data/world_generator_prop_data.h" +#ifdef ESS_PRESENT #include "../../entity_spell_system/entities/data/entity_data.h" - -#include "../data/dungeon_room_data.h" +#endif class DungeonRoomData; @@ -46,16 +52,20 @@ public: int get_sizez(); void set_sizez(int value); + #ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); + #endif Ref get_data(); void set_data(Ref value); + #ifdef VOXELMAN_PRESENT //Structure Ref get_structure(); void set_structure(Ref structure); + #endif //Props Ref get_prop_data(const int index) const; @@ -64,20 +74,28 @@ public: void remove_prop_data(const int index); int get_prop_data_count() const; + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); void add_entity_data(const Ref entity_data); void remove_entity_data(const int index); int get_entity_data_count() const; + #endif void setup(); + + #ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_room(Ref structure, bool spawn_mobs); + #else + void setup_library(Ref library); + void generate_chunk(Node *chunk, bool spawn_mobs); + #endif DungeonRoom(); ~DungeonRoom(); @@ -98,11 +116,17 @@ private: int _sizey; int _sizez; + #ifdef VOXELMAN_PRESENT Ref _environment; - Ref _data; Ref _structure; + #endif + + Ref _data; Vector > _prop_datas; + + #ifdef ESS_PRESENT Vector > _entity_datas; + #endif }; #endif diff --git a/main/planet.cpp b/main/planet.cpp index 085ba6f..ea49db5 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -14,12 +14,14 @@ void Planet::set_level_range(Vector2 value) { _level_range = value; } +#ifdef VOXELMAN_PRESENT Ref Planet::get_environment() { return _environment; } void Planet::set_environment(Ref value) { _environment = value; } +#endif Ref Planet::get_data() { return _data; @@ -85,6 +87,7 @@ void Planet::setup() { } } +#ifdef VOXELMAN_PRESENT void Planet::setup_library(Ref library) { if (!_data.is_valid()) return; @@ -123,6 +126,24 @@ void Planet::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) { void Planet::generate_chunk_bind(Node *chunk, bool spawn_mobs) { generate_chunk(Object::cast_to(chunk), spawn_mobs); } +#else +void Planet::setup_library(Ref library) { + if (!_data.is_valid()) + return; + + if (has_method("_setup_library")) { + call("_setup_library", library); + } +} + +void Planet::generate_chunk(Node *chunk, bool spawn_mobs) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk, spawn_mobs); + } +} +#endif Ref Planet::generate_map() { ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); @@ -134,7 +155,10 @@ Planet::Planet() { _current_seed = 0; } Planet::~Planet() { + #ifdef VOXELMAN_PRESENT _environment.unref(); + #endif + _data.unref(); _biomes.clear(); _dungeons.clear(); @@ -142,14 +166,26 @@ Planet::~Planet() { void Planet::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); + + #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #else + BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + #endif - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk_bind); ClassDB::bind_method(D_METHOD("setup"), &Planet::setup); - ClassDB::bind_method(D_METHOD("setup_library", "library"), &Planet::setup_library); - ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Planet::_setup_library); + #ifdef VOXELMAN_PRESENT + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk_bind); + ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Planet::_setup_library); + #else + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk); + #endif + + ClassDB::bind_method(D_METHOD("setup_library", "library"), &Planet::setup_library); + ClassDB::bind_method(D_METHOD("get_current_seed"), &Planet::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Planet::set_current_seed); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); @@ -158,9 +194,11 @@ void Planet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Planet::set_level_range); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &Planet::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Planet::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); + #endif ClassDB::bind_method(D_METHOD("get_data"), &Planet::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Planet::set_data); diff --git a/main/planet.h b/main/planet.h index 23fd44d..c55f0e1 100644 --- a/main/planet.h +++ b/main/planet.h @@ -10,10 +10,12 @@ #include "../data/planet_data.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" #include "../../voxelman/library/voxelman_library.h" +#endif class PlanetData; @@ -27,10 +29,12 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); + #ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); - + #endif + Ref get_data(); void set_data(Ref value); @@ -49,11 +53,18 @@ public: int get_dungeon_count() const; void setup(); + + #ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); + #else + void generate_chunk(Node *chunk, bool spawn_mobs); + void setup_library(Ref library); + #endif + Ref generate_map(); Planet(); @@ -65,7 +76,11 @@ protected: private: int _current_seed; Vector2 _level_range; + + #ifdef VOXELMAN_PRESENT Ref _environment; + #endif + Ref _data; Vector > _biomes; Vector > _dungeons;