From 260c430f11b0b591eaf4714516419aa327d2842c Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 19 Apr 2021 22:28:21 +0200 Subject: [PATCH] Removed Dungeon, DungeonCorridor, and DungeonRoom. Added Building (it's Dungeon but with a cleaned up api.) --- SCsub | 4 +- config.py | 4 +- main/biome.cpp | 84 +- main/biome.h | 20 +- main/building.cpp | 641 +++++++++++++ main/{dungeon_room.h => building.h} | 89 +- main/dungeon.cpp | 1357 --------------------------- main/dungeon.h | 343 ------- main/dungeon_corridor.cpp | 84 -- main/dungeon_corridor.h | 56 -- main/dungeon_room.cpp | 836 ----------------- main/planet.cpp | 84 +- main/planet.h | 19 +- register_types.cpp | 8 +- 14 files changed, 772 insertions(+), 2857 deletions(-) create mode 100644 main/building.cpp rename main/{dungeon_room.h => building.h} (75%) delete mode 100644 main/dungeon.cpp delete mode 100644 main/dungeon.h delete mode 100644 main/dungeon_corridor.cpp delete mode 100644 main/dungeon_corridor.h delete mode 100644 main/dungeon_room.cpp diff --git a/SCsub b/SCsub index fd5e671..b0cd6c4 100644 --- a/SCsub +++ b/SCsub @@ -23,9 +23,7 @@ sources = [ "register_types.cpp", - "main/dungeon_room.cpp", - "main/dungeon_corridor.cpp", - "main/dungeon.cpp", + "main/building.cpp", "main/biome.cpp", "main/planet.cpp", diff --git a/config.py b/config.py index 4dbb3f7..6088560 100644 --- a/config.py +++ b/config.py @@ -9,9 +9,7 @@ def get_doc_classes(): "WorldGeneratorPropData", "Planet", - "Dungeon", - "DungeonRoom", - "DungeonCorridor", + "Building", "Biome", "WorldGenerator", diff --git a/main/biome.cpp b/main/biome.cpp index b60fa55..ffc5d50 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -139,46 +139,46 @@ void Biome::set_entity_datas(const Vector &entity_datas) { } #endif -//// Dungeons //// -Ref Biome::get_dungeon(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeons.size(), Ref()); +//// Buildings //// +Ref Biome::get_building(const int index) const { + ERR_FAIL_INDEX_V(index, _buildings.size(), Ref()); - return _dungeons.get(index); + return _buildings.get(index); } -void Biome::set_dungeon(const int index, const Ref dungeon) { - ERR_FAIL_INDEX(index, _dungeons.size()); +void Biome::set_building(const int index, const Ref building) { + ERR_FAIL_INDEX(index, _buildings.size()); - _dungeons.set(index, dungeon); + _buildings.set(index, building); } -void Biome::add_dungeon(const Ref dungeon) { - _dungeons.push_back(dungeon); +void Biome::add_building(const Ref building) { + _buildings.push_back(building); } -void Biome::remove_dungeon(const int index) { - ERR_FAIL_INDEX(index, _dungeons.size()); +void Biome::remove_building(const int index) { + ERR_FAIL_INDEX(index, _buildings.size()); - _dungeons.remove(index); + _buildings.remove(index); } -int Biome::get_dungeon_count() const { - return _dungeons.size(); +int Biome::get_building_count() const { + return _buildings.size(); } -Vector Biome::get_dungeons() { +Vector Biome::get_buildings() { Vector r; - for (int i = 0; i < _dungeons.size(); i++) { + for (int i = 0; i < _buildings.size(); i++) { #if VERSION_MAJOR < 4 - r.push_back(_dungeons[i].get_ref_ptr()); + r.push_back(_buildings[i].get_ref_ptr()); #else - r.push_back(_dungeons[i]); + r.push_back(_buildings[i]); #endif } return r; } -void Biome::set_dungeons(const Vector &dungeon_datas) { - _dungeons.clear(); - for (int i = 0; i < dungeon_datas.size(); i++) { - Ref dungeon_data = Ref(dungeon_datas[i]); +void Biome::set_buildings(const Vector &buildings) { + _buildings.clear(); + for (int i = 0; i < buildings.size(); i++) { + Ref building = Ref(buildings[i]); - _dungeons.push_back(dungeon_data); + _buildings.push_back(building); } } @@ -207,13 +207,13 @@ Ref Biome::_instance(const int seed, Ref inst) { inst->add_prop_data(p); } - for (int i = 0; i < _dungeons.size(); ++i) { - Ref d = _dungeons[i]; + for (int i = 0; i < _buildings.size(); ++i) { + Ref d = _buildings[i]; if (!d.is_valid()) continue; - inst->add_dungeon(d->instance(seed)); + inst->add_building(d->instance(seed)); } #ifdef ESS_PRESENT @@ -403,8 +403,8 @@ void Biome::_setup_voxel_library(Ref library) { } } - for (int i = 0; i < get_dungeon_count(); ++i) { - Ref d = get_dungeon(i); + for (int i = 0; i < get_building_count(); ++i) { + Ref d = get_building(i); if (d.is_valid()) { d->setup_voxel_library(library); @@ -552,14 +552,6 @@ void Biome::_setup_terra_library(Ref library) { } } - for (int i = 0; i < get_dungeon_count(); ++i) { - Ref d = get_dungeon(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } - #ifdef PROPS_PRESENT for (int i = 0; i < get_prop_data_count(); ++i) { Ref s = get_prop_data(i); @@ -585,7 +577,7 @@ Biome::~Biome() { _entity_datas.clear(); #endif - _dungeons.clear(); + _buildings.clear(); _prop_datas.clear(); @@ -661,16 +653,16 @@ void Biome::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); #endif - //Dungeons - ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Biome::get_dungeon); - ClassDB::bind_method(D_METHOD("set_dungeon", "index", "data"), &Biome::set_dungeon); - ClassDB::bind_method(D_METHOD("add_dungeon", "dungeon"), &Biome::add_dungeon); - ClassDB::bind_method(D_METHOD("remove_dungeon", "index"), &Biome::remove_dungeon); - ClassDB::bind_method(D_METHOD("get_dungeon_count"), &Biome::get_dungeon_count); + //Buildings + ClassDB::bind_method(D_METHOD("get_building", "index"), &Biome::get_building); + ClassDB::bind_method(D_METHOD("set_building", "index", "data"), &Biome::set_building); + ClassDB::bind_method(D_METHOD("add_building", "dungeon"), &Biome::add_building); + ClassDB::bind_method(D_METHOD("remove_building", "index"), &Biome::remove_building); + ClassDB::bind_method(D_METHOD("get_building_count"), &Biome::get_building_count); - ClassDB::bind_method(D_METHOD("get_dungeons"), &Biome::get_dungeons); - ClassDB::bind_method(D_METHOD("set_dungeons", "dungeon_datas"), &Biome::set_dungeons); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeons", PROPERTY_HINT_NONE, "17/17:Dungeon", PROPERTY_USAGE_DEFAULT, "Dungeon"), "set_dungeons", "get_dungeons"); + ClassDB::bind_method(D_METHOD("get_buildings"), &Biome::get_buildings); + ClassDB::bind_method(D_METHOD("set_buildings", "dungeon_datas"), &Biome::set_buildings); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buildings", PROPERTY_HINT_NONE, "17/17:Building", PROPERTY_USAGE_DEFAULT, "Building"), "set_buildings", "get_buildings"); #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo("_setup_voxel_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); diff --git a/main/biome.h b/main/biome.h index 4121f21..6544491 100644 --- a/main/biome.h +++ b/main/biome.h @@ -33,7 +33,7 @@ SOFTWARE. #include "core/resource.h" #endif -#include "dungeon.h" +#include "building.h" #include "../data/world_generator_prop_data.h" #include "scene/resources/packed_scene.h" @@ -93,15 +93,15 @@ public: void set_entity_datas(const Vector &entity_datas); #endif - //Dungeons - Ref get_dungeon(const int index) const; - void set_dungeon(const int index, const Ref dungeon); - void add_dungeon(const Ref dungeon); - void remove_dungeon(const int index); - int get_dungeon_count() const; + //Buildings + Ref get_building(const int index) const; + void set_building(const int index, const Ref building); + void add_building(const Ref building); + void remove_building(const int index); + int get_building_count() const; - Vector get_dungeons(); - void set_dungeons(const Vector &dungeon_datas); + Vector get_buildings(); + void set_buildings(const Vector &buildings); Ref instance(const int seed); virtual Ref _instance(const int seed, Ref inst); @@ -192,7 +192,7 @@ private: Vector > _entity_datas; #endif - Vector > _dungeons; + Vector > _buildings; #ifdef VOXELMAN_PRESENT Ref _voxel_environment; diff --git a/main/building.cpp b/main/building.cpp new file mode 100644 index 0000000..4eb5692 --- /dev/null +++ b/main/building.cpp @@ -0,0 +1,641 @@ +/* +Copyright (c) 2019-2021 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "building.h" + +int Building::get_current_seed() { + return _current_seed; +} +void Building::set_current_seed(int value) { + _current_seed = value; +} + +Vector2 Building::get_level_range() { + return _level_range; +} +void Building::set_level_range(Vector2 value) { + _level_range = value; +} + +//Position +int Building::get_posx() { + return _posx; +} +void Building::set_posx(int value) { + _posx = value; +} + +int Building::get_posy() { + return _posy; +} +void Building::set_posy(int value) { + _posy = value; +} + +int Building::get_posz() { + return _posz; +} +void Building::set_posz(int value) { + _posz = value; +} + +//Size +int Building::get_sizex() { + return _sizex; +} +void Building::set_sizex(int value) { + _sizex = value; +} + +int Building::get_sizey() { + return _sizey; +} +void Building::set_sizey(int value) { + _sizey = value; +} + +int Building::get_sizez() { + return _sizez; +} +void Building::set_sizez(int value) { + _sizez = value; +} + +Ref Building::instance(const int seed) { + Ref inst; + + inst = Ref(Object::cast_to(ClassDB::instance(get_class_name()))); + ERR_FAIL_COND_V(!inst.is_valid(), inst); + + if (!get_script().is_null()) + inst->set_script(get_script()); + + return call("_instance", seed, inst); +} + +Ref Building::_instance(const int seed, Ref inst) { + inst->set_current_seed(seed); + inst->set_level_range(_level_range); + + inst->set_posx(_posx); + inst->set_posy(_posy); + inst->set_posz(_posz); + + inst->set_sizex(_sizex); + inst->set_sizey(_sizey); + inst->set_sizez(_sizez); + +#ifdef ESS_PRESENT + for (int i = 0; i < _entity_datas.size(); ++i) { + Ref d = _entity_datas[i]; + + inst->add_entity_data(d); + } +#endif + +#ifdef VOXELMAN_PRESENT + inst->set_voxel_environment(_voxel_environment); + + for (int i = 0; i < _voxel_environment_datas.size(); ++i) { + Ref d = _voxel_environment_datas[i]; + + if (!d.is_valid()) + continue; + + inst->add_voxel_environment_data(d); + } + + for (int i = 0; i < _voxel_surfaces.size(); ++i) { + Ref d = _voxel_surfaces[i]; + + if (!d.is_valid()) + continue; + + inst->add_voxel_surface(d); + } +#endif + +#ifdef TERRAMAN_PRESENT + inst->set_terra_environment(_terra_environment); + + for (int i = 0; i < _terra_environment_datas.size(); ++i) { + Ref d = _terra_environment_datas[i]; + + if (!d.is_valid()) + continue; + + inst->add_terra_environment_data(d); + } + + for (int i = 0; i < _terra_surfaces.size(); ++i) { + Ref d = _terra_surfaces[i]; + + if (!d.is_valid()) + continue; + + inst->add_terra_surface(d); + } +#endif + + return inst; +} + +void Building::setup() { + if (has_method("_setup")) { + call("_setup"); + } +} + +#ifdef ESS_PRESENT +//Entities +Ref Building::get_entity_data(const int index) const { + ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); + + return _entity_datas.get(index); +} +void Building::set_entity_data(const int index, const Ref entity_data) { + ERR_FAIL_INDEX(index, _entity_datas.size()); + + _entity_datas.set(index, entity_data); +} +void Building::add_entity_data(const Ref entity_data) { + _entity_datas.push_back(entity_data); +} +void Building::remove_entity_data(const int index) { + ERR_FAIL_INDEX(index, _entity_datas.size()); + + _entity_datas.remove(index); +} +int Building::get_entity_data_count() const { + return _entity_datas.size(); +} + +Vector Building::get_entity_datas() { + Vector r; + for (int i = 0; i < _entity_datas.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_entity_datas[i].get_ref_ptr()); +#else + r.push_back(_entity_datas[i]); +#endif + } + return r; +} +void Building::set_entity_datas(const Vector &entity_datas) { + _entity_datas.clear(); + for (int i = 0; i < entity_datas.size(); i++) { + Ref entity_data = Ref(entity_datas[i]); + + _entity_datas.push_back(entity_data); + } +} +#endif + +#ifdef VOXELMAN_PRESENT +Ref Building::get_voxel_environment() { + return _voxel_environment; +} +void Building::set_voxel_environment(Ref value) { + _voxel_environment = value; +} + +//// Surfaces //// +Ref Building::get_voxel_surface(const int index) const { + ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); + + return _voxel_surfaces.get(index); +} +void Building::set_voxel_surface(const int index, const Ref voxel_surface) { + ERR_FAIL_INDEX(index, _voxel_surfaces.size()); + + _voxel_surfaces.set(index, voxel_surface); +} +void Building::add_voxel_surface(const Ref voxel_surface) { + _voxel_surfaces.push_back(voxel_surface); +} +void Building::remove_voxel_surface(const int index) { + ERR_FAIL_INDEX(index, _voxel_surfaces.size()); + + _voxel_surfaces.remove(index); +} +int Building::get_voxel_surface_count() const { + return _voxel_surfaces.size(); +} + +Vector Building::get_voxel_surfaces() { + Vector r; + for (int i = 0; i < _voxel_surfaces.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_voxel_surfaces[i].get_ref_ptr()); +#else + r.push_back(_voxel_surfaces[i]); +#endif + } + return r; +} +void Building::set_voxel_surfaces(const Vector &voxel_surfaces) { + _voxel_surfaces.clear(); + for (int i = 0; i < voxel_surfaces.size(); i++) { + Ref voxel_surface = Ref(voxel_surfaces[i]); + + _voxel_surfaces.push_back(voxel_surface); + } +} + +//Environments +Ref Building::get_voxel_environment_data(const int index) const { + ERR_FAIL_INDEX_V(index, _voxel_environment_datas.size(), Ref()); + + return _voxel_environment_datas.get(index); +} +void Building::set_voxel_environment_data(const int index, const Ref environment_data) { + ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); + + _voxel_environment_datas.set(index, environment_data); +} +void Building::add_voxel_environment_data(const Ref environment_data) { + _voxel_environment_datas.push_back(environment_data); +} +void Building::remove_voxel_environment_data(const int index) { + ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); + + _voxel_environment_datas.remove(index); +} +int Building::get_voxel_environment_data_count() const { + return _voxel_environment_datas.size(); +} + +Vector Building::get_voxel_environment_datas() { + Vector r; + for (int i = 0; i < _voxel_environment_datas.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_voxel_environment_datas[i].get_ref_ptr()); +#else + r.push_back(_voxel_environment_datas[i]); +#endif + } + return r; +} +void Building::set_voxel_environment_datas(const Vector &environment_datas) { + _voxel_environment_datas.clear(); + for (int i = 0; i < environment_datas.size(); i++) { + Ref environment_data = Ref(environment_datas[i]); + + _voxel_environment_datas.push_back(environment_data); + } +} + +void Building::setup_voxel_library(Ref library) { + if (has_method("_setup_voxel_library")) { + call("_setup_voxel_library", library); + } +} + +void Building::_setup_voxel_library(Ref library) { + for (int i = 0; i < get_voxel_surface_count(); ++i) { + Ref s = get_voxel_surface(i); + + if (s.is_valid()) { + library->voxel_surface_add(s); + } + } +} + +void Building::generate_voxel_chunk(Ref chunk, bool spawn_mobs) { + ERR_FAIL_COND(!chunk.is_valid()); + + if (has_method("_generate_voxel_chunk")) { + call("_generate_voxel_chunk", chunk, spawn_mobs); + } +} + +void Building::generate_voxel_structure(Ref structure, bool spawn_mobs) { + if (has_method("_generate_voxel_structure")) { + call("_generate_voxel_structure", structure, spawn_mobs); + } +} +#endif + +#ifdef TERRAMAN_PRESENT +Ref Building::get_terra_environment() { + return _terra_environment; +} +void Building::set_terra_environment(Ref value) { + _terra_environment = value; +} + +//// Surfaces //// +Ref Building::get_terra_surface(const int index) const { + ERR_FAIL_INDEX_V(index, _terra_surfaces.size(), Ref()); + + return _terra_surfaces.get(index); +} +void Building::set_terra_surface(const int index, const Ref terra_surface) { + ERR_FAIL_INDEX(index, _terra_surfaces.size()); + + _terra_surfaces.set(index, terra_surface); +} +void Building::add_terra_surface(const Ref terra_surface) { + _terra_surfaces.push_back(terra_surface); +} +void Building::remove_terra_surface(const int index) { + ERR_FAIL_INDEX(index, _terra_surfaces.size()); + + _terra_surfaces.remove(index); +} +int Building::get_terra_surface_count() const { + return _terra_surfaces.size(); +} + +Vector Building::get_terra_surfaces() { + Vector r; + for (int i = 0; i < _terra_surfaces.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_terra_surfaces[i].get_ref_ptr()); +#else + r.push_back(_terra_surfaces[i]); +#endif + } + return r; +} +void Building::set_terra_surfaces(const Vector &terra_surfaces) { + _terra_surfaces.clear(); + for (int i = 0; i < terra_surfaces.size(); i++) { + Ref terra_surface = Ref(terra_surfaces[i]); + + _terra_surfaces.push_back(terra_surface); + } +} + +//Environments +Ref Building::get_terra_environment_data(const int index) const { + ERR_FAIL_INDEX_V(index, _terra_environment_datas.size(), Ref()); + + return _terra_environment_datas.get(index); +} +void Building::set_terra_environment_data(const int index, const Ref environment_data) { + ERR_FAIL_INDEX(index, _terra_environment_datas.size()); + + _terra_environment_datas.set(index, environment_data); +} +void Building::add_terra_environment_data(const Ref environment_data) { + _terra_environment_datas.push_back(environment_data); +} +void Building::remove_terra_environment_data(const int index) { + ERR_FAIL_INDEX(index, _terra_environment_datas.size()); + + _terra_environment_datas.remove(index); +} +int Building::get_terra_environment_data_count() const { + return _terra_environment_datas.size(); +} + +Vector Building::get_terra_environment_datas() { + Vector r; + for (int i = 0; i < _terra_environment_datas.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_terra_environment_datas[i].get_ref_ptr()); +#else + r.push_back(_terra_environment_datas[i]); +#endif + } + return r; +} +void Building::set_terra_environment_datas(const Vector &environment_datas) { + _terra_environment_datas.clear(); + for (int i = 0; i < environment_datas.size(); i++) { + Ref environment_data = Ref(environment_datas[i]); + + _terra_environment_datas.push_back(environment_data); + } +} + +void Building::setup_terra_library(Ref library) { + if (has_method("_setup_terra_library")) { + call("_setup_terra_library", library); + } +} + +void Building::_setup_terra_library(Ref library) { + for (int i = 0; i < get_terra_surface_count(); ++i) { + Ref s = get_terra_surface(i); + + if (s.is_valid()) { + library->voxel_surface_add(s); + } + } +} + +void Building::generate_terra_chunk(Ref chunk, bool spawn_mobs) { + ERR_FAIL_COND(!chunk.is_valid()); + + if (has_method("_generate_terra_chunk")) { + call("_generate_terra_chunk", chunk, spawn_mobs); + } +} + +void Building::generate_terra_structure(Ref structure, bool spawn_mobs) { + if (has_method("_generate_terra_structure")) { + call("_generate_terra_structure", structure, spawn_mobs); + } +} +#endif + +Ref Building::generate_map() { + ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); + + return call("_generate_map"); +} + +Building::Building() { + _current_seed = 0; + + _posx = 0; + _posy = 0; + _posz = 0; + + _sizex = 0; + _sizey = 0; + _sizez = 0; +} +Building::~Building() { +#ifdef ESS_PRESENT + _entity_datas.clear(); +#endif + +#ifdef VOXELMAN_PRESENT + _voxel_environment.unref(); + + _voxel_environment_datas.clear(); + _voxel_surfaces.clear(); +#endif + +#ifdef TERRAMAN_PRESENT + _terra_environment.unref(); + + _terra_environment_datas.clear(); + _terra_surfaces.clear(); +#endif +} + +void Building::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "inst", PROPERTY_HINT_RESOURCE_TYPE, "Building"), + "_instance", + PropertyInfo(Variant::INT, "p_seed"), + PropertyInfo(Variant::OBJECT, "p_instance", PROPERTY_HINT_RESOURCE_TYPE, "Building"))); + + BIND_VMETHOD(MethodInfo("_setup")); + + ClassDB::bind_method(D_METHOD("instance", "seed"), &Building::instance); + ClassDB::bind_method(D_METHOD("_instance", "p_seed", "p_instance"), &Building::_instance); + + ClassDB::bind_method(D_METHOD("setup"), &Building::setup); + + ClassDB::bind_method(D_METHOD("get_current_seed"), &Building::get_current_seed); + ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Building::set_current_seed); + ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); + + ClassDB::bind_method(D_METHOD("get_level_range"), &Building::get_level_range); + ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Building::set_level_range); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); + + //Position + ClassDB::bind_method(D_METHOD("get_posx"), &Building::get_posx); + ClassDB::bind_method(D_METHOD("set_posx", "value"), &Building::set_posx); + ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx"); + + ClassDB::bind_method(D_METHOD("get_posy"), &Building::get_posy); + ClassDB::bind_method(D_METHOD("set_posy", "value"), &Building::set_posy); + ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy"); + + ClassDB::bind_method(D_METHOD("get_posz"), &Building::get_posz); + ClassDB::bind_method(D_METHOD("set_posz", "value"), &Building::set_posz); + ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz"); + + //Size + ClassDB::bind_method(D_METHOD("get_sizex"), &Building::get_sizex); + ClassDB::bind_method(D_METHOD("set_sizex", "value"), &Building::set_sizex); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex"); + + ClassDB::bind_method(D_METHOD("get_sizey"), &Building::get_sizey); + ClassDB::bind_method(D_METHOD("set_sizey", "value"), &Building::set_sizey); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey"); + + ClassDB::bind_method(D_METHOD("get_sizez"), &Building::get_sizez); + ClassDB::bind_method(D_METHOD("set_sizez", "value"), &Building::set_sizez); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); + +#ifdef ESS_PRESENT + //Entities + ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &Building::get_entity_data); + ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &Building::set_entity_data); + ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Building::add_entity_data); + ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Building::remove_entity_data); + ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Building::get_entity_data_count); + + ClassDB::bind_method(D_METHOD("get_entity_datas"), &Building::get_entity_datas); + ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &Building::set_entity_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); +#endif + +#ifdef VOXELMAN_PRESENT + BIND_VMETHOD(MethodInfo("_setup_voxel_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); + BIND_VMETHOD(MethodInfo("_generate_voxel_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_voxel_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + + ClassDB::bind_method(D_METHOD("setup_voxel_library", "library"), &Building::setup_voxel_library); + ClassDB::bind_method(D_METHOD("_setup_voxel_library", "library"), &Building::_setup_voxel_library); + + ClassDB::bind_method(D_METHOD("generate_voxel_chunk", "chunk", "spawn_mobs"), &Building::generate_voxel_chunk); + ClassDB::bind_method(D_METHOD("generate_voxel_structure", "structure", "spawn_mobs"), &Building::generate_voxel_structure); + + //Environment + ClassDB::bind_method(D_METHOD("get_voxel_environment"), &Building::get_voxel_environment); + ClassDB::bind_method(D_METHOD("set_voxel_environment", "value"), &Building::set_voxel_environment); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_voxel_environment", "get_voxel_environment"); + + //Environments + ClassDB::bind_method(D_METHOD("get_voxel_environment_data", "index"), &Building::get_voxel_environment_data); + ClassDB::bind_method(D_METHOD("set_voxel_environment_data", "index", "data"), &Building::set_voxel_environment_data); + ClassDB::bind_method(D_METHOD("add_voxel_environment_data", "environment_data"), &Building::add_voxel_environment_data); + ClassDB::bind_method(D_METHOD("remove_voxel_environment_data", "index"), &Building::remove_voxel_environment_data); + ClassDB::bind_method(D_METHOD("get_voxel_environment_data_count"), &Building::get_voxel_environment_data_count); + + ClassDB::bind_method(D_METHOD("get_voxel_environment_datas"), &Building::get_voxel_environment_datas); + ClassDB::bind_method(D_METHOD("set_voxel_environment_datas", "environment_datas"), &Building::set_voxel_environment_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_voxel_environment_datas", "get_voxel_environment_datas"); + + //Surfaces + ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &Building::get_voxel_surface); + ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &Building::set_voxel_surface); + ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &Building::add_voxel_surface); + ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &Building::remove_voxel_surface); + ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &Building::get_voxel_surface_count); + + ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &Building::get_voxel_surfaces); + ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &Building::set_voxel_surfaces); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_voxel_surfaces", "get_voxel_surfaces"); +#endif + +#ifdef TERRAMAN_PRESENT + BIND_VMETHOD(MethodInfo("_setup_terra_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"))); + BIND_VMETHOD(MethodInfo("_generate_terra_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "TerraStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + BIND_VMETHOD(MethodInfo("_generate_terra_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); + + ClassDB::bind_method(D_METHOD("setup_terra_library", "library"), &Building::setup_terra_library); + ClassDB::bind_method(D_METHOD("_setup_terra_library", "library"), &Building::_setup_terra_library); + + ClassDB::bind_method(D_METHOD("generate_terra_chunk", "chunk", "spawn_mobs"), &Building::generate_terra_chunk); + ClassDB::bind_method(D_METHOD("generate_terra_structure", "structure", "spawn_mobs"), &Building::generate_terra_structure); + + //Environment + ClassDB::bind_method(D_METHOD("get_terra_environment"), &Building::get_terra_environment); + ClassDB::bind_method(D_METHOD("set_terra_environment", "value"), &Building::set_terra_environment); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "terra_environment", PROPERTY_HINT_RESOURCE_TYPE, "TerraEnvironmentData"), "set_terra_environment", "get_terra_environment"); + + //Environments + ClassDB::bind_method(D_METHOD("get_terra_environment_data", "index"), &Building::get_terra_environment_data); + ClassDB::bind_method(D_METHOD("set_terra_environment_data", "index", "data"), &Building::set_terra_environment_data); + ClassDB::bind_method(D_METHOD("add_terra_environment_data", "environment_data"), &Building::add_terra_environment_data); + ClassDB::bind_method(D_METHOD("remove_terra_environment_data", "index"), &Building::remove_terra_environment_data); + ClassDB::bind_method(D_METHOD("get_terra_environment_data_count"), &Building::get_terra_environment_data_count); + + ClassDB::bind_method(D_METHOD("get_terra_environment_datas"), &Building::get_terra_environment_datas); + ClassDB::bind_method(D_METHOD("set_terra_environment_datas", "environment_datas"), &Building::set_terra_environment_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_environment_datas", PROPERTY_HINT_NONE, "17/17:TerraEnvironmentData", PROPERTY_USAGE_DEFAULT, "TerraEnvironmentData"), "set_terra_environment_datas", "get_terra_environment_datas"); + + //Surfaces + ClassDB::bind_method(D_METHOD("get_terra_surface", "index"), &Building::get_terra_surface); + ClassDB::bind_method(D_METHOD("set_terra_surface", "index", "data"), &Building::set_terra_surface); + ClassDB::bind_method(D_METHOD("add_terra_surface", "terra_surface"), &Building::add_terra_surface); + ClassDB::bind_method(D_METHOD("remove_terra_surface", "index"), &Building::remove_terra_surface); + ClassDB::bind_method(D_METHOD("get_terra_surface_count"), &Building::get_terra_surface_count); + + ClassDB::bind_method(D_METHOD("get_terra_surfaces"), &Building::get_terra_surfaces); + ClassDB::bind_method(D_METHOD("set_terra_surfaces", "terra_surfaces"), &Building::set_terra_surfaces); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_surfaces", PROPERTY_HINT_NONE, "17/17:TerraSurface", PROPERTY_USAGE_DEFAULT, "TerraSurface"), "set_terra_surfaces", "get_terra_surfaces"); +#endif + + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); + + ClassDB::bind_method(D_METHOD("generate_map"), &Building::generate_map); +} diff --git a/main/dungeon_room.h b/main/building.h similarity index 75% rename from main/dungeon_room.h rename to main/building.h index 80226fd..d25f2c0 100644 --- a/main/dungeon_room.h +++ b/main/building.h @@ -20,25 +20,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef DUNGEON_ROOM_H -#define DUNGEON_ROOM_H +#ifndef BUILDING_H +#define BUILDING_H #include "core/version.h" #if VERSION_MAJOR > 3 +#include "core/io/image.h" #include "core/io/resource.h" #include "core/object/reference.h" -#include "core/templates/vector.h" #else +#include "core/image.h" #include "core/reference.h" #include "core/resource.h" -#include "core/vector.h" #endif -#include "../data/world_generator_prop_data.h" - -#include "scene/resources/packed_scene.h" - #ifdef VOXELMAN_PRESENT #include "../../voxelman/library/voxelman_library.h" #include "../../voxelman/world/environment_data.h" @@ -48,8 +44,8 @@ SOFTWARE. #ifdef TERRAMAN_PRESENT #include "../../terraman/library/terraman_library.h" -#include "../../terraman/world/terra_environment_data.h" #include "../../terraman/world/terra_chunk.h" +#include "../../terraman/world/terra_environment_data.h" #include "../../terraman/world/terra_structure.h" #endif @@ -57,8 +53,8 @@ SOFTWARE. #include "../../entity_spell_system/entities/data/entity_data.h" #endif -class DungeonRoom : public Resource { - GDCLASS(DungeonRoom, Resource); +class Building : public Resource { + GDCLASS(Building, Resource); public: int get_current_seed(); @@ -67,26 +63,6 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); - //Min Size - int get_min_sizex(); - void set_min_sizex(int value); - - int get_min_sizey(); - void set_min_sizey(int value); - - int get_min_sizez(); - void set_min_sizez(int value); - - //Max Size - int get_max_sizex(); - void set_max_sizex(int value); - - int get_max_sizey(); - void set_max_sizey(int value); - - int get_max_sizez(); - void set_max_sizez(int value); - //Pos int get_posx(); void set_posx(int value); @@ -107,22 +83,16 @@ public: int get_sizez(); void set_sizez(int value); - //Props - Ref get_prop_data(const int index) const; - void set_prop_data(const int index, const Ref prop_data); - void add_prop_data(const Ref prop_data); - void remove_prop_data(const int index); - int get_prop_data_count() const; - - Vector get_prop_datas(); - void set_prop_datas(const Vector &prop_datas); + Ref instance(const int seed); + virtual Ref _instance(const int seed, Ref inst); + void setup(); #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 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; @@ -130,20 +100,11 @@ public: void set_entity_datas(const Vector &entity_datas); #endif - Ref instance(const int seed); - virtual Ref _instance(const int seed, Ref inst); - - void setup(); - #ifdef VOXELMAN_PRESENT //Environment Ref get_voxel_environment(); void set_voxel_environment(Ref value); - //Structure - Ref get_voxel_structure(); - void set_voxel_structure(Ref structure); - //Environments Ref get_voxel_environment_data(const int index) const; void set_voxel_environment_data(const int index, const Ref environment_data); @@ -168,7 +129,7 @@ public: void _setup_voxel_library(Ref library); void generate_voxel_chunk(Ref chunk, bool spawn_mobs); - void generate_voxel_room(Ref structure, bool spawn_mobs); + void generate_voxel_structure(Ref structure, bool spawn_mobs); #endif #ifdef TERRAMAN_PRESENT @@ -176,10 +137,6 @@ public: Ref get_terra_environment(); void set_terra_environment(Ref value); - //Structure - Ref get_terra_structure(); - void set_terra_structure(Ref structure); - //Environments Ref get_terra_environment_data(const int index) const; void set_terra_environment_data(const int index, const Ref environment_data); @@ -204,11 +161,13 @@ public: void _setup_terra_library(Ref library); void generate_terra_chunk(Ref chunk, bool spawn_mobs); - void generate_terra_room(Ref structure, bool spawn_mobs); + void generate_terra_structure(Ref structure, bool spawn_mobs); #endif - DungeonRoom(); - ~DungeonRoom(); + Ref generate_map(); + + Building(); + ~Building(); protected: static void _bind_methods(); @@ -218,14 +177,6 @@ private: Vector2 _level_range; - int _min_sizex; - int _min_sizey; - int _min_sizez; - - int _max_sizex; - int _max_sizey; - int _max_sizez; - int _posx; int _posy; int _posz; @@ -234,15 +185,12 @@ private: int _sizey; int _sizez; - Vector > _prop_datas; - #ifdef ESS_PRESENT Vector > _entity_datas; #endif #ifdef VOXELMAN_PRESENT Ref _voxel_environment; - Ref _voxel_structure; Vector > _voxel_environment_datas; Vector > _voxel_surfaces; @@ -250,7 +198,6 @@ private: #ifdef TERRAMAN_PRESENT Ref _terra_environment; - Ref _terra_structure; Vector > _terra_environment_datas; Vector > _terra_surfaces; diff --git a/main/dungeon.cpp b/main/dungeon.cpp deleted file mode 100644 index e9f6db5..0000000 --- a/main/dungeon.cpp +++ /dev/null @@ -1,1357 +0,0 @@ -/* -Copyright (c) 2019-2021 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "dungeon.h" - -int Dungeon::get_current_seed() { - return _current_seed; -} -void Dungeon::set_current_seed(int value) { - _current_seed = value; -} - -Vector2 Dungeon::get_level_range() { - return _level_range; -} -void Dungeon::set_level_range(Vector2 value) { - _level_range = value; -} - -//Min Size -int Dungeon::get_min_sizex() { - return _min_sizex; -} -void Dungeon::set_min_sizex(int value) { - _min_sizex = value; -} - -int Dungeon::get_min_sizey() { - return _min_sizey; -} -void Dungeon::set_min_sizey(int value) { - _min_sizey = value; -} - -int Dungeon::get_min_sizez() { - return _min_sizez; -} -void Dungeon::set_min_sizez(int value) { - _min_sizez = value; -} - -//Max Size -int Dungeon::get_max_sizex() { - return _max_sizex; -} -void Dungeon::set_max_sizex(int value) { - _max_sizex = value; -} - -int Dungeon::get_max_sizey() { - return _max_sizey; -} -void Dungeon::set_max_sizey(int value) { - _max_sizey = value; -} - -int Dungeon::get_max_sizez() { - return _max_sizez; -} -void Dungeon::set_max_sizez(int value) { - _max_sizez = value; -} - -int Dungeon::get_min_room_count() { - return _min_room_count; -} -void Dungeon::set_min_room_count(int value) { - _min_room_count = value; -} - -int Dungeon::get_max_room_count() { - return _max_room_count; -} -void Dungeon::set_max_room_count(int value) { - _max_room_count = value; -} - -//Position -int Dungeon::get_posx() { - return _posx; -} -void Dungeon::set_posx(int value) { - _posx = value; -} - -int Dungeon::get_posy() { - return _posy; -} -void Dungeon::set_posy(int value) { - _posy = value; -} - -int Dungeon::get_posz() { - return _posz; -} -void Dungeon::set_posz(int value) { - _posz = value; -} - -//Size -int Dungeon::get_sizex() { - return _sizex; -} -void Dungeon::set_sizex(int value) { - _sizex = value; -} - -int Dungeon::get_sizey() { - return _sizey; -} -void Dungeon::set_sizey(int value) { - _sizey = value; -} - -int Dungeon::get_sizez() { - return _sizez; -} -void Dungeon::set_sizez(int value) { - _sizez = value; -} - -int Dungeon::get_room_count() { - return _room_count; -} -void Dungeon::set_room_count(int value) { - _room_count = value; -} - -//Rooms -Ref Dungeon::get_dungeon_room(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_rooms.size(), Ref()); - - return _dungeon_rooms.get(index); -} -void Dungeon::set_dungeon_room(const int index, const Ref dungeon_room) { - ERR_FAIL_INDEX(index, _dungeon_rooms.size()); - - _dungeon_rooms.set(index, dungeon_room); -} -void Dungeon::add_dungeon_room(const Ref dungeon_room) { - _dungeon_rooms.push_back(dungeon_room); -} -void Dungeon::remove_dungeon_room(const int index) { - ERR_FAIL_INDEX(index, _dungeon_rooms.size()); - - _dungeon_rooms.remove(index); -} - -int Dungeon::get_dungeon_room_count() const { - return _dungeon_rooms.size(); -} - -Vector Dungeon::get_dungeon_rooms() { - Vector r; - for (int i = 0; i < _dungeon_rooms.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_rooms[i].get_ref_ptr()); -#else - r.push_back(_dungeon_rooms[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_rooms(const Vector &dungeon_rooms) { - _dungeon_rooms.clear(); - for (int i = 0; i < dungeon_rooms.size(); i++) { - Ref dungeon_room_data = Ref(dungeon_rooms[i]); - - _dungeon_rooms.push_back(dungeon_room_data); - } -} - -//Start Rooms -Ref Dungeon::get_dungeon_start_room(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_start_rooms.size(), Ref()); - - return _dungeon_start_rooms.get(index); -} -void Dungeon::set_dungeon_start_room(const int index, const Ref dungeon_start_room) { - ERR_FAIL_INDEX(index, _dungeon_start_rooms.size()); - - _dungeon_start_rooms.set(index, dungeon_start_room); -} -void Dungeon::add_dungeon_start_room(const Ref dungeon_start_room) { - _dungeon_start_rooms.push_back(dungeon_start_room); -} -void Dungeon::remove_dungeon_start_room(const int index) { - ERR_FAIL_INDEX(index, _dungeon_start_rooms.size()); - - _dungeon_start_rooms.remove(index); -} - -int Dungeon::get_dungeon_start_room_count() const { - return _dungeon_start_rooms.size(); -} - -Vector Dungeon::get_dungeon_start_rooms() { - Vector r; - for (int i = 0; i < _dungeon_start_rooms.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_start_rooms[i].get_ref_ptr()); -#else - r.push_back(_dungeon_start_rooms[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_start_rooms(const Vector &dungeon_start_rooms) { - _dungeon_start_rooms.clear(); - for (int i = 0; i < dungeon_start_rooms.size(); i++) { - Ref dungeon_start_room_data = Ref(dungeon_start_rooms[i]); - - _dungeon_start_rooms.push_back(dungeon_start_room_data); - } -} - -//End Rooms -Ref Dungeon::get_dungeon_end_room(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_end_rooms.size(), Ref()); - - return _dungeon_end_rooms.get(index); -} -void Dungeon::set_dungeon_end_room(const int index, const Ref dungeon_end_room) { - ERR_FAIL_INDEX(index, _dungeon_end_rooms.size()); - - _dungeon_end_rooms.set(index, dungeon_end_room); -} -void Dungeon::add_dungeon_end_room(const Ref dungeon_end_room) { - _dungeon_end_rooms.push_back(dungeon_end_room); -} -void Dungeon::remove_dungeon_end_room(const int index) { - ERR_FAIL_INDEX(index, _dungeon_end_rooms.size()); - - _dungeon_end_rooms.remove(index); -} - -int Dungeon::get_dungeon_end_room_count() const { - return _dungeon_end_rooms.size(); -} - -Vector Dungeon::get_dungeon_end_rooms() { - Vector r; - for (int i = 0; i < _dungeon_end_rooms.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_end_rooms[i].get_ref_ptr()); -#else - r.push_back(_dungeon_end_rooms[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_end_rooms(const Vector &dungeon_end_rooms) { - _dungeon_end_rooms.clear(); - for (int i = 0; i < dungeon_end_rooms.size(); i++) { - Ref dungeon_end_room_data = Ref(dungeon_end_rooms[i]); - - _dungeon_end_rooms.push_back(dungeon_end_room_data); - } -} - -//Corridors -Ref Dungeon::get_dungeon_corridor(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_corridors.size(), Ref()); - - return _dungeon_corridors.get(index); -} -void Dungeon::set_dungeon_corridor(const int index, const Ref dungeon_corridor) { - ERR_FAIL_INDEX(index, _dungeon_corridors.size()); - - _dungeon_corridors.set(index, dungeon_corridor); -} -void Dungeon::add_dungeon_corridor(const Ref dungeon_corridor) { - _dungeon_corridors.push_back(dungeon_corridor); -} -void Dungeon::remove_dungeon_corridor(const int index) { - ERR_FAIL_INDEX(index, _dungeon_corridors.size()); - - _dungeon_corridors.remove(index); -} -int Dungeon::get_dungeon_corridor_count() const { - return _dungeon_corridors.size(); -} - -Vector Dungeon::get_dungeon_corridors() { - Vector r; - for (int i = 0; i < _dungeon_corridors.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_corridors[i].get_ref_ptr()); -#else - r.push_back(_dungeon_corridors[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_corridors(const Vector &dungeon_corridors) { - _dungeon_corridors.clear(); - for (int i = 0; i < dungeon_corridors.size(); i++) { - Ref dungeon_corridor_data = Ref(dungeon_corridors[i]); - - _dungeon_corridors.push_back(dungeon_corridor_data); - } -} - -//Room Datas -Ref Dungeon::get_dungeon_room_data(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_room_datas.size(), Ref()); - - return _dungeon_room_datas.get(index); -} -void Dungeon::set_dungeon_room_data(const int index, const Ref dungeon_room) { - ERR_FAIL_INDEX(index, _dungeon_room_datas.size()); - - _dungeon_room_datas.set(index, dungeon_room); -} -void Dungeon::add_dungeon_room_data(const Ref dungeon_room) { - _dungeon_room_datas.push_back(dungeon_room); -} -void Dungeon::remove_dungeon_room_data(const int index) { - ERR_FAIL_INDEX(index, _dungeon_room_datas.size()); - - _dungeon_room_datas.remove(index); -} - -int Dungeon::get_dungeon_room_data_count() const { - return _dungeon_room_datas.size(); -} - -Vector Dungeon::get_dungeon_room_datas() { - Vector r; - for (int i = 0; i < _dungeon_room_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_room_datas[i].get_ref_ptr()); -#else - r.push_back(_dungeon_room_datas[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_room_datas(const Vector &dungeon_room_datas) { - _dungeon_room_datas.clear(); - for (int i = 0; i < dungeon_room_datas.size(); i++) { - Ref dungeon_room_data = Ref(dungeon_room_datas[i]); - - _dungeon_room_datas.push_back(dungeon_room_data); - } -} - -//Start Room Datas -Ref Dungeon::get_dungeon_start_room_data(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_start_room_datas.size(), Ref()); - - return _dungeon_start_room_datas.get(index); -} -void Dungeon::set_dungeon_start_room_data(const int index, const Ref dungeon_start_room) { - ERR_FAIL_INDEX(index, _dungeon_start_room_datas.size()); - - _dungeon_start_room_datas.set(index, dungeon_start_room); -} -void Dungeon::add_dungeon_start_room_data(const Ref dungeon_start_room) { - _dungeon_start_room_datas.push_back(dungeon_start_room); -} -void Dungeon::remove_dungeon_start_room_data(const int index) { - ERR_FAIL_INDEX(index, _dungeon_start_room_datas.size()); - - _dungeon_start_room_datas.remove(index); -} - -int Dungeon::get_dungeon_start_room_data_count() const { - return _dungeon_start_room_datas.size(); -} - -Vector Dungeon::get_dungeon_start_room_datas() { - Vector r; - for (int i = 0; i < _dungeon_start_room_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_start_room_datas[i].get_ref_ptr()); -#else - r.push_back(_dungeon_start_room_datas[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_start_room_datas(const Vector &dungeon_start_room_datas) { - _dungeon_start_room_datas.clear(); - for (int i = 0; i < dungeon_start_room_datas.size(); i++) { - Ref dungeon_start_room_data = Ref(dungeon_start_room_datas[i]); - - _dungeon_start_room_datas.push_back(dungeon_start_room_data); - } -} - -//End Room Datas -Ref Dungeon::get_dungeon_end_room_data(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_end_room_datas.size(), Ref()); - - return _dungeon_end_room_datas.get(index); -} -void Dungeon::set_dungeon_end_room_data(const int index, const Ref dungeon_end_room) { - ERR_FAIL_INDEX(index, _dungeon_end_room_datas.size()); - - _dungeon_end_room_datas.set(index, dungeon_end_room); -} -void Dungeon::add_dungeon_end_room_data(const Ref dungeon_end_room) { - _dungeon_end_room_datas.push_back(dungeon_end_room); -} -void Dungeon::remove_dungeon_end_room_data(const int index) { - ERR_FAIL_INDEX(index, _dungeon_end_room_datas.size()); - - _dungeon_end_room_datas.remove(index); -} - -int Dungeon::get_dungeon_end_room_data_count() const { - return _dungeon_end_room_datas.size(); -} - -Vector Dungeon::get_dungeon_end_room_datas() { - Vector r; - for (int i = 0; i < _dungeon_end_room_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_end_room_datas[i].get_ref_ptr()); -#else - r.push_back(_dungeon_end_room_datas[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_end_room_datas(const Vector &dungeon_end_room_datas) { - _dungeon_end_room_datas.clear(); - for (int i = 0; i < dungeon_end_room_datas.size(); i++) { - Ref dungeon_end_room_data = Ref(dungeon_end_room_datas[i]); - - _dungeon_end_room_datas.push_back(dungeon_end_room_data); - } -} - -//Corridor Datas -Ref Dungeon::get_dungeon_corridor_data(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_corridor_datas.size(), Ref()); - - return _dungeon_corridor_datas.get(index); -} -void Dungeon::set_dungeon_corridor_data(const int index, const Ref dungeon_corridor) { - ERR_FAIL_INDEX(index, _dungeon_corridor_datas.size()); - - _dungeon_corridor_datas.set(index, dungeon_corridor); -} -void Dungeon::add_dungeon_corridor_data(const Ref dungeon_corridor) { - _dungeon_corridor_datas.push_back(dungeon_corridor); -} -void Dungeon::remove_dungeon_corridor_data(const int index) { - ERR_FAIL_INDEX(index, _dungeon_corridor_datas.size()); - - _dungeon_corridor_datas.remove(index); -} -int Dungeon::get_dungeon_corridor_data_count() const { - return _dungeon_corridor_datas.size(); -} - -Vector Dungeon::get_dungeon_corridor_datas() { - Vector r; - for (int i = 0; i < _dungeon_corridor_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_corridor_datas[i].get_ref_ptr()); -#else - r.push_back(_dungeon_corridor_datas[i]); -#endif - } - return r; -} -void Dungeon::set_dungeon_corridor_datas(const Vector &dungeon_corridor_datas) { - _dungeon_corridor_datas.clear(); - for (int i = 0; i < dungeon_corridor_datas.size(); i++) { - Ref dungeon_corridor_data = Ref(dungeon_corridor_datas[i]); - - _dungeon_corridor_datas.push_back(dungeon_corridor_data); - } -} - -#ifdef ESS_PRESENT -//Entities -Ref Dungeon::get_entity_data(const int index) const { - ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); - - return _entity_datas.get(index); -} -void Dungeon::set_entity_data(const int index, const Ref entity_data) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.set(index, entity_data); -} -void Dungeon::add_entity_data(const Ref entity_data) { - _entity_datas.push_back(entity_data); -} -void Dungeon::remove_entity_data(const int index) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.remove(index); -} -int Dungeon::get_entity_data_count() const { - return _entity_datas.size(); -} - -Vector Dungeon::get_entity_datas() { - Vector r; - for (int i = 0; i < _entity_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_datas[i]); -#endif - } - return r; -} -void Dungeon::set_entity_datas(const Vector &entity_datas) { - _entity_datas.clear(); - for (int i = 0; i < entity_datas.size(); i++) { - Ref entity_data = Ref(entity_datas[i]); - - _entity_datas.push_back(entity_data); - } -} -#endif - -Ref Dungeon::instance(const int seed) { - Ref inst; - - inst = Ref(Object::cast_to(ClassDB::instance(get_class_name()))); - ERR_FAIL_COND_V(!inst.is_valid(), inst); - - if (!get_script().is_null()) - inst->set_script(get_script()); - - return call("_instance", seed, inst); -} - -Ref Dungeon::_instance(const int seed, Ref inst) { - inst->set_current_seed(seed); - inst->set_level_range(_level_range); - - inst->set_posx(_posx); - inst->set_posy(_posy); - inst->set_posz(_posz); - - inst->set_sizex(_sizex); - inst->set_sizey(_sizey); - inst->set_sizez(_sizez); - - inst->set_room_count(_room_count); - - inst->set_min_sizex(_min_sizex); - inst->set_min_sizey(_min_sizey); - inst->set_min_sizez(_min_sizez); - - inst->set_max_sizex(_max_sizex); - inst->set_max_sizey(_max_sizey); - inst->set_max_sizez(_max_sizez); - - inst->set_min_room_count(_min_room_count); - inst->set_max_room_count(_max_room_count); - - for (int i = 0; i < _dungeon_rooms.size(); ++i) { - Ref r = _dungeon_rooms[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_room(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_start_rooms.size(); ++i) { - Ref r = _dungeon_start_rooms[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_start_room(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_end_rooms.size(); ++i) { - Ref r = _dungeon_end_rooms[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_end_room(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_corridors.size(); ++i) { - Ref r = _dungeon_corridors[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_corridor(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_room_datas.size(); ++i) { - Ref r = _dungeon_room_datas[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_room_data(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_start_room_datas.size(); ++i) { - Ref r = _dungeon_start_room_datas[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_start_room_data(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_end_room_datas.size(); ++i) { - Ref r = _dungeon_end_room_datas[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_end_room_data(r->instance(seed)); - } - - for (int i = 0; i < _dungeon_corridor_datas.size(); ++i) { - Ref r = _dungeon_corridor_datas[i]; - - if (!r.is_valid()) - continue; - - inst->add_dungeon_corridor_data(r->instance(seed)); - } - -#ifdef ESS_PRESENT - for (int i = 0; i < _entity_datas.size(); ++i) { - Ref d = _entity_datas[i]; - - inst->add_entity_data(d); - } -#endif - -#ifdef VOXELMAN_PRESENT - inst->set_voxel_environment(_voxel_environment); - - for (int i = 0; i < _voxel_environment_datas.size(); ++i) { - Ref d = _voxel_environment_datas[i]; - - if (!d.is_valid()) - continue; - - inst->add_voxel_environment_data(d); - } - - for (int i = 0; i < _voxel_surfaces.size(); ++i) { - Ref d = _voxel_surfaces[i]; - - if (!d.is_valid()) - continue; - - inst->add_voxel_surface(d); - } -#endif - -#ifdef TERRAMAN_PRESENT - inst->set_terra_environment(_terra_environment); - - for (int i = 0; i < _terra_environment_datas.size(); ++i) { - Ref d = _terra_environment_datas[i]; - - if (!d.is_valid()) - continue; - - inst->add_terra_environment_data(d); - } - - for (int i = 0; i < _terra_surfaces.size(); ++i) { - Ref d = _terra_surfaces[i]; - - if (!d.is_valid()) - continue; - - inst->add_terra_surface(d); - } -#endif - - return inst; -} - -void Dungeon::setup() { - if (has_method("_setup")) { - call("_setup"); - } -} - - -#ifdef VOXELMAN_PRESENT -Ref Dungeon::get_voxel_environment() { - return _voxel_environment; -} -void Dungeon::set_voxel_environment(Ref value) { - _voxel_environment = value; -} - -//// Surfaces //// -Ref Dungeon::get_voxel_surface(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); - - return _voxel_surfaces.get(index); -} -void Dungeon::set_voxel_surface(const int index, const Ref voxel_surface) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.set(index, voxel_surface); -} -void Dungeon::add_voxel_surface(const Ref voxel_surface) { - _voxel_surfaces.push_back(voxel_surface); -} -void Dungeon::remove_voxel_surface(const int index) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.remove(index); -} -int Dungeon::get_voxel_surface_count() const { - return _voxel_surfaces.size(); -} - -Vector Dungeon::get_voxel_surfaces() { - Vector r; - for (int i = 0; i < _voxel_surfaces.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_voxel_surfaces[i].get_ref_ptr()); -#else - r.push_back(_voxel_surfaces[i]); -#endif - } - return r; -} -void Dungeon::set_voxel_surfaces(const Vector &voxel_surfaces) { - _voxel_surfaces.clear(); - for (int i = 0; i < voxel_surfaces.size(); i++) { - Ref voxel_surface = Ref(voxel_surfaces[i]); - - _voxel_surfaces.push_back(voxel_surface); - } -} - -//Environments -Ref Dungeon::get_voxel_environment_data(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_environment_datas.size(), Ref()); - - return _voxel_environment_datas.get(index); -} -void Dungeon::set_voxel_environment_data(const int index, const Ref environment_data) { - ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); - - _voxel_environment_datas.set(index, environment_data); -} -void Dungeon::add_voxel_environment_data(const Ref environment_data) { - _voxel_environment_datas.push_back(environment_data); -} -void Dungeon::remove_voxel_environment_data(const int index) { - ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); - - _voxel_environment_datas.remove(index); -} -int Dungeon::get_voxel_environment_data_count() const { - return _voxel_environment_datas.size(); -} - -Vector Dungeon::get_voxel_environment_datas() { - Vector r; - for (int i = 0; i < _voxel_environment_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_voxel_environment_datas[i].get_ref_ptr()); -#else - r.push_back(_voxel_environment_datas[i]); -#endif - } - return r; -} -void Dungeon::set_voxel_environment_datas(const Vector &environment_datas) { - _voxel_environment_datas.clear(); - for (int i = 0; i < environment_datas.size(); i++) { - Ref environment_data = Ref(environment_datas[i]); - - _voxel_environment_datas.push_back(environment_data); - } -} - -void Dungeon::setup_voxel_library(Ref library) { - if (has_method("_setup_voxel_library")) { - call("_setup_voxel_library", library); - } -} - -void Dungeon::_setup_voxel_library(Ref library) { - for (int i = 0; i < get_voxel_surface_count(); ++i) { - Ref s = get_voxel_surface(i); - - if (s.is_valid()) { - library->voxel_surface_add(s); - } - } - - for (int i = 0; i < get_dungeon_corridor_count(); ++i) { - Ref d = get_dungeon_corridor(i); - - if (d.is_valid()) { - d->setup_voxel_library(library); - } - } - - for (int i = 0; i < get_dungeon_end_room_count(); ++i) { - Ref d = get_dungeon_end_room(i); - - if (d.is_valid()) { - d->setup_voxel_library(library); - } - } - - for (int i = 0; i < get_dungeon_room_count(); ++i) { - Ref d = get_dungeon_room(i); - - if (d.is_valid()) { - d->setup_voxel_library(library); - } - } - - for (int i = 0; i < get_dungeon_start_room_count(); ++i) { - Ref d = get_dungeon_start_room(i); - - if (d.is_valid()) { - d->setup_voxel_library(library); - } - } -} - -void Dungeon::generate_voxel_chunk(Ref chunk, bool spawn_mobs) { - ERR_FAIL_COND(!chunk.is_valid()); - - if (has_method("_generate_voxel_chunk")) { - call("_generate_voxel_chunk", chunk, spawn_mobs); - } -} - -void Dungeon::generate_voxel_structure(Ref structure, bool spawn_mobs) { - if (has_method("_generate_voxel_structure")) { - call("_generate_voxel_structure", structure, spawn_mobs); - } -} -#endif - -#ifdef TERRAMAN_PRESENT -Ref Dungeon::get_terra_environment() { - return _terra_environment; -} -void Dungeon::set_terra_environment(Ref value) { - _terra_environment = value; -} - -//// Surfaces //// -Ref Dungeon::get_terra_surface(const int index) const { - ERR_FAIL_INDEX_V(index, _terra_surfaces.size(), Ref()); - - return _terra_surfaces.get(index); -} -void Dungeon::set_terra_surface(const int index, const Ref terra_surface) { - ERR_FAIL_INDEX(index, _terra_surfaces.size()); - - _terra_surfaces.set(index, terra_surface); -} -void Dungeon::add_terra_surface(const Ref terra_surface) { - _terra_surfaces.push_back(terra_surface); -} -void Dungeon::remove_terra_surface(const int index) { - ERR_FAIL_INDEX(index, _terra_surfaces.size()); - - _terra_surfaces.remove(index); -} -int Dungeon::get_terra_surface_count() const { - return _terra_surfaces.size(); -} - -Vector Dungeon::get_terra_surfaces() { - Vector r; - for (int i = 0; i < _terra_surfaces.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_terra_surfaces[i].get_ref_ptr()); -#else - r.push_back(_terra_surfaces[i]); -#endif - } - return r; -} -void Dungeon::set_terra_surfaces(const Vector &terra_surfaces) { - _terra_surfaces.clear(); - for (int i = 0; i < terra_surfaces.size(); i++) { - Ref terra_surface = Ref(terra_surfaces[i]); - - _terra_surfaces.push_back(terra_surface); - } -} - -//Environments -Ref Dungeon::get_terra_environment_data(const int index) const { - ERR_FAIL_INDEX_V(index, _terra_environment_datas.size(), Ref()); - - return _terra_environment_datas.get(index); -} -void Dungeon::set_terra_environment_data(const int index, const Ref environment_data) { - ERR_FAIL_INDEX(index, _terra_environment_datas.size()); - - _terra_environment_datas.set(index, environment_data); -} -void Dungeon::add_terra_environment_data(const Ref environment_data) { - _terra_environment_datas.push_back(environment_data); -} -void Dungeon::remove_terra_environment_data(const int index) { - ERR_FAIL_INDEX(index, _terra_environment_datas.size()); - - _terra_environment_datas.remove(index); -} -int Dungeon::get_terra_environment_data_count() const { - return _terra_environment_datas.size(); -} - -Vector Dungeon::get_terra_environment_datas() { - Vector r; - for (int i = 0; i < _terra_environment_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_terra_environment_datas[i].get_ref_ptr()); -#else - r.push_back(_terra_environment_datas[i]); -#endif - } - return r; -} -void Dungeon::set_terra_environment_datas(const Vector &environment_datas) { - _terra_environment_datas.clear(); - for (int i = 0; i < environment_datas.size(); i++) { - Ref environment_data = Ref(environment_datas[i]); - - _terra_environment_datas.push_back(environment_data); - } -} - -void Dungeon::setup_terra_library(Ref library) { - if (has_method("_setup_terra_library")) { - call("_setup_terra_library", library); - } -} - -void Dungeon::_setup_terra_library(Ref library) { - for (int i = 0; i < get_terra_surface_count(); ++i) { - Ref s = get_terra_surface(i); - - if (s.is_valid()) { - library->voxel_surface_add(s); - } - } - - for (int i = 0; i < get_dungeon_corridor_count(); ++i) { - Ref d = get_dungeon_corridor(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } - - for (int i = 0; i < get_dungeon_end_room_count(); ++i) { - Ref d = get_dungeon_end_room(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } - - for (int i = 0; i < get_dungeon_room_count(); ++i) { - Ref d = get_dungeon_room(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } - - for (int i = 0; i < get_dungeon_start_room_count(); ++i) { - Ref d = get_dungeon_start_room(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } -} - -void Dungeon::generate_terra_chunk(Ref chunk, bool spawn_mobs) { - ERR_FAIL_COND(!chunk.is_valid()); - - if (has_method("_generate_terra_chunk")) { - call("_generate_terra_chunk", chunk, spawn_mobs); - } -} - -void Dungeon::generate_terra_structure(Ref structure, bool spawn_mobs) { - if (has_method("_generate_terra_structure")) { - call("_generate_terra_structure", structure, spawn_mobs); - } -} -#endif - -Ref Dungeon::generate_map() { - ERR_FAIL_COND_V(!has_method("_generate_map"), Ref()); - - return call("_generate_map"); -} - -Dungeon::Dungeon() { - _current_seed = 0; - - _min_sizex = 0; - _min_sizey = 0; - _min_sizez = 0; - - _max_sizex = 0; - _max_sizey = 0; - _max_sizez = 0; - - _min_room_count = 0; - _max_room_count = 0; - - _posx = 0; - _posy = 0; - _posz = 0; - - _sizex = 0; - _sizey = 0; - _sizez = 0; - - _room_count = 0; -} -Dungeon::~Dungeon() { - _dungeon_rooms.clear(); - _dungeon_start_rooms.clear(); - _dungeon_end_rooms.clear(); - _dungeon_corridors.clear(); - -#ifdef ESS_PRESENT - _entity_datas.clear(); -#endif - -#ifdef VOXELMAN_PRESENT - _voxel_environment.unref(); - - _voxel_environment_datas.clear(); - _voxel_surfaces.clear(); -#endif - -#ifdef TERRAMAN_PRESENT - _terra_environment.unref(); - - _terra_environment_datas.clear(); - _terra_surfaces.clear(); -#endif -} - -void Dungeon::_bind_methods() { - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "inst", PROPERTY_HINT_RESOURCE_TYPE, "Dungeon"), - "_instance", - PropertyInfo(Variant::INT, "p_seed"), - PropertyInfo(Variant::OBJECT, "p_instance", PROPERTY_HINT_RESOURCE_TYPE, "Dungeon"))); - - BIND_VMETHOD(MethodInfo("_setup")); - - ClassDB::bind_method(D_METHOD("instance", "seed"), &Dungeon::instance); - ClassDB::bind_method(D_METHOD("_instance", "p_seed", "p_instance"), &Dungeon::_instance); - - ClassDB::bind_method(D_METHOD("setup"), &Dungeon::setup); - - - 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); - ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); - - ClassDB::bind_method(D_METHOD("get_level_range"), &Dungeon::get_level_range); - ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Dungeon::set_level_range); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); - - //Min Size - ClassDB::bind_method(D_METHOD("get_min_sizex"), &Dungeon::get_min_sizex); - ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &Dungeon::set_min_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex"); - - ClassDB::bind_method(D_METHOD("get_min_sizey"), &Dungeon::get_min_sizey); - ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &Dungeon::set_min_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey"); - - ClassDB::bind_method(D_METHOD("get_min_sizez"), &Dungeon::get_min_sizez); - ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &Dungeon::set_min_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez"); - - //Max Size - ClassDB::bind_method(D_METHOD("get_max_sizex"), &Dungeon::get_max_sizex); - ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &Dungeon::set_max_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex"); - - ClassDB::bind_method(D_METHOD("get_max_sizey"), &Dungeon::get_max_sizey); - ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &Dungeon::set_max_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey"); - - ClassDB::bind_method(D_METHOD("get_max_sizez"), &Dungeon::get_max_sizez); - ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &Dungeon::set_max_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez"); - - //Room Count - ClassDB::bind_method(D_METHOD("get_min_room_count"), &Dungeon::get_min_room_count); - ClassDB::bind_method(D_METHOD("set_min_room_count", "value"), &Dungeon::set_min_room_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_room_count"), "set_min_room_count", "get_min_room_count"); - - ClassDB::bind_method(D_METHOD("get_max_room_count"), &Dungeon::get_max_room_count); - ClassDB::bind_method(D_METHOD("set_max_room_count", "value"), &Dungeon::set_max_room_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_room_count"), "set_max_room_count", "get_max_room_count"); - - //Position - ClassDB::bind_method(D_METHOD("get_posx"), &Dungeon::get_posx); - ClassDB::bind_method(D_METHOD("set_posx", "value"), &Dungeon::set_posx); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx"); - - ClassDB::bind_method(D_METHOD("get_posy"), &Dungeon::get_posy); - ClassDB::bind_method(D_METHOD("set_posy", "value"), &Dungeon::set_posy); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy"); - - ClassDB::bind_method(D_METHOD("get_posz"), &Dungeon::get_posz); - ClassDB::bind_method(D_METHOD("set_posz", "value"), &Dungeon::set_posz); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz"); - - //Size - ClassDB::bind_method(D_METHOD("get_sizex"), &Dungeon::get_sizex); - ClassDB::bind_method(D_METHOD("set_sizex", "value"), &Dungeon::set_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex"); - - ClassDB::bind_method(D_METHOD("get_sizey"), &Dungeon::get_sizey); - ClassDB::bind_method(D_METHOD("set_sizey", "value"), &Dungeon::set_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey"); - - ClassDB::bind_method(D_METHOD("get_sizez"), &Dungeon::get_sizez); - ClassDB::bind_method(D_METHOD("set_sizez", "value"), &Dungeon::set_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); - - //Room Count - ClassDB::bind_method(D_METHOD("get_room_count"), &Dungeon::get_room_count); - ClassDB::bind_method(D_METHOD("set_room_count", "value"), &Dungeon::set_room_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "room_count"), "set_room_count", "get_room_count"); - - //Rooms - ClassDB::bind_method(D_METHOD("get_dungeon_room", "index"), &Dungeon::get_dungeon_room); - ClassDB::bind_method(D_METHOD("set_dungeon_room", "index", "data"), &Dungeon::set_dungeon_room); - ClassDB::bind_method(D_METHOD("add_dungeon_room", "dungeon_room"), &Dungeon::add_dungeon_room); - ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &Dungeon::remove_dungeon_room); - - ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &Dungeon::get_dungeon_room_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_rooms"), &Dungeon::get_dungeon_rooms); - ClassDB::bind_method(D_METHOD("set_dungeon_rooms", "dungeon_rooms"), &Dungeon::set_dungeon_rooms); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_rooms", "get_dungeon_rooms"); - - //Start Rooms - ClassDB::bind_method(D_METHOD("get_dungeon_start_room", "index"), &Dungeon::get_dungeon_start_room); - ClassDB::bind_method(D_METHOD("set_dungeon_start_room", "index", "data"), &Dungeon::set_dungeon_start_room); - ClassDB::bind_method(D_METHOD("add_dungeon_start_room", "dungeon_start_room"), &Dungeon::add_dungeon_start_room); - ClassDB::bind_method(D_METHOD("remove_dungeon_start_room", "index"), &Dungeon::remove_dungeon_start_room); - - ClassDB::bind_method(D_METHOD("get_dungeon_start_room_count"), &Dungeon::get_dungeon_start_room_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_start_rooms"), &Dungeon::get_dungeon_start_rooms); - ClassDB::bind_method(D_METHOD("set_dungeon_start_rooms", "dungeon_start_rooms"), &Dungeon::set_dungeon_start_rooms); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_start_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_start_rooms", "get_dungeon_start_rooms"); - - //End Rooms - ClassDB::bind_method(D_METHOD("get_dungeon_end_room", "index"), &Dungeon::get_dungeon_end_room); - ClassDB::bind_method(D_METHOD("set_dungeon_end_room", "index", "data"), &Dungeon::set_dungeon_end_room); - ClassDB::bind_method(D_METHOD("add_dungeon_end_room", "dungeon_end_room"), &Dungeon::add_dungeon_end_room); - ClassDB::bind_method(D_METHOD("remove_dungeon_end_room", "index"), &Dungeon::remove_dungeon_end_room); - ClassDB::bind_method(D_METHOD("get_dungeon_end_room_count"), &Dungeon::get_dungeon_end_room_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_end_rooms"), &Dungeon::get_dungeon_end_rooms); - ClassDB::bind_method(D_METHOD("set_dungeon_end_rooms", "dungeon_end_rooms"), &Dungeon::set_dungeon_end_rooms); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_end_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_end_rooms", "get_dungeon_end_rooms"); - - //Corridors - ClassDB::bind_method(D_METHOD("get_dungeon_corridor", "index"), &Dungeon::get_dungeon_corridor); - ClassDB::bind_method(D_METHOD("set_dungeon_corridor", "index", "data"), &Dungeon::set_dungeon_corridor); - ClassDB::bind_method(D_METHOD("add_dungeon_corridor", "dungeon_corridor"), &Dungeon::add_dungeon_corridor); - ClassDB::bind_method(D_METHOD("remove_dungeon_corridor", "index"), &Dungeon::remove_dungeon_corridor); - ClassDB::bind_method(D_METHOD("get_dungeon_corridor_count"), &Dungeon::get_dungeon_corridor_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_corridors"), &Dungeon::get_dungeon_corridors); - ClassDB::bind_method(D_METHOD("set_dungeon_corridors", "dungeon_corridors"), &Dungeon::set_dungeon_corridors); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridors", PROPERTY_HINT_NONE, "17/17:DungeonCorridor", PROPERTY_USAGE_DEFAULT, "DungeonCorridor"), "set_dungeon_corridors", "get_dungeon_corridors"); - - //Room Datas - ClassDB::bind_method(D_METHOD("get_dungeon_room_data", "index"), &Dungeon::get_dungeon_room_data); - ClassDB::bind_method(D_METHOD("set_dungeon_room_data", "index", "data"), &Dungeon::set_dungeon_room_data); - ClassDB::bind_method(D_METHOD("add_dungeon_room_data", "dungeon_room_data"), &Dungeon::add_dungeon_room_data); - ClassDB::bind_method(D_METHOD("remove_dungeon_room_data", "index"), &Dungeon::remove_dungeon_room_data); - - ClassDB::bind_method(D_METHOD("get_dungeon_room_data_count"), &Dungeon::get_dungeon_room_data_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_room_datas"), &Dungeon::get_dungeon_room_datas); - ClassDB::bind_method(D_METHOD("set_dungeon_room_datas", "dungeon_room_datas"), &Dungeon::set_dungeon_room_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_room_datas", "get_dungeon_room_datas"); - - //Start Room Datas - ClassDB::bind_method(D_METHOD("get_dungeon_start_room_data", "index"), &Dungeon::get_dungeon_start_room_data); - ClassDB::bind_method(D_METHOD("set_dungeon_start_room_data", "index", "data"), &Dungeon::set_dungeon_start_room_data); - ClassDB::bind_method(D_METHOD("add_dungeon_start_room_data", "dungeon_start_room_data"), &Dungeon::add_dungeon_start_room_data); - ClassDB::bind_method(D_METHOD("remove_dungeon_start_room_data", "index"), &Dungeon::remove_dungeon_start_room_data); - - ClassDB::bind_method(D_METHOD("get_dungeon_start_room_data_count"), &Dungeon::get_dungeon_start_room_data_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_start_room_datas"), &Dungeon::get_dungeon_start_room_datas); - ClassDB::bind_method(D_METHOD("set_dungeon_start_room_datas", "dungeon_start_room_datas"), &Dungeon::set_dungeon_start_room_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_start_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_start_room_datas", "get_dungeon_start_room_datas"); - - //End Room Datas - ClassDB::bind_method(D_METHOD("get_dungeon_end_room_data", "index"), &Dungeon::get_dungeon_end_room_data); - ClassDB::bind_method(D_METHOD("set_dungeon_end_room_data", "index", "data"), &Dungeon::set_dungeon_end_room_data); - ClassDB::bind_method(D_METHOD("add_dungeon_end_room_data", "dungeon_end_room_data"), &Dungeon::add_dungeon_end_room_data); - ClassDB::bind_method(D_METHOD("remove_dungeon_end_room_data", "index"), &Dungeon::remove_dungeon_end_room_data); - ClassDB::bind_method(D_METHOD("get_dungeon_end_room_data_count"), &Dungeon::get_dungeon_end_room_data_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_end_room_datas"), &Dungeon::get_dungeon_end_room_datas); - ClassDB::bind_method(D_METHOD("set_dungeon_end_room_datas", "dungeon_end_room_datas"), &Dungeon::set_dungeon_end_room_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_end_room_datas", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_end_room_datas", "get_dungeon_end_room_datas"); - - //Corridor Datas - ClassDB::bind_method(D_METHOD("get_dungeon_corridor_data", "index"), &Dungeon::get_dungeon_corridor_data); - ClassDB::bind_method(D_METHOD("set_dungeon_corridor_data", "index", "data"), &Dungeon::set_dungeon_corridor_data); - ClassDB::bind_method(D_METHOD("add_dungeon_corridor_data", "dungeon_corridor_data"), &Dungeon::add_dungeon_corridor_data); - ClassDB::bind_method(D_METHOD("remove_dungeon_corridor_data", "index"), &Dungeon::remove_dungeon_corridor_data); - ClassDB::bind_method(D_METHOD("get_dungeon_corridor_data_count"), &Dungeon::get_dungeon_corridor_data_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_corridor_datas"), &Dungeon::get_dungeon_corridor_datas); - ClassDB::bind_method(D_METHOD("set_dungeon_corridor_datas", "dungeon_corridor_datas"), &Dungeon::set_dungeon_corridor_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridor_datas", PROPERTY_HINT_NONE, "17/17:DungeonCorridor", PROPERTY_USAGE_DEFAULT, "DungeonCorridor"), "set_dungeon_corridor_datas", "get_dungeon_corridor_datas"); - -#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); - - ClassDB::bind_method(D_METHOD("get_entity_datas"), &Dungeon::get_entity_datas); - ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &Dungeon::set_entity_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); -#endif - -#ifdef VOXELMAN_PRESENT - BIND_VMETHOD(MethodInfo("_setup_voxel_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); - BIND_VMETHOD(MethodInfo("_generate_voxel_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_voxel_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - - ClassDB::bind_method(D_METHOD("setup_voxel_library", "library"), &Dungeon::setup_voxel_library); - ClassDB::bind_method(D_METHOD("_setup_voxel_library", "library"), &Dungeon::_setup_voxel_library); - - ClassDB::bind_method(D_METHOD("generate_voxel_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_voxel_chunk); - ClassDB::bind_method(D_METHOD("generate_voxel_structure", "structure", "spawn_mobs"), &Dungeon::generate_voxel_structure); - - //Environment - ClassDB::bind_method(D_METHOD("get_voxel_environment"), &Dungeon::get_voxel_environment); - ClassDB::bind_method(D_METHOD("set_voxel_environment", "value"), &Dungeon::set_voxel_environment); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_voxel_environment", "get_voxel_environment"); - - //Environments - ClassDB::bind_method(D_METHOD("get_voxel_environment_data", "index"), &Dungeon::get_voxel_environment_data); - ClassDB::bind_method(D_METHOD("set_voxel_environment_data", "index", "data"), &Dungeon::set_voxel_environment_data); - ClassDB::bind_method(D_METHOD("add_voxel_environment_data", "environment_data"), &Dungeon::add_voxel_environment_data); - ClassDB::bind_method(D_METHOD("remove_voxel_environment_data", "index"), &Dungeon::remove_voxel_environment_data); - ClassDB::bind_method(D_METHOD("get_voxel_environment_data_count"), &Dungeon::get_voxel_environment_data_count); - - ClassDB::bind_method(D_METHOD("get_voxel_environment_datas"), &Dungeon::get_voxel_environment_datas); - ClassDB::bind_method(D_METHOD("set_voxel_environment_datas", "environment_datas"), &Dungeon::set_voxel_environment_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_voxel_environment_datas", "get_voxel_environment_datas"); - - //Surfaces - ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &Dungeon::get_voxel_surface); - ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &Dungeon::set_voxel_surface); - ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &Dungeon::add_voxel_surface); - ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &Dungeon::remove_voxel_surface); - ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &Dungeon::get_voxel_surface_count); - - ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &Dungeon::get_voxel_surfaces); - ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &Dungeon::set_voxel_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_voxel_surfaces", "get_voxel_surfaces"); -#endif - -#ifdef TERRAMAN_PRESENT - BIND_VMETHOD(MethodInfo("_setup_terra_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"))); - BIND_VMETHOD(MethodInfo("_generate_terra_structure", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "TerraStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_terra_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - - ClassDB::bind_method(D_METHOD("setup_terra_library", "library"), &Dungeon::setup_terra_library); - ClassDB::bind_method(D_METHOD("_setup_terra_library", "library"), &Dungeon::_setup_terra_library); - - ClassDB::bind_method(D_METHOD("generate_terra_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_terra_chunk); - ClassDB::bind_method(D_METHOD("generate_terra_structure", "structure", "spawn_mobs"), &Dungeon::generate_terra_structure); - - //Environment - ClassDB::bind_method(D_METHOD("get_terra_environment"), &Dungeon::get_terra_environment); - ClassDB::bind_method(D_METHOD("set_terra_environment", "value"), &Dungeon::set_terra_environment); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "terra_environment", PROPERTY_HINT_RESOURCE_TYPE, "TerraEnvironmentData"), "set_terra_environment", "get_terra_environment"); - - //Environments - ClassDB::bind_method(D_METHOD("get_terra_environment_data", "index"), &Dungeon::get_terra_environment_data); - ClassDB::bind_method(D_METHOD("set_terra_environment_data", "index", "data"), &Dungeon::set_terra_environment_data); - ClassDB::bind_method(D_METHOD("add_terra_environment_data", "environment_data"), &Dungeon::add_terra_environment_data); - ClassDB::bind_method(D_METHOD("remove_terra_environment_data", "index"), &Dungeon::remove_terra_environment_data); - ClassDB::bind_method(D_METHOD("get_terra_environment_data_count"), &Dungeon::get_terra_environment_data_count); - - ClassDB::bind_method(D_METHOD("get_terra_environment_datas"), &Dungeon::get_terra_environment_datas); - ClassDB::bind_method(D_METHOD("set_terra_environment_datas", "environment_datas"), &Dungeon::set_terra_environment_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_environment_datas", PROPERTY_HINT_NONE, "17/17:TerraEnvironmentData", PROPERTY_USAGE_DEFAULT, "TerraEnvironmentData"), "set_terra_environment_datas", "get_terra_environment_datas"); - - //Surfaces - ClassDB::bind_method(D_METHOD("get_terra_surface", "index"), &Dungeon::get_terra_surface); - ClassDB::bind_method(D_METHOD("set_terra_surface", "index", "data"), &Dungeon::set_terra_surface); - ClassDB::bind_method(D_METHOD("add_terra_surface", "terra_surface"), &Dungeon::add_terra_surface); - ClassDB::bind_method(D_METHOD("remove_terra_surface", "index"), &Dungeon::remove_terra_surface); - ClassDB::bind_method(D_METHOD("get_terra_surface_count"), &Dungeon::get_terra_surface_count); - - ClassDB::bind_method(D_METHOD("get_terra_surfaces"), &Dungeon::get_terra_surfaces); - ClassDB::bind_method(D_METHOD("set_terra_surfaces", "terra_surfaces"), &Dungeon::set_terra_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_surfaces", PROPERTY_HINT_NONE, "17/17:TerraSurface", PROPERTY_USAGE_DEFAULT, "TerraSurface"), "set_terra_surfaces", "get_terra_surfaces"); -#endif - - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); - - ClassDB::bind_method(D_METHOD("generate_map"), &Dungeon::generate_map); -} diff --git a/main/dungeon.h b/main/dungeon.h deleted file mode 100644 index 9850c6e..0000000 --- a/main/dungeon.h +++ /dev/null @@ -1,343 +0,0 @@ -/* -Copyright (c) 2019-2021 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef DUNGEON_H -#define DUNGEON_H - -#include "core/version.h" - -#if VERSION_MAJOR > 3 -#include "core/io/resource.h" -#include "core/object/reference.h" -#else -#include "core/reference.h" -#include "core/resource.h" -#endif - -#include "dungeon_corridor.h" -#include "dungeon_room.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" -#endif - -#ifdef TERRAMAN_PRESENT -#include "../../terraman/library/terraman_library.h" -#include "../../terraman/world/terra_environment_data.h" -#include "../../terraman/world/terra_chunk.h" -#include "../../terraman/world/terra_structure.h" -#endif - -#ifdef ESS_PRESENT -#include "../../entity_spell_system/entities/data/entity_data.h" -#endif - -class Dungeon : public Resource { - GDCLASS(Dungeon, Resource); - -public: - int get_current_seed(); - void set_current_seed(int value); - - Vector2 get_level_range(); - void set_level_range(Vector2 value); - - //Min Size - int get_min_sizex(); - void set_min_sizex(int value); - - int get_min_sizey(); - void set_min_sizey(int value); - - int get_min_sizez(); - void set_min_sizez(int value); - - //Max Size - int get_max_sizex(); - void set_max_sizex(int value); - - int get_max_sizey(); - void set_max_sizey(int value); - - int get_max_sizez(); - void set_max_sizez(int value); - - //Room Count - int get_min_room_count(); - void set_min_room_count(int value); - - int get_max_room_count(); - void set_max_room_count(int value); - - //Pos - int get_posx(); - void set_posx(int value); - - int get_posy(); - void set_posy(int value); - - int get_posz(); - void set_posz(int value); - - //Size - int get_sizex(); - void set_sizex(int value); - - int get_sizey(); - void set_sizey(int value); - - int get_sizez(); - void set_sizez(int value); - - //Room Count - int get_room_count(); - void set_room_count(int value); - - //Rooms - Ref get_dungeon_room(const int index) const; - void set_dungeon_room(const int index, const Ref dungeon_room); - void add_dungeon_room(const Ref dungeon_room); - void remove_dungeon_room(const int index); - int get_dungeon_room_count() const; - - Vector get_dungeon_rooms(); - void set_dungeon_rooms(const Vector &dungeon_rooms); - - //Start Rooms - Ref get_dungeon_start_room(const int index) const; - void set_dungeon_start_room(const int index, const Ref dungeon_start_room); - void add_dungeon_start_room(const Ref dungeon_start_room); - void remove_dungeon_start_room(const int index); - int get_dungeon_start_room_count() const; - - Vector get_dungeon_start_rooms(); - void set_dungeon_start_rooms(const Vector &dungeon_start_rooms); - - //End Rooms - Ref get_dungeon_end_room(const int index) const; - void set_dungeon_end_room(const int index, const Ref dungeon_end_room); - void add_dungeon_end_room(const Ref dungeon_end_room); - void remove_dungeon_end_room(const int index); - int get_dungeon_end_room_count() const; - - Vector get_dungeon_end_rooms(); - void set_dungeon_end_rooms(const Vector &dungeon_end_rooms); - - //Corridors - Ref get_dungeon_corridor(const int index) const; - void set_dungeon_corridor(const int index, const Ref dungeon_corridors); - void add_dungeon_corridor(const Ref dungeon_corridors); - void remove_dungeon_corridor(const int index); - int get_dungeon_corridor_count() const; - - Vector get_dungeon_corridors(); - void set_dungeon_corridors(const Vector &dungeon_corridors); - - //Room Datas - Ref get_dungeon_room_data(const int index) const; - void set_dungeon_room_data(const int index, const Ref dungeon_room); - void add_dungeon_room_data(const Ref dungeon_room); - void remove_dungeon_room_data(const int index); - int get_dungeon_room_data_count() const; - - Vector get_dungeon_room_datas(); - void set_dungeon_room_datas(const Vector &dungeon_rooms); - - //Start Room Datas - Ref get_dungeon_start_room_data(const int index) const; - void set_dungeon_start_room_data(const int index, const Ref dungeon_start_room); - void add_dungeon_start_room_data(const Ref dungeon_start_room); - void remove_dungeon_start_room_data(const int index); - int get_dungeon_start_room_data_count() const; - - Vector get_dungeon_start_room_datas(); - void set_dungeon_start_room_datas(const Vector &dungeon_start_rooms); - - //End Room Datas - Ref get_dungeon_end_room_data(const int index) const; - void set_dungeon_end_room_data(const int index, const Ref dungeon_end_room); - void add_dungeon_end_room_data(const Ref dungeon_end_room); - void remove_dungeon_end_room_data(const int index); - int get_dungeon_end_room_data_count() const; - - Vector get_dungeon_end_room_datas(); - void set_dungeon_end_room_datas(const Vector &dungeon_end_rooms); - - //Corridor Datas - Ref get_dungeon_corridor_data(const int index) const; - void set_dungeon_corridor_data(const int index, const Ref dungeon_corridors); - void add_dungeon_corridor_data(const Ref dungeon_corridors); - void remove_dungeon_corridor_data(const int index); - int get_dungeon_corridor_data_count() const; - - Vector get_dungeon_corridor_datas(); - void set_dungeon_corridor_datas(const Vector &dungeon_corridors); - -#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; - - Vector get_entity_datas(); - void set_entity_datas(const Vector &entity_datas); -#endif - - Ref instance(const int seed); - virtual Ref _instance(const int seed, Ref inst); - - void setup(); - -#ifdef VOXELMAN_PRESENT - //Environment - Ref get_voxel_environment(); - void set_voxel_environment(Ref value); - - //Environments - Ref get_voxel_environment_data(const int index) const; - void set_voxel_environment_data(const int index, const Ref environment_data); - void add_voxel_environment_data(const Ref environment_data); - void remove_voxel_environment_data(const int index); - int get_voxel_environment_data_count() const; - - Vector get_voxel_environment_datas(); - void set_voxel_environment_datas(const Vector &environment_datas); - - //Surfaces - Ref get_voxel_surface(const int index) const; - void set_voxel_surface(const int index, const Ref voxel_surface); - void add_voxel_surface(const Ref voxel_surface); - void remove_voxel_surface(const int index); - int get_voxel_surface_count() const; - - Vector get_voxel_surfaces(); - void set_voxel_surfaces(const Vector &voxel_surfaces); - - void setup_voxel_library(Ref library); - void _setup_voxel_library(Ref library); - - void generate_voxel_chunk(Ref chunk, bool spawn_mobs); - void generate_voxel_structure(Ref structure, bool spawn_mobs); -#endif - -#ifdef TERRAMAN_PRESENT - //Environment - Ref get_terra_environment(); - void set_terra_environment(Ref value); - - //Environments - Ref get_terra_environment_data(const int index) const; - void set_terra_environment_data(const int index, const Ref environment_data); - void add_terra_environment_data(const Ref environment_data); - void remove_terra_environment_data(const int index); - int get_terra_environment_data_count() const; - - Vector get_terra_environment_datas(); - void set_terra_environment_datas(const Vector &environment_datas); - - //Surfaces - Ref get_terra_surface(const int index) const; - void set_terra_surface(const int index, const Ref terra_surface); - void add_terra_surface(const Ref terra_surface); - void remove_terra_surface(const int index); - int get_terra_surface_count() const; - - Vector get_terra_surfaces(); - void set_terra_surfaces(const Vector &terra_surfaces); - - void setup_terra_library(Ref library); - void _setup_terra_library(Ref library); - - void generate_terra_chunk(Ref chunk, bool spawn_mobs); - void generate_terra_structure(Ref structure, bool spawn_mobs); -#endif - - Ref generate_map(); - - Dungeon(); - ~Dungeon(); - -protected: - static void _bind_methods(); - -private: - int _current_seed; - - Vector2 _level_range; - - int _posx; - int _posy; - int _posz; - - int _sizex; - int _sizey; - int _sizez; - - int _room_count; - - int _min_sizex; - int _min_sizey; - int _min_sizez; - - int _max_sizex; - int _max_sizey; - int _max_sizez; - - int _min_room_count; - int _max_room_count; - - - Vector > _dungeon_rooms; - Vector > _dungeon_start_rooms; - Vector > _dungeon_end_rooms; - Vector > _dungeon_corridors; - - Vector > _dungeon_room_datas; - Vector > _dungeon_start_room_datas; - Vector > _dungeon_end_room_datas; - Vector > _dungeon_corridor_datas; - -#ifdef ESS_PRESENT - Vector > _entity_datas; -#endif - -#ifdef VOXELMAN_PRESENT - Ref _voxel_environment; - - Vector > _voxel_environment_datas; - Vector > _voxel_surfaces; -#endif - -#ifdef TERRAMAN_PRESENT - Ref _terra_environment; - - Vector > _terra_environment_datas; - Vector > _terra_surfaces; -#endif -}; - -#endif diff --git a/main/dungeon_corridor.cpp b/main/dungeon_corridor.cpp deleted file mode 100644 index 6ec5feb..0000000 --- a/main/dungeon_corridor.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (c) 2019-2021 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "dungeon_corridor.h" - -int DungeonCorridor::get_max_connections() { - return _max_connections; -} -void DungeonCorridor::set_max_connections(int value) { - _max_connections = value; -} - -//Rooms -Ref DungeonCorridor::get_dungeon_room(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_rooms.size(), Ref()); - - return _dungeon_rooms.get(index); -} -void DungeonCorridor::set_dungeon_room(const int index, const Ref dungeon_room) { - ERR_FAIL_INDEX(index, _dungeon_rooms.size()); - - _dungeon_rooms.set(index, dungeon_room); -} -void DungeonCorridor::add_dungeon_room(const Ref dungeon_room) { - _dungeon_rooms.push_back(dungeon_room); -} -void DungeonCorridor::remove_dungeon_room(const int index) { - ERR_FAIL_INDEX(index, _dungeon_rooms.size()); - - _dungeon_rooms.remove(index); -} - -int DungeonCorridor::get_dungeon_room_count() const { - return _dungeon_rooms.size(); -} - -Ref DungeonCorridor::_instance(const int seed, Ref inst) { - DungeonRoom::_instance(seed, inst); - - Ref cinst = inst; - cinst->set_max_connections(_max_connections); - - return cinst; -} - -DungeonCorridor::DungeonCorridor() { - _max_connections = 2; -} -DungeonCorridor::~DungeonCorridor() { - _dungeon_rooms.clear(); -} - -void DungeonCorridor::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_max_connections"), &DungeonCorridor::get_max_connections); - ClassDB::bind_method(D_METHOD("set_max_connections", "value"), &DungeonCorridor::set_max_connections); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_connections"), "set_max_connections", "get_max_connections"); - - //Rooms - ClassDB::bind_method(D_METHOD("get_dungeon_room", "index"), &DungeonCorridor::get_dungeon_room); - ClassDB::bind_method(D_METHOD("set_dungeon_room", "index", "data"), &DungeonCorridor::set_dungeon_room); - ClassDB::bind_method(D_METHOD("add_dungeon_room", "dungeon_room"), &DungeonCorridor::add_dungeon_room); - ClassDB::bind_method(D_METHOD("remove_dungeon_room", "index"), &DungeonCorridor::remove_dungeon_room); - - ClassDB::bind_method(D_METHOD("get_dungeon_room_count"), &DungeonCorridor::get_dungeon_room_count); -} diff --git a/main/dungeon_corridor.h b/main/dungeon_corridor.h deleted file mode 100644 index 54904a2..0000000 --- a/main/dungeon_corridor.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2019-2021 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef DUNGEON_CORRIDOR_H -#define DUNGEON_CORRIDOR_H - -#include "dungeon_room.h" - -class DungeonCorridor : public DungeonRoom { - GDCLASS(DungeonCorridor, DungeonRoom); - -public: - int get_max_connections(); - void set_max_connections(int value); - - //Rooms - Ref get_dungeon_room(const int index) const; - void set_dungeon_room(const int index, const Ref dungeon_room); - void add_dungeon_room(const Ref dungeon_room); - void remove_dungeon_room(const int index); - - int get_dungeon_room_count() const; - - Ref _instance(const int seed, Ref inst); - - DungeonCorridor(); - ~DungeonCorridor(); - -protected: - static void _bind_methods(); - -private: - int _max_connections; - Vector > _dungeon_rooms; -}; - -#endif diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp deleted file mode 100644 index af659d0..0000000 --- a/main/dungeon_room.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/* -Copyright (c) 2019-2021 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "dungeon_room.h" - -int DungeonRoom::get_current_seed() { - return _current_seed; -} -void DungeonRoom::set_current_seed(int value) { - _current_seed = value; -} - -Vector2 DungeonRoom::get_level_range() { - return _level_range; -} -void DungeonRoom::set_level_range(Vector2 value) { - _level_range = value; -} - -//Min Size -int DungeonRoom::get_min_sizex() { - return _min_sizex; -} -void DungeonRoom::set_min_sizex(int value) { - _min_sizex = value; -} - -int DungeonRoom::get_min_sizey() { - return _min_sizey; -} -void DungeonRoom::set_min_sizey(int value) { - _min_sizey = value; -} - -int DungeonRoom::get_min_sizez() { - return _min_sizez; -} -void DungeonRoom::set_min_sizez(int value) { - _min_sizez = value; -} - -//Max Size -int DungeonRoom::get_max_sizex() { - return _max_sizex; -} -void DungeonRoom::set_max_sizex(int value) { - _max_sizex = value; -} - -int DungeonRoom::get_max_sizey() { - return _max_sizey; -} -void DungeonRoom::set_max_sizey(int value) { - _max_sizey = value; -} - -int DungeonRoom::get_max_sizez() { - return _max_sizez; -} -void DungeonRoom::set_max_sizez(int value) { - _max_sizez = value; -} - -//Position -int DungeonRoom::get_posx() { - return _posx; -} -void DungeonRoom::set_posx(int value) { - _posx = value; -} - -int DungeonRoom::get_posy() { - return _posy; -} -void DungeonRoom::set_posy(int value) { - _posy = value; -} - -int DungeonRoom::get_posz() { - return _posz; -} -void DungeonRoom::set_posz(int value) { - _posz = value; -} - -//Size -int DungeonRoom::get_sizex() { - return _sizex; -} -void DungeonRoom::set_sizex(int value) { - _sizex = value; -} - -int DungeonRoom::get_sizey() { - return _sizey; -} -void DungeonRoom::set_sizey(int value) { - _sizey = value; -} - -int DungeonRoom::get_sizez() { - return _sizez; -} -void DungeonRoom::set_sizez(int value) { - _sizez = value; -} - -//Props -Ref DungeonRoom::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); - - return _prop_datas.get(index); -} -void DungeonRoom::set_prop_data(const int index, const Ref prop_data) { - ERR_FAIL_INDEX(index, _prop_datas.size()); - - _prop_datas.set(index, prop_data); -} -void DungeonRoom::add_prop_data(const Ref prop_data) { - _prop_datas.push_back(prop_data); -} -void DungeonRoom::remove_prop_data(const int index) { - ERR_FAIL_INDEX(index, _prop_datas.size()); - - _prop_datas.remove(index); -} -int DungeonRoom::get_prop_data_count() const { - return _prop_datas.size(); -} - -Vector DungeonRoom::get_prop_datas() { - Vector r; - for (int i = 0; i < _prop_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_prop_datas[i].get_ref_ptr()); -#else - r.push_back(_prop_datas[i]); -#endif - } - return r; -} -void DungeonRoom::set_prop_datas(const Vector &prop_datas) { - _prop_datas.clear(); - for (int i = 0; i < prop_datas.size(); i++) { - Ref prop_data = Ref(prop_datas[i]); - - _prop_datas.push_back(prop_data); - } -} - -#ifdef ESS_PRESENT -//Entities -Ref DungeonRoom::get_entity_data(const int index) const { - ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); - - return _entity_datas.get(index); -} -void DungeonRoom::set_entity_data(const int index, const Ref entity_data) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.set(index, entity_data); -} -void DungeonRoom::add_entity_data(const Ref entity_data) { - _entity_datas.push_back(entity_data); -} -void DungeonRoom::remove_entity_data(const int index) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.remove(index); -} -int DungeonRoom::get_entity_data_count() const { - return _entity_datas.size(); -} - -Vector DungeonRoom::get_entity_datas() { - Vector r; - for (int i = 0; i < _entity_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_datas[i]); -#endif - } - return r; -} -void DungeonRoom::set_entity_datas(const Vector &entity_datas) { - _entity_datas.clear(); - for (int i = 0; i < entity_datas.size(); i++) { - Ref entity_data = Ref(entity_datas[i]); - - _entity_datas.push_back(entity_data); - } -} - -#endif - -Ref DungeonRoom::instance(const int seed) { - Ref inst; - - inst = Ref(Object::cast_to(ClassDB::instance(get_class_name()))); - ERR_FAIL_COND_V(!inst.is_valid(), inst); - - if (!get_script().is_null()) - inst->set_script(get_script()); - - return call("_instance", seed, inst); -} - -Ref DungeonRoom::_instance(const int seed, Ref inst) { - inst->set_current_seed(seed); - inst->set_level_range(_level_range); - - inst->set_posx(_posx); - inst->set_posy(_posy); - inst->set_posz(_posz); - - inst->set_sizex(_sizex); - inst->set_sizey(_sizey); - inst->set_sizez(_sizez); - - inst->set_min_sizex(_min_sizex); - inst->set_min_sizey(_min_sizey); - inst->set_min_sizez(_min_sizez); - - inst->set_max_sizex(_max_sizex); - inst->set_max_sizey(_max_sizey); - inst->set_max_sizez(_max_sizez); - - for (int i = 0; i < _prop_datas.size(); ++i) { - Ref p = _prop_datas[i]; - - inst->add_prop_data(p); - } - -#ifdef ESS_PRESENT - for (int i = 0; i < _entity_datas.size(); ++i) { - Ref d = _entity_datas[i]; - - inst->add_entity_data(d); - } -#endif - -#ifdef VOXELMAN_PRESENT - inst->set_voxel_environment(_voxel_environment); - //don't - //inst->set_structure(_structure); - - for (int i = 0; i < _voxel_environment_datas.size(); ++i) { - Ref d = _voxel_environment_datas[i]; - - if (!d.is_valid()) - continue; - - inst->add_voxel_environment_data(d); - } - - for (int i = 0; i < _voxel_surfaces.size(); ++i) { - Ref d = _voxel_surfaces[i]; - - if (!d.is_valid()) - continue; - - inst->add_voxel_surface(d); - } -#endif - - -#ifdef TERRAMAN_PRESENT - inst->set_terra_environment(_terra_environment); - //don't - //inst->set_structure(_structure); - - for (int i = 0; i < _terra_environment_datas.size(); ++i) { - Ref d = _terra_environment_datas[i]; - - if (!d.is_valid()) - continue; - - inst->add_terra_environment_data(d); - } - - for (int i = 0; i < _terra_surfaces.size(); ++i) { - Ref d = _terra_surfaces[i]; - - if (!d.is_valid()) - continue; - - inst->add_terra_surface(d); - } -#endif - - return inst; -} - -void DungeonRoom::setup() { - if (has_method("_setup")) { - call("_setup"); - } -} - -#ifdef VOXELMAN_PRESENT - -Ref DungeonRoom::get_voxel_environment() { - return _voxel_environment; -} -void DungeonRoom::set_voxel_environment(Ref value) { - _voxel_environment = value; -} - -Ref DungeonRoom::get_voxel_structure() { - return _voxel_structure; -} -void DungeonRoom::set_voxel_structure(Ref structure) { - _voxel_structure = structure; -} - -//Environments -Ref DungeonRoom::get_voxel_environment_data(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_environment_datas.size(), Ref()); - - return _voxel_environment_datas.get(index); -} -void DungeonRoom::set_voxel_environment_data(const int index, const Ref environment_data) { - ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); - - _voxel_environment_datas.set(index, environment_data); -} -void DungeonRoom::add_voxel_environment_data(const Ref environment_data) { - _voxel_environment_datas.push_back(environment_data); -} -void DungeonRoom::remove_voxel_environment_data(const int index) { - ERR_FAIL_INDEX(index, _voxel_environment_datas.size()); - - _voxel_environment_datas.remove(index); -} -int DungeonRoom::get_voxel_environment_data_count() const { - return _voxel_environment_datas.size(); -} - -Vector DungeonRoom::get_voxel_environment_datas() { - Vector r; - for (int i = 0; i < _voxel_environment_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_voxel_environment_datas[i].get_ref_ptr()); -#else - r.push_back(_voxel_environment_datas[i]); -#endif - } - return r; -} -void DungeonRoom::set_voxel_environment_datas(const Vector &environment_datas) { - _voxel_environment_datas.clear(); - for (int i = 0; i < environment_datas.size(); i++) { - Ref environment_data = Ref(environment_datas[i]); - - _voxel_environment_datas.push_back(environment_data); - } -} - -//// Surfaces //// -Ref DungeonRoom::get_voxel_surface(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); - - return _voxel_surfaces.get(index); -} -void DungeonRoom::set_voxel_surface(const int index, const Ref voxel_surface) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.set(index, voxel_surface); -} -void DungeonRoom::add_voxel_surface(const Ref voxel_surface) { - _voxel_surfaces.push_back(voxel_surface); -} -void DungeonRoom::remove_voxel_surface(const int index) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.remove(index); -} -int DungeonRoom::get_voxel_surface_count() const { - return _voxel_surfaces.size(); -} - -Vector DungeonRoom::get_voxel_surfaces() { - Vector r; - for (int i = 0; i < _voxel_surfaces.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_voxel_surfaces[i].get_ref_ptr()); -#else - r.push_back(_voxel_surfaces[i]); -#endif - } - return r; -} -void DungeonRoom::set_voxel_surfaces(const Vector &voxel_surfaces) { - _voxel_surfaces.clear(); - for (int i = 0; i < voxel_surfaces.size(); i++) { - Ref voxel_surface = Ref(voxel_surfaces[i]); - - _voxel_surfaces.push_back(voxel_surface); - } -} - -void DungeonRoom::setup_voxel_library(Ref library) { - if (has_method("_setup_voxel_library")) { - call("_setup_voxel_library", library); - } -} - -void DungeonRoom::_setup_voxel_library(Ref library) { - for (int i = 0; i < get_voxel_surface_count(); ++i) { - Ref s = get_voxel_surface(i); - - if (s.is_valid()) { - library->voxel_surface_add(s); - } - } - -#ifdef PROPS_PRESENT - for (int i = 0; i < get_prop_data_count(); ++i) { - Ref s = get_prop_data(i); - - if (s.is_valid()) { - Ref pd = s->get_prop(); - - if (pd.is_valid()) - library->prop_add(pd); - } - } -#endif -} - -void DungeonRoom::generate_voxel_chunk(Ref chunk, bool spawn_mobs) { - ERR_FAIL_COND(!chunk.is_valid()); - - if (has_method("_generate_voxel_chunk")) { - call("_generate_voxel_chunk", chunk, spawn_mobs); - } -} - -void DungeonRoom::generate_voxel_room(Ref structure, bool spawn_mobs) { - if (has_method("_generate_voxel_room")) { - call("_generate_voxel_room", structure, spawn_mobs); - } -} -#endif - -#ifdef TERRAMAN_PRESENT - -Ref DungeonRoom::get_terra_environment() { - return _terra_environment; -} -void DungeonRoom::set_terra_environment(Ref value) { - _terra_environment = value; -} - -Ref DungeonRoom::get_terra_structure() { - return _terra_structure; -} -void DungeonRoom::set_terra_structure(Ref structure) { - _terra_structure = structure; -} - -//Environments -Ref DungeonRoom::get_terra_environment_data(const int index) const { - ERR_FAIL_INDEX_V(index, _terra_environment_datas.size(), Ref()); - - return _terra_environment_datas.get(index); -} -void DungeonRoom::set_terra_environment_data(const int index, const Ref environment_data) { - ERR_FAIL_INDEX(index, _terra_environment_datas.size()); - - _terra_environment_datas.set(index, environment_data); -} -void DungeonRoom::add_terra_environment_data(const Ref environment_data) { - _terra_environment_datas.push_back(environment_data); -} -void DungeonRoom::remove_terra_environment_data(const int index) { - ERR_FAIL_INDEX(index, _terra_environment_datas.size()); - - _terra_environment_datas.remove(index); -} -int DungeonRoom::get_terra_environment_data_count() const { - return _terra_environment_datas.size(); -} - -Vector DungeonRoom::get_terra_environment_datas() { - Vector r; - for (int i = 0; i < _terra_environment_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_terra_environment_datas[i].get_ref_ptr()); -#else - r.push_back(_terra_environment_datas[i]); -#endif - } - return r; -} -void DungeonRoom::set_terra_environment_datas(const Vector &environment_datas) { - _terra_environment_datas.clear(); - for (int i = 0; i < environment_datas.size(); i++) { - Ref environment_data = Ref(environment_datas[i]); - - _terra_environment_datas.push_back(environment_data); - } -} - -//// Surfaces //// -Ref DungeonRoom::get_terra_surface(const int index) const { - ERR_FAIL_INDEX_V(index, _terra_surfaces.size(), Ref()); - - return _terra_surfaces.get(index); -} -void DungeonRoom::set_terra_surface(const int index, const Ref terra_surface) { - ERR_FAIL_INDEX(index, _terra_surfaces.size()); - - _terra_surfaces.set(index, terra_surface); -} -void DungeonRoom::add_terra_surface(const Ref terra_surface) { - _terra_surfaces.push_back(terra_surface); -} -void DungeonRoom::remove_terra_surface(const int index) { - ERR_FAIL_INDEX(index, _terra_surfaces.size()); - - _terra_surfaces.remove(index); -} -int DungeonRoom::get_terra_surface_count() const { - return _terra_surfaces.size(); -} - -Vector DungeonRoom::get_terra_surfaces() { - Vector r; - for (int i = 0; i < _terra_surfaces.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_terra_surfaces[i].get_ref_ptr()); -#else - r.push_back(_terra_surfaces[i]); -#endif - } - return r; -} -void DungeonRoom::set_terra_surfaces(const Vector &terra_surfaces) { - _terra_surfaces.clear(); - for (int i = 0; i < terra_surfaces.size(); i++) { - Ref terra_surface = Ref(terra_surfaces[i]); - - _terra_surfaces.push_back(terra_surface); - } -} - -void DungeonRoom::setup_terra_library(Ref library) { - if (has_method("_setup_terra_library")) { - call("_setup_terra_library", library); - } -} - -void DungeonRoom::_setup_terra_library(Ref library) { - for (int i = 0; i < get_terra_surface_count(); ++i) { - Ref s = get_terra_surface(i); - - if (s.is_valid()) { - library->voxel_surface_add(s); - } - } - -#ifdef PROPS_PRESENT - for (int i = 0; i < get_prop_data_count(); ++i) { - Ref s = get_prop_data(i); - - if (s.is_valid()) { - Ref pd = s->get_prop(); - - if (pd.is_valid()) - library->prop_add(pd); - } - } -#endif -} - -void DungeonRoom::generate_terra_chunk(Ref chunk, bool spawn_mobs) { - ERR_FAIL_COND(!chunk.is_valid()); - - if (has_method("_generate_terra_chunk")) { - call("_generate_terra_chunk", chunk, spawn_mobs); - } -} - -void DungeonRoom::generate_terra_room(Ref structure, bool spawn_mobs) { - if (has_method("_generate_terra_room")) { - call("_generate_terra_room", structure, spawn_mobs); - } -} -#endif - -DungeonRoom::DungeonRoom() { - _current_seed = 0; - - _min_sizex = 0; - _min_sizey = 0; - _min_sizez = 0; - - _max_sizex = 0; - _max_sizey = 0; - _max_sizez = 0; - - _posx = 0; - _posy = 0; - _posz = 0; - - _sizex = 0; - _sizey = 0; - _sizez = 0; -} -DungeonRoom::~DungeonRoom() { - _prop_datas.clear(); - -#ifdef ESS_PRESENT - _entity_datas.clear(); -#endif - -#ifdef VOXELMAN_PRESENT - _voxel_environment.unref(); - _voxel_structure.unref(); - - _voxel_environment_datas.clear(); - _voxel_surfaces.clear(); -#endif - -#ifdef TERRAMAN_PRESENT - _terra_environment.unref(); - _terra_structure.unref(); - - _terra_environment_datas.clear(); - _terra_surfaces.clear(); -#endif -} - -void DungeonRoom::_bind_methods() { - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "inst", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"), - "_instance", - PropertyInfo(Variant::INT, "p_seed"), - PropertyInfo(Variant::OBJECT, "p_instance", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"))); - - BIND_VMETHOD(MethodInfo("_setup")); - - ClassDB::bind_method(D_METHOD("instance", "seed"), &DungeonRoom::instance); - ClassDB::bind_method(D_METHOD("_instance", "p_seed", "p_instance"), &DungeonRoom::_instance); - - ClassDB::bind_method(D_METHOD("setup"), &DungeonRoom::setup); - - 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); - ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); - - ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonRoom::get_level_range); - ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoom::set_level_range); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); - - //Min Size - ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonRoom::get_min_sizex); - ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonRoom::set_min_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex"); - - ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonRoom::get_min_sizey); - ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonRoom::set_min_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey"); - - ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonRoom::get_min_sizez); - ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonRoom::set_min_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez"); - - //Max Size - ClassDB::bind_method(D_METHOD("get_max_sizex"), &DungeonRoom::get_max_sizex); - ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonRoom::set_max_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex"); - - ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonRoom::get_max_sizey); - ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonRoom::set_max_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey"); - - ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonRoom::get_max_sizez); - ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonRoom::set_max_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez"); - - //Position - ClassDB::bind_method(D_METHOD("get_posx"), &DungeonRoom::get_posx); - ClassDB::bind_method(D_METHOD("set_posx", "value"), &DungeonRoom::set_posx); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posx"), "set_posx", "get_posx"); - - ClassDB::bind_method(D_METHOD("get_posy"), &DungeonRoom::get_posy); - ClassDB::bind_method(D_METHOD("set_posy", "value"), &DungeonRoom::set_posy); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posy"), "set_posy", "get_posy"); - - ClassDB::bind_method(D_METHOD("get_posz"), &DungeonRoom::get_posz); - ClassDB::bind_method(D_METHOD("set_posz", "value"), &DungeonRoom::set_posz); - ADD_PROPERTY(PropertyInfo(Variant::INT, "posz"), "set_posz", "get_posz"); - - //Size - ClassDB::bind_method(D_METHOD("get_sizex"), &DungeonRoom::get_sizex); - ClassDB::bind_method(D_METHOD("set_sizex", "value"), &DungeonRoom::set_sizex); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizex"), "set_sizex", "get_sizex"); - - ClassDB::bind_method(D_METHOD("get_sizey"), &DungeonRoom::get_sizey); - ClassDB::bind_method(D_METHOD("set_sizey", "value"), &DungeonRoom::set_sizey); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizey"), "set_sizey", "get_sizey"); - - ClassDB::bind_method(D_METHOD("get_sizez"), &DungeonRoom::get_sizez); - ClassDB::bind_method(D_METHOD("set_sizez", "value"), &DungeonRoom::set_sizez); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sizez"), "set_sizez", "get_sizez"); - - //Props - ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoom::get_prop_data); - ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoom::set_prop_data); - ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoom::add_prop_data); - ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoom::remove_prop_data); - ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoom::get_prop_data_count); - - ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoom::get_prop_datas); - ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoom::set_prop_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); - -#ifdef ESS_PRESENT - //Entities - ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &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); - - ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoom::get_entity_datas); - ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoom::set_entity_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); -#endif - -#ifdef VOXELMAN_PRESENT - ClassDB::bind_method(D_METHOD("get_voxel_environment"), &DungeonRoom::get_voxel_environment); - ClassDB::bind_method(D_METHOD("set_voxel_environment", "value"), &DungeonRoom::set_voxel_environment); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_voxel_environment", "get_voxel_environment"); - - ClassDB::bind_method(D_METHOD("get_voxel_structure"), &DungeonRoom::get_voxel_structure); - ClassDB::bind_method(D_METHOD("set_voxel_structure", "value"), &DungeonRoom::set_voxel_structure); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), "set_voxel_structure", "get_voxel_structure"); - - //Environments - ClassDB::bind_method(D_METHOD("get_voxel_environment_data", "index"), &DungeonRoom::get_voxel_environment_data); - ClassDB::bind_method(D_METHOD("set_voxel_environment_data", "index", "data"), &DungeonRoom::set_voxel_environment_data); - ClassDB::bind_method(D_METHOD("add_voxel_environment_data", "environment_data"), &DungeonRoom::add_voxel_environment_data); - ClassDB::bind_method(D_METHOD("remove_voxel_environment_data", "index"), &DungeonRoom::remove_voxel_environment_data); - ClassDB::bind_method(D_METHOD("get_voxel_environment_data_count"), &DungeonRoom::get_voxel_environment_data_count); - - ClassDB::bind_method(D_METHOD("get_voxel_environment_datas"), &DungeonRoom::get_voxel_environment_datas); - ClassDB::bind_method(D_METHOD("set_voxel_environment_datas", "voxel_environment_datas"), &DungeonRoom::set_voxel_environment_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_voxel_environment_datas", "get_voxel_environment_datas"); - - //Surfaces - ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &DungeonRoom::get_voxel_surface); - ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &DungeonRoom::set_voxel_surface); - ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &DungeonRoom::add_voxel_surface); - ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &DungeonRoom::remove_voxel_surface); - ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &DungeonRoom::get_voxel_surface_count); - - ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &DungeonRoom::get_voxel_surfaces); - ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &DungeonRoom::set_voxel_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_voxel_surfaces", "get_voxel_surfaces"); - - BIND_VMETHOD(MethodInfo("_setup_voxel_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"))); - BIND_VMETHOD(MethodInfo("_generate_voxel_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_voxel_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - - ClassDB::bind_method(D_METHOD("setup_voxel_library", "library"), &DungeonRoom::setup_voxel_library); - ClassDB::bind_method(D_METHOD("_setup_voxel_library", "library"), &DungeonRoom::_setup_voxel_library); - - ClassDB::bind_method(D_METHOD("generate_voxel_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_voxel_chunk); - ClassDB::bind_method(D_METHOD("generate_voxel_room", "structure", "spawn_mobs"), &DungeonRoom::generate_voxel_room); -#endif - -#ifdef TERRAMAN_PRESENT - ClassDB::bind_method(D_METHOD("get_terra_environment"), &DungeonRoom::get_terra_environment); - ClassDB::bind_method(D_METHOD("set_terra_environment", "value"), &DungeonRoom::set_terra_environment); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "terra_environment", PROPERTY_HINT_RESOURCE_TYPE, "TerraEnvironmentData"), "set_terra_environment", "get_terra_environment"); - - ClassDB::bind_method(D_METHOD("get_terra_structure"), &DungeonRoom::get_terra_structure); - ClassDB::bind_method(D_METHOD("set_terra_structure", "value"), &DungeonRoom::set_terra_structure); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "terra_structure", PROPERTY_HINT_RESOURCE_TYPE, "TerraStructure"), "set_terra_structure", "get_terra_structure"); - - //Environments - ClassDB::bind_method(D_METHOD("get_terra_environment_data", "index"), &DungeonRoom::get_terra_environment_data); - ClassDB::bind_method(D_METHOD("set_terra_environment_data", "index", "data"), &DungeonRoom::set_terra_environment_data); - ClassDB::bind_method(D_METHOD("add_terra_environment_data", "environment_data"), &DungeonRoom::add_terra_environment_data); - ClassDB::bind_method(D_METHOD("remove_terra_environment_data", "index"), &DungeonRoom::remove_terra_environment_data); - ClassDB::bind_method(D_METHOD("get_terra_environment_data_count"), &DungeonRoom::get_terra_environment_data_count); - - ClassDB::bind_method(D_METHOD("get_terra_environment_datas"), &DungeonRoom::get_terra_environment_datas); - ClassDB::bind_method(D_METHOD("set_terra_environment_datas", "terra_environment_datas"), &DungeonRoom::set_terra_environment_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_environment_datas", PROPERTY_HINT_NONE, "17/17:TerraEnvironmentData", PROPERTY_USAGE_DEFAULT, "TerraEnvironmentData"), "set_terra_environment_datas", "get_terra_environment_datas"); - - //Surfaces - ClassDB::bind_method(D_METHOD("get_terra_surface", "index"), &DungeonRoom::get_terra_surface); - ClassDB::bind_method(D_METHOD("set_terra_surface", "index", "data"), &DungeonRoom::set_terra_surface); - ClassDB::bind_method(D_METHOD("add_terra_surface", "terra_surface"), &DungeonRoom::add_terra_surface); - ClassDB::bind_method(D_METHOD("remove_terra_surface", "index"), &DungeonRoom::remove_terra_surface); - ClassDB::bind_method(D_METHOD("get_terra_surface_count"), &DungeonRoom::get_terra_surface_count); - - ClassDB::bind_method(D_METHOD("get_terra_surfaces"), &DungeonRoom::get_terra_surfaces); - ClassDB::bind_method(D_METHOD("set_terra_surfaces", "terra_surfaces"), &DungeonRoom::set_terra_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_surfaces", PROPERTY_HINT_NONE, "17/17:TerraSurface", PROPERTY_USAGE_DEFAULT, "TerraSurface"), "set_terra_surfaces", "get_terra_surfaces"); - - BIND_VMETHOD(MethodInfo("_setup_terra_library", PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"))); - BIND_VMETHOD(MethodInfo("_generate_terra_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "TerraStructure"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - BIND_VMETHOD(MethodInfo("_generate_terra_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"), PropertyInfo(Variant::BOOL, "spawn_mobs"))); - - ClassDB::bind_method(D_METHOD("setup_terra_library", "library"), &DungeonRoom::setup_terra_library); - ClassDB::bind_method(D_METHOD("_setup_terra_library", "library"), &DungeonRoom::_setup_terra_library); - - ClassDB::bind_method(D_METHOD("generate_terra_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_terra_chunk); - ClassDB::bind_method(D_METHOD("generate_terra_room", "structure", "spawn_mobs"), &DungeonRoom::generate_terra_room); -#endif - -} diff --git a/main/planet.cpp b/main/planet.cpp index 88e631f..573788b 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -104,27 +104,47 @@ void Planet::set_biomes(const Vector &biomes) { } } -//// Dungeons //// -Ref Planet::get_dungeon(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeons.size(), Ref()); +//// Buildings //// +Ref Planet::get_building(const int index) const { + ERR_FAIL_INDEX_V(index, _buildings.size(), Ref()); - return _dungeons.get(index); + return _buildings.get(index); } -void Planet::set_dungeon(const int index, const Ref dungeon) { - ERR_FAIL_INDEX(index, _dungeons.size()); +void Planet::set_building(const int index, const Ref building) { + ERR_FAIL_INDEX(index, _buildings.size()); - _dungeons.set(index, dungeon); + _buildings.set(index, building); } -void Planet::add_dungeon(const Ref dungeon) { - _dungeons.push_back(dungeon); +void Planet::add_building(const Ref building) { + _buildings.push_back(building); } -void Planet::remove_dungeon(const int index) { - ERR_FAIL_INDEX(index, _dungeons.size()); +void Planet::remove_building(const int index) { + ERR_FAIL_INDEX(index, _buildings.size()); - _dungeons.remove(index); + _buildings.remove(index); } -int Planet::get_dungeon_count() const { - return _dungeons.size(); +int Planet::get_building_count() const { + return _buildings.size(); +} + +Vector Planet::get_buildings() { + Vector r; + for (int i = 0; i < _buildings.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_buildings[i].get_ref_ptr()); +#else + r.push_back(_buildings[i]); +#endif + } + return r; +} +void Planet::set_buildings(const Vector &buildings) { + _buildings.clear(); + for (int i = 0; i < buildings.size(); i++) { + Ref building = Ref(buildings[i]); + + _buildings.push_back(building); + } } Ref Planet::instance(const int seed) { @@ -153,13 +173,13 @@ Ref Planet::_instance(const int seed, Ref inst) { inst->add_biome(b->instance(seed)); } - for (int i = 0; i < _dungeons.size(); ++i) { - Ref d = _dungeons[i]; + for (int i = 0; i < _buildings.size(); ++i) { + Ref d = _buildings[i]; if (!d.is_valid()) continue; - inst->add_dungeon(d->instance(seed)); + inst->add_building(d->instance(seed)); } #ifdef FASTNOISE_PRESENT @@ -349,8 +369,8 @@ void Planet::_setup_voxel_library(Ref library) { } } - for (int i = 0; i < get_dungeon_count(); ++i) { - Ref d = get_dungeon(i); + for (int i = 0; i < get_building_count(); ++i) { + Ref d = get_building(i); if (d.is_valid()) { d->setup_voxel_library(library); @@ -486,14 +506,6 @@ void Planet::_setup_terra_library(Ref library) { s->setup_terra_library(library); } } - - for (int i = 0; i < get_dungeon_count(); ++i) { - Ref d = get_dungeon(i); - - if (d.is_valid()) { - d->setup_terra_library(library); - } - } } void Planet::generate_terra_chunk(Ref chunk, bool spawn_mobs) { @@ -512,7 +524,7 @@ Planet::Planet() { } Planet::~Planet() { _biomes.clear(); - _dungeons.clear(); + _buildings.clear(); #ifdef FASTNOISE_PRESENT _humidity_noise_params.unref(); @@ -580,12 +592,16 @@ void Planet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_biomes", "biomes"), &Planet::set_biomes); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "biomes", PROPERTY_HINT_NONE, "17/17:Biome", PROPERTY_USAGE_DEFAULT, "Biome"), "set_biomes", "get_biomes"); - //Dungeons - ClassDB::bind_method(D_METHOD("get_dungeon", "index"), &Planet::get_dungeon); - ClassDB::bind_method(D_METHOD("set_dungeon", "index", "data"), &Planet::set_dungeon); - ClassDB::bind_method(D_METHOD("add_dungeon", "dungeon"), &Planet::add_dungeon); - ClassDB::bind_method(D_METHOD("remove_dungeon", "index"), &Planet::remove_dungeon); - ClassDB::bind_method(D_METHOD("get_dungeon_count"), &Planet::get_dungeon_count); + //Buildings + ClassDB::bind_method(D_METHOD("get_building", "index"), &Planet::get_building); + ClassDB::bind_method(D_METHOD("set_building", "index", "data"), &Planet::set_building); + ClassDB::bind_method(D_METHOD("add_building", "dungeon"), &Planet::add_building); + ClassDB::bind_method(D_METHOD("remove_building", "index"), &Planet::remove_building); + ClassDB::bind_method(D_METHOD("get_building_count"), &Planet::get_building_count); + + ClassDB::bind_method(D_METHOD("get_buildings"), &Planet::get_buildings); + ClassDB::bind_method(D_METHOD("set_buildings", "buildings"), &Planet::set_buildings); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buildings", PROPERTY_HINT_NONE, "17/17:Building", PROPERTY_USAGE_DEFAULT, "Building"), "set_buildings", "get_buildings"); BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_generate_map")); diff --git a/main/planet.h b/main/planet.h index b3d0cf3..a62d1b5 100644 --- a/main/planet.h +++ b/main/planet.h @@ -36,7 +36,7 @@ SOFTWARE. #endif #include "biome.h" -#include "dungeon.h" +#include "building.h" #ifdef FASTNOISE_PRESENT #include "../../fastnoise/fastnoise_noise_params.h" @@ -87,12 +87,15 @@ public: Vector get_biomes(); void set_biomes(const Vector &biome_datas); - //Dungeons - Ref get_dungeon(const int index) const; - void set_dungeon(const int index, const Ref dungeon); - void add_dungeon(const Ref dungeon); - void remove_dungeon(const int index); - int get_dungeon_count() const; + //Building + Ref get_building(const int index) const; + void set_building(const int index, const Ref building); + void add_building(const Ref building); + void remove_building(const int index); + int get_building_count() const; + + Vector get_buildings(); + void set_buildings(const Vector &buildings); Ref instance(const int seed); virtual Ref _instance(const int seed, Ref inst); @@ -176,7 +179,7 @@ private: Vector2 _level_range; Vector > _biomes; - Vector > _dungeons; + Vector > _buildings; #ifdef FASTNOISE_PRESENT Ref _humidity_noise_params; diff --git a/register_types.cpp b/register_types.cpp index 630ec7b..955e9a5 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -24,10 +24,8 @@ SOFTWARE. #include "data/world_generator_prop_data.h" +#include "main/building.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" @@ -35,9 +33,7 @@ SOFTWARE. void register_world_generator_types() { ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();