diff --git a/SCsub b/SCsub index 6e3e8ca..d1827c7 100644 --- a/SCsub +++ b/SCsub @@ -30,7 +30,6 @@ sources = [ "data/dungeon_room_data.cpp", "data/dungeon_corridor_data.cpp", "data/dungeon_data.cpp", - "data/biome_data.cpp", "data/world_generator_prop_data.cpp", "world_generator.cpp", diff --git a/config.py b/config.py index fda6ce5..7c90fff 100644 --- a/config.py +++ b/config.py @@ -6,12 +6,10 @@ def configure(env): def get_doc_classes(): return [ - "BiomeData", "DungeonCorridorData", "DungeonData", "DungeonRoomData", "WorldGeneratorPropData", - "BiomeData", "Planet", "Dungeon", diff --git a/data/biome_data.cpp b/data/biome_data.cpp deleted file mode 100644 index 0e85886..0000000 --- a/data/biome_data.cpp +++ /dev/null @@ -1,391 +0,0 @@ -/* -Copyright (c) 2019-2020 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 "biome_data.h" - -#include "core/version.h" - -#include "../main/biome.h" - -Ref BiomeData::get_biome() { - return _biome; -} -void BiomeData::set_biome(const Ref &biome) { - _biome = biome; -} - -Vector2 BiomeData::get_level_range() { - return _level_range; -} -void BiomeData::set_level_range(Vector2 value) { - _level_range = value; -} - -Vector2 BiomeData::get_humidity_range() { - return _humidity_range; -} -void BiomeData::set_humidity_range(Vector2 range) { - _humidity_range = range; -} - -Vector2 BiomeData::get_temperature_range() { - return _temperature_range; -} -void BiomeData::set_temperature_range(Vector2 range) { - _temperature_range = range; -} - -//// DungeonData //// - -Ref BiomeData::get_dungeon_data(const int index) const { - ERR_FAIL_INDEX_V(index, _dungeon_datas.size(), Ref()); - - return _dungeon_datas.get(index); -} -void BiomeData::set_dungeon_data(const int index, const Ref dungeon_data) { - ERR_FAIL_INDEX(index, _dungeon_datas.size()); - - _dungeon_datas.set(index, dungeon_data); -} -void BiomeData::add_dungeon_data(const Ref dungeon_data) { - _dungeon_datas.push_back(dungeon_data); -} -void BiomeData::remove_dungeon_data(const int index) { - ERR_FAIL_INDEX(index, _dungeon_datas.size()); - - _dungeon_datas.remove(index); -} - -int BiomeData::get_dungeon_data_count() const { - return _dungeon_datas.size(); -} - -Vector BiomeData::get_dungeon_datas() { - Vector r; - for (int i = 0; i < _dungeon_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_dungeon_datas[i].get_ref_ptr()); -#else - r.push_back(_dungeon_datas[i]); -#endif - } - return r; -} -void BiomeData::set_dungeon_datas(const Vector &dungeon_datas) { - _dungeon_datas.clear(); - for (int i = 0; i < dungeon_datas.size(); i++) { - Ref dungeon_data = Ref(dungeon_datas[i]); - - _dungeon_datas.push_back(dungeon_data); - } -} - -//// PROP DATA //// - -Ref BiomeData::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); - - return _prop_datas.get(index); -} -void BiomeData::set_prop_data(const int index, const Ref prop_data) { - ERR_FAIL_INDEX(index, _prop_datas.size()); - - _prop_datas.set(index, prop_data); -} -void BiomeData::add_prop_data(const Ref prop_data) { - _prop_datas.push_back(prop_data); -} -void BiomeData::remove_prop_data(const int index) { - ERR_FAIL_INDEX(index, _prop_datas.size()); - - _prop_datas.remove(index); -} - -int BiomeData::get_prop_data_count() const { - return _prop_datas.size(); -} - -Vector BiomeData::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 BiomeData::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 BiomeData::get_entity_data(const int index) const { - ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref()); - - return _entity_datas.get(index); -} -void BiomeData::set_entity_data(const int index, const Ref entity_data) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.set(index, entity_data); -} -void BiomeData::add_entity_data(const Ref entity_data) { - _entity_datas.push_back(entity_data); -} -void BiomeData::remove_entity_data(const int index) { - ERR_FAIL_INDEX(index, _entity_datas.size()); - - _entity_datas.remove(index); -} - -int BiomeData::get_entity_data_count() const { - return _entity_datas.size(); -} - -Vector BiomeData::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 BiomeData::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 -//Environments -Ref BiomeData::get_environment_data(const int index) const { - ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref()); - - return _environment_datas.get(index); -} -void BiomeData::set_environment_data(const int index, const Ref environment_data) { - ERR_FAIL_INDEX(index, _environment_datas.size()); - - _environment_datas.set(index, environment_data); -} -void BiomeData::add_environment_data(const Ref environment_data) { - _environment_datas.push_back(environment_data); -} -void BiomeData::remove_environment_data(const int index) { - ERR_FAIL_INDEX(index, _environment_datas.size()); - - _environment_datas.remove(index); -} -int BiomeData::get_environment_data_count() const { - return _environment_datas.size(); -} - -Vector BiomeData::get_environment_datas() { - Vector r; - for (int i = 0; i < _environment_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_environment_datas[i].get_ref_ptr()); -#else - r.push_back(_environment_datas[i]); -#endif - } - return r; -} -void BiomeData::set_environment_datas(const Vector &environment_datas) { - _environment_datas.clear(); - for (int i = 0; i < environment_datas.size(); i++) { - Ref environment_data = Ref(environment_datas[i]); - - _environment_datas.push_back(environment_data); - } -} - -//// Surfaces //// -Ref BiomeData::get_voxel_surface(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); - - return _voxel_surfaces.get(index); -} -void BiomeData::set_voxel_surface(const int index, const Ref voxel_surface) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.set(index, voxel_surface); -} -void BiomeData::add_voxel_surface(const Ref voxel_surface) { - _voxel_surfaces.push_back(voxel_surface); -} -void BiomeData::remove_voxel_surface(const int index) { - ERR_FAIL_INDEX(index, _voxel_surfaces.size()); - - _voxel_surfaces.remove(index); -} -int BiomeData::get_voxel_surface_count() const { - return _voxel_surfaces.size(); -} - -Vector BiomeData::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 BiomeData::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); - } -} - -#endif - -Ref BiomeData::instance() { - Ref biome; - - if (!_biome.is_valid()) { - biome.instance(); - } else { - biome = _biome->duplicate(); - } - - biome->set_data(Ref(this)); - - return biome; -} - -BiomeData::BiomeData() { -} -BiomeData::~BiomeData() { - _dungeon_datas.clear(); - _prop_datas.clear(); - -#ifdef ESS_PRESENT - _entity_datas.clear(); -#endif - -#ifdef VOXELMAN_PRESENT - _environment_datas.clear(); - _voxel_surfaces.clear(); - _liquid_voxel_surfaces.clear(); -#endif -} - -void BiomeData::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_biome"), &BiomeData::get_biome); - ClassDB::bind_method(D_METHOD("set_biome", "value"), &BiomeData::set_biome); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "biome", PROPERTY_HINT_RESOURCE_TYPE, "Biome"), "set_biome", "get_biome"); - - ClassDB::bind_method(D_METHOD("get_level_range"), &BiomeData::get_level_range); - ClassDB::bind_method(D_METHOD("set_level_range", "value"), &BiomeData::set_level_range); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); - - ClassDB::bind_method(D_METHOD("get_humidity_range"), &BiomeData::get_humidity_range); - ClassDB::bind_method(D_METHOD("set_humidity_range", "value"), &BiomeData::set_humidity_range); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "humidity_range"), "set_humidity_range", "get_humidity_range"); - - ClassDB::bind_method(D_METHOD("get_temperature_range"), &BiomeData::get_temperature_range); - ClassDB::bind_method(D_METHOD("set_temperature_range", "value"), &BiomeData::set_temperature_range); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "temperature_range"), "set_temperature_range", "get_temperature_range"); - - //DungeonDatas - ClassDB::bind_method(D_METHOD("get_dungeon_data", "index"), &BiomeData::get_dungeon_data); - ClassDB::bind_method(D_METHOD("set_dungeon_data", "index", "data"), &BiomeData::set_dungeon_data); - ClassDB::bind_method(D_METHOD("add_dungeon_data", "dungeon_data"), &BiomeData::add_dungeon_data); - ClassDB::bind_method(D_METHOD("remove_dungeon_data", "index"), &BiomeData::remove_dungeon_data); - ClassDB::bind_method(D_METHOD("get_dungeon_data_count"), &BiomeData::get_dungeon_data_count); - - ClassDB::bind_method(D_METHOD("get_dungeon_datas"), &BiomeData::get_dungeon_datas); - ClassDB::bind_method(D_METHOD("set_dungeon_datas", "dungeon_datas"), &BiomeData::set_dungeon_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_datas", PROPERTY_HINT_NONE, "17/17:DungeonData", PROPERTY_USAGE_DEFAULT, "DungeonData"), "set_dungeon_datas", "get_dungeon_datas"); - - //WorldGeneratorPropData - ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &BiomeData::get_prop_data); - ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &BiomeData::set_prop_data); - ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &BiomeData::add_prop_data); - ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &BiomeData::remove_prop_data); - ClassDB::bind_method(D_METHOD("get_prop_data_count"), &BiomeData::get_prop_data_count); - - ClassDB::bind_method(D_METHOD("get_prop_datas"), &BiomeData::get_prop_datas); - ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &BiomeData::set_prop_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); - -#ifdef ESS_PRESENT - //Entities - ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &BiomeData::get_entity_data); - ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &BiomeData::set_entity_data); - ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &BiomeData::add_entity_data); - ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &BiomeData::remove_entity_data); - ClassDB::bind_method(D_METHOD("get_entity_data_count"), &BiomeData::get_entity_data_count); - - ClassDB::bind_method(D_METHOD("get_entity_datas"), &BiomeData::get_entity_datas); - ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &BiomeData::set_entity_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); -#endif - -#ifdef VOXELMAN_PRESENT - //Environments - ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &BiomeData::get_environment_data); - ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &BiomeData::set_environment_data); - ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &BiomeData::add_environment_data); - ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &BiomeData::remove_environment_data); - ClassDB::bind_method(D_METHOD("get_environment_data_count"), &BiomeData::get_environment_data_count); - - ClassDB::bind_method(D_METHOD("get_environment_datas"), &BiomeData::get_environment_datas); - ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &BiomeData::set_environment_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas"); - - //Surfaces - ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &BiomeData::get_voxel_surface); - ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &BiomeData::set_voxel_surface); - ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &BiomeData::add_voxel_surface); - ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &BiomeData::remove_voxel_surface); - ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &BiomeData::get_voxel_surface_count); - - ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &BiomeData::get_voxel_surfaces); - ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &BiomeData::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 - - ClassDB::bind_method(D_METHOD("instance"), &BiomeData::instance); -} diff --git a/data/biome_data.h b/data/biome_data.h deleted file mode 100644 index 10e0018..0000000 --- a/data/biome_data.h +++ /dev/null @@ -1,148 +0,0 @@ -/* -Copyright (c) 2019-2020 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_data_H -#define dungeon_data_H - -#include "core/math/vector2.h" -#include "core/resource.h" -#include "core/script_language.h" -#include "core/ustring.h" -#include "core/vector.h" - -#include "../main/biome.h" -#include "dungeon_data.h" -#include "world_generator_prop_data.h" - -#ifdef VOXELMAN_PRESENT -#include "../../voxelman/library/voxel_surface.h" -#include "../../voxelman/world/environment_data.h" -#endif - -#ifdef ESS_PRESENT -#include "../../entity_spell_system/entities/data/entity_data.h" -#endif - -class Biome; - -class BiomeData : public Resource { - GDCLASS(BiomeData, Resource); - -public: - Ref get_biome(); - void set_biome(const Ref &biome); - - Vector2 get_level_range(); - void set_level_range(Vector2 value); - - Vector2 get_humidity_range(); - void set_humidity_range(Vector2 range); - - Vector2 get_temperature_range(); - void set_temperature_range(Vector2 range); - - //DungeonData - Ref get_dungeon_data(const int index) const; - void set_dungeon_data(const int index, const Ref dungeon_data); - void add_dungeon_data(const Ref dungeon_data); - void remove_dungeon_data(const int index); - - int get_dungeon_data_count() const; - - Vector get_dungeon_datas(); - void set_dungeon_datas(const Vector &dungeon_datas); - - //WorldGeneratorPropData - 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); - -#ifdef ESS_PRESENT - //Entities - Ref get_entity_data(const int index) const; - void set_entity_data(const int index, const Ref entity_data); - void add_entity_data(const Ref entity_data); - void remove_entity_data(const int index); - int get_entity_data_count() const; - - Vector get_entity_datas(); - void set_entity_datas(const Vector &entity_datas); -#endif - -#ifdef VOXELMAN_PRESENT - //Environments - Ref get_environment_data(const int index) const; - void set_environment_data(const int index, const Ref environment_data); - void add_environment_data(const Ref environment_data); - void remove_environment_data(const int index); - int get_environment_data_count() const; - - Vector get_environment_datas(); - void set_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); -#endif - - Ref instance(); - - BiomeData(); - ~BiomeData(); - -protected: - static void _bind_methods(); - -private: - Ref _biome; - - Vector2 _level_range; - - Vector2 _humidity_range; - Vector2 _temperature_range; - - Vector > _dungeon_datas; - Vector > _prop_datas; - -#ifdef ESS_PRESENT - Vector > _entity_datas; -#endif - -#ifdef VOXELMAN_PRESENT - Vector > _environment_datas; - Vector > _voxel_surfaces; - Vector > _liquid_voxel_surfaces; -#endif -}; - -#endif diff --git a/main/biome.cpp b/main/biome.cpp index b707f13..4489b2b 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -36,6 +36,20 @@ void Biome::set_level_range(Vector2 value) { _level_range = value; } +Vector2 Biome::get_humidity_range() { + return _humidity_range; +} +void Biome::set_humidity_range(Vector2 range) { + _humidity_range = range; +} + +Vector2 Biome::get_temperature_range() { + return _temperature_range; +} +void Biome::set_temperature_range(Vector2 range) { + _temperature_range = range; +} + #ifdef VOXELMAN_PRESENT Ref Biome::get_environment() { return _environment; @@ -45,13 +59,6 @@ void Biome::set_environment(Ref value) { } #endif -Ref Biome::get_data() { - return _data; -} -void Biome::set_data(Ref value) { - _data = value; -} - //// Prop Data //// Ref Biome::get_prop_data(const int index) const { ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); @@ -76,6 +83,26 @@ int Biome::get_prop_data_count() const { return _prop_datas.size(); } +Vector Biome::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 Biome::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 Biome::get_entity_data(const int index) const { @@ -99,6 +126,26 @@ void Biome::remove_entity_data(const int index) { int Biome::get_entity_data_count() const { return _entity_datas.size(); } + +Vector Biome::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 Biome::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 //// Dungeons //// @@ -124,10 +171,116 @@ int Biome::get_dungeon_count() const { return _dungeons.size(); } -void Biome::setup() { - if (!_data.is_valid()) - return; +Vector Biome::get_dungeons() { + Vector r; + for (int i = 0; i < _dungeons.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_dungeons[i].get_ref_ptr()); +#else + r.push_back(_dungeons[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]); + _dungeons.push_back(dungeon_data); + } +} + +#ifdef VOXELMAN_PRESENT +//Environments +Ref Biome::get_environment_data(const int index) const { + ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref()); + + return _environment_datas.get(index); +} +void Biome::set_environment_data(const int index, const Ref environment_data) { + ERR_FAIL_INDEX(index, _environment_datas.size()); + + _environment_datas.set(index, environment_data); +} +void Biome::add_environment_data(const Ref environment_data) { + _environment_datas.push_back(environment_data); +} +void Biome::remove_environment_data(const int index) { + ERR_FAIL_INDEX(index, _environment_datas.size()); + + _environment_datas.remove(index); +} +int Biome::get_environment_data_count() const { + return _environment_datas.size(); +} + +Vector Biome::get_environment_datas() { + Vector r; + for (int i = 0; i < _environment_datas.size(); i++) { +#if VERSION_MAJOR < 4 + r.push_back(_environment_datas[i].get_ref_ptr()); +#else + r.push_back(_environment_datas[i]); +#endif + } + return r; +} +void Biome::set_environment_datas(const Vector &environment_datas) { + _environment_datas.clear(); + for (int i = 0; i < environment_datas.size(); i++) { + Ref environment_data = Ref(environment_datas[i]); + + _environment_datas.push_back(environment_data); + } +} + +//// Surfaces //// +Ref Biome::get_voxel_surface(const int index) const { + ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref()); + + return _voxel_surfaces.get(index); +} +void Biome::set_voxel_surface(const int index, const Ref voxel_surface) { + ERR_FAIL_INDEX(index, _voxel_surfaces.size()); + + _voxel_surfaces.set(index, voxel_surface); +} +void Biome::add_voxel_surface(const Ref voxel_surface) { + _voxel_surfaces.push_back(voxel_surface); +} +void Biome::remove_voxel_surface(const int index) { + ERR_FAIL_INDEX(index, _voxel_surfaces.size()); + + _voxel_surfaces.remove(index); +} +int Biome::get_voxel_surface_count() const { + return _voxel_surfaces.size(); +} + +Vector Biome::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 Biome::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); + } +} + +#endif + +void Biome::setup() { if (has_method("_setup")) { call("_setup"); } @@ -152,17 +305,14 @@ void Biome::generate_stack(Ref chunk, int x, int z, bool spawn_mobs) void Biome::setup_library(Ref library) { ERR_FAIL_COND(!library.is_valid()); - if (!_data.is_valid()) - return; - if (has_method("_setup_library")) { call("_setup_library", library); } } void Biome::_setup_library(Ref library) { - for (int i = 0; i < _data->get_voxel_surface_count(); ++i) { - Ref s = _data->get_voxel_surface(i); + for (int i = 0; i < get_voxel_surface_count(); ++i) { + Ref s = get_voxel_surface(i); if (s.is_valid()) { library->add_voxel_surface(s); @@ -178,8 +328,8 @@ void Biome::_setup_library(Ref library) { } #ifdef PROPS_PRESENT - for (int i = 0; i < _data->get_prop_data_count(); ++i) { - Ref s = _data->get_prop_data(i); + 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(); @@ -217,7 +367,6 @@ Biome::~Biome() { _environment.unref(); #endif - _data.unref(); _prop_datas.clear(); #ifdef ESS_PRESENT @@ -225,6 +374,18 @@ Biome::~Biome() { #endif _dungeons.clear(); + + _prop_datas.clear(); + +#ifdef ESS_PRESENT + _entity_datas.clear(); +#endif + +#ifdef VOXELMAN_PRESENT + _environment_datas.clear(); + _voxel_surfaces.clear(); + _liquid_voxel_surfaces.clear(); +#endif } void Biome::_bind_methods() { @@ -259,16 +420,20 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range"); + ClassDB::bind_method(D_METHOD("get_humidity_range"), &Biome::get_humidity_range); + ClassDB::bind_method(D_METHOD("set_humidity_range", "value"), &Biome::set_humidity_range); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "humidity_range"), "set_humidity_range", "get_humidity_range"); + + ClassDB::bind_method(D_METHOD("get_temperature_range"), &Biome::get_temperature_range); + ClassDB::bind_method(D_METHOD("set_temperature_range", "value"), &Biome::set_temperature_range); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "temperature_range"), "set_temperature_range", "get_temperature_range"); + #ifdef VOXELMAN_PRESENT ClassDB::bind_method(D_METHOD("get_environment"), &Biome::get_environment); ClassDB::bind_method(D_METHOD("set_environment", "value"), &Biome::set_environment); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment"); #endif - ClassDB::bind_method(D_METHOD("get_data"), &Biome::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &Biome::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "BiomeData", 0), "set_data", "get_data"); - //Props ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &Biome::get_prop_data); ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &Biome::set_prop_data); @@ -276,6 +441,10 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &Biome::remove_prop_data); ClassDB::bind_method(D_METHOD("get_prop_data_count"), &Biome::get_prop_data_count); + ClassDB::bind_method(D_METHOD("get_prop_datas"), &Biome::get_prop_datas); + ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &Biome::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"), &Biome::get_entity_data); @@ -283,6 +452,10 @@ void Biome::_bind_methods() { ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &Biome::add_entity_data); ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &Biome::remove_entity_data); ClassDB::bind_method(D_METHOD("get_entity_data_count"), &Biome::get_entity_data_count); + + ClassDB::bind_method(D_METHOD("get_entity_datas"), &Biome::get_entity_datas); + ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &Biome::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 //Dungeons @@ -291,4 +464,32 @@ void Biome::_bind_methods() { 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); + + 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"); + +#ifdef VOXELMAN_PRESENT + //Environments + ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &Biome::get_environment_data); + ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &Biome::set_environment_data); + ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &Biome::add_environment_data); + ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &Biome::remove_environment_data); + ClassDB::bind_method(D_METHOD("get_environment_data_count"), &Biome::get_environment_data_count); + + ClassDB::bind_method(D_METHOD("get_environment_datas"), &Biome::get_environment_datas); + ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &Biome::set_environment_datas); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas"); + + //Surfaces + ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &Biome::get_voxel_surface); + ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &Biome::set_voxel_surface); + ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &Biome::add_voxel_surface); + ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &Biome::remove_voxel_surface); + ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &Biome::get_voxel_surface_count); + + ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &Biome::get_voxel_surfaces); + ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &Biome::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 } diff --git a/main/biome.h b/main/biome.h index 1b527a7..e082a8b 100644 --- a/main/biome.h +++ b/main/biome.h @@ -28,7 +28,6 @@ SOFTWARE. #include "dungeon.h" -#include "../data/biome_data.h" #include "../data/world_generator_prop_data.h" #include "scene/resources/packed_scene.h" @@ -42,8 +41,6 @@ SOFTWARE. #include "../../entity_spell_system/entities/data/entity_data.h" #endif -class BiomeData; - class Biome : public Resource { GDCLASS(Biome, Resource); @@ -54,15 +51,18 @@ public: Vector2 get_level_range(); void set_level_range(Vector2 value); + Vector2 get_humidity_range(); + void set_humidity_range(Vector2 range); + + Vector2 get_temperature_range(); + void set_temperature_range(Vector2 range); + #ifdef VOXELMAN_PRESENT //Environment Ref get_environment(); void set_environment(Ref value); #endif - Ref get_data(); - void set_data(Ref value); - //WorldGeneratorPropData Ref get_prop_data(const int index) const; void set_prop_data(const int index, const Ref prop_data); @@ -71,6 +71,9 @@ public: int get_prop_data_count() const; + Vector get_prop_datas(); + void set_prop_datas(const Vector &prop_datas); + #ifdef ESS_PRESENT //Entities Ref get_entity_data(const int index) const; @@ -78,6 +81,9 @@ public: void add_entity_data(const Ref entity_data); void remove_entity_data(const int index); int get_entity_data_count() const; + + Vector get_entity_datas(); + void set_entity_datas(const Vector &entity_datas); #endif //Dungeons @@ -87,6 +93,31 @@ public: void remove_dungeon(const int index); int get_dungeon_count() const; + Vector get_dungeons(); + void set_dungeons(const Vector &dungeon_datas); + +#ifdef VOXELMAN_PRESENT + //Environments + Ref get_environment_data(const int index) const; + void set_environment_data(const int index, const Ref environment_data); + void add_environment_data(const Ref environment_data); + void remove_environment_data(const int index); + int get_environment_data_count() const; + + Vector get_environment_datas(); + void set_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); +#endif + void setup(); #ifdef VOXELMAN_PRESENT @@ -112,11 +143,13 @@ private: Vector2 _level_range; + Vector2 _humidity_range; + Vector2 _temperature_range; + #ifdef VOXELMAN_PRESENT Ref _environment; #endif - Ref _data; Vector > _prop_datas; #ifdef ESS_PRESENT @@ -124,6 +157,12 @@ private: #endif Vector > _dungeons; + +#ifdef VOXELMAN_PRESENT + Vector > _environment_datas; + Vector > _voxel_surfaces; + Vector > _liquid_voxel_surfaces; +#endif }; #endif diff --git a/register_types.cpp b/register_types.cpp index cb6d023..415608e 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -22,7 +22,6 @@ SOFTWARE. #include "register_types.h" -#include "data/biome_data.h" #include "data/dungeon_corridor_data.h" #include "data/dungeon_data.h" #include "data/dungeon_room_data.h" @@ -40,7 +39,6 @@ void register_world_generator_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();