Merged in the WorldGenerator module.

This commit is contained in:
Relintai 2019-11-09 14:07:04 +01:00
parent 802e602336
commit 019ad0c8ec
40 changed files with 4114 additions and 0 deletions

19
SCsub
View File

@ -35,3 +35,22 @@ env.add_source_files(env.modules_sources,"props/prop_data_prop.cpp")
env.add_source_files(env.modules_sources,"props/prop_data_entity.cpp")
env.add_source_files(env.modules_sources,"level_generator/voxelman_level_generator.cpp")
env.add_source_files(env.modules_sources,"register_types.cpp")
env.add_source_files(env.modules_sources,"world_generator/main/dungeon_room.cpp")
env.add_source_files(env.modules_sources,"world_generator/main/dungeon_corridor.cpp")
env.add_source_files(env.modules_sources,"world_generator/main/dungeon.cpp")
env.add_source_files(env.modules_sources,"world_generator/main/biome.cpp")
env.add_source_files(env.modules_sources,"world_generator/main/planet.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/dungeon_room_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/dungeon_corridor_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/dungeon_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/biome_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/planet_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/data/world_generator_prop_data.cpp")
env.add_source_files(env.modules_sources,"world_generator/world_generator.cpp")

View File

@ -29,6 +29,22 @@
#include "level_generator/voxelman_level_generator.h"
#include "world_generator/data/dungeon_room_data.h"
#include "world_generator/data/dungeon_corridor_data.h"
#include "world_generator/data/dungeon_data.h"
#include "world_generator/data/biome_data.h"
#include "world_generator/data/planet_data.h"
#include "world_generator/data/world_generator_prop_data.h"
#include "world_generator/main/biome.h"
#include "world_generator/main/dungeon.h"
#include "world_generator/main/dungeon_corridor.h"
#include "world_generator/main/dungeon_room.h"
#include "world_generator/main/planet.h"
#include "world_generator/world_generator.h"
void register_voxelman_types() {
ClassDB::register_class<VoxelMesher>();
ClassDB::register_class<VoxelMesherTransvoxel>();
@ -59,6 +75,21 @@ void register_voxelman_types() {
ClassDB::register_class<PropDataEntity>();
ClassDB::register_class<VoxelmanLevelGenerator>();
ClassDB::register_class<DungeonRoomData>();
ClassDB::register_class<DungeonCorridorData>();
ClassDB::register_class<DungeonData>();
ClassDB::register_class<BiomeData>();
ClassDB::register_class<PlanetData>();
ClassDB::register_class<WorldGeneratorPropData>();
ClassDB::register_class<DungeonRoom>();
ClassDB::register_class<DungeonCorridor>();
ClassDB::register_class<Dungeon>();
ClassDB::register_class<Biome>();
ClassDB::register_class<Planet>();
ClassDB::register_class<WorldGenerator>();
}
void unregister_voxelman_types() {

View File

@ -0,0 +1,267 @@
#include "biome_data.h"
Vector2 BiomeData::get_level_range() {
return _level_range;
}
void BiomeData::set_level_range(Vector2 value) {
_level_range = value;
}
Vector2 BiomeData::get_humidity_range() {
return _humidity_range;
}
void BiomeData::set_humidity_range(Vector2 range) {
_humidity_range = range;
}
Vector2 BiomeData::get_temperature_range() {
return _temperature_range;
}
void BiomeData::set_temperature_range(Vector2 range) {
_temperature_range = range;
}
//// DungeonData ////
Ref<DungeonData> BiomeData::get_dungeon_data(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_datas.size(), Ref<DungeonData>());
return _dungeon_datas.get(index);
}
void BiomeData::set_dungeon_data(const int index, const Ref<DungeonData> dungeon_data) {
ERR_FAIL_INDEX(index, _dungeon_datas.size());
_dungeon_datas.set(index, dungeon_data);
}
void BiomeData::add_dungeon_data(const Ref<DungeonData> dungeon_data) {
_dungeon_datas.push_back(dungeon_data);
}
void BiomeData::remove_dungeon_data(const int index) {
ERR_FAIL_INDEX(index, _dungeon_datas.size());
_dungeon_datas.remove(index);
}
int BiomeData::get_dungeon_data_count() const {
return _dungeon_datas.size();
}
Vector<Variant> BiomeData::get_dungeon_datas() {
Vector<Variant> r;
for (int i = 0; i < _dungeon_datas.size(); i++) {
r.push_back(_dungeon_datas[i].get_ref_ptr());
}
return r;
}
void BiomeData::set_dungeon_datas(const Vector<Variant> &dungeon_datas) {
_dungeon_datas.clear();
for (int i = 0; i < dungeon_datas.size(); i++) {
Ref<DungeonData> dungeon_data = Ref<DungeonData>(dungeon_datas[i]);
_dungeon_datas.push_back(dungeon_data);
}
}
//// PROP DATA ////
Ref<WorldGeneratorPropData> BiomeData::get_prop_data(const int index) const {
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<WorldGeneratorPropData>());
return _prop_datas.get(index);
}
void BiomeData::set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.set(index, prop_data);
}
void BiomeData::add_prop_data(const Ref<WorldGeneratorPropData> prop_data) {
_prop_datas.push_back(prop_data);
}
void BiomeData::remove_prop_data(const int index) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.remove(index);
}
int BiomeData::get_prop_data_count() const {
return _prop_datas.size();
}
Vector<Variant> BiomeData::get_prop_datas() {
Vector<Variant> r;
for (int i = 0; i < _prop_datas.size(); i++) {
r.push_back(_prop_datas[i].get_ref_ptr());
}
return r;
}
void BiomeData::set_prop_datas(const Vector<Variant> &prop_datas) {
_prop_datas.clear();
for (int i = 0; i < prop_datas.size(); i++) {
Ref<WorldGeneratorPropData> prop_data = Ref<WorldGeneratorPropData>(prop_datas[i]);
_prop_datas.push_back(prop_data);
}
}
//Entities
Ref<EntityData> BiomeData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void BiomeData::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void BiomeData::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void BiomeData::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int BiomeData::get_entity_data_count() const {
return _entity_datas.size();
}
Vector<Variant> BiomeData::get_entity_datas() {
Vector<Variant> r;
for (int i = 0; i < _entity_datas.size(); i++) {
r.push_back(_entity_datas[i].get_ref_ptr());
}
return r;
}
void BiomeData::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.clear();
for (int i = 0; i < entity_datas.size(); i++) {
Ref<EntityData> entity_data = Ref<EntityData>(entity_datas[i]);
_entity_datas.push_back(entity_data);
}
}
//Environments
Ref<EnvironmentData> BiomeData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
return _environment_datas.get(index);
}
void BiomeData::set_environment_data(const int index, const Ref<EnvironmentData> environment_data) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.set(index, environment_data);
}
void BiomeData::add_environment_data(const Ref<EnvironmentData> environment_data) {
_environment_datas.push_back(environment_data);
}
void BiomeData::remove_environment_data(const int index) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.remove(index);
}
int BiomeData::get_environment_data_count() const {
return _environment_datas.size();
}
Vector<Variant> BiomeData::get_environment_datas() {
Vector<Variant> r;
for (int i = 0; i < _environment_datas.size(); i++) {
r.push_back(_environment_datas[i].get_ref_ptr());
}
return r;
}
void BiomeData::set_environment_datas(const Vector<Variant> &environment_datas) {
_environment_datas.clear();
for (int i = 0; i < environment_datas.size(); i++) {
Ref<EnvironmentData> environment_data = Ref<EnvironmentData>(environment_datas[i]);
_environment_datas.push_back(environment_data);
}
}
Ref<Biome> BiomeData::setup_biome(int seed) {
if (has_method("_setup_biome")) {
return call("_setup_biome", seed);
}
return Ref<Biome>(NULL);
}
BiomeData::BiomeData() {
}
BiomeData::~BiomeData() {
_dungeon_datas.clear();
_prop_datas.clear();
_entity_datas.clear();
}
void BiomeData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "Biome"), "_setup_biome", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_biome", "seed"), &BiomeData::setup_biome);
ClassDB::bind_method(D_METHOD("get_level_range"), &BiomeData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &BiomeData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
ClassDB::bind_method(D_METHOD("get_humidity_range"), &BiomeData::get_humidity_range);
ClassDB::bind_method(D_METHOD("set_humidity_range", "value"), &BiomeData::set_humidity_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "humidity_range"), "set_humidity_range", "get_humidity_range");
ClassDB::bind_method(D_METHOD("get_temperature_range"), &BiomeData::get_temperature_range);
ClassDB::bind_method(D_METHOD("set_temperature_range", "value"), &BiomeData::set_temperature_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "temperature_range"), "set_temperature_range", "get_temperature_range");
//DungeonDatas
ClassDB::bind_method(D_METHOD("get_dungeon_data", "index"), &BiomeData::get_dungeon_data);
ClassDB::bind_method(D_METHOD("set_dungeon_data", "index", "data"), &BiomeData::set_dungeon_data);
ClassDB::bind_method(D_METHOD("add_dungeon_data", "dungeon_data"), &BiomeData::add_dungeon_data);
ClassDB::bind_method(D_METHOD("remove_dungeon_data", "index"), &BiomeData::remove_dungeon_data);
ClassDB::bind_method(D_METHOD("get_dungeon_data_count"), &BiomeData::get_dungeon_data_count);
ClassDB::bind_method(D_METHOD("get_dungeon_datas"), &BiomeData::get_dungeon_datas);
ClassDB::bind_method(D_METHOD("set_dungeon_datas", "dungeon_datas"), &BiomeData::set_dungeon_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_datas", PROPERTY_HINT_NONE, "17/17:DungeonData", PROPERTY_USAGE_DEFAULT, "DungeonData"), "set_dungeon_datas", "get_dungeon_datas");
//WorldGeneratorPropData
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &BiomeData::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &BiomeData::set_prop_data);
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &BiomeData::add_prop_data);
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &BiomeData::remove_prop_data);
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &BiomeData::get_prop_data_count);
ClassDB::bind_method(D_METHOD("get_prop_datas"), &BiomeData::get_prop_datas);
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &BiomeData::set_prop_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas");
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &BiomeData::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &BiomeData::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &BiomeData::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &BiomeData::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &BiomeData::get_entity_data_count);
ClassDB::bind_method(D_METHOD("get_entity_datas"), &BiomeData::get_entity_datas);
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &BiomeData::set_entity_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
//Environments
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &BiomeData::get_environment_data);
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &BiomeData::set_environment_data);
ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &BiomeData::add_environment_data);
ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &BiomeData::remove_environment_data);
ClassDB::bind_method(D_METHOD("get_environment_data_count"), &BiomeData::get_environment_data_count);
ClassDB::bind_method(D_METHOD("get_environment_datas"), &BiomeData::get_environment_datas);
ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &BiomeData::set_environment_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas");
}

View File

@ -0,0 +1,91 @@
#ifndef dungeon_data_H
#define dungeon_data_H
#include "core/resource.h"
#include "core/vector.h"
#include "core/math/vector2.h"
#include "../main/biome.h"
#include "dungeon_data.h"
#include "world_generator_prop_data.h"
#include "../../world/environment_data.h"
#include "../../../entity_spell_system/entities/data/entity_data.h"
class BiomeData : public Resource {
GDCLASS(BiomeData, Resource);
public:
Vector2 get_level_range();
void set_level_range(Vector2 value);
Vector2 get_humidity_range();
void set_humidity_range(Vector2 range);
Vector2 get_temperature_range();
void set_temperature_range(Vector2 range);
//DungeonData
Ref<DungeonData> get_dungeon_data(const int index) const;
void set_dungeon_data(const int index, const Ref<DungeonData> dungeon_data);
void add_dungeon_data(const Ref<DungeonData> dungeon_data);
void remove_dungeon_data(const int index);
int get_dungeon_data_count() const;
Vector<Variant> get_dungeon_datas();
void set_dungeon_datas(const Vector<Variant> &dungeon_datas);
//WorldGeneratorPropData
Ref<WorldGeneratorPropData> get_prop_data(const int index) const;
void set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data);
void add_prop_data(const Ref<WorldGeneratorPropData> prop_data);
void remove_prop_data(const int index);
int get_prop_data_count() const;
Vector<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
void add_environment_data(const Ref<EnvironmentData> environment_data);
void remove_environment_data(const int index);
int get_environment_data_count() const;
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
Ref<Biome> setup_biome(int seed);
BiomeData();
~BiomeData();
protected:
static void _bind_methods();
private:
Vector2 _level_range;
Vector2 _humidity_range;
Vector2 _temperature_range;
Vector<Ref<DungeonData> > _dungeon_datas;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
Vector<Ref<EntityData> > _entity_datas;
Vector<Ref<EnvironmentData> > _environment_datas;
};
#endif

