From 128f40a6f61a3a4d06b9849dbd20ab64076bec87 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 7 Nov 2019 19:47:59 +0100 Subject: [PATCH] Renamed PropData to WorldGeneratorPropData. --- SCsub | 2 +- data/biome_data.cpp | 14 ++++---- data/biome_data.h | 12 +++---- data/dungeon_room_data.cpp | 12 +++---- data/dungeon_room_data.h | 10 +++--- data/prop_data.cpp | 32 ------------------- data/world_generator_prop_data.cpp | 32 +++++++++++++++++++ ...rop_data.h => world_generator_prop_data.h} | 8 ++--- main/biome.cpp | 8 ++--- main/biome.h | 12 +++---- main/dungeon_room.cpp | 8 ++--- main/dungeon_room.h | 10 +++--- register_types.cpp | 4 +-- 13 files changed, 82 insertions(+), 82 deletions(-) delete mode 100644 data/prop_data.cpp create mode 100644 data/world_generator_prop_data.cpp rename data/{prop_data.h => world_generator_prop_data.h} (62%) diff --git a/SCsub b/SCsub index 2f5706d..4fa9ab7 100644 --- a/SCsub +++ b/SCsub @@ -13,7 +13,7 @@ env.add_source_files(env.modules_sources,"data/dungeon_corridor_data.cpp") env.add_source_files(env.modules_sources,"data/dungeon_data.cpp") env.add_source_files(env.modules_sources,"data/biome_data.cpp") env.add_source_files(env.modules_sources,"data/planet_data.cpp") -env.add_source_files(env.modules_sources,"data/prop_data.cpp") +env.add_source_files(env.modules_sources,"data/world_generator_prop_data.cpp") env.add_source_files(env.modules_sources,"world_generator.cpp") diff --git a/data/biome_data.cpp b/data/biome_data.cpp index 0e753bb..24c5ab9 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -64,17 +64,17 @@ void BiomeData::set_dungeon_datas(const Vector &dungeon_datas) { //// PROP DATA //// -Ref BiomeData::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); +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) { +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) { +void BiomeData::add_prop_data(const Ref prop_data) { _prop_datas.push_back(prop_data); } void BiomeData::remove_prop_data(const int index) { @@ -97,7 +97,7 @@ Vector BiomeData::get_prop_datas() { 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]); + Ref prop_data = Ref(prop_datas[i]); _prop_datas.push_back(prop_data); } @@ -229,7 +229,7 @@ void BiomeData::_bind_methods() { 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"); - //PropData + //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); @@ -239,7 +239,7 @@ void BiomeData::_bind_methods() { 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:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_prop_datas", "get_prop_datas"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &BiomeData::get_entity_data); diff --git a/data/biome_data.h b/data/biome_data.h index 49f8282..38af74b 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -7,7 +7,7 @@ #include "../main/biome.h" #include "dungeon_data.h" -#include "prop_data.h" +#include "world_generator_prop_data.h" #include "../../voxelman/world/environment_data.h" #include "../../entity_spell_system/entities/data/entity_data.h" @@ -35,10 +35,10 @@ public: Vector get_dungeon_datas(); void set_dungeon_datas(const Vector &dungeon_datas); - //PropData - 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); + //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; @@ -83,7 +83,7 @@ private: Vector2 _temperature_range; Vector > _dungeon_datas; - Vector > _prop_datas; + Vector > _prop_datas; Vector > _entity_datas; Vector > _environment_datas; }; diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp index 96919be..8a49a40 100644 --- a/data/dungeon_room_data.cpp +++ b/data/dungeon_room_data.cpp @@ -52,17 +52,17 @@ void DungeonRoomData::set_max_sizez(int value) { } //Props -Ref DungeonRoomData::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); +Ref DungeonRoomData::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); return _prop_datas.get(index); } -void DungeonRoomData::set_prop_data(const int index, const Ref prop_data) { +void DungeonRoomData::set_prop_data(const int index, const Ref prop_data) { ERR_FAIL_INDEX(index, _prop_datas.size()); _prop_datas.set(index, prop_data); } -void DungeonRoomData::add_prop_data(const Ref prop_data) { +void DungeonRoomData::add_prop_data(const Ref prop_data) { _prop_datas.push_back(prop_data); } void DungeonRoomData::remove_prop_data(const int index) { @@ -84,7 +84,7 @@ Vector DungeonRoomData::get_prop_datas() { void DungeonRoomData::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]); + Ref prop_data = Ref(prop_datas[i]); _prop_datas.push_back(prop_data); } @@ -234,7 +234,7 @@ void DungeonRoomData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoomData::get_prop_datas); ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoomData::set_prop_datas); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_prop_datas", "get_prop_datas"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas"); //Entities ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoomData::get_entity_data); diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index 40b704f..37bcb41 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -4,7 +4,7 @@ #include "core/resource.h" #include "../main/dungeon_room.h" -#include "prop_data.h" +#include "world_generator_prop_data.h" #include "../../voxelman/world/environment_data.h" #include "../../entity_spell_system/entities/data/entity_data.h" @@ -37,9 +37,9 @@ public: void set_max_sizez(int value); //Prop Data - 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); + 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; @@ -88,7 +88,7 @@ private: int _max_sizey; int _max_sizez; - Vector > _prop_datas; + Vector > _prop_datas; Vector > _entity_datas; Vector > _environment_datas; }; diff --git a/data/prop_data.cpp b/data/prop_data.cpp deleted file mode 100644 index 774558e..0000000 --- a/data/prop_data.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "prop_data.h" - -bool PropData::can_spawn(int seed) { - if (has_method("_can_spawn")) { - return call("_can_spawn", seed); - } - - return false; -} - -Ref PropData::get_prop(int seed) { - if (has_method("_get_prop")) { - return call("_get_prop", seed); - } - - return Ref(NULL); -} - -PropData::PropData() { - -} -PropData::~PropData() { - -} - -void PropData::_bind_methods() { - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanProp"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); - - ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &PropData::can_spawn); - ClassDB::bind_method(D_METHOD("get_prop", "seed"), &PropData::get_prop); -} diff --git a/data/world_generator_prop_data.cpp b/data/world_generator_prop_data.cpp new file mode 100644 index 0000000..f225ab9 --- /dev/null +++ b/data/world_generator_prop_data.cpp @@ -0,0 +1,32 @@ +#include "world_generator_prop_data.h" + +bool WorldGeneratorPropData::can_spawn(int seed) { + if (has_method("_can_spawn")) { + return call("_can_spawn", seed); + } + + return false; +} + +Ref WorldGeneratorPropData::get_prop(int seed) { + if (has_method("_get_prop")) { + return call("_get_prop", seed); + } + + return Ref(NULL); +} + +WorldGeneratorPropData::WorldGeneratorPropData() { + +} +WorldGeneratorPropData::~WorldGeneratorPropData() { + +} + +void WorldGeneratorPropData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanProp"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + + ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &WorldGeneratorPropData::can_spawn); + ClassDB::bind_method(D_METHOD("get_prop", "seed"), &WorldGeneratorPropData::get_prop); +} diff --git a/data/prop_data.h b/data/world_generator_prop_data.h similarity index 62% rename from data/prop_data.h rename to data/world_generator_prop_data.h index 2152085..c4fba73 100644 --- a/data/prop_data.h +++ b/data/world_generator_prop_data.h @@ -5,16 +5,16 @@ #include "../../voxelman/props/voxelman_prop.h" -class PropData : public Resource { - GDCLASS(PropData, Resource); +class WorldGeneratorPropData : public Resource { + GDCLASS(WorldGeneratorPropData, Resource); public: bool can_spawn(int seed); Ref get_prop(int seed); - PropData(); - ~PropData(); + WorldGeneratorPropData(); + ~WorldGeneratorPropData(); protected: static void _bind_methods(); diff --git a/main/biome.cpp b/main/biome.cpp index 23934a1..faa88fe 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -15,17 +15,17 @@ void Biome::set_environment(Ref value) { } //// Prop Data //// -Ref Biome::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); +Ref Biome::get_prop_data(const int index) const { + ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); return _prop_datas.get(index); } -void Biome::set_prop_data(const int index, const Ref prop_data) { +void Biome::set_prop_data(const int index, const Ref prop_data) { ERR_FAIL_INDEX(index, _prop_datas.size()); _prop_datas.set(index, prop_data); } -void Biome::add_prop_data(const Ref prop_data) { +void Biome::add_prop_data(const Ref prop_data) { _prop_datas.push_back(prop_data); } void Biome::remove_prop_data(const int index) { diff --git a/main/biome.h b/main/biome.h index 1725058..8325c56 100644 --- a/main/biome.h +++ b/main/biome.h @@ -4,7 +4,7 @@ #include "core/reference.h" #include "../../voxelman/world/voxel_chunk.h" -#include "../data/prop_data.h" +#include "../data/world_generator_prop_data.h" #include "dungeon.h" #include "../../voxelman/world/environment_data.h" #include "../../entity_spell_system/entities/data/entity_data.h" @@ -20,10 +20,10 @@ public: Ref get_environment(); void set_environment(Ref value); - //PropData - 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); + //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; @@ -59,7 +59,7 @@ private: Vector2 _level_range; Ref _environment; - Vector > _prop_datas; + Vector > _prop_datas; Vector > _entity_datas; Vector > _dungeons; }; diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index b69a959..727e2de 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -73,17 +73,17 @@ void DungeonRoom::set_structure(Ref structure) { } //Props -Ref DungeonRoom::get_prop_data(const int index) const { - ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref()); +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) { +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) { +void DungeonRoom::add_prop_data(const Ref prop_data) { _prop_datas.push_back(prop_data); } void DungeonRoom::remove_prop_data(const int index) { diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 5c5e90c..b3c139d 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -6,7 +6,7 @@ #include "../../voxelman/world/voxel_chunk.h" #include "../../voxelman/world/voxel_structure.h" -#include "../data/prop_data.h" +#include "../data/world_generator_prop_data.h" #include "../../voxelman/world/environment_data.h" #include "../../entity_spell_system/entities/data/entity_data.h" @@ -49,9 +49,9 @@ public: void set_structure(Ref structure); //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); + 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; @@ -90,7 +90,7 @@ private: Ref _environment; Ref _structure; - Vector > _prop_datas; + Vector > _prop_datas; Vector > _entity_datas; }; diff --git a/register_types.cpp b/register_types.cpp index 8fee9ca..5bdb3a2 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -5,7 +5,7 @@ #include "data/dungeon_data.h" #include "data/biome_data.h" #include "data/planet_data.h" -#include "data/prop_data.h" +#include "data/world_generator_prop_data.h" #include "main/dungeon_room.h" #include "main/dungeon_corridor.h" @@ -21,7 +21,7 @@ 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();