Now this module can be compiled without voxelman. Will detect if present automatically. (see the SCub file) Also added guards for ESS, but compiling without ESS was not tested.

This commit is contained in:
Relintai 2019-12-19 18:49:32 +01:00
parent 290d973ea9
commit 58e38c07bd
20 changed files with 483 additions and 81 deletions

12
SCsub
View File

@ -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")

View File

@ -117,8 +117,8 @@ void BiomeData::set_prop_datas(const Vector<Variant> &prop_datas) {
}
}
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> BiomeData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
@ -158,6 +158,9 @@ void BiomeData::set_entity_datas(const Vector<Variant> &entity_datas) {
}
}
#endif
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> BiomeData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
@ -275,17 +278,24 @@ void BiomeData::set_liquid_voxel_surfaces(const Vector<Variant> &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
}

View File

@ -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<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
@ -65,7 +70,9 @@ public:
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
#endif
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
@ -95,6 +102,7 @@ public:
Vector<Variant> get_liquid_voxel_surfaces();
void set_liquid_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#endif
BiomeData();
~BiomeData();
@ -113,10 +121,16 @@ private:
Vector<Ref<DungeonData> > _dungeon_datas;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -239,6 +239,7 @@ void DungeonData::set_dungeon_corridor_datas(const Vector<Variant> &dungeon_corr
}
}
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> DungeonData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
@ -277,7 +278,9 @@ void DungeonData::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.push_back(entity_data);
}
}
#endif
#ifdef VOXELMAN_PRESENT
//// Surfaces ////
Ref<VoxelSurface> DungeonData::get_voxel_surface(const int index) const {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>());
@ -394,6 +397,7 @@ void DungeonData::set_environment_datas(const Vector<Variant> &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
}

View File

@ -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<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
@ -65,6 +69,7 @@ public:
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
#endif
//Rooms
Ref<DungeonRoomData> get_dungeon_room_data(const int index) const;
@ -106,6 +111,7 @@ public:
Vector<Variant> get_dungeon_corridor_datas();
void set_dungeon_corridor_datas(const Vector<Variant> &dungeon_corridor_datas);
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
@ -115,7 +121,9 @@ public:
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
#endif
#ifdef VOXELMAN_PRESENT
//Surfaces
Ref<VoxelSurface> get_voxel_surface(const int index) const;
void set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface);
@ -135,6 +143,7 @@ public:
Vector<Variant> get_liquid_voxel_surfaces();
void set_liquid_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#endif
DungeonData();
~DungeonData();
@ -159,15 +168,23 @@ private:
int _min_room_count;
int _max_room_count;
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
#endif
Vector<Ref<DungeonRoomData> > _dungeon_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_start_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_end_room_datas;
Vector<Ref<DungeonRoomData> > _dungeon_corridor_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
#ifdef VOXELMAN_PRESENT
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -104,6 +104,7 @@ void DungeonRoomData::set_prop_datas(const Vector<Variant> &prop_datas) {
}
}
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> DungeonRoomData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
@ -143,45 +144,6 @@ 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);
}
}
//// Surfaces ////
Ref<VoxelSurface> DungeonRoomData::get_voxel_surface(const int index) const {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>());
@ -260,6 +222,51 @@ void DungeonRoomData::set_liquid_voxel_surfaces(const Vector<Variant> &voxel_sur
}
}
#endif
#ifdef ESS_PRESENT
//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);
}
}
#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
}

View File

@ -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<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
#ifdef VOXELMAN_PRESENT
//TOO: Environments are useful for every game, this should be decoupled from voxelman.
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
@ -67,16 +73,6 @@ public:
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_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);
//Surfaces
Ref<VoxelSurface> get_voxel_surface(const int index) const;
void set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface);
@ -96,6 +92,21 @@ public:
Vector<Variant> get_liquid_voxel_surfaces();
void set_liquid_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#else
//TODO Create generic binds
#endif
#ifdef ESS_PRESENT
//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);
#endif
DungeonRoomData();
~DungeonRoomData();
@ -118,10 +129,16 @@ private:
int _max_sizez;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -81,6 +81,7 @@ void PlanetData::set_biome_datas(const Vector<Variant> &biome_datas) {
}
}
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> PlanetData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
@ -198,6 +199,7 @@ void PlanetData::set_liquid_voxel_surfaces(const Vector<Variant> &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
}