View File

@ -0,0 +1,33 @@
#include "dungeon_corridor_data.h"
int DungeonCorridorData::get_max_connections() {
return _max_connections;
}
void DungeonCorridorData::set_max_connections(int value) {
_max_connections = value;
}
Ref<DungeonCorridor> DungeonCorridorData::setup_corridor(int seed) {
if (has_method("_setup_corridor")) {
return call("_setup_corridor", seed);
}
return Ref<DungeonCorridor>();
}
DungeonCorridorData::DungeonCorridorData() {
_max_connections = 2;
}
DungeonCorridorData::~DungeonCorridorData() {
}
void DungeonCorridorData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "corridor", PROPERTY_HINT_RESOURCE_TYPE, "DungeonCorridor"), "_setup_corridor", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_corridor", "seed"), &DungeonCorridorData::setup_corridor);
ClassDB::bind_method(D_METHOD("get_max_connections"), &DungeonCorridorData::get_max_connections);
ClassDB::bind_method(D_METHOD("set_max_connections", "value"), &DungeonCorridorData::set_max_connections);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_connections"), "set_max_connections", "get_max_connections");
}

View File

@ -0,0 +1,27 @@
#ifndef DUNGEON_CORRIDOR_DATA_H
#define DUNGEON_CORRIDOR_DATA_H
#include "dungeon_room_data.h"
#include "../main/dungeon_corridor.h"
class DungeonCorridorData : public DungeonRoomData {
GDCLASS(DungeonCorridorData, DungeonRoomData);
public:
int get_max_connections();
void set_max_connections(int value);
Ref<DungeonCorridor> setup_corridor(int seed);
DungeonCorridorData();
~DungeonCorridorData();
protected:
static void _bind_methods();
private:
int _max_connections;
};
#endif

View File

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

View File

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

View File

@ -0,0 +1,262 @@
#include "dungeon_room_data.h"
Vector2 DungeonRoomData::get_level_range() {
return _level_range;
}
void DungeonRoomData::set_level_range(Vector2 value) {
_level_range = value;
}
//Min Size
int DungeonRoomData::get_min_sizex() {
return _min_sizex;
}
void DungeonRoomData::set_min_sizex(int value) {
_min_sizex = value;
}
int DungeonRoomData::get_min_sizey() {
return _min_sizey;
}
void DungeonRoomData::set_min_sizey(int value) {
_min_sizey = value;
}
int DungeonRoomData::get_min_sizez() {
return _min_sizez;
}
void DungeonRoomData::set_min_sizez(int value) {
_min_sizez = value;
}
//Max Size
int DungeonRoomData::get_max_sizex() {
return _max_sizex;
}
void DungeonRoomData::set_max_sizex(int value) {
_max_sizex = value;
}
int DungeonRoomData::get_max_sizey() {
return _max_sizey;
}
void DungeonRoomData::set_max_sizey(int value) {
_max_sizey = value;
}
int DungeonRoomData::get_max_sizez() {
return _max_sizez;
}
void DungeonRoomData::set_max_sizez(int value) {
_max_sizez = value;
}
//Props
Ref<WorldGeneratorPropData> DungeonRoomData::get_prop_data(const int index) const {
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<WorldGeneratorPropData>());
return _prop_datas.get(index);
}
void DungeonRoomData::set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.set(index, prop_data);
}
void DungeonRoomData::add_prop_data(const Ref<WorldGeneratorPropData> prop_data) {
_prop_datas.push_back(prop_data);
}
void DungeonRoomData::remove_prop_data(const int index) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.remove(index);
}
int DungeonRoomData::get_prop_data_count() const {
return _prop_datas.size();
}
Vector<Variant> DungeonRoomData::get_prop_datas() {
Vector<Variant> r;
for (int i = 0; i < _prop_datas.size(); i++) {
r.push_back(_prop_datas[i].get_ref_ptr());
}
return r;
}
void DungeonRoomData::set_prop_datas(const Vector<Variant> &prop_datas) {
_prop_datas.clear();
for (int i = 0; i < prop_datas.size(); i++) {
Ref<WorldGeneratorPropData> prop_data = Ref<WorldGeneratorPropData>(prop_datas[i]);
_prop_datas.push_back(prop_data);
}
}
//Environments
Ref<EnvironmentData> DungeonRoomData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
return _environment_datas.get(index);
}
void DungeonRoomData::set_environment_data(const int index, const Ref<EnvironmentData> environment_data) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.set(index, environment_data);
}
void DungeonRoomData::add_environment_data(const Ref<EnvironmentData> environment_data) {
_environment_datas.push_back(environment_data);
}
void DungeonRoomData::remove_environment_data(const int index) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.remove(index);
}
int DungeonRoomData::get_environment_data_count() const {
return _environment_datas.size();
}
Vector<Variant> DungeonRoomData::get_environment_datas() {
Vector<Variant> r;
for (int i = 0; i < _environment_datas.size(); i++) {
r.push_back(_environment_datas[i].get_ref_ptr());
}
return r;
}
void DungeonRoomData::set_environment_datas(const Vector<Variant> &environment_datas) {
_environment_datas.clear();
for (int i = 0; i < environment_datas.size(); i++) {
Ref<EnvironmentData> environment_data = Ref<EnvironmentData>(environment_datas[i]);
_environment_datas.push_back(environment_data);
}
}
//Entities
Ref<EntityData> DungeonRoomData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void DungeonRoomData::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void DungeonRoomData::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void DungeonRoomData::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int DungeonRoomData::get_entity_data_count() const {
return _entity_datas.size();
}
Vector<Variant> DungeonRoomData::get_entity_datas() {
Vector<Variant> r;
for (int i = 0; i < _entity_datas.size(); i++) {
r.push_back(_entity_datas[i].get_ref_ptr());
}
return r;
}
void DungeonRoomData::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.clear();
for (int i = 0; i < entity_datas.size(); i++) {
Ref<EntityData> entity_data = Ref<EntityData>(entity_datas[i]);
_entity_datas.push_back(entity_data);
}
}
Ref<DungeonRoom> DungeonRoomData::setup_room(int seed) {
if (has_method("_setup_room")) {
return call("_setup_room", seed);
}
return Ref<DungeonRoom>();
}
DungeonRoomData::DungeonRoomData() {
_min_sizex = 0;
_min_sizey = 0;
_min_sizez = 0;
_max_sizex = 0;
_max_sizey = 0;
_max_sizez = 0;
}
DungeonRoomData::~DungeonRoomData() {
}
void DungeonRoomData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"), "_setup_room", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_room", "seed"), &DungeonRoomData::setup_room);
ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonRoomData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoomData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
//Min Size
ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonRoomData::get_min_sizex);
ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonRoomData::set_min_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex");
ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonRoomData::get_min_sizey);
ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonRoomData::set_min_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey");
ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonRoomData::get_min_sizez);
ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonRoomData::set_min_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez");
//Max Size
ClassDB::bind_method(D_METHOD("get_max_sizex"), &DungeonRoomData::get_max_sizex);
ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonRoomData::set_max_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex");
ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonRoomData::get_max_sizey);
ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonRoomData::set_max_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey");
ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonRoomData::get_max_sizez);
ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonRoomData::set_max_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez");
//Props
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoomData::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoomData::set_prop_data);
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoomData::add_prop_data);
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoomData::remove_prop_data);
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoomData::get_prop_data_count);
ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoomData::get_prop_datas);
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoomData::set_prop_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas");
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoomData::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoomData::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoomData::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoomData::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoomData::get_entity_data_count);
ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoomData::get_entity_datas);
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoomData::set_entity_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
//Environments
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonRoomData::get_environment_data);
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonRoomData::set_environment_data);
ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &DungeonRoomData::add_environment_data);
ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &DungeonRoomData::remove_environment_data);
ClassDB::bind_method(D_METHOD("get_environment_data_count"), &DungeonRoomData::get_environment_data_count);
ClassDB::bind_method(D_METHOD("get_environment_datas"), &DungeonRoomData::get_environment_datas);
ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &DungeonRoomData::set_environment_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas");
}

View File

@ -0,0 +1,96 @@
#ifndef DUNGEON_ROOM_DATA_H
#define DUNGEON_ROOM_DATA_H
#include "core/resource.h"
#include "../main/dungeon_room.h"
#include "world_generator_prop_data.h"
#include "../../world/environment_data.h"
#include "../../../entity_spell_system/entities/data/entity_data.h"
class DungeonRoomData : public Resource {
GDCLASS(DungeonRoomData, Resource);
public:
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Min Size
int get_min_sizex();
void set_min_sizex(int value);
int get_min_sizey();
void set_min_sizey(int value);
int get_min_sizez();
void set_min_sizez(int value);
//Max Size
int get_max_sizex();
void set_max_sizex(int value);
int get_max_sizey();
void set_max_sizey(int value);
int get_max_sizez();
void set_max_sizez(int value);
//Prop Data
Ref<WorldGeneratorPropData> get_prop_data(const int index) const;
void set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data);
void add_prop_data(const Ref<WorldGeneratorPropData> prop_data);
void remove_prop_data(const int index);
int get_prop_data_count() const;
Vector<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
void add_environment_data(const Ref<EnvironmentData> environment_data);
void remove_environment_data(const int index);
int get_environment_data_count() const;
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
Ref<DungeonRoom> setup_room(int seed);
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
DungeonRoomData();
~DungeonRoomData();
protected:
static void _bind_methods();
private:
Vector2 _level_range;
int _min_sizex;
int _min_sizey;
int _min_sizez;
int _max_sizex;
int _max_sizey;
int _max_sizez;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
Vector<Ref<EntityData> > _entity_datas;
Vector<Ref<EnvironmentData> > _environment_datas;
};
#endif

View File

