From e5f5d205f8aea478294ad4796b0f3c771dd7e7cf Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 9 Jan 2020 04:28:08 +0100 Subject: [PATCH] Clang format everything. --- data/biome_data.cpp | 17 +- data/biome_data.h | 26 +- data/dungeon_corridor_data.cpp | 1 - data/dungeon_corridor_data.h | 2 +- data/dungeon_data.cpp | 20 +- data/dungeon_data.h | 34 +-- data/dungeon_room_data.cpp | 16 +- data/dungeon_room_data.h | 26 +- data/planet_data.cpp | 9 +- data/planet_data.h | 16 +- data/world_generator_prop_data.cpp | 8 +- data/world_generator_prop_data.h | 12 +- main/biome.cpp | 30 +-- main/biome.h | 26 +- main/dungeon.cpp | 28 +-- main/dungeon.h | 30 +-- main/dungeon_corridor.cpp | 1 - main/dungeon_corridor.h | 2 +- main/dungeon_room.cpp | 38 +-- main/dungeon_room.h | 36 +-- main/planet.cpp | 22 +- main/planet.h | 25 +- queued/DungeonCorridor.cpp | 195 +++++++-------- queued/DungeonCorridor.h | 86 ++++--- queued/DungeonEndRoom.cpp | 64 ++--- queued/DungeonEndRoom.h | 26 +- queued/DungeonGenerator.cpp | 376 ++++++++++++++--------------- queued/DungeonGenerator.h | 164 +++++++------ queued/DungeonRoom.cpp | 299 +++++++++++------------ queued/DungeonRoom.h | 125 +++++----- queued/DungeonStartRoom.cpp | 37 ++- queued/DungeonStartRoom.h | 33 +-- queued/IntRect.cpp | 78 +++--- queued/IntRect.h | 79 +++--- queued/TileConsts.cpp | 113 +++++---- queued/TileConsts.h | 139 ++++++----- register_types.cpp | 16 +- world_generator.cpp | 1 - world_generator.h | 4 +- 39 files changed, 1136 insertions(+), 1124 deletions(-) diff --git a/data/biome_data.cpp b/data/biome_data.cpp index a0ff792..aebad17 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -281,21 +281,20 @@ void BiomeData::set_liquid_voxel_surfaces(const Vector &voxel_surfaces) #endif BiomeData::BiomeData() { - } BiomeData::~BiomeData() { _dungeon_datas.clear(); _prop_datas.clear(); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); - #endif +#endif } void BiomeData::_bind_methods() { @@ -341,7 +340,7 @@ void BiomeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &BiomeData::set_prop_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &BiomeData::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &BiomeData::set_entity_data); @@ -352,9 +351,9 @@ void BiomeData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_datas"), &BiomeData::get_entity_datas); ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &BiomeData::set_entity_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &BiomeData::get_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &BiomeData::set_environment_data); @@ -387,5 +386,5 @@ void BiomeData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &BiomeData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &BiomeData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); - #endif +#endif } diff --git a/data/biome_data.h b/data/biome_data.h index b729f53..34247b3 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -1,19 +1,19 @@ #ifndef dungeon_data_H #define dungeon_data_H -#include "core/resource.h" -#include "core/vector.h" #include "core/math/vector2.h" -#include "core/ustring.h" +#include "core/resource.h" #include "core/script_language.h" +#include "core/ustring.h" +#include "core/vector.h" #include "../main/biome.h" #include "dungeon_data.h" #include "world_generator_prop_data.h" #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#include "../../voxelman/world/environment_data.h" #endif #ifdef ESS_PRESENT @@ -22,7 +22,7 @@ class BiomeData : public Resource { GDCLASS(BiomeData, Resource); - + public: String get_target_class_name(); void set_target_class_name(String name); @@ -60,7 +60,7 @@ public: Vector get_prop_datas(); void set_prop_datas(const Vector &prop_datas); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); @@ -70,9 +70,9 @@ public: Vector get_entity_datas(); void set_entity_datas(const Vector &entity_datas); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -102,7 +102,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); - #endif +#endif BiomeData(); ~BiomeData(); @@ -122,15 +122,15 @@ private: Vector > _dungeon_datas; Vector > _prop_datas; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; - #endif +#endif }; #endif diff --git a/data/dungeon_corridor_data.cpp b/data/dungeon_corridor_data.cpp index f60c956..ca7b1f9 100644 --- a/data/dungeon_corridor_data.cpp +++ b/data/dungeon_corridor_data.cpp @@ -19,7 +19,6 @@ DungeonCorridorData::DungeonCorridorData() { _max_connections = 2; } DungeonCorridorData::~DungeonCorridorData() { - } void DungeonCorridorData::_bind_methods() { diff --git a/data/dungeon_corridor_data.h b/data/dungeon_corridor_data.h index b895b3c..2f226db 100644 --- a/data/dungeon_corridor_data.h +++ b/data/dungeon_corridor_data.h @@ -7,7 +7,7 @@ class DungeonCorridorData : public DungeonRoomData { GDCLASS(DungeonCorridorData, DungeonRoomData); - + public: int get_max_connections(); void set_max_connections(int value); diff --git a/data/dungeon_data.cpp b/data/dungeon_data.cpp index 0c6bc10..e3368c6 100644 --- a/data/dungeon_data.cpp +++ b/data/dungeon_data.cpp @@ -412,24 +412,24 @@ DungeonData::DungeonData() { _max_room_count = 0; } DungeonData::~DungeonData() { - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment_datas.clear(); - #endif +#endif _dungeon_room_datas.clear(); _dungeon_start_room_datas.clear(); _dungeon_end_room_datas.clear(); _dungeon_corridor_datas.clear(); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _entity_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); - #endif +#endif } void DungeonData::_bind_methods() { @@ -524,7 +524,7 @@ void DungeonData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_dungeon_corridor_datas", "dungeon_corridor_datas"), &DungeonData::set_dungeon_corridor_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridor_datas", PROPERTY_HINT_NONE, "17/17:DungeonCorridorData", PROPERTY_USAGE_DEFAULT, "DungeonCorridorData"), "set_dungeon_corridor_datas", "get_dungeon_corridor_datas"); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonData::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonData::set_entity_data); @@ -535,9 +535,9 @@ void DungeonData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonData::get_entity_datas); ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonData::set_entity_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonData::get_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonData::set_environment_data); @@ -570,5 +570,5 @@ void DungeonData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &DungeonData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &DungeonData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); - #endif +#endif } diff --git a/data/dungeon_data.h b/data/dungeon_data.h index 6d0dbfa..e29c6f2 100644 --- a/data/dungeon_data.h +++ b/data/dungeon_data.h @@ -2,17 +2,17 @@ #define DUNGEON_DATA_H #include "core/resource.h" -#include "core/vector.h" -#include "core/ustring.h" #include "core/script_language.h" +#include "core/ustring.h" +#include "core/vector.h" #include "../main/dungeon.h" -#include "dungeon_room_data.h" #include "dungeon_corridor_data.h" +#include "dungeon_room_data.h" #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#include "../../voxelman/world/environment_data.h" #endif #ifdef ESS_PRESENT @@ -21,7 +21,7 @@ class DungeonData : public Resource { GDCLASS(DungeonData, Resource); - + public: String get_target_class_name(); void set_target_class_name(String name); @@ -59,7 +59,7 @@ public: int get_max_room_count(); void set_max_room_count(int value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -69,7 +69,7 @@ public: Vector get_environment_datas(); void set_environment_datas(const Vector &environment_datas); - #endif +#endif //Rooms Ref get_dungeon_room_data(const int index) const; @@ -111,7 +111,7 @@ public: Vector get_dungeon_corridor_datas(); void set_dungeon_corridor_datas(const Vector &dungeon_corridor_datas); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); @@ -121,9 +121,9 @@ public: Vector get_entity_datas(); void set_entity_datas(const Vector &entity_datas); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Surfaces Ref get_voxel_surface(const int index) const; void set_voxel_surface(const int index, const Ref voxel_surface); @@ -143,7 +143,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); - #endif +#endif DungeonData(); ~DungeonData(); @@ -168,23 +168,23 @@ private: int _min_room_count; int _max_room_count; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Vector > _environment_datas; - #endif +#endif Vector > _dungeon_room_datas; Vector > _dungeon_start_room_datas; Vector > _dungeon_end_room_datas; Vector > _dungeon_corridor_datas; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; - #endif +#endif }; #endif diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp index f516eb6..c6c3446 100644 --- a/data/dungeon_room_data.cpp +++ b/data/dungeon_room_data.cpp @@ -279,15 +279,15 @@ DungeonRoomData::DungeonRoomData() { DungeonRoomData::~DungeonRoomData() { _prop_datas.clear(); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); - #endif +#endif } void DungeonRoomData::_bind_methods() { @@ -340,7 +340,7 @@ void DungeonRoomData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoomData::set_prop_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoomData::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoomData::set_entity_data); @@ -351,9 +351,9 @@ void DungeonRoomData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoomData::get_entity_datas); ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoomData::set_entity_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonRoomData::get_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonRoomData::set_environment_data); @@ -386,5 +386,5 @@ void DungeonRoomData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &DungeonRoomData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &DungeonRoomData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); - #endif +#endif } diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index 9af681b..d72c449 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -2,8 +2,8 @@ #define DUNGEON_ROOM_DATA_H #include "core/resource.h" -#include "core/ustring.h" #include "core/script_language.h" +#include "core/ustring.h" #include "../main/dungeon_room.h" #include "world_generator_prop_data.h" @@ -13,13 +13,13 @@ #endif #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#include "../../voxelman/world/environment_data.h" #endif class DungeonRoomData : public Resource { GDCLASS(DungeonRoomData, Resource); - + public: String get_target_class_name(); void set_target_class_name(String name); @@ -60,7 +60,7 @@ public: Vector get_prop_datas(); void set_prop_datas(const Vector &prop_datas); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //TOO: Environments are useful for every game, this should be decoupled from voxelman. //Environments @@ -92,11 +92,11 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); - #else - //TODO Create generic binds - #endif +#else +//TODO Create generic binds +#endif - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); @@ -106,7 +106,7 @@ public: Vector get_entity_datas(); void set_entity_datas(const Vector &entity_datas); - #endif +#endif DungeonRoomData(); ~DungeonRoomData(); @@ -130,15 +130,15 @@ private: Vector > _prop_datas; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; - #endif +#endif }; #endif diff --git a/data/planet_data.cpp b/data/planet_data.cpp index eee4a62..3cb001d 100644 --- a/data/planet_data.cpp +++ b/data/planet_data.cpp @@ -121,7 +121,6 @@ void PlanetData::set_environment_datas(const Vector &environment_datas) } } - //// Surfaces //// Ref PlanetData::get_voxel_surface(const int index) const { ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); @@ -210,11 +209,11 @@ PlanetData::~PlanetData() { _biome_datas.clear(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment_datas.clear(); _voxel_surfaces.clear(); _liquid_voxel_surfaces.clear(); - #endif +#endif } void PlanetData::_bind_methods() { @@ -253,7 +252,7 @@ void PlanetData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_biome_datas", "biome_datas"), &PlanetData::set_biome_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "biome_datas", PROPERTY_HINT_NONE, "17/17:BiomeData", PROPERTY_USAGE_DEFAULT, "BiomeData"), "set_biome_datas", "get_biome_datas"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &PlanetData::get_environment_data); ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &PlanetData::set_environment_data); @@ -286,5 +285,5 @@ void PlanetData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &PlanetData::get_liquid_voxel_surfaces); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces", "voxel_surfaces"), &PlanetData::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); - #endif +#endif } diff --git a/data/planet_data.h b/data/planet_data.h index 82eb51d..c775714 100644 --- a/data/planet_data.h +++ b/data/planet_data.h @@ -2,22 +2,22 @@ #define biome_data_H #include "core/resource.h" -#include "core/ustring.h" #include "core/script_language.h" +#include "core/ustring.h" #include "../../fastnoise/fastnoise_noise_params.h" -#include "../main/planet.h" #include "../data/biome_data.h" +#include "../main/planet.h" #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" +#include "../../voxelman/world/environment_data.h" #endif class PlanetData : public Resource { GDCLASS(PlanetData, Resource); - + public: int get_id() const; void set_id(const int value); @@ -47,7 +47,7 @@ public: Vector get_biome_datas(); void set_biome_datas(const Vector &biome_datas); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environments Ref get_environment_data(const int index) const; void set_environment_data(const int index, const Ref environment_data); @@ -77,7 +77,7 @@ public: Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &voxel_surfaces); - #endif +#endif PlanetData(); ~PlanetData(); @@ -97,11 +97,11 @@ private: Ref _temperature_noise_params; Vector > _biome_datas; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Vector > _environment_datas; Vector > _voxel_surfaces; Vector > _liquid_voxel_surfaces; - #endif +#endif }; #endif diff --git a/data/world_generator_prop_data.cpp b/data/world_generator_prop_data.cpp index 6f4327b..82033fe 100644 --- a/data/world_generator_prop_data.cpp +++ b/data/world_generator_prop_data.cpp @@ -27,20 +27,18 @@ Ref WorldGeneratorPropData::get_prop(int seed) { #endif WorldGeneratorPropData::WorldGeneratorPropData() { - } WorldGeneratorPropData::~WorldGeneratorPropData() { - } void WorldGeneratorPropData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); - #else +#else BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); - #endif +#endif ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &WorldGeneratorPropData::can_spawn); ClassDB::bind_method(D_METHOD("get_prop", "seed"), &WorldGeneratorPropData::get_prop); diff --git a/data/world_generator_prop_data.h b/data/world_generator_prop_data.h index 7301086..71a3bd1 100644 --- a/data/world_generator_prop_data.h +++ b/data/world_generator_prop_data.h @@ -9,23 +9,21 @@ class WorldGeneratorPropData : public Resource { GDCLASS(WorldGeneratorPropData, Resource); - -public: +public: bool can_spawn(int seed); - - #ifdef VOXELMAN_PRESENT + +#ifdef VOXELMAN_PRESENT Ref get_prop(int seed); - #else +#else Ref get_prop(int seed); - #endif +#endif WorldGeneratorPropData(); ~WorldGeneratorPropData(); protected: static void _bind_methods(); - }; #endif diff --git a/main/biome.cpp b/main/biome.cpp index 1041af1..9244d29 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -184,43 +184,43 @@ Biome::Biome() { _current_seed = 0; } Biome::~Biome() { - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment.unref(); - #endif +#endif _data.unref(); _prop_datas.clear(); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif _dungeons.clear(); } void Biome::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - - #ifdef VOXELMAN_PRESENT + +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #else +#else BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #endif +#endif ClassDB::bind_method(D_METHOD("setup"), &Biome::setup); ClassDB::bind_method(D_METHOD("setup_library", "library"), &Biome::setup_library); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Biome::_setup_library); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack_bind); - #else +#else ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk); - #endif +#endif ClassDB::bind_method(D_METHOD("get_current_seed"), &Biome::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Biome::set_current_seed); @@ -230,11 +230,11 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &Biome::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Biome::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); - #endif +#endif ClassDB::bind_method(D_METHOD("get_data"), &Biome::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Biome::set_data); @@ -247,14 +247,14 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &Biome::remove_prop_data); ClassDB::bind_method(D_METHOD("get_prop_data_count"), &Biome::get_prop_data_count); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Biome::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Biome::set_entity_data); ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Biome::add_entity_data); ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Biome::remove_entity_data); ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Biome::get_entity_data_count); - #endif +#endif //Dungeons ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Biome::get_dungeon); diff --git a/main/biome.h b/main/biome.h index 8bf8f37..1e2aacf 100644 --- a/main/biome.h +++ b/main/biome.h @@ -9,8 +9,8 @@ #include "../data/world_generator_prop_data.h" #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxelman_library.h" +#include "../../voxelman/world/environment_data.h" #include "../../voxelman/world/voxel_chunk.h" #endif @@ -22,7 +22,7 @@ class BiomeData; class Biome : public Reference { GDCLASS(Biome, Reference); - + public: int get_current_seed(); void set_current_seed(int value); @@ -30,11 +30,11 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); - #endif +#endif Ref get_data(); void set_data(Ref value); @@ -47,14 +47,14 @@ public: int get_prop_data_count() const; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); void add_entity_data(const Ref entity_data); void remove_entity_data(const int index); int get_entity_data_count() const; - #endif +#endif //Dungeons Ref get_dungeon(const int index) const; @@ -65,7 +65,7 @@ public: void setup(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_stack(VoxelChunk *chunk, int x, int z, bool spawn_mobs); @@ -73,11 +73,11 @@ public: void setup_library(Ref library); void _setup_library(Ref library); - #else +#else void generate_chunk(Node *chunk, bool spawn_mobs); void setup_library(Ref library); - #endif +#endif Biome(); ~Biome(); @@ -90,16 +90,16 @@ private: Vector2 _level_range; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Ref _environment; - #endif +#endif Ref _data; Vector > _prop_datas; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif Vector > _dungeons; }; diff --git a/main/dungeon.cpp b/main/dungeon.cpp index ca1cfed..33bea93 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -295,9 +295,9 @@ Dungeon::Dungeon() { _room_count = 0; } Dungeon::~Dungeon() { - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment.unref(); - #endif +#endif _data.unref(); _dungeon_rooms.clear(); @@ -305,35 +305,35 @@ Dungeon::~Dungeon() { _dungeon_end_rooms.clear(); _dungeon_corridors.clear(); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif } void Dungeon::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #else +#else BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #endif +#endif ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("setup_library", "library"), &Dungeon::setup_library); ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Dungeon::_setup_library); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure); - #else +#else ClassDB::bind_method(D_METHOD("setup_library", "library"), &Dungeon::setup_library); ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk); - #endif +#endif ClassDB::bind_method(D_METHOD("get_current_seed"), &Dungeon::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Dungeon::set_current_seed); @@ -374,12 +374,12 @@ void Dungeon::_bind_methods() { ClassDB::bind_method(D_METHOD("set_room_count", "value"), &Dungeon::set_room_count); ADD_PROPERTY(PropertyInfo(Variant::INT, "room_count"), "set_room_count", "get_room_count"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environment ClassDB::bind_method(D_METHOD("get_environment"), &Dungeon::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Dungeon::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); - #endif +#endif ClassDB::bind_method(D_METHOD("get_data"), &Dungeon::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Dungeon::set_data); @@ -415,14 +415,14 @@ void Dungeon::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_dungeon_corridor", "index"), &Dungeon::remove_dungeon_corridor); ClassDB::bind_method(D_METHOD("get_dungeon_corridor_count"), &Dungeon::get_dungeon_corridor_count); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Dungeon::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Dungeon::set_entity_data); ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Dungeon::add_entity_data); ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Dungeon::remove_entity_data); ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Dungeon::get_entity_data_count); - #endif +#endif BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); diff --git a/main/dungeon.h b/main/dungeon.h index cf89a32..6b6f87c 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -3,16 +3,16 @@ #include "core/reference.h" -#include "dungeon_room.h" #include "dungeon_corridor.h" +#include "dungeon_room.h" #include "../data/dungeon_data.h" #ifdef VOXELMAN_PRESENT +#include "../../voxelman/library/voxelman_library.h" +#include "../../voxelman/world/environment_data.h" #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/voxel_structure.h" -#include "../../voxelman/world/environment_data.h" -#include "../../voxelman/library/voxelman_library.h" #else #include "scene/main/node.h" #endif @@ -25,7 +25,7 @@ class DungeonData; class Dungeon : public Reference { GDCLASS(Dungeon, Reference); - + public: int get_current_seed(); void set_current_seed(int value); @@ -57,11 +57,11 @@ public: int get_room_count(); void set_room_count(int value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); - #endif +#endif Ref get_data(); void set_data(Ref value); @@ -94,28 +94,28 @@ public: void remove_dungeon_corridor(const int index); int get_dungeon_corridor_count() const; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_datas); void add_entity_data(const Ref entity_datas); void remove_entity_data(const int index); int get_entity_data_count() const; - #endif +#endif void setup(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_structure(Ref structure, bool spawn_mobs); - #else +#else void setup_library(Ref library); void generate_chunk(Node *chunk, bool spawn_mobs); - #endif +#endif Ref generate_map(); @@ -140,9 +140,9 @@ private: int _room_count; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Ref _environment; - #endif +#endif Ref _data; Vector > _dungeon_rooms; @@ -150,9 +150,9 @@ private: Vector > _dungeon_end_rooms; Vector > _dungeon_corridors; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif }; #endif diff --git a/main/dungeon_corridor.cpp b/main/dungeon_corridor.cpp index 6e27d13..9be640b 100644 --- a/main/dungeon_corridor.cpp +++ b/main/dungeon_corridor.cpp @@ -31,7 +31,6 @@ int DungeonCorridor::get_dungeon_room_count() const { return _dungeon_rooms.size(); } - DungeonCorridor::DungeonCorridor() { _max_connections = 2; } diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h index f0885e3..d55158a 100644 --- a/main/dungeon_corridor.h +++ b/main/dungeon_corridor.h @@ -5,7 +5,7 @@ class DungeonCorridor : public DungeonRoom { GDCLASS(DungeonCorridor, DungeonRoom); - + public: int get_max_connections(); void set_max_connections(int value); diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index 7a65682..a662351 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -223,41 +223,41 @@ DungeonRoom::~DungeonRoom() { _data.unref(); _prop_datas.clear(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment.unref(); _structure.unref(); - #endif +#endif - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT _entity_datas.clear(); - #endif +#endif } void DungeonRoom::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - - #ifdef VOXELMAN_PRESENT + +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #else +#else BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #endif +#endif ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup); ClassDB::bind_method(D_METHOD("setup_library", "library"), &DungeonRoom::setup_library); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("_setup_library", "library"), &DungeonRoom::_setup_library); - #endif +#endif - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk_bind); ClassDB::bind_method(D_METHOD("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room); - #else +#else ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk); - #endif +#endif ClassDB::bind_method(D_METHOD("get_current_seed"), &DungeonRoom::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &DungeonRoom::set_current_seed); @@ -293,21 +293,21 @@ void DungeonRoom::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sizez", "value"), &DungeonRoom::set_sizez); ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &DungeonRoom::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &DungeonRoom::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); - #endif +#endif ClassDB::bind_method(D_METHOD("get_data"), &DungeonRoom::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &DungeonRoom::set_data); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PlanetData"), "set_data", "get_data"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_structure"), &DungeonRoom::get_structure); ClassDB::bind_method(D_METHOD("set_structure", "value"), &DungeonRoom::set_structure); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), "set_structure", "get_structure"); - #endif +#endif //Props ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoom::get_prop_data); @@ -316,12 +316,12 @@ void DungeonRoom::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoom::remove_prop_data); ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoom::get_prop_data_count); - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoom::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoom::set_entity_data); ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoom::add_entity_data); ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoom::remove_entity_data); ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoom::get_entity_data_count); - #endif +#endif } diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 5123e25..c03994f 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -4,14 +4,14 @@ #include "core/reference.h" #include "core/vector.h" -#include "../data/world_generator_prop_data.h" #include "../data/dungeon_room_data.h" +#include "../data/world_generator_prop_data.h" #ifdef VOXELMAN_PRESENT +#include "../../voxelman/library/voxelman_library.h" +#include "../../voxelman/world/environment_data.h" #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/voxel_structure.h" -#include "../../voxelman/world/environment_data.h" -#include "../../voxelman/library/voxelman_library.h" #else #include "scene/main/node.h" #endif @@ -24,7 +24,7 @@ class DungeonRoomData; class DungeonRoom : public Reference { GDCLASS(DungeonRoom, Reference); - + public: int get_current_seed(); void set_current_seed(int value); @@ -52,20 +52,20 @@ public: int get_sizez(); void set_sizez(int value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); - #endif +#endif Ref get_data(); void set_data(Ref value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Structure Ref get_structure(); void set_structure(Ref structure); - #endif +#endif //Props Ref get_prop_data(const int index) const; @@ -74,28 +74,28 @@ public: void remove_prop_data(const int index); int get_prop_data_count() const; - #ifdef ESS_PRESENT +#ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; void set_entity_data(const int index, const Ref entity_data); void add_entity_data(const Ref entity_data); void remove_entity_data(const int index); int get_entity_data_count() const; - #endif +#endif void setup(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); void generate_room(Ref structure, bool spawn_mobs); - #else +#else void setup_library(Ref library); void generate_chunk(Node *chunk, bool spawn_mobs); - #endif +#endif DungeonRoom(); ~DungeonRoom(); @@ -116,17 +116,17 @@ private: int _sizey; int _sizez; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Ref _environment; Ref _structure; - #endif +#endif Ref _data; Vector > _prop_datas; - - #ifdef ESS_PRESENT + +#ifdef ESS_PRESENT Vector > _entity_datas; - #endif +#endif }; #endif diff --git a/main/planet.cpp b/main/planet.cpp index ea49db5..ed8a694 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -155,9 +155,9 @@ Planet::Planet() { _current_seed = 0; } Planet::~Planet() { - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT _environment.unref(); - #endif +#endif _data.unref(); _biomes.clear(); @@ -167,25 +167,25 @@ Planet::~Planet() { void Planet::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup")); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #else +#else BIND_VMETHOD(MethodInfo("_setup_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - #endif +#endif ClassDB::bind_method(D_METHOD("setup"), &Planet::setup); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk_bind); ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Planet::_setup_library); - #else +#else ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk); - #endif +#endif ClassDB::bind_method(D_METHOD("setup_library", "library"), &Planet::setup_library); - + ClassDB::bind_method(D_METHOD("get_current_seed"), &Planet::get_current_seed); ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Planet::set_current_seed); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); @@ -194,11 +194,11 @@ void Planet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Planet::set_level_range); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &Planet::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Planet::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); - #endif +#endif ClassDB::bind_method(D_METHOD("get_data"), &Planet::get_data); ClassDB::bind_method(D_METHOD("set_data", "value"), &Planet::set_data); diff --git a/main/planet.h b/main/planet.h index c55f0e1..2b650f7 100644 --- a/main/planet.h +++ b/main/planet.h @@ -1,9 +1,8 @@ #ifndef PLANET_H #define PLANET_H -#include "core/reference.h" #include "core/image.h" - +#include "core/reference.h" #include "biome.h" #include "dungeon.h" @@ -11,17 +10,17 @@ #include "../data/planet_data.h" #ifdef VOXELMAN_PRESENT -#include "../../voxelman/world/voxel_chunk.h" -#include "../../voxelman/world/environment_data.h" #include "../../voxelman/library/voxel_surface.h" #include "../../voxelman/library/voxelman_library.h" +#include "../../voxelman/world/environment_data.h" +#include "../../voxelman/world/voxel_chunk.h" #endif class PlanetData; class Planet : public Reference { GDCLASS(Planet, Reference); - + public: int get_current_seed(); void set_current_seed(int value); @@ -29,12 +28,12 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); - #endif - +#endif + Ref get_data(); void set_data(Ref value); @@ -54,16 +53,16 @@ public: void setup(); - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT void setup_library(Ref library); void _setup_library(Ref library); void generate_chunk(VoxelChunk *chunk, bool spawn_mobs); void generate_chunk_bind(Node *chunk, bool spawn_mobs); - #else +#else void generate_chunk(Node *chunk, bool spawn_mobs); void setup_library(Ref library); - #endif +#endif Ref generate_map(); @@ -77,9 +76,9 @@ private: int _current_seed; Vector2 _level_range; - #ifdef VOXELMAN_PRESENT +#ifdef VOXELMAN_PRESENT Ref _environment; - #endif +#endif Ref _data; Vector > _biomes; diff --git a/queued/DungeonCorridor.cpp b/queued/DungeonCorridor.cpp index 7bee6d7..2ca91c3 100644 --- a/queued/DungeonCorridor.cpp +++ b/queued/DungeonCorridor.cpp @@ -1,101 +1,81 @@ #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* 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); +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 *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); } - 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* 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())) { + } + } + this->Write(dungeon, this->widthir); + this->Write(dungeon, this->heightir); +} +void DungeonCorridor::Write(ArrayND *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()) && (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))) { + } 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 (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); - } - } - } + } else { + if (i == ((rect->getY() + rect->getHeight()) - 1)) { + dungeon->SetData(j, i, 11); + } else { + dungeon->SetData(j, i, 1); } } } @@ -105,21 +85,22 @@ namespace BS { } } } - 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); - } - } - } } } +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); + } +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonCorridor.h b/queued/DungeonCorridor.h index e571b04..7cc8b63 100644 --- a/queued/DungeonCorridor.h +++ b/queued/DungeonCorridor.h @@ -1,49 +1,61 @@ #pragma once -#include #include "DungeonRoom.h" #include "IntRect.h" #include "Mathf.h" #include "UnityEngine.h" #include "Vector3.h" #include "Voxelizzer.h" +#include 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* dungeon); - private: - void Write(ArrayND* dungeon, IntRect* rect); - public: - virtual void GenerateAIPlayers(int level); - private: - void GenerateAIPlayers(int level, IntRect* rect); - }; - } - } -} +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 *dungeon); + +private: + void Write(ArrayND *dungeon, IntRect *rect); + +public: + virtual void GenerateAIPlayers(int level); + +private: + void GenerateAIPlayers(int level, IntRect *rect); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonEndRoom.cpp b/queued/DungeonEndRoom.cpp index 05cc920..93a7145 100644 --- a/queued/DungeonEndRoom.cpp +++ b/queued/DungeonEndRoom.cpp @@ -1,37 +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* 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); - } - +namespace Levels { +namespace Generator { +DungeonEndRoom::DungeonEndRoom(int x, int y, int width, int height) : + DungeonRoom(x, y, width, height) { +} +void DungeonEndRoom::WriteRoom(ArrayND *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); } + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonEndRoom.h b/queued/DungeonEndRoom.h index c86e52f..2fc55b4 100644 --- a/queued/DungeonEndRoom.h +++ b/queued/DungeonEndRoom.h @@ -1,19 +1,19 @@ #pragma once -#include #include "DungeonRoom.h" #include "UnityEngine.h" +#include 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* dungeon); - }; - } - } -} +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 *dungeon); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonGenerator.cpp b/queued/DungeonGenerator.cpp index f21ef90..1d32cba 100644 --- a/queued/DungeonGenerator.cpp +++ b/queued/DungeonGenerator.cpp @@ -1,205 +1,187 @@ #include "DungeonGenerator.h" namespace BS { - namespace Levels { - namespace Generator { - ArrayND* DungeonGenerator::getDungeon(){ - return this->dungeon; +namespace Levels { +namespace Generator { +ArrayND *DungeonGenerator::getDungeon() { + return this->dungeon; +} +void DungeonGenerator::Awake() { + this->rooms = new List_T(); + this->corridors = new List_T(); + this->dungeon = new ArrayND(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); } - void DungeonGenerator::Awake() - { - this->rooms = new List_T(); - this->corridors = new List_T(); - this->dungeon = new ArrayND(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); + } + } + 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::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(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; - } - } } } +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(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; +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonGenerator.h b/queued/DungeonGenerator.h index 4d0a929..e568508 100644 --- a/queued/DungeonGenerator.h +++ b/queued/DungeonGenerator.h @@ -1,17 +1,17 @@ #pragma once -#include -#include "MonoBehaviour.h" -#include "GameObject.h" -#include "DungeonRoom.h" -#include -#include "DungeonCorridor.h" -#include -#include "UnityEngine.h" #include "BrokenSeals.h" #include "CxNet.h" -#include "DungeonStartRoom.h" +#include "DungeonCorridor.h" #include "DungeonEndRoom.h" +#include "DungeonRoom.h" +#include "DungeonStartRoom.h" +#include "GameObject.h" +#include "MonoBehaviour.h" #include "TileConsts.h" +#include "UnityEngine.h" +#include +#include +#include using namespace UnityEngine; using namespace System::Collections::Generic; @@ -19,65 +19,87 @@ 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* dungeon; - private: - List_T* rooms; - private: - List_T* corridors; - private: - StringBuilder* sb; - public: - ArrayND* 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(); - }; - } - } -} +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 *dungeon; + +private: + List_T *rooms; + +private: + List_T *corridors; + +private: + StringBuilder *sb; + +public: + ArrayND *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(); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonRoom.cpp b/queued/DungeonRoom.cpp index 7d913d7..ccccdf8 100644 --- a/queued/DungeonRoom.cpp +++ b/queued/DungeonRoom.cpp @@ -1,161 +1,148 @@ #include "DungeonRoom.h" namespace BS { - namespace Levels { - namespace Generator { - Array* DungeonRoom::biga; - Array* DungeonRoom::bigb; - Array* DungeonRoom::smalla; - Array* 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* 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* expr_06 = new Array(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* expr_3A = new Array(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* expr_E7 = new Array(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* expr_11B = new Array(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; - } - +namespace Levels { +namespace Generator { +Array *DungeonRoom::biga; +Array *DungeonRoom::bigb; +Array *DungeonRoom::smalla; +Array *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 *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 *expr_06 = new Array(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 *expr_3A = new Array(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 *expr_E7 = new Array(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 *expr_11B = new Array(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; +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonRoom.h b/queued/DungeonRoom.h index 1d5f485..5d98eb0 100644 --- a/queued/DungeonRoom.h +++ b/queued/DungeonRoom.h @@ -1,64 +1,81 @@ #pragma once -#include -#include "UnityEngine.h" -#include "Vector3.h" -#include "Voxelizzer.h" #include "Entity.h" #include "EntityType.h" #include "Quaternion.h" +#include "UnityEngine.h" +#include "Vector3.h" +#include "Voxelizzer.h" +#include 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* biga; - private: - static Array* bigb; - private: - static Array* smalla; - private: - static Array* 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* dungeon); - public: - virtual void GenerateAIPlayers(int level); - public: - String* GenerateName(); - static: - DungeonRoom(); - }; - } - } -} +namespace Levels { +namespace Generator { +class DungeonRoom : public virtual Object { +private: + static Array *biga; + +private: + static Array *bigb; + +private: + static Array *smalla; + +private: + static Array *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 *dungeon); + +public: + virtual void GenerateAIPlayers(int level); + +public: + String *GenerateName(); + static : DungeonRoom(); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonStartRoom.cpp b/queued/DungeonStartRoom.cpp index 8453010..fa55b7c 100644 --- a/queued/DungeonStartRoom.cpp +++ b/queued/DungeonStartRoom.cpp @@ -1,23 +1,22 @@ #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(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) - { - } - - } +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(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) { +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/DungeonStartRoom.h b/queued/DungeonStartRoom.h index 044125a..36a7c29 100644 --- a/queued/DungeonStartRoom.h +++ b/queued/DungeonStartRoom.h @@ -1,27 +1,28 @@ #pragma once -#include #include "DungeonRoom.h" #include "GameObject.h" +#include "Quaternion.h" #include "UnityEngine.h" #include "Vector3.h" #include "Voxelizzer.h" -#include "Quaternion.h" +#include 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); - }; - } - } -} +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); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/IntRect.cpp b/queued/IntRect.cpp index 667cea8..56551ea 100644 --- a/queued/IntRect.cpp +++ b/queued/IntRect.cpp @@ -1,46 +1,38 @@ #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; - } - - } - } +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; +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/IntRect.h b/queued/IntRect.h index 6607084..6905d5d 100644 --- a/queued/IntRect.h +++ b/queued/IntRect.h @@ -3,37 +3,48 @@ 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); - }; - } - } -} +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); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/TileConsts.cpp b/queued/TileConsts.cpp index 054637a..98f98f5 100644 --- a/queued/TileConsts.cpp +++ b/queued/TileConsts.cpp @@ -1,71 +1,70 @@ #include "TileConsts.h" namespace BS { - namespace Levels { - namespace Generator { - bool TileConsts::isWall(char tile){ - switch (tile){ - case 11: - return true; +namespace Levels { +namespace Generator { +bool TileConsts::isWall(char tile) { + switch (tile) { + case 11: + return true; - case 12: - return true; + case 12: + return true; - case 13: - return true; + case 13: + return true; - case 14: - return true; + case 14: + return true; - case 15: - return true; + case 15: + return true; - case 16: - return true; + case 16: + return true; - case 17: - return true; + case 17: + return true; - case 18: - return true; + case 18: + return true; - case 21: - return true; + case 21: + return true; - case 22: - 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; - } - - } + 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; +} + +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/queued/TileConsts.h b/queued/TileConsts.h index 3056fe8..446ba9c 100644 --- a/queued/TileConsts.h +++ b/queued/TileConsts.h @@ -3,61 +3,84 @@ 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(); - }; - } - } -} +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(); +}; +} // namespace Generator +} // namespace Levels +} // namespace BS diff --git a/register_types.cpp b/register_types.cpp index 5bdb3a2..268eb44 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,16 +1,16 @@ #include "register_types.h" -#include "data/dungeon_room_data.h" +#include "data/biome_data.h" #include "data/dungeon_corridor_data.h" #include "data/dungeon_data.h" -#include "data/biome_data.h" +#include "data/dungeon_room_data.h" #include "data/planet_data.h" #include "data/world_generator_prop_data.h" -#include "main/dungeon_room.h" -#include "main/dungeon_corridor.h" -#include "main/dungeon.h" #include "main/biome.h" +#include "main/dungeon.h" +#include "main/dungeon_corridor.h" +#include "main/dungeon_room.h" #include "main/planet.h" #include "world_generator.h" @@ -30,9 +30,7 @@ void register_world_generator_types() { ClassDB::register_class(); ClassDB::register_class(); -} - -void unregister_world_generator_types() { - } +void unregister_world_generator_types() { +} diff --git a/world_generator.cpp b/world_generator.cpp index 7279c88..95ed1d2 100644 --- a/world_generator.cpp +++ b/world_generator.cpp @@ -48,7 +48,6 @@ Ref WorldGenerator::setup_planet(int seed) { } WorldGenerator::WorldGenerator() { - } WorldGenerator::~WorldGenerator() { _planet_datas.clear(); diff --git a/world_generator.h b/world_generator.h index 668c79c..9dbbb58 100644 --- a/world_generator.h +++ b/world_generator.h @@ -8,10 +8,9 @@ #include "main/planet.h" - class WorldGenerator : public Resource { GDCLASS(WorldGenerator, Resource); - + public: Ref get_planet_data(const int index) const; void set_planet_data(const int index, const Ref planet_data); @@ -32,7 +31,6 @@ protected: static void _bind_methods(); private: - Vector > _planet_datas; };