View File

@ -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<Variant> get_biome_datas();
void set_biome_datas(const Vector<Variant> &biome_datas);
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
@ -74,6 +77,7 @@ public:
Vector<Variant> get_liquid_voxel_surfaces();
void set_liquid_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#endif
PlanetData();
~PlanetData();
@ -92,9 +96,12 @@ private:
Ref<FastnoiseNoiseParams> _humidity_noise_params;
Ref<FastnoiseNoiseParams> _temperature_noise_params;
Vector<Ref<BiomeData> > _biome_datas;
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -8,6 +8,7 @@ bool WorldGeneratorPropData::can_spawn(int seed) {
return false;
}
#ifdef VOXELMAN_PRESENT
Ref<PropData> WorldGeneratorPropData::get_prop(int seed) {
if (has_method("_get_prop")) {
return call("_get_prop", seed);
@ -15,6 +16,15 @@ Ref<PropData> WorldGeneratorPropData::get_prop(int seed) {
return Ref<PropData>(NULL);
}
#else
Ref<Resource> WorldGeneratorPropData::get_prop(int seed) {
if (has_method("_get_prop")) {
return call("_get_prop", seed);
}
return Ref<Resource>(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);

View File

@ -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<PropData> get_prop(int seed);
#else
Ref<Resource> get_prop(int seed);
#endif
WorldGeneratorPropData();
~WorldGeneratorPropData();

View File

@ -14,12 +14,14 @@ void Biome::set_level_range(Vector2 value) {
_level_range = value;
}
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> Biome::get_environment() {
return _environment;
}
void Biome::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
#endif
Ref<BiomeData> 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<EntityData> Biome::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
@ -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<Dungeon> 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<VoxelChunk>(chunk), x, z, spawn_mobs);
}
void Biome::setup() {
if (!_data.is_valid())
return;
if (has_method("_setup")) {
call("_setup");
}
}
void Biome::setup_library(Ref<VoxelmanLibrary> library) {
if (!_data.is_valid())
return;
@ -156,30 +161,66 @@ void Biome::_setup_library(Ref<VoxelmanLibrary> library) {
}
}
}
#else
void Biome::setup_library(Ref<Resource> 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);

View File

@ -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<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
#endif
Ref<BiomeData> get_data();
void set_data(Ref<BiomeData> value);
@ -41,12 +47,14 @@ public:
int get_prop_data_count() const;
#ifdef ESS_PRESENT
//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;
#endif
//Dungeons
Ref<Dungeon> 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<VoxelmanLibrary> library);
void _setup_library(Ref<VoxelmanLibrary> library);
#else
void generate_chunk(Node *chunk, bool spawn_mobs);
void setup_library(Ref<Resource> library);
#endif
Biome();
~Biome();
@ -75,10 +90,17 @@ private:
Vector2 _level_range;
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> _environment;
#endif
Ref<BiomeData> _data;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
Vector<Ref<Dungeon> > _dungeons;
};

View File

@ -65,12 +65,14 @@ void Dungeon::set_room_count(int value) {
_room_count = value;
}
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> Dungeon::get_environment() {
return _environment;
}
void Dungeon::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
#endif
Ref<DungeonData> 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<EntityData> Dungeon::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<DungeonCorridor>());
@ -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<VoxelmanLibrary> library) {
if (!_data.is_valid())
return;
@ -251,6 +256,24 @@ void Dungeon::generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs)
call("_generate_structure", structure, spawn_mobs);
}
}
#else
void Dungeon::setup_library(Ref<Resource> 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<Image> Dungeon::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
@ -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"));

View File

@ -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<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
#endif
Ref<DungeonData> get_data();
void set_data(Ref<DungeonData> value);
@ -86,20 +94,28 @@ public:
void remove_dungeon_corridor(const int index);
int get_dungeon_corridor_count() const;
#ifdef ESS_PRESENT
//Entities
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;
#endif
void setup();
#ifdef VOXELMAN_PRESENT
void setup_library(Ref<VoxelmanLibrary> library);
void _setup_library(Ref<VoxelmanLibrary> library);
void generate_chunk(VoxelChunk *chunk, bool spawn_mobs);
void generate_chunk_bind(Node *chunk, bool spawn_mobs);
void generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs);
#else
void setup_library(Ref<Resource> library);
void generate_chunk(Node *chunk, bool spawn_mobs);
#endif
Ref<Image> generate_map();
@ -124,13 +140,19 @@ private:
int _room_count;
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> _environment;
#endif
Ref<DungeonData> _data;
Vector<Ref<DungeonRoom> > _dungeon_rooms;
Vector<Ref<DungeonRoom> > _dungeon_start_rooms;
Vector<Ref<DungeonRoom> > _dungeon_end_rooms;
Vector<Ref<DungeonCorridor> > _dungeon_corridors;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
};
#endif