@ -0,0 +1,169 @@
#include "planet_data.h"
int PlanetData::get_id() const {
return _id;
}
void PlanetData::set_id(const int value) {
_id = value;
}
Vector2 PlanetData::get_level_range() {
return _level_range;
}
void PlanetData::set_level_range(Vector2 value) {
_level_range = value;
}
Ref<FastnoiseNoiseParams> PlanetData::get_humidity_noise_params() {
return _humidity_noise_params;
}
void PlanetData::set_humidity_noise_params(Ref<FastnoiseNoiseParams> value) {
_humidity_noise_params = value;
}
Ref<FastnoiseNoiseParams> PlanetData::get_temperature_noise_params() {
return _temperature_noise_params;
}
void PlanetData::set_temperature_noise_params(Ref<FastnoiseNoiseParams> value) {
_temperature_noise_params = value;
}
//Biomes
Ref<BiomeData> PlanetData::get_biome_data(const int index) const {
ERR_FAIL_INDEX_V(index, _biome_datas.size(), Ref<BiomeData>());
return _biome_datas.get(index);
}
void PlanetData::set_biome_data(const int index, const Ref<BiomeData> biome_data) {
ERR_FAIL_INDEX(index, _biome_datas.size());
_biome_datas.set(index, biome_data);
}
void PlanetData::add_biome_data(const Ref<BiomeData> biome_data) {
_biome_datas.push_back(biome_data);
}
void PlanetData::remove_biome_data(const int index) {
ERR_FAIL_INDEX(index, _biome_datas.size());
_biome_datas.remove(index);
}
int PlanetData::get_biome_data_count() const {
return _biome_datas.size();
}
Vector<Variant> PlanetData::get_biome_datas() {
Vector<Variant> r;
for (int i = 0; i < _biome_datas.size(); i++) {
r.push_back(_biome_datas[i].get_ref_ptr());
}
return r;
}
void PlanetData::set_biome_datas(const Vector<Variant> &biome_datas) {
_biome_datas.clear();
for (int i = 0; i < biome_datas.size(); i++) {
Ref<BiomeData> biome_data = Ref<BiomeData>(biome_datas[i]);
_biome_datas.push_back(biome_data);
}
}
//Environments
Ref<EnvironmentData> PlanetData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
return _environment_datas.get(index);
}
void PlanetData::set_environment_data(const int index, const Ref<EnvironmentData> environment_data) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.set(index, environment_data);
}
void PlanetData::add_environment_data(const Ref<EnvironmentData> environment_data) {
_environment_datas.push_back(environment_data);
}
void PlanetData::remove_environment_data(const int index) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.remove(index);
}
int PlanetData::get_environment_data_count() const {
return _environment_datas.size();
}
Vector<Variant> PlanetData::get_environment_datas() {
Vector<Variant> r;
for (int i = 0; i < _environment_datas.size(); i++) {
r.push_back(_environment_datas[i].get_ref_ptr());
}
return r;
}
void PlanetData::set_environment_datas(const Vector<Variant> &environment_datas) {
_environment_datas.clear();
for (int i = 0; i < environment_datas.size(); i++) {
Ref<EnvironmentData> environment_data = Ref<EnvironmentData>(environment_datas[i]);
_environment_datas.push_back(environment_data);
}
}
Ref<Planet> PlanetData::setup_planet(int seed) {
if (has_method("_setup_planet")) {
return call("_setup_planet", seed);
}
return Ref<Planet>(NULL);
}
PlanetData::PlanetData() {
_id = 0;
}
PlanetData::~PlanetData() {
_biome_datas.clear();
}
void PlanetData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "biome", PROPERTY_HINT_RESOURCE_TYPE, "Planet"), "_setup_planet", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_planet", "seed"), &PlanetData::setup_planet);
ClassDB::bind_method(D_METHOD("get_id"), &PlanetData::get_id);
ClassDB::bind_method(D_METHOD("set_id", "value"), &PlanetData::set_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
ClassDB::bind_method(D_METHOD("get_level_range"), &PlanetData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &PlanetData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
ClassDB::bind_method(D_METHOD("get_humidity_noise_params"), &PlanetData::get_humidity_noise_params);
ClassDB::bind_method(D_METHOD("set_humidity_noise_params", "value"), &PlanetData::set_humidity_noise_params);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "humidity_noise_params", PROPERTY_HINT_RESOURCE_TYPE, "FastnoiseNoiseParams"), "set_humidity_noise_params", "get_humidity_noise_params");
ClassDB::bind_method(D_METHOD("get_temperature_noise_params"), &PlanetData::get_temperature_noise_params);
ClassDB::bind_method(D_METHOD("set_temperature_noise_params", "value"), &PlanetData::set_temperature_noise_params);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "temperature_noise_params", PROPERTY_HINT_RESOURCE_TYPE, "FastnoiseNoiseParams"), "set_temperature_noise_params", "get_temperature_noise_params");
ClassDB::bind_method(D_METHOD("get_biome_data", "index"), &PlanetData::get_biome_data);
ClassDB::bind_method(D_METHOD("set_biome_data", "index", "data"), &PlanetData::set_biome_data);
ClassDB::bind_method(D_METHOD("add_biome_data", "biome_data"), &PlanetData::add_biome_data);
ClassDB::bind_method(D_METHOD("remove_biome_data", "index"), &PlanetData::remove_biome_data);
ClassDB::bind_method(D_METHOD("get_biome_data_count"), &PlanetData::get_biome_data_count);
ClassDB::bind_method(D_METHOD("get_biome_datas"), &PlanetData::get_biome_datas);
ClassDB::bind_method(D_METHOD("set_biome_datas", "biome_datas"), &PlanetData::set_biome_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "biome_datas", PROPERTY_HINT_NONE, "17/17:BiomeData", PROPERTY_USAGE_DEFAULT, "BiomeData"), "set_biome_datas", "get_biome_datas");
//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);
ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &PlanetData::add_environment_data);
ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &PlanetData::remove_environment_data);
ClassDB::bind_method(D_METHOD("get_environment_data_count"), &PlanetData::get_environment_data_count);
ClassDB::bind_method(D_METHOD("get_environment_datas"), &PlanetData::get_environment_datas);
ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &PlanetData::set_environment_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas");
}

View File

@ -0,0 +1,69 @@
#ifndef biome_data_H
#define biome_data_H
#include "core/resource.h"
#include "../../../fastnoise/fastnoise_noise_params.h"
#include "../main/planet.h"
#include "../data/biome_data.h"
#include "../../world/environment_data.h"
class PlanetData : public Resource {
GDCLASS(PlanetData, Resource);
public:
int get_id() const;
void set_id(const int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
Ref<FastnoiseNoiseParams> get_humidity_noise_params();
void set_humidity_noise_params(Ref<FastnoiseNoiseParams> value);
Ref<FastnoiseNoiseParams> get_temperature_noise_params();
void set_temperature_noise_params(Ref<FastnoiseNoiseParams> value);
//Biomes
Ref<BiomeData> get_biome_data(const int index) const;
void set_biome_data(const int index, const Ref<BiomeData> biome_data);
void add_biome_data(const Ref<BiomeData> biome_data);
void remove_biome_data(const int index);
int get_biome_data_count() const;
Vector<Variant> get_biome_datas();
void set_biome_datas(const Vector<Variant> &biome_datas);
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
void add_environment_data(const Ref<EnvironmentData> environment_data);
void remove_environment_data(const int index);
int get_environment_data_count() const;
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
Ref<Planet> setup_planet(int seed);
PlanetData();
~PlanetData();
protected:
static void _bind_methods();
private:
int _id;
Vector2 _level_range;
Ref<FastnoiseNoiseParams> _humidity_noise_params;
Ref<FastnoiseNoiseParams> _temperature_noise_params;
Vector<Ref<BiomeData> > _biome_datas;
Vector<Ref<EnvironmentData> > _environment_datas;
};
#endif

View File

@ -0,0 +1,32 @@
#include "world_generator_prop_data.h"
bool WorldGeneratorPropData::can_spawn(int seed) {
if (has_method("_can_spawn")) {
return call("_can_spawn", seed);
}
return false;
}
Ref<PropData> WorldGeneratorPropData::get_prop(int seed) {
if (has_method("_get_prop")) {
return call("_get_prop", seed);
}
return Ref<PropData>(NULL);
}
WorldGeneratorPropData::WorldGeneratorPropData() {
}
WorldGeneratorPropData::~WorldGeneratorPropData() {
}
void WorldGeneratorPropData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "_get_prop", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &WorldGeneratorPropData::can_spawn);
ClassDB::bind_method(D_METHOD("get_prop", "seed"), &WorldGeneratorPropData::get_prop);
}

View File

@ -0,0 +1,24 @@
#ifndef WORLD_GENERATOR_PROP_DATA_H
#define WORLD_GENERATOR_PROP_DATA_H
#include "core/resource.h"
#include "../../props/prop_data.h"
class WorldGeneratorPropData : public Resource {
GDCLASS(WorldGeneratorPropData, Resource);
public:
bool can_spawn(int seed);
Ref<PropData> get_prop(int seed);
WorldGeneratorPropData();
~WorldGeneratorPropData();
protected:
static void _bind_methods();
};
#endif

View File

@ -0,0 +1,159 @@
#include "biome.h"
Vector2 Biome::get_level_range() {
return _level_range;
}
void Biome::set_level_range(Vector2 value) {
_level_range = value;
}
Ref<EnvironmentData> Biome::get_environment() {
return _environment;
}
void Biome::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
//// Prop Data ////
Ref<WorldGeneratorPropData> Biome::get_prop_data(const int index) const {
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<WorldGeneratorPropData>());
return _prop_datas.get(index);
}
void Biome::set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.set(index, prop_data);
}
void Biome::add_prop_data(const Ref<WorldGeneratorPropData> prop_data) {
_prop_datas.push_back(prop_data);
}
void Biome::remove_prop_data(const int index) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.remove(index);
}
int Biome::get_prop_data_count() const {
return _prop_datas.size();
}
//Entities
Ref<EntityData> Biome::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void Biome::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void Biome::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void Biome::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int Biome::get_entity_data_count() const {
return _entity_datas.size();
}
//// Dungeons ////
Ref<Dungeon> Biome::get_dungeon(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeons.size(), Ref<Dungeon>());
return _dungeons.get(index);
}
void Biome::set_dungeon(const int index, const Ref<Dungeon> dungeon) {
ERR_FAIL_INDEX(index, _dungeons.size());
_dungeons.set(index, dungeon);
}
void Biome::add_dungeon(const Ref<Dungeon> dungeon) {
_dungeons.push_back(dungeon);
}
void Biome::remove_dungeon(const int index) {
ERR_FAIL_INDEX(index, _dungeons.size());
_dungeons.remove(index);
}
int Biome::get_dungeon_count() const {
return _dungeons.size();
}
void Biome::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs);
}
}
void Biome::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
void Biome::generate_stack(VoxelChunk *chunk, int x, int z, bool spawn_mobs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
if (has_method("_generate_stack")) {
call("_generate_stack", chunk, x, z, spawn_mobs);
}
}
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);
}
Biome::Biome() {
}
Biome::~Biome() {
_environment.unref();
_prop_datas.clear();
_entity_datas.clear();
_dungeons.clear();
}
void Biome::_bind_methods() {
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")));
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);
ClassDB::bind_method(D_METHOD("get_level_range"), &Biome::get_level_range);
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");
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");
//Props
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &Biome::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &Biome::set_prop_data);
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &Biome::add_prop_data);
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);
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Biome::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Biome::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Biome::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Biome::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Biome::get_entity_data_count);
//Dungeons
ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Biome::get_dungeon);
ClassDB::bind_method(D_METHOD("set_dungeon", "index", "data"), &Biome::set_dungeon);
ClassDB::bind_method(D_METHOD("add_dungeon", "dungeon"), &Biome::add_dungeon);
ClassDB::bind_method(D_METHOD("remove_dungeon", "index"), &Biome::remove_dungeon);
ClassDB::bind_method(D_METHOD("get_dungeon_count"), &Biome::get_dungeon_count);
}

View File

@ -0,0 +1,67 @@
#ifndef BIOME_H
#define BIOME_H
#include "core/reference.h"
#include "../../world/voxel_chunk.h"
#include "../data/world_generator_prop_data.h"
#include "dungeon.h"
#include "../../world/environment_data.h"
#include "../../../entity_spell_system/entities/data/entity_data.h"
class Biome : public Reference {
GDCLASS(Biome, Reference);
public:
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Environment
Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
//WorldGeneratorPropData
Ref<WorldGeneratorPropData> get_prop_data(const int index) const;
void set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data);
void add_prop_data(const Ref<WorldGeneratorPropData> prop_data);
void remove_prop_data(const int index);
int get_prop_data_count() const;
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
//Dungeons
Ref<Dungeon> get_dungeon(const int index) const;
void set_dungeon(const int index, const Ref<Dungeon> dungeon);
void add_dungeon(const Ref<Dungeon> dungeon);
void remove_dungeon(const int index);
int get_dungeon_count() const;
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);
Biome();
~Biome();
protected:
static void _bind_methods();
private:
Vector2 _level_range;
Ref<EnvironmentData> _environment;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
Vector<Ref<EntityData> > _entity_datas;
Vector<Ref<Dungeon> > _dungeons;
};
#endif

View File

@ -0,0 +1,343 @@
#include "dungeon.h"
int Dungeon::get_seed() {
return _seed;
}
void Dungeon::set_seed(int value) {
_seed = value;
}
Vector2 Dungeon::get_level_range() {
return _level_range;
}
void Dungeon::set_level_range(Vector2 value) {
_level_range = value;
}
//Position
int Dungeon::get_posx() {
return _posx;
}
void Dungeon::set_posx(int value) {
_posx = value;
}
int Dungeon::get_posy() {
return _posy;
}
void Dungeon::set_posy(int value) {
_posy = value;
}
int Dungeon::get_posz() {
return _posz;
}
void Dungeon::set_posz(int value) {
_posz = value;
}
//Size
int Dungeon::get_sizex() {
return _sizex;
}
void Dungeon::set_sizex(int value) {
_sizex = value;
}
int Dungeon::get_sizey() {
return _sizey;
}
void Dungeon::set_sizey(int value) {
_sizey = value;
}
int Dungeon::get_sizez() {
return _sizez;
}
void Dungeon::set_sizez(int value) {
_sizez = value;
}
int Dungeon::get_room_count() {
return _room_count;
}
void Dungeon::set_room_count(int value) {
_room_count = value;
}
Ref<EnvironmentData> Dungeon::get_environment() {
return _environment;
}
void Dungeon::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
//Rooms
Ref<DungeonRoom> Dungeon::get_dungeon_room(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_rooms.size(), Ref<DungeonRoom>());
return _dungeon_rooms.get(index);
}
void Dungeon::set_dungeon_room(const int index, const Ref<DungeonRoom> dungeon_room) {
ERR_FAIL_INDEX(index, _dungeon_rooms.size());
_dungeon_rooms.set(index, dungeon_room);
}
void Dungeon::add_dungeon_room(const Ref<DungeonRoom> dungeon_room) {
_dungeon_rooms.push_back(dungeon_room);
}
void Dungeon::remove_dungeon_room(const int index) {
ERR_FAIL_INDEX(index, _dungeon_rooms.size());
_dungeon_rooms.remove(index);
}
int Dungeon::get_dungeon_room_count() const {
return _dungeon_rooms.size();
}
//Start Rooms
Ref<DungeonRoom> Dungeon::get_dungeon_start_room(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_start_rooms.size(), Ref<DungeonRoom>());
return _dungeon_start_rooms.get(index);
}
void Dungeon::set_dungeon_start_room(const int index, const Ref<DungeonRoom> dungeon_start_room) {
ERR_FAIL_INDEX(index, _dungeon_start_rooms.size());
_dungeon_start_rooms.set(index, dungeon_start_room);
}
void Dungeon::add_dungeon_start_room(const Ref<DungeonRoom> dungeon_start_room) {
_dungeon_start_rooms.push_back(dungeon_start_room);
}
void Dungeon::remove_dungeon_start_room(const int index) {
ERR_FAIL_INDEX(index, _dungeon_start_rooms.size());
_dungeon_start_rooms.remove(index);
}
int Dungeon::get_dungeon_start_room_count() const {
return _dungeon_start_rooms.size();
}
//End Rooms
Ref<DungeonRoom> Dungeon::get_dungeon_end_room(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_end_rooms.size(), Ref<DungeonRoom>());
return _dungeon_end_rooms.get(index);
}
void Dungeon::set_dungeon_end_room(const int index, const Ref<DungeonRoom> dungeon_end_room) {
ERR_FAIL_INDEX(index, _dungeon_end_rooms.size());
_dungeon_end_rooms.set(index, dungeon_end_room);
}
void Dungeon::add_dungeon_end_room(const Ref<DungeonRoom> dungeon_end_room) {
_dungeon_end_rooms.push_back(dungeon_end_room);
}
void Dungeon::remove_dungeon_end_room(const int index) {
ERR_FAIL_INDEX(index, _dungeon_end_rooms.size());
_dungeon_end_rooms.remove(index);
}
int Dungeon::get_dungeon_end_room_count() const {
return _dungeon_end_rooms.size();
}
//Corridors
Ref<DungeonCorridor> Dungeon::get_dungeon_corridor(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_corridors.size(), Ref<DungeonCorridor>());
return _dungeon_corridors.get(index);
}
void Dungeon::set_dungeon_corridor(const int index, const Ref<DungeonCorridor> dungeon_corridor) {
ERR_FAIL_INDEX(index, _dungeon_corridors.size());
_dungeon_corridors.set(index, dungeon_corridor);
}
void Dungeon::add_dungeon_corridor(const Ref<DungeonCorridor> dungeon_corridor) {
_dungeon_corridors.push_back(dungeon_corridor);
}
void Dungeon::remove_dungeon_corridor(const int index) {
ERR_FAIL_INDEX(index, _dungeon_corridors.size());
_dungeon_corridors.remove(index);
}
int Dungeon::get_dungeon_corridor_count() const {
return _dungeon_corridors.size();
}
//Entities
Ref<EntityData> Dungeon::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<DungeonCorridor>());
return _entity_datas.get(index);
}
void Dungeon::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void Dungeon::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void Dungeon::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int Dungeon::get_entity_data_count() const {
return _entity_datas.size();
}
void Dungeon::setup() {
if (has_method("_setup")) {
call("_setup");
}
}
void Dungeon::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs);
}
}
void Dungeon::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
void Dungeon::generate_structure(Ref<VoxelStructure> structure, bool spawn_mobs) {
if (has_method("_generate_structure")) {
call("_generate_structure", structure, spawn_mobs);
}
}
Ref<Image> Dungeon::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
return call("_generate_map");
}
Dungeon::Dungeon() {
_seed = 0;
_posx = 0;
_posy = 0;
_posz = 0;
_sizex = 0;
_sizey = 0;
_sizez = 0;
_room_count = 0;
}
Dungeon::~Dungeon() {
_environment.unref();
_dungeon_rooms.clear();
_dungeon_start_rooms.clear();
_dungeon_end_rooms.clear();
_dungeon_corridors.clear();
_entity_datas.clear();
}
void Dungeon::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup"));
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")));
ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup);
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);
ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &Dungeon::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &Dungeon::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Dungeon::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
//Position
ClassDB::bind_method(D_METHOD("get_posx"), &Dungeon::get_posx);
ClassDB::bind_method(D_METHOD("set_posx", "value"), &Dungeon::set_posx);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx");
ClassDB::bind_method(D_METHOD("get_posy"), &Dungeon::get_posy);
ClassDB::bind_method(D_METHOD("set_posy", "value"), &Dungeon::set_posy);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy");
ClassDB::bind_method(D_METHOD("get_posz"), &Dungeon::get_posz);
ClassDB::bind_method(D_METHOD("set_posz", "value"), &Dungeon::set_posz);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz");
//Size
ClassDB::bind_method(D_METHOD("get_sizex"), &Dungeon::get_sizex);
ClassDB::bind_method(D_METHOD("set_sizex", "value"), &Dungeon::set_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex");
ClassDB::bind_method(D_METHOD("get_sizey"), &Dungeon::get_sizey);
ClassDB::bind_method(D_METHOD("set_sizey", "value"), &Dungeon::set_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey");
ClassDB::bind_method(D_METHOD("get_sizez"), &Dungeon::get_sizez);
ClassDB::bind_method(D_METHOD("set_sizez", "value"), &Dungeon::set_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez");
//Room Count
ClassDB::bind_method(D_METHOD("get_room_count"), &Dungeon::get_room_count);
ClassDB::bind_method(D_METHOD("set_room_count", "value"), &Dungeon::set_room_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "room_count"), "set_room_count", "get_room_count");
//Environment
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");
//Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_room", "index"), &Dungeon::get_dungeon_room);
ClassDB::bind_method(D_METHOD("set_dungeon_room", "index", "data"), &Dungeon::set_dungeon_room);
ClassDB::bind_method(D_METHOD("add_dungeon_room", "dungeon_room"), &Dungeon::add_dungeon_room);
ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &Dungeon::remove_dungeon_room);
ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &Dungeon::get_dungeon_room_count);
//Start Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_start_room", "index"), &Dungeon::get_dungeon_start_room);
ClassDB::bind_method(D_METHOD("set_dungeon_start_room", "index", "data"), &Dungeon::set_dungeon_start_room);
ClassDB::bind_method(D_METHOD("add_dungeon_start_room", "dungeon_start_room"), &Dungeon::add_dungeon_start_room);
ClassDB::bind_method(D_METHOD("remove_dungeon_start_room", "index"), &Dungeon::remove_dungeon_start_room);
ClassDB::bind_method(D_METHOD("get_dungeon_start_room_count"), &Dungeon::get_dungeon_start_room_count);
//End Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_end_room", "index"), &Dungeon::get_dungeon_end_room);
ClassDB::bind_method(D_METHOD("set_dungeon_end_room", "index", "data"), &Dungeon::set_dungeon_end_room);
ClassDB::bind_method(D_METHOD("add_dungeon_end_room", "dungeon_end_room"), &Dungeon::add_dungeon_end_room);
ClassDB::bind_method(D_METHOD("remove_dungeon_end_room", "index"), &Dungeon::remove_dungeon_end_room);
ClassDB::bind_method(D_METHOD("get_dungeon_end_room_count"), &Dungeon::get_dungeon_end_room_count);
//Corridors
ClassDB::bind_method(D_METHOD("get_dungeon_corridor", "index"), &Dungeon::get_dungeon_corridor);
ClassDB::bind_method(D_METHOD("set_dungeon_corridor", "index", "data"), &Dungeon::set_dungeon_corridor);
ClassDB::bind_method(D_METHOD("add_dungeon_corridor", "dungeon_corridor"), &Dungeon::add_dungeon_corridor);
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);
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Dungeon::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Dungeon::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Dungeon::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Dungeon::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Dungeon::get_entity_data_count);
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map"));
ClassDB::bind_method(D_METHOD("generate_map"), &Dungeon::generate_map);
}

View File

@ -0,0 +1,129 @@
#ifndef DUNGEON_H
#define DUNGEON_H
#include "core/reference.h"
#include "dungeon_room.h"
#include "dungeon_corridor.h"
#include "../../world/voxel_chunk.h"
#include "../../world/voxel_structure.h"
#include "../../world/environment_data.h"
#include "../../../entity_spell_system/entities/data/entity_data.h"
class Dungeon : public Reference {
GDCLASS(Dungeon, Reference);
public:
int get_seed();
void set_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Pos
int get_posx();
void set_posx(int value);
int get_posy();
void set_posy(int value);
int get_posz();
void set_posz(int value);
//Size
int get_sizex();
void set_sizex(int value);
int get_sizey();
void set_sizey(int value);
int get_sizez();
void set_sizez(int value);
//Room Count
int get_room_count();
void set_room_count(int value);
//Environment
Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
//Rooms
Ref<DungeonRoom> get_dungeon_room(const int index) const;
void set_dungeon_room(const int index, const Ref<DungeonRoom> dungeon_room);
void add_dungeon_room(const Ref<DungeonRoom> dungeon_room);
void remove_dungeon_room(const int index);
int get_dungeon_room_count() const;
//Start Rooms
Ref<DungeonRoom> get_dungeon_start_room(const int index) const;
void set_dungeon_start_room(const int index, const Ref<DungeonRoom> dungeon_start_room);
void add_dungeon_start_room(const Ref<DungeonRoom> dungeon_start_room);
void remove_dungeon_start_room(const int index);
int get_dungeon_start_room_count() const;
//End Rooms
Ref<DungeonRoom> get_dungeon_end_room(const int index) const;
void set_dungeon_end_room(const int index, const Ref<DungeonRoom> dungeon_end_room);
void add_dungeon_end_room(const Ref<DungeonRoom> dungeon_end_room);
void remove_dungeon_end_room(const int index);
int get_dungeon_end_room_count() const;
//Corridors
Ref<DungeonCorridor> get_dungeon_corridor(const int index) const;
void set_dungeon_corridor(const int index, const Ref<DungeonCorridor> dungeon_corridors);
void add_dungeon_corridor(const Ref<DungeonCorridor> dungeon_corridors);
void remove_dungeon_corridor(const int index);
int get_dungeon_corridor_count() const;
//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;
void setup();
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);
Ref<Image> generate_map();
Dungeon();
~Dungeon();
protected:
static void _bind_methods();
private:
int _seed;
Vector2 _level_range;
int _posx;
int _posy;
int _posz;
int _sizex;
int _sizey;
int _sizez;
int _room_count;
Ref<EnvironmentData> _environment;
Vector<Ref<DungeonRoom> > _dungeon_rooms;
Vector<Ref<DungeonRoom> > _dungeon_start_rooms;
Vector<Ref<DungeonRoom> > _dungeon_end_rooms;
Vector<Ref<DungeonCorridor> > _dungeon_corridors;
Vector<Ref<EntityData> > _entity_datas;
};
#endif

View File