View File

@ -3,7 +3,6 @@
#include "dungeon_room.h"
class DungeonCorridor : public DungeonRoom {
GDCLASS(DungeonCorridor, DungeonRoom);

View File

@ -58,12 +58,14 @@ void DungeonRoom::set_sizez(int value) {
_sizez = value;
}
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> DungeonRoom::get_environment() {
return _environment;
}
void DungeonRoom::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
#endif
Ref<DungeonRoomData> DungeonRoom::get_data() {
return _data;
@ -74,12 +76,14 @@ void DungeonRoom::set_data(Ref<DungeonRoomData> value) {
setup();
}
#ifdef VOXELMAN_PRESENT
Ref<VoxelStructure> DungeonRoom::get_structure() {
return _structure;
}
void DungeonRoom::set_structure(Ref<VoxelStructure> structure) {
_structure = structure;
}
#endif
//Props
Ref<WorldGeneratorPropData> 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<EntityData> DungeonRoom::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
@ -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<VoxelmanLibrary> library) {
if (!_data.is_valid())
return;
@ -180,6 +187,26 @@ void DungeonRoom::generate_room(Ref<VoxelStructure> structure, bool spawn_mobs)
call("_generate_room", structure, spawn_mobs);
}
}
#else
void DungeonRoom::setup_library(Ref<Resource> 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
}

View File

@ -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<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
#endif
Ref<DungeonRoomData> get_data();
void set_data(Ref<DungeonRoomData> value);
#ifdef VOXELMAN_PRESENT
//Structure
Ref<VoxelStructure> get_structure();
void set_structure(Ref<VoxelStructure> structure);
#endif
//Props
Ref<WorldGeneratorPropData> 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<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;
#endif
void setup();
#ifdef VOXELMAN_PRESENT
void setup_library(Ref<VoxelmanLibrary> library);
void _setup_library(Ref<VoxelmanLibrary> library);
void generate_chunk(VoxelChunk *chunk, bool spawn_mobs);
void generate_chunk_bind(Node *chunk, bool spawn_mobs);
void generate_room(Ref<VoxelStructure> structure, bool spawn_mobs);
#else
void setup_library(Ref<Resource> 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<EnvironmentData> _environment;
Ref<DungeonRoomData> _data;
Ref<VoxelStructure> _structure;
#endif
Ref<DungeonRoomData> _data;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
};
#endif

View File

@ -14,12 +14,14 @@ void Planet::set_level_range(Vector2 value) {
_level_range = value;
}
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> Planet::get_environment() {
return _environment;
}
void Planet::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
#endif
Ref<PlanetData> Planet::get_data() {
return _data;
@ -85,6 +87,7 @@ void Planet::setup() {
}
}
#ifdef VOXELMAN_PRESENT
void Planet::setup_library(Ref<VoxelmanLibrary> 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<VoxelChunk>(chunk), spawn_mobs);
}
#else
void Planet::setup_library(Ref<Resource> 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<Image> Planet::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
@ -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);

View File

@ -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<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
#endif
Ref<PlanetData> get_data();
void set_data(Ref<PlanetData> value);
@ -49,11 +53,18 @@ public:
int get_dungeon_count() const;
void setup();
#ifdef VOXELMAN_PRESENT
void setup_library(Ref<VoxelmanLibrary> library);
void _setup_library(Ref<VoxelmanLibrary> 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<Resource> library);
#endif
Ref<Image> generate_map();
Planet();
@ -65,7 +76,11 @@ protected:
private:
int _current_seed;
Vector2 _level_range;
#ifdef VOXELMAN_PRESENT
Ref<EnvironmentData> _environment;
#endif
Ref<PlanetData> _data;
Vector<Ref<Biome> > _biomes;
Vector<Ref<Dungeon> > _dungeons;