@ -0,0 +1,54 @@
#include "dungeon_corridor.h"
int DungeonCorridor::get_max_connections() {
return _max_connections;
}
void DungeonCorridor::set_max_connections(int value) {
_max_connections = value;
}
//Rooms
Ref<DungeonRoom> DungeonCorridor::get_dungeon_room(const int index) const {
ERR_FAIL_INDEX_V(index, _dungeon_rooms.size(), Ref<DungeonRoom>());
return _dungeon_rooms.get(index);
}
void DungeonCorridor::set_dungeon_room(const int index, const Ref<DungeonRoom> dungeon_room) {
ERR_FAIL_INDEX(index, _dungeon_rooms.size());
_dungeon_rooms.set(index, dungeon_room);
}
void DungeonCorridor::add_dungeon_room(const Ref<DungeonRoom> dungeon_room) {
_dungeon_rooms.push_back(dungeon_room);
}
void DungeonCorridor::remove_dungeon_room(const int index) {
ERR_FAIL_INDEX(index, _dungeon_rooms.size());
_dungeon_rooms.remove(index);
}
int DungeonCorridor::get_dungeon_room_count() const {
return _dungeon_rooms.size();
}
DungeonCorridor::DungeonCorridor() {
_max_connections = 2;
}
DungeonCorridor::~DungeonCorridor() {
_dungeon_rooms.clear();
}
void DungeonCorridor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_max_connections"), &DungeonCorridor::get_max_connections);
ClassDB::bind_method(D_METHOD("set_max_connections", "value"), &DungeonCorridor::set_max_connections);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_connections"), "set_max_connections", "get_max_connections");
//Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_room", "index"), &DungeonCorridor::get_dungeon_room);
ClassDB::bind_method(D_METHOD("set_dungeon_room", "index", "data"), &DungeonCorridor::set_dungeon_room);
ClassDB::bind_method(D_METHOD("add_dungeon_room", "dungeon_room"), &DungeonCorridor::add_dungeon_room);
ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &DungeonCorridor::remove_dungeon_room);
ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &DungeonCorridor::get_dungeon_room_count);
}

View File

@ -0,0 +1,33 @@
#ifndef DUNGEON_CORRIDOR_H
#define DUNGEON_CORRIDOR_H
#include "dungeon_room.h"
class DungeonCorridor : public DungeonRoom {
GDCLASS(DungeonCorridor, DungeonRoom);
public:
int get_max_connections();
void set_max_connections(int value);
//Rooms
Ref<DungeonRoom> get_dungeon_room(const int index) const;
void set_dungeon_room(const int index, const Ref<DungeonRoom> dungeon_room);
void add_dungeon_room(const Ref<DungeonRoom> dungeon_room);
void remove_dungeon_room(const int index);
int get_dungeon_room_count() const;
DungeonCorridor();
~DungeonCorridor();
protected:
static void _bind_methods();
private:
int _max_connections;
Vector<Ref<DungeonRoom> > _dungeon_rooms;
};
#endif

View File

@ -0,0 +1,231 @@
#include "dungeon_room.h"
int DungeonRoom::get_seed() {
return _seed;
}
void DungeonRoom::set_seed(int value) {
_seed = value;
}
Vector2 DungeonRoom::get_level_range() {
return _level_range;
}
void DungeonRoom::set_level_range(Vector2 value) {
_level_range = value;
}
//Position
int DungeonRoom::get_posx() {
return _posx;
}
void DungeonRoom::set_posx(int value) {
_posx = value;
}
int DungeonRoom::get_posy() {
return _posy;
}
void DungeonRoom::set_posy(int value) {
_posy = value;
}
int DungeonRoom::get_posz() {
return _posz;
}
void DungeonRoom::set_posz(int value) {
_posz = value;
}
//Size
int DungeonRoom::get_sizex() {
return _sizex;
}
void DungeonRoom::set_sizex(int value) {
_sizex = value;
}
int DungeonRoom::get_sizey() {
return _sizey;
}
void DungeonRoom::set_sizey(int value) {
_sizey = value;
}
int DungeonRoom::get_sizez() {
return _sizez;
}
void DungeonRoom::set_sizez(int value) {
_sizez = value;
}
Ref<EnvironmentData> DungeonRoom::get_environment() {
return _environment;
}
void DungeonRoom::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
Ref<VoxelStructure> DungeonRoom::get_structure() {
return _structure;
}
void DungeonRoom::set_structure(Ref<VoxelStructure> structure) {
_structure = structure;
}
//Props
Ref<WorldGeneratorPropData> DungeonRoom::get_prop_data(const int index) const {
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<WorldGeneratorPropData>());
return _prop_datas.get(index);
}
void DungeonRoom::set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.set(index, prop_data);
}
void DungeonRoom::add_prop_data(const Ref<WorldGeneratorPropData> prop_data) {
_prop_datas.push_back(prop_data);
}
void DungeonRoom::remove_prop_data(const int index) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.remove(index);
}
int DungeonRoom::get_prop_data_count() const {
return _prop_datas.size();
}
//Entities
Ref<EntityData> DungeonRoom::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void DungeonRoom::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void DungeonRoom::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void DungeonRoom::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int DungeonRoom::get_entity_data_count() const {
return _entity_datas.size();
}
void DungeonRoom::setup() {
if (has_method("_setup")) {
call("_setup");
}
}
void DungeonRoom::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs);
}
}
void DungeonRoom::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
void DungeonRoom::generate_room(Ref<VoxelStructure> structure, bool spawn_mobs) {
if (has_method("_generate_room")) {
call("_generate_room", structure, spawn_mobs);
}
}
DungeonRoom::DungeonRoom() {
_seed = 0;
_posx = 0;
_posy = 0;
_posz = 0;
_sizex = 0;
_sizey = 0;
_sizez = 0;
}
DungeonRoom::~DungeonRoom() {
_environment.unref();
_prop_datas.clear();
_entity_datas.clear();
}
void DungeonRoom::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup"));
BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs")));
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs")));
ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup);
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);
ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &DungeonRoom::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonRoom::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoom::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
//Position
ClassDB::bind_method(D_METHOD("get_posx"), &DungeonRoom::get_posx);
ClassDB::bind_method(D_METHOD("set_posx", "value"), &DungeonRoom::set_posx);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx");
ClassDB::bind_method(D_METHOD("get_posy"), &DungeonRoom::get_posy);
ClassDB::bind_method(D_METHOD("set_posy", "value"), &DungeonRoom::set_posy);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy");
ClassDB::bind_method(D_METHOD("get_posz"), &DungeonRoom::get_posz);
ClassDB::bind_method(D_METHOD("set_posz", "value"), &DungeonRoom::set_posz);
ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz");
//Size
ClassDB::bind_method(D_METHOD("get_sizex"), &DungeonRoom::get_sizex);
ClassDB::bind_method(D_METHOD("set_sizex", "value"), &DungeonRoom::set_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex");
ClassDB::bind_method(D_METHOD("get_sizey"), &DungeonRoom::get_sizey);
ClassDB::bind_method(D_METHOD("set_sizey", "value"), &DungeonRoom::set_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey");
ClassDB::bind_method(D_METHOD("get_sizez"), &DungeonRoom::get_sizez);
ClassDB::bind_method(D_METHOD("set_sizez", "value"), &DungeonRoom::set_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez");
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");
ClassDB::bind_method(D_METHOD("get_structure"), &DungeonRoom::get_structure);
ClassDB::bind_method(D_METHOD("set_structure", "value"), &DungeonRoom::set_structure);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), "set_structure", "get_structure");
//Props
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoom::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoom::set_prop_data);
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoom::add_prop_data);
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoom::remove_prop_data);
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoom::get_prop_data_count);
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoom::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoom::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoom::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoom::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoom::get_entity_data_count);
}

View File

@ -0,0 +1,97 @@
#ifndef DUNGEON_ROOM_H
#define DUNGEON_ROOM_H
#include "core/reference.h"
#include "core/vector.h"
#include "../../world/voxel_chunk.h"
#include "../../world/voxel_structure.h"
#include "../data/world_generator_prop_data.h"
#include "../../world/environment_data.h"
#include "../../../entity_spell_system/entities/data/entity_data.h"
class DungeonRoom : public Reference {
GDCLASS(DungeonRoom, Reference);
public:
int get_seed();
void set_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Pos
int get_posx();
void set_posx(int value);
int get_posy();
void set_posy(int value);
int get_posz();
void set_posz(int value);
//Size
int get_sizex();
void set_sizex(int value);
int get_sizey();
void set_sizey(int value);
int get_sizez();
void set_sizez(int value);
//Environment
Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
//Structure
Ref<VoxelStructure> get_structure();
void set_structure(Ref<VoxelStructure> structure);
//Props
Ref<WorldGeneratorPropData> get_prop_data(const int index) const;
void set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data);
void add_prop_data(const Ref<WorldGeneratorPropData> prop_data);
void remove_prop_data(const int index);
int get_prop_data_count() const;
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
void setup();
void generate_chunk(VoxelChunk *chunk, bool spawn_mobs);
void generate_chunk_bind(Node *chunk, bool spawn_mobs);
void generate_room(Ref<VoxelStructure> structure, bool spawn_mobs);
DungeonRoom();
~DungeonRoom();
protected:
static void _bind_methods();
private:
int _seed;
Vector2 _level_range;
int _posx;
int _posy;
int _posz;
int _sizex;
int _sizey;
int _sizez;
Ref<EnvironmentData> _environment;
Ref<VoxelStructure> _structure;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
Vector<Ref<EntityData> > _entity_datas;
};
#endif

View File

@ -0,0 +1,108 @@
#include "planet.h"
int Planet::get_seed() {
return _seed;
}
void Planet::set_seed(int value) {
_seed = value;
}
Vector2 Planet::get_level_range() {
return _level_range;
}
void Planet::set_level_range(Vector2 value) {
_level_range = value;
}
Ref<EnvironmentData> Planet::get_environment() {
return _environment;
}
void Planet::set_environment(Ref<EnvironmentData> value) {
_environment = value;
}
Ref<Biome> Planet::get_biome(const int index) const {
ERR_FAIL_INDEX_V(index, _biomes.size(), Ref<Biome>());
return _biomes.get(index);
}
void Planet::set_biome(const int index, const Ref<Biome> biome) {
ERR_FAIL_INDEX(index, _biomes.size());
_biomes.set(index, biome);
}
void Planet::add_biome(const Ref<Biome> biome) {
_biomes.push_back(biome);
}
void Planet::remove_biome(const int index) {
ERR_FAIL_INDEX(index, _biomes.size());
_biomes.remove(index);
}
int Planet::get_biome_count() const {
return _biomes.size();
}
void Planet::setup() {
if (has_method("_setup")) {
call("_setup");
}
}
void Planet::generate_chunk(VoxelChunk *chunk, bool spawn_mobs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk, spawn_mobs);
}
}
void Planet::generate_chunk_bind(Node *chunk, bool spawn_mobs) {
generate_chunk(Object::cast_to<VoxelChunk>(chunk), spawn_mobs);
}
Ref<Image> Planet::generate_map() {
ERR_FAIL_COND_V(!has_method("_generate_map"), Ref<Image>());
return call("_generate_map");
}
Planet::Planet() {
_seed = 0;
}
Planet::~Planet() {
_environment.unref();
_biomes.clear();
}
void Planet::_bind_methods() {
BIND_VMETHOD(MethodInfo("_setup"));
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs")));
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("get_seed"), &Planet::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &Planet::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &Planet::get_level_range);
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");
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");
ClassDB::bind_method(D_METHOD("get_biome", "index"), &Planet::get_biome);
ClassDB::bind_method(D_METHOD("set_biome", "index", "data"), &Planet::set_biome);
ClassDB::bind_method(D_METHOD("add_biome", "biome"), &Planet::add_biome);
ClassDB::bind_method(D_METHOD("remove_biome", "index"), &Planet::remove_biome);
ClassDB::bind_method(D_METHOD("get_biome_count"), &Planet::get_biome_count);
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map"));
ClassDB::bind_method(D_METHOD("generate_map"), &Planet::generate_map);
}

View File

@ -0,0 +1,50 @@
#ifndef PLANET_H
#define PLANET_H
#include "core/reference.h"
#include "core/image.h"
#include "../../world/voxel_chunk.h"
#include "biome.h"
#include "../../world/environment_data.h"
class Planet : public Reference {
GDCLASS(Planet, Reference);
public:
int get_seed();
void set_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Environment
Ref<EnvironmentData> get_environment();
void set_environment(Ref<EnvironmentData> value);
Ref<Biome> get_biome(const int index) const;
void set_biome(const int index, const Ref<Biome> biome);
void add_biome(const Ref<Biome> biome);
void remove_biome(const int index);
int get_biome_count() const;
void setup();
void generate_chunk(VoxelChunk *chunk, bool spawn_mobs);
void generate_chunk_bind(Node *chunk, bool spawn_mobs);
Ref<Image> generate_map();
Planet();
~Planet();
protected:
static void _bind_methods();
private:
int _seed;
Vector2 _level_range;
Ref<EnvironmentData> _environment;
Vector<Ref<Biome> > _biomes;
};
#endif

View File

@ -0,0 +1,125 @@
#include "DungeonCorridor.h"
namespace BS {
namespace Levels {
namespace Generator {
DungeonRoom* DungeonCorridor::getStartRoom(){
return this->startRoom;
}
void DungeonCorridor::setStartRoom(DungeonRoom* value)
{
this->startRoom = value;
}
DungeonRoom* DungeonCorridor::getEndRoom()
{
return this->endRoom;
}
void DungeonCorridor::setEndRoom(DungeonRoom* value)
{
this->endRoom = value;
}
DungeonCorridor::DungeonCorridor(int size, DungeonRoom* startRoom, DungeonRoom* endRoom)
{
size = 4;
this->size = size;
this->setStartRoom(startRoom);
this->setEndRoom(endRoom);
}
void DungeonCorridor::GenerateCorridor(ArrayND<char, 2>* dungeon)
{
int num = this->getStartRoom()->X + Mathf::RoundToInt((float)(this->getStartRoom()->Width) / (float)2);
int num2 = this->getStartRoom()->Y + Mathf::RoundToInt((float)(this->getStartRoom()->Height) / (float)2);
int num3 = this->getEndRoom()->X + Mathf::RoundToInt((float)(this->getEndRoom()->Width) / (float)2);
int num4 = this->getEndRoom()->Y + Mathf::RoundToInt((float)(this->getEndRoom()->Height) / (float)2);
if ((num <= num3) && (num2 <= num4)) {
this->widthir = new IntRect(num, num2, num3 - num, this->size);
this->heightir = new IntRect((this->widthir->X + this->widthir->Width) - this->size, num2, this->size, num4 - num2);
}
else {
if ((num > num3) && (num2 <= num4)) {
this->widthir = new IntRect(num3, num2, num - num3, this->size);
this->heightir = new IntRect(this->widthir->X, num2, this->size, num4 - num2);
}
else {
if ((num <= num3) && (num2 > num4)) {
this->widthir = new IntRect(num, num4, num3 - num, this->size);
this->heightir = new IntRect(num, num4, this->size, num2 - num4);
}
else {
if ((num > num3) && (num2 > num4)) {
this->widthir = new IntRect(num3 - this->size, num2 - this->size, num - num3, this->size);
this->heightir = new IntRect(this->widthir->X, num4, this->size, num2 - num4);
}
}
}
}
this->Write(dungeon, this->widthir);
this->Write(dungeon, this->heightir);
}
void DungeonCorridor::Write(ArrayND<char, 2>* dungeon, IntRect* rect)
{
for (int i = rect->getY(); i < (rect->getY() + rect->getHeight()); i += 1) {
for (int j = rect->getX(); j < (rect->getX() + rect->getWidth()); j += 1) {
if (((*(dungeon->GetData(j, i)) != 1) && (*(dungeon->GetData(j, i)) != 2)) && (*(dungeon->GetData(j, i)) != 20)) {
if ((j == rect->getX()) && (i == rect->getY())) {
dungeon->SetData(j, i, 13);
}
else {
if ((j == rect->getX()) && (i == ((rect->getY() + rect->getHeight()) - 1))) {
dungeon->SetData(j, i, 13);
}
else {
if ((j == ((rect->getX() + rect->getWidth()) - 1)) && (i == rect->getY())) {
dungeon->SetData(j, i, 13);
}
else {
if ((j == ((rect->getX() + rect->getWidth()) - 1)) && (i == ((rect->getY() + rect->getHeight()) - 1))) {
dungeon->SetData(j, i, 13);
}
else {
if (j == rect->getX()) {
dungeon->SetData(j, i, 14);
}
else {
if (j == ((rect->getX() + rect->getWidth()) - 1)) {
dungeon->SetData(j, i, 12);
}
else {
if (i == rect->getY()) {
dungeon->SetData(j, i, 13);
}
else {
if (i == ((rect->getY() + rect->getHeight()) - 1)) {
dungeon->SetData(j, i, 11);
}
else {
dungeon->SetData(j, i, 1);
}
}
}
}
}
}
}
}
}
}
}
}
void DungeonCorridor::GenerateAIPlayers(int level)
{
this->GenerateAIPlayers(level, this->widthir);
this->GenerateAIPlayers(level, this->heightir);
}
void DungeonCorridor::GenerateAIPlayers(int level, IntRect* rect)
{
int num = UnityEngine::Random::Range(0, 3);
for (int i = 0; i < num; i += 1) {
int num2 = rect->getX() + UnityEngine::Random::Range(1, rect->getWidth() - 2);
int num3 = rect->getY() + UnityEngine::Random::Range(1, rect->getHeight() - 2);
new Vector3(((float)(num2) * Voxelizzer::world->voxelScale) * (float)2, Voxelizzer::world->voxelScale, ((float)(num3) * Voxelizzer::world->voxelScale) * (float)2);
}
}
}
}
}

View File

@ -0,0 +1,49 @@
#pragma once
#include <System/System.h>
#include "DungeonRoom.h"
#include "IntRect.h"
#include "Mathf.h"
#include "UnityEngine.h"
#include "Vector3.h"
#include "Voxelizzer.h"
using namespace UnityEngine;
using namespace VoxelToolbox;
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class DungeonCorridor : public virtual Object
{
private:
DungeonRoom* startRoom;
private:
DungeonRoom* endRoom;
public:
int size;
private:
IntRect* widthir;
private:
IntRect* heightir;
public:
DungeonRoom* getStartRoom();
public:
void setStartRoom(DungeonRoom* value);
public:
DungeonRoom* getEndRoom();
public:
void setEndRoom(DungeonRoom* value);
public:
DungeonCorridor(int size, DungeonRoom* startRoom, DungeonRoom* endRoom);
public:
void GenerateCorridor(ArrayND<char, 2>* dungeon);
private:
void Write(ArrayND<char, 2>* dungeon, IntRect* rect);
public:
virtual void GenerateAIPlayers(int level);
private:
void GenerateAIPlayers(int level, IntRect* rect);
};
}
}
}

View File

@ -0,0 +1,37 @@
#include "DungeonEndRoom.h"
namespace BS {
namespace Levels {
namespace Generator {
DungeonEndRoom::DungeonEndRoom(int x, int y, int width, int height) : DungeonRoom(x, y, width, height){
}
void DungeonEndRoom::WriteRoom(ArrayND<char, 2>* dungeon)
{
for (int i = DungeonRoom::getY(); i < (DungeonRoom::getY() + DungeonRoom::getHeight()); i += 1) {
for (int j = DungeonRoom::getX(); j < (DungeonRoom::getX() + DungeonRoom::getWidth()); j += 1) {
dungeon->SetData(j, i, 1);
}
}
for (int k = DungeonRoom::getX() + 1; k < ((DungeonRoom::getX() + DungeonRoom::getWidth()) - 1); k += 1) {
dungeon->SetData(k, (DungeonRoom::getY() + DungeonRoom::getHeight()) - 1, 11);
}
for (int l = DungeonRoom::getX() + 1; l < ((DungeonRoom::getX() + DungeonRoom::getWidth()) - 1); l += 1) {
dungeon->SetData(l, DungeonRoom::getY(), 13);
}
for (int m = DungeonRoom::getY() + 1; m < ((DungeonRoom::getY() + DungeonRoom::getHeight()) - 1); m += 1) {
dungeon->SetData(DungeonRoom::getX(), m, 14);
}
for (int n = DungeonRoom::getY() + 1; n < ((DungeonRoom::getY() + DungeonRoom::getHeight()) - 1); n += 1) {
dungeon->SetData((DungeonRoom::getX() + DungeonRoom::getWidth()) - 1, n, 12);
}
dungeon->SetData(DungeonRoom::getX(), DungeonRoom::getY(), 13);
dungeon->SetData((DungeonRoom::getX() + DungeonRoom::getWidth()) - 1, DungeonRoom::getY(), 13);
dungeon->SetData(DungeonRoom::getX(), (DungeonRoom::getY() + DungeonRoom::getHeight()) - 1, 13);
dungeon->SetData((DungeonRoom::getX() + DungeonRoom::getWidth()) - 1, (DungeonRoom::getY() + DungeonRoom::getHeight()) - 1, 13);
int num = UnityEngine::Random::Range(DungeonRoom::getX() + 1, (DungeonRoom::getX() + DungeonRoom::getWidth()) - 1);
int num2 = UnityEngine::Random::Range(DungeonRoom::getY() + 1, (DungeonRoom::getY() + DungeonRoom::getHeight()) - 1);
dungeon->SetData(num, num2, 20);
}
}
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <System/System.h>
#include "DungeonRoom.h"
#include "UnityEngine.h"
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class DungeonEndRoom : public virtual DungeonRoom, public virtual Object
{
public:
DungeonEndRoom(int x, int y, int width, int height);
public:
virtual void WriteRoom(ArrayND<char, 2>* dungeon);
};
}
}
}

View File

@ -0,0 +1,205 @@
#include "DungeonGenerator.h"
namespace BS {
namespace Levels {
namespace Generator {
ArrayND<char, 2>* DungeonGenerator::getDungeon(){
return this->dungeon;
}
void DungeonGenerator::Awake()
{
this->rooms = new List_T<DungeonRoom>();
this->corridors = new List_T<DungeonCorridor>();
this->dungeon = new ArrayND<char>(this->DUNGEON_Size_X, this->DUNGEON_Size_Y);
}
void DungeonGenerator::Generate(int level)
{
UnityEngine::Random::InitState(BrokenSeals::Game->Seed);
if (!CxNet::IsServer) {
this->SpawnMobs = false;
}
this->GenerateDungeon();
this->GenerateCorridors();
this->PreprocessDungeonSimple();
this->GeneratePlayers(level);
}
void DungeonGenerator::GenerateDungeon()
{
for (int i = 0; i < this->ROOM_PLACEMENT_TRIES; i += 1) {
int x = UnityEngine::Random::Range(0, this->DUNGEON_Size_X - this->ROOM_MAX_SIZE);
int y = UnityEngine::Random::Range(0, this->DUNGEON_Size_Y - this->ROOM_MAX_SIZE);
int width = UnityEngine::Random::Range(this->ROOM_MIN_SIZE, this->ROOM_MAX_SIZE);
int height = UnityEngine::Random::Range(this->ROOM_MIN_SIZE, this->ROOM_MAX_SIZE);
if (this->CanPlaceRoom(x, y, width, height)) {
if (this->rooms->Count > 0) {
DungeonRoom* dungeonRoom = new DungeonRoom(x, y, width, height);
dungeonRoom->WriteRoom(this->dungeon);
this->corridors->Add(new DungeonCorridor(this->CORRIDOR_SIZE, this->rooms->GetData(this->rooms->Count - 1), dungeonRoom));
this->rooms->Add(dungeonRoom);
}
else {
DungeonStartRoom* dungeonStartRoom = new DungeonStartRoom(x, y, width, height);
dungeonStartRoom->WriteRoom(this->dungeon);
dungeonStartRoom->GenerateSpawnPoint(this->startPositionPrefab);
this->rooms->Add(dungeonStartRoom);
}
}
}
DungeonRoom* dungeonRoom2 = this->rooms->GetData(this->rooms->Count - 1);
this->rooms->Remove(dungeonRoom2);
this->corridors->RemoveAt(this->corridors->Count - 1);
DungeonEndRoom* dungeonEndRoom = new DungeonEndRoom(dungeonRoom2->getX(), dungeonRoom2->getY(), dungeonRoom2->getWidth(), dungeonRoom2->getHeight());
this->corridors->Add(new DungeonCorridor(this->CORRIDOR_SIZE, this->rooms->GetData(this->rooms->Count - 1), dungeonEndRoom));
this->rooms->Add(dungeonEndRoom);
dungeonEndRoom->WriteRoom(this->dungeon);
}
void DungeonGenerator::GenerateCorridors()
{
for (int i = 0; i < this->corridors->Count; i += 1) {
this->corridors->GetData(i)->GenerateCorridor(this->dungeon);
}
}
void DungeonGenerator::GeneratePlayers(int level)
{
if (!this->SpawnMobs) {
return;
}
for (int i = 0; i < this->rooms->Count; i += 1) {
this->rooms->GetData(i)->GenerateAIPlayers(level);
}
for (int j = 0; j < this->corridors->Count; j += 1) {
this->corridors->GetData(j)->GenerateAIPlayers(level);
}
}
void DungeonGenerator::PreprocessDungeonSimple()
{
for (int i = 1; i < this->DUNGEON_Size_X; i += 1) {
for (int j = 1; j < this->DUNGEON_Size_Y; j += 1) {
this->dungeon->GetData(i, j);
if (TileConsts::isWall(this->dungeon->GetData(i, j))) {
bool arg_68_0 = *(this->dungeon->GetData(i, j - 1)) == 0;
bool flag = *(this->dungeon->GetData(i - 1, j)) == 0;
bool flag2 = *(this->dungeon->GetData(i - 1, j - 1)) == 0;
if ((arg_68_0 | flag) | flag2) {
this->dungeon->SetData(i, j, 12);
}
}
}
}
}
void DungeonGenerator::PreprocessDungeon()
{
for (int i = 1; i < this->DUNGEON_Size_X; i += 1) {
for (int j = 1; j < this->DUNGEON_Size_Y; j += 1) {
char b = this->dungeon->GetData(i, j);
if (((b != 0) && (b != 1)) && (b != 20)) {
bool flag = TileConsts::isWall(this->dungeon->GetData(i, j + 1));
bool flag2 = TileConsts::isWall(this->dungeon->GetData(i, j - 1));
bool flag3 = TileConsts::isWall(this->dungeon->GetData(i - 1, j));
bool flag4 = TileConsts::isWall(this->dungeon->GetData(i + 1, j));
bool flag5 = TileConsts::isWall(this->dungeon->GetData(i + 1, j + 1));
bool flag6 = TileConsts::isWall(this->dungeon->GetData(i - 1, j + 1));
bool flag7 = TileConsts::isWall(this->dungeon->GetData(i + 1, j - 1));
bool flag8 = TileConsts::isWall(this->dungeon->GetData(i - 1, j - 1));
if (!flag & flag2) {
if (((!flag4 & flag) & flag3) && !flag2) {
this->dungeon->SetData(i, j, 17);
}
else {
if (((!flag4 && !flag) & flag3) & flag2) {
this->dungeon->SetData(i, j, 18);
}
else {
if (((!flag3 && !flag) & flag4) & flag2) {
this->dungeon->SetData(i, j, 17);
}
else {
if (((((((flag3 && !flag8) && !flag2) && !flag7) && !flag4) && !flag5) & flag) && !flag6) {
this->dungeon->SetData(i, j, 23);
}
else {
if ((!flag3 & flag) & flag4) {
}
if (((((((flag3 && !flag8) & flag2) && !flag7) && !flag4) && !flag5) && !flag) && !flag6) {
this->dungeon->SetData(i, j, 22);
}
else {
if (((((((!flag3 && !flag8) && !flag2) && !flag7) & flag4) && !flag5) & flag) && !flag6) {
this->dungeon->SetData(i, j, 21);
}
}
}
}
}
}
}
}
}
}
}
String* DungeonGenerator::StringifyDungeon()
{
this->sb = new StringBuilder();
for (int i = 0; i < this->DUNGEON_Size_Y; i += 1) {
for (int j = 0; j < this->DUNGEON_Size_X; j += 1) {
if (*(this->dungeon->GetData(j, i)) != 0) {
this->sb->Append(j);
this->sb->Append(new String(";"));
this->sb->Append(i);
this->sb->Append(new String(";"));
this->sb->Append(this->dungeon->GetData(j, i));
this->sb->Append(new String("|"));
}
}
}
return this->sb->ToString();
}
void DungeonGenerator::GenerateDebugDungeon()
{
this->dungeon = new ArrayND<char>(this->DUNGEON_Size_X, this->DUNGEON_Size_Y);
for (int i = 0; i < this->DUNGEON_Size_Y; i += 1) {
for (int j = 0; j < this->DUNGEON_Size_X; j += 1) {
this->dungeon->SetData(j, i, 1);
}
}
for (int k = 0; k < 300; k += 1) {
this->dungeon->SetData(UnityEngine::Random::Range(0, this->DUNGEON_Size_X), UnityEngine::Random::Range(0, this->DUNGEON_Size_Y), 2);
}
}
bool DungeonGenerator::CanPlaceRoom(int x, int y, int width, int height)
{
for (int i = y; i < (y + height); i += 1) {
for (int j = x; j < (x + width); j += 1) {
if (*(this->dungeon->GetData(j, i)) != 0) {
return false;
}
}
}
return true;
}
void DungeonGenerator::Reset()
{
if (this->rooms == null) {
return;
}
this->rooms->Clear();
this->corridors->Clear();
for (int i = 0; i < this->DUNGEON_Size_Y; i += 1) {
for (int j = 0; j < this->DUNGEON_Size_X; j += 1) {
this->dungeon->SetData(j, i, 0);
}
}
}
DungeonGenerator::DungeonGenerator()
{
SpawnMobs = true;
DUNGEON_Size_X = 200;
DUNGEON_Size_Y = 200;
ROOM_MIN_SIZE = 20;
ROOM_MAX_SIZE = 26;
ROOM_PLACEMENT_TRIES = 100;
CORRIDOR_SIZE = 4;
}
}
}
}

View File

@ -0,0 +1,83 @@
#pragma once
#include <System/System.h>
#include "MonoBehaviour.h"
#include "GameObject.h"
#include "DungeonRoom.h"
#include <System/Collections/Generic/List.h>
#include "DungeonCorridor.h"
#include <System/Text/StringBuilder.h>
#include "UnityEngine.h"
#include "BrokenSeals.h"
#include "CxNet.h"
#include "DungeonStartRoom.h"
#include "DungeonEndRoom.h"
#include "TileConsts.h"
using namespace UnityEngine;
using namespace System::Collections::Generic;
using namespace System::Text;
using namespace CxNetworking;
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class DungeonGenerator : public virtual MonoBehaviour, public virtual Object
{
public:
int Seed;
public:
bool SpawnMobs;
public:
int DUNGEON_Size_X;
public:
int DUNGEON_Size_Y;
public:
int ROOM_MIN_SIZE;
public:
int ROOM_MAX_SIZE;
public:
int ROOM_PLACEMENT_TRIES;
public:
int CORRIDOR_SIZE;
//Attribute: SerializeField*
private:
GameObject* startPositionPrefab;
private:
ArrayND<char, 2>* dungeon;
private:
List_T<DungeonRoom>* rooms;
private:
List_T<DungeonCorridor>* corridors;
private:
StringBuilder* sb;
public:
ArrayND<char, 2>* getDungeon();
//Ignored empty method declaration
private:
void Awake();
public:
void Generate(int level);
public:
void GenerateDungeon();
public:
void GenerateCorridors();
public:
void GeneratePlayers(int level);
public:
void PreprocessDungeonSimple();
public:
void PreprocessDungeon();
public:
String* StringifyDungeon();
private:
void GenerateDebugDungeon();
private:
bool CanPlaceRoom(int x, int y, int width, int height);
public:
void Reset();
public:
DungeonGenerator();
};
}
}
}

View File

@ -0,0 +1,161 @@
#include "DungeonRoom.h"
namespace BS {
namespace Levels {
namespace Generator {
Array<String>* DungeonRoom::biga;
Array<String>* DungeonRoom::bigb;
Array<String>* DungeonRoom::smalla;
Array<String>* DungeonRoom::smallb;
int DungeonRoom::getX(){
return this->x;
}
void DungeonRoom::setX(int value)
{
this->x = value;
}
int DungeonRoom::getY()
{
return this->y;
}
void DungeonRoom::setY(int value)
{
this->y = value;
}
int DungeonRoom::getWidth()
{
return this->width;
}
void DungeonRoom::setWidth(int value)
{
this->width = value;
}
int DungeonRoom::getHeight()
{
return this->height;
}
void DungeonRoom::setHeight(int value)
{
this->height = value;
}
DungeonRoom::DungeonRoom(int x, int y, int width, int height)
{
this->setX(x);
this->setY(y);
this->setWidth(width);
this->setHeight(height);
}
void DungeonRoom::WriteRoom(ArrayND<char, 2>* dungeon)
{
for (int i = this->getY(); i < (this->getY() + this->getHeight()); i += 1) {
for (int j = this->getX(); j < (this->getX() + this->getWidth()); j += 1) {
dungeon->SetData(j, i, 1);
}
}
for (int k = this->getX() + 1; k < ((this->getX() + this->getWidth()) - 1); k += 1) {
dungeon->SetData(k, (this->getY() + this->getHeight()) - 1, 11);
}
for (int l = this->getX() + 1; l < ((this->getX() + this->getWidth()) - 1); l += 1) {
dungeon->SetData(l, this->getY(), 13);
}
for (int m = this->getY() + 1; m < ((this->getY() + this->getHeight()) - 1); m += 1) {
dungeon->SetData(this->getX(), m, 14);
}
for (int n = this->getY() + 1; n < ((this->getY() + this->getHeight()) - 1); n += 1) {
dungeon->SetData((this->getX() + this->getWidth()) - 1, n, 12);
}
dungeon->SetData(this->getX(), this->getY(), 13);
dungeon->SetData((this->getX() + this->getWidth()) - 1, this->getY(), 13);
dungeon->SetData(this->getX(), (this->getY() + this->getHeight()) - 1, 13);
dungeon->SetData((this->getX() + this->getWidth()) - 1, (this->getY() + this->getHeight()) - 1, 13);
}
void DungeonRoom::GenerateAIPlayers(int level)
{
int num = UnityEngine::Random::Range(3, 5);
for (int i = 0; i < num; i += 1) {
int num2 = this->getX() + UnityEngine::Random::Range(1, this->getWidth() - 2);
int num3 = this->getY() + UnityEngine::Random::Range(1, this->getHeight() - 2);
Vector3* position = new Vector3((float)(num2) * Voxelizzer::world->voxelScale, Voxelizzer::world->voxelScale, (float)(num3) * Voxelizzer::world->voxelScale);
Entity::SSpawn(EntityType::Mob, UnityEngine::Random::Range(10000, 10005), level, this->GenerateName(), 0u, null, false, position, );
}
}
String* DungeonRoom::GenerateName()
{
UnityEngine::Random::State* state = UnityEngine::Random::state;
String* text = DungeonRoom::biga->GetData(UnityEngine::Random::Range(0, DungeonRoom::biga->Length));
bool flag = false;
int num = UnityEngine::Random::Range(3, 7);
for (int i = 0; i < num; i += 1) {
if (flag) {
*text += DungeonRoom::smallb->GetData(UnityEngine::Random::Range(0, DungeonRoom::smallb->Length));
}
else {
*text += DungeonRoom::smalla->GetData(UnityEngine::Random::Range(0, DungeonRoom::smalla->Length));
}
flag = !flag;
}
UnityEngine::Random::state = state;
return text;
}
DungeonRoom::DungeonRoom()
{
Array<String>* expr_06 = new Array<String>(5);
expr_06->SetData(0, new String("A"));
expr_06->SetData(1, new String("E"));
expr_06->SetData(2, new String("I"));
expr_06->SetData(3, new String("O"));
expr_06->SetData(4, new String("U"));
DungeonRoom::biga = expr_06;
Array<String>* expr_3A = new Array<String>(19);
expr_3A->SetData(0, new String("B"));
expr_3A->SetData(1, new String("C"));
expr_3A->SetData(2, new String("D"));
expr_3A->SetData(3, new String("E"));
expr_3A->SetData(4, new String("F"));
expr_3A->SetData(5, new String("G"));
expr_3A->SetData(6, new String("H"));
expr_3A->SetData(7, new String("J"));
expr_3A->SetData(8, new String("K"));
expr_3A->SetData(9, new String("L"));
expr_3A->SetData(10, new String("M"));
expr_3A->SetData(11, new String("N"));
expr_3A->SetData(12, new String("P"));
expr_3A->SetData(13, new String("Q"));
expr_3A->SetData(14, new String("R"));
expr_3A->SetData(15, new String("V"));
expr_3A->SetData(16, new String("X"));
expr_3A->SetData(17, new String("Y"));
expr_3A->SetData(18, new String("Z"));
DungeonRoom::bigb = expr_3A;
Array<String>* expr_E7 = new Array<String>(5);
expr_E7->SetData(0, new String("a"));
expr_E7->SetData(1, new String("e"));
expr_E7->SetData(2, new String("i"));
expr_E7->SetData(3, new String("o"));
expr_E7->SetData(4, new String("u"));
DungeonRoom::smalla = expr_E7;
Array<String>* expr_11B = new Array<String>(19);
expr_11B->SetData(0, new String("b"));
expr_11B->SetData(1, new String("c"));
expr_11B->SetData(2, new String("d"));
expr_11B->SetData(3, new String("e"));
expr_11B->SetData(4, new String("f"));
expr_11B->SetData(5, new String("g"));
expr_11B->SetData(6, new String("h"));
expr_11B->SetData(7, new String("j"));
expr_11B->SetData(8, new String("k"));
expr_11B->SetData(9, new String("l"));
expr_11B->SetData(10, new String("m"));
expr_11B->SetData(11, new String("n"));
expr_11B->SetData(12, new String("p"));
expr_11B->SetData(13, new String("q"));
expr_11B->SetData(14, new String("r"));
expr_11B->SetData(15, new String("v"));
expr_11B->SetData(16, new String("x"));
expr_11B->SetData(17, new String("y"));
expr_11B->SetData(18, new String("z"));
DungeonRoom::smallb = expr_11B;
}
}
}
}

View File

@ -0,0 +1,64 @@
#pragma once
#include <System/System.h>
#include "UnityEngine.h"
#include "Vector3.h"
#include "Voxelizzer.h"
#include "Entity.h"
#include "EntityType.h"
#include "Quaternion.h"
using namespace UnityEngine;
using namespace VoxelToolbox;
using namespace BS::Player;
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class DungeonRoom : public virtual Object
{
private:
static Array<String>* biga;
private:
static Array<String>* bigb;
private:
static Array<String>* smalla;
private:
static Array<String>* smallb;
private:
int x;
private:
int y;
private:
int width;
private:
int height;
public:
int getX();
public:
void setX(int value);
public:
int getY();
public:
void setY(int value);
public:
int getWidth();
public:
void setWidth(int value);
public:
int getHeight();
public:
void setHeight(int value);
public:
DungeonRoom(int x, int y, int width, int height);
public:
virtual void WriteRoom(ArrayND<char, 2>* dungeon);
public:
virtual void GenerateAIPlayers(int level);
public:
String* GenerateName();
static:
DungeonRoom();
};
}
}
}

View File

@ -0,0 +1,23 @@
#include "DungeonStartRoom.h"
namespace BS {
namespace Levels {
namespace Generator {
DungeonStartRoom::DungeonStartRoom(int x, int y, int width, int height) : DungeonRoom(x, y, 8, 8){
}
void DungeonStartRoom::GenerateSpawnPoint(GameObject* startPositionPrefab)
{
bool flag = false;
while (!flag) {
int num = DungeonRoom::getX() + UnityEngine::Random::Range(1, DungeonRoom::getWidth() - 2);
int num2 = DungeonRoom::getY() + UnityEngine::Random::Range(1, DungeonRoom::getHeight() - 2);
flag = true;
UnityEngine::Object::Instantiate<GameObject>(startPositionPrefab, Vector3::zero, Quaternion::identity)->transform->position = new Vector3((float)(num) * Voxelizzer::world->voxelScale, Voxelizzer::world->voxelScale, (float)(num2) * Voxelizzer::world->voxelScale);
}
}
void DungeonStartRoom::GenerateAIPlayers(int level)
{
}
}
}
}

View File

@ -0,0 +1,27 @@
#pragma once
#include <System/System.h>
#include "DungeonRoom.h"
#include "GameObject.h"
#include "UnityEngine.h"
#include "Vector3.h"
#include "Voxelizzer.h"
#include "Quaternion.h"
using namespace UnityEngine;
using namespace VoxelToolbox;
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class DungeonStartRoom : public virtual DungeonRoom, public virtual Object
{
public:
DungeonStartRoom(int x, int y, int width, int height);
public:
void GenerateSpawnPoint(GameObject* startPositionPrefab);
public:
virtual void GenerateAIPlayers(int level);
};
}
}
}

View File

@ -0,0 +1,46 @@
#include "IntRect.h"
namespace BS {
namespace Levels {
namespace Generator {
int IntRect::getX(){
return this->x;
}
void IntRect::setX(int value)
{
this->x = value;
}
int IntRect::getY()
{
return this->y;
}
void IntRect::setY(int value)
{
this->y = value;
}
int IntRect::getWidth()
{
return this->width;
}
void IntRect::setWidth(int value)
{
this->width = value;
}
int IntRect::getHeight()
{
return this->height;
}
void IntRect::setHeight(int value)
{
this->height = value;
}
IntRect::IntRect(int x, int y, int width, int height)
{
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}
}
}
}

View File

@ -0,0 +1,39 @@
#pragma once
#include <System/System.h>
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class IntRect : public virtual Object
{
private:
int x;
private:
int y;
private:
int width;
private:
int height;
public:
int getX();
public:
void setX(int value);
public:
int getY();
public:
void setY(int value);
public:
int getWidth();
public:
void setWidth(int value);
public:
int getHeight();
public:
void setHeight(int value);
public:
IntRect(int x, int y, int width, int height);
};
}
}
}

View File

@ -0,0 +1,71 @@
#include "TileConsts.h"
namespace BS {
namespace Levels {
namespace Generator {
bool TileConsts::isWall(char tile){
switch (tile){
case 11:
return true;
case 12:
return true;
case 13:
return true;
case 14:
return true;
case 15:
return true;
case 16:
return true;
case 17:
return true;
case 18:
return true;
case 21:
return true;
case 22:
return true;
case 23:
return true;
}
return false;
}
TileConsts::TileConsts()
{
Floor = 1;
Floor_Var1 = 2;
Floor_Up = 3;
Floor_Left = 4;
Floor_Down = 5;
Floor_Right = 6;
Floor_UpRight = 7;
Floor_UpLeft = 8;
Floor_DownLeft = 9;
Floor_DownRight = 10;
Wall_Up = 11;
Wall_Right = 12;
Wall_Down = 13;
Wall_Left = 14;
Wall_Corner_TopRight = 15;
Wall_Corner_TopLeft = 16;
Wall_Corner_BottomRight = 17;
Wall_Corner_BottomRight_Outside = 23;
Wall_Corner_BottomLeft = 18;
Wall_Corner_BottomLeft_Outside = 21;
Wall_Corner_BottomLeft_Half_Outside = 22;
Roof_Wood_Single = 19;
Stair_Down = 20;
}
}
}
}

View File

@ -0,0 +1,63 @@
#pragma once
#include <System/System.h>
using namespace System;
namespace BS {
namespace Levels {
namespace Generator {
class TileConsts : public virtual Object
{
public:
char Floor;
public:
char Floor_Var1;
public:
char Floor_Up;
public:
char Floor_Left;
public:
char Floor_Down;
public:
char Floor_Right;
public:
char Floor_UpRight;
public:
char Floor_UpLeft;
public:
char Floor_DownLeft;
public:
char Floor_DownRight;
public:
char Wall_Up;
public:
char Wall_Right;
public:
char Wall_Down;
public:
char Wall_Left;
public:
char Wall_Corner_TopRight;
public:
char Wall_Corner_TopLeft;
public:
char Wall_Corner_BottomRight;
public:
char Wall_Corner_BottomRight_Outside;
public:
char Wall_Corner_BottomLeft;
public:
char Wall_Corner_BottomLeft_Outside;
public:
char Wall_Corner_BottomLeft_Half_Outside;
public:
char Roof_Wood_Single;
public:
char Stair_Down;
public:
static bool isWall(char tile);
public:
TileConsts();
};
}
}
}

View File

@ -0,0 +1,72 @@
#include "world_generator.h"
Ref<PlanetData> WorldGenerator::get_planet_data(const int index) const {
ERR_FAIL_INDEX_V(index, _planet_datas.size(), Ref<PlanetData>());
return _planet_datas.get(index);
}
void WorldGenerator::set_planet_data(const int index, const Ref<PlanetData> planet_data) {
ERR_FAIL_INDEX(index, _planet_datas.size());
_planet_datas.set(index, planet_data);
}
void WorldGenerator::add_planet_data(const Ref<PlanetData> planet_data) {
_planet_datas.push_back(planet_data);
}
void WorldGenerator::remove_planet_data(const int index) {
ERR_FAIL_INDEX(index, _planet_datas.size());
_planet_datas.remove(index);
}
int WorldGenerator::get_planet_data_count() const {
return _planet_datas.size();
}
Vector<Variant> WorldGenerator::get_planet_datas() {
Vector<Variant> r;
for (int i = 0; i < _planet_datas.size(); i++) {
r.push_back(_planet_datas[i].get_ref_ptr());
}
return r;
}
void WorldGenerator::set_planet_datas(const Vector<Variant> &planet_datas) {
_planet_datas.clear();
for (int i = 0; i < planet_datas.size(); i++) {
Ref<PlanetData> planet_data = Ref<PlanetData>(planet_datas[i]);
_planet_datas.push_back(planet_data);
}
}
Ref<Planet> WorldGenerator::setup_planet(int seed) {
if (has_method("_setup_planet")) {
return call("_setup_planet");
}
return Ref<Planet>(NULL);
}
WorldGenerator::WorldGenerator() {
}
WorldGenerator::~WorldGenerator() {
_planet_datas.clear();
}
void WorldGenerator::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "planet", PROPERTY_HINT_RESOURCE_TYPE, "Planet"), "_setup_planet", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_planet", "seed"), &WorldGenerator::setup_planet);
ClassDB::bind_method(D_METHOD("get_planet_data", "index"), &WorldGenerator::get_planet_data);
ClassDB::bind_method(D_METHOD("set_planet_data", "index", "data"), &WorldGenerator::set_planet_data);
ClassDB::bind_method(D_METHOD("add_planet_data", "planet_data"), &WorldGenerator::add_planet_data);
ClassDB::bind_method(D_METHOD("remove_planet_data", "index"), &WorldGenerator::remove_planet_data);
ClassDB::bind_method(D_METHOD("get_planet_data_count"), &WorldGenerator::get_planet_data_count);
ClassDB::bind_method(D_METHOD("get_planet_datas"), &WorldGenerator::get_planet_datas);
ClassDB::bind_method(D_METHOD("set_planet_datas", "planet_datas"), &WorldGenerator::set_planet_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "planet_datas", PROPERTY_HINT_NONE, "17/17:PlanetData", PROPERTY_USAGE_DEFAULT, "PlanetData"), "set_planet_datas", "get_planet_datas");
}

View File

@ -0,0 +1,39 @@
#ifndef WORLD_GENERATOR_H
#define WORLD_GENERATOR_H
#include "core/resource.h"
#include "core/vector.h"
#include "data/planet_data.h"
#include "main/planet.h"
class WorldGenerator : public Resource {
GDCLASS(WorldGenerator, Resource);
public:
Ref<PlanetData> get_planet_data(const int index) const;
void set_planet_data(const int index, const Ref<PlanetData> planet_data);
void add_planet_data(const Ref<PlanetData> planet_data);
void remove_planet_data(const int index);
int get_planet_data_count() const;
Vector<Variant> get_planet_datas();
void set_planet_datas(const Vector<Variant> &planet_datas);
Ref<Planet> setup_planet(int seed);
WorldGenerator();
~WorldGenerator();
protected:
static void _bind_methods();
private:
Vector<Ref<PlanetData> > _planet_datas;
};
#endif