diff --git a/data/biome_data.cpp b/data/biome_data.cpp index cd55fa1..2276ca7 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -272,7 +272,7 @@ void BiomeData::set_liquid_voxel_surface(const int index, const Ref voxel_surface) { +void BiomeData::add_liquid_surface(const Ref voxel_surface) { _liquid_voxel_surfaces.push_back(voxel_surface); } void BiomeData::remove_liquid_voxel_surface(const int index) { @@ -401,7 +401,7 @@ void BiomeData::_bind_methods() { //Liquid Surfaces ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface", "index"), &BiomeData::get_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "data"), &BiomeData::set_liquid_voxel_surface); - ClassDB::bind_method(D_METHOD("add_liquid_voxel_surface", "voxel_surface"), &BiomeData::add_liquid_voxel_surface); + ClassDB::bind_method(D_METHOD("add_liquid_surface", "voxel_surface"), &BiomeData::add_liquid_surface); ClassDB::bind_method(D_METHOD("remove_liquid_voxel_surface", "index"), &BiomeData::remove_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface_count"), &BiomeData::get_liquid_voxel_surface_count); diff --git a/data/biome_data.h b/data/biome_data.h index c31b4d2..844d48c 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -118,7 +118,7 @@ public: //Liquid Surfaces Ref get_liquid_voxel_surface(const int index) const; void set_liquid_voxel_surface(const int index, const Ref voxel_surface); - void add_liquid_voxel_surface(const Ref voxel_surface); + void add_liquid_surface(const Ref voxel_surface); void remove_liquid_voxel_surface(const int index); int get_liquid_voxel_surface_count() const; diff --git a/data/dungeon_data.cpp b/data/dungeon_data.cpp index 37d457a..902d6ac 100644 --- a/data/dungeon_data.cpp +++ b/data/dungeon_data.cpp @@ -353,7 +353,7 @@ void DungeonData::set_liquid_voxel_surface(const int index, const Ref voxel_surface) { +void DungeonData::add_liquid_surface(const Ref voxel_surface) { _liquid_voxel_surfaces.push_back(voxel_surface); } void DungeonData::remove_liquid_voxel_surface(const int index) { @@ -585,7 +585,7 @@ void DungeonData::_bind_methods() { //Liquid Surfaces ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface", "index"), &DungeonData::get_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "data"), &DungeonData::set_liquid_voxel_surface); - ClassDB::bind_method(D_METHOD("add_liquid_voxel_surface", "voxel_surface"), &DungeonData::add_liquid_voxel_surface); + ClassDB::bind_method(D_METHOD("add_liquid_surface", "voxel_surface"), &DungeonData::add_liquid_surface); ClassDB::bind_method(D_METHOD("remove_liquid_voxel_surface", "index"), &DungeonData::remove_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface_count"), &DungeonData::get_liquid_voxel_surface_count); diff --git a/data/dungeon_data.h b/data/dungeon_data.h index 7a51973..f4fb6eb 100644 --- a/data/dungeon_data.h +++ b/data/dungeon_data.h @@ -159,7 +159,7 @@ public: //Liquid Surfaces Ref get_liquid_voxel_surface(const int index) const; void set_liquid_voxel_surface(const int index, const Ref voxel_surface); - void add_liquid_voxel_surface(const Ref voxel_surface); + void add_liquid_surface(const Ref voxel_surface); void remove_liquid_voxel_surface(const int index); int get_liquid_voxel_surface_count() const; diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp index 4f8b9e8..18bd976 100644 --- a/data/dungeon_room_data.cpp +++ b/data/dungeon_room_data.cpp @@ -216,7 +216,7 @@ void DungeonRoomData::set_liquid_voxel_surface(const int index, const Ref voxel_surface) { +void DungeonRoomData::add_liquid_surface(const Ref voxel_surface) { _liquid_voxel_surfaces.push_back(voxel_surface); } void DungeonRoomData::remove_liquid_voxel_surface(const int index) { @@ -401,7 +401,7 @@ void DungeonRoomData::_bind_methods() { //Liquid Surfaces ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface", "index"), &DungeonRoomData::get_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "data"), &DungeonRoomData::set_liquid_voxel_surface); - ClassDB::bind_method(D_METHOD("add_liquid_voxel_surface", "voxel_surface"), &DungeonRoomData::add_liquid_voxel_surface); + ClassDB::bind_method(D_METHOD("add_liquid_surface", "voxel_surface"), &DungeonRoomData::add_liquid_surface); ClassDB::bind_method(D_METHOD("remove_liquid_voxel_surface", "index"), &DungeonRoomData::remove_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface_count"), &DungeonRoomData::get_liquid_voxel_surface_count); diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index 992128a..0385f6e 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -108,7 +108,7 @@ public: //Liquid Surfaces Ref get_liquid_voxel_surface(const int index) const; void set_liquid_voxel_surface(const int index, const Ref voxel_surface); - void add_liquid_voxel_surface(const Ref voxel_surface); + void add_liquid_surface(const Ref voxel_surface); void remove_liquid_voxel_surface(const int index); int get_liquid_voxel_surface_count() const; diff --git a/data/planet_data.cpp b/data/planet_data.cpp index fa93ebc..1efa3f9 100644 --- a/data/planet_data.cpp +++ b/data/planet_data.cpp @@ -193,7 +193,7 @@ void PlanetData::set_liquid_voxel_surface(const int index, const Ref voxel_surface) { +void PlanetData::add_liquid_surface(const Ref voxel_surface) { _liquid_voxel_surfaces.push_back(voxel_surface); } void PlanetData::remove_liquid_voxel_surface(const int index) { @@ -300,7 +300,7 @@ void PlanetData::_bind_methods() { //Liquid Surfaces ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface", "index"), &PlanetData::get_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "data"), &PlanetData::set_liquid_voxel_surface); - ClassDB::bind_method(D_METHOD("add_liquid_voxel_surface", "voxel_surface"), &PlanetData::add_liquid_voxel_surface); + ClassDB::bind_method(D_METHOD("add_liquid_surface", "voxel_surface"), &PlanetData::add_liquid_surface); ClassDB::bind_method(D_METHOD("remove_liquid_voxel_surface", "index"), &PlanetData::remove_liquid_voxel_surface); ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface_count"), &PlanetData::get_liquid_voxel_surface_count); diff --git a/data/planet_data.h b/data/planet_data.h index 574bcf2..134350f 100644 --- a/data/planet_data.h +++ b/data/planet_data.h @@ -93,7 +93,7 @@ public: //Liquid Surfaces Ref get_liquid_voxel_surface(const int index) const; void set_liquid_voxel_surface(const int index, const Ref voxel_surface); - void add_liquid_voxel_surface(const Ref voxel_surface); + void add_liquid_surface(const Ref voxel_surface); void remove_liquid_voxel_surface(const int index); int get_liquid_voxel_surface_count() const; diff --git a/data/world_generator_prop_data.cpp b/data/world_generator_prop_data.cpp index 6a04111..1cedee8 100644 --- a/data/world_generator_prop_data.cpp +++ b/data/world_generator_prop_data.cpp @@ -31,37 +31,61 @@ bool WorldGeneratorPropData::can_spawn(int seed) { } #ifdef VOXELMAN_PRESENT -Ref WorldGeneratorPropData::get_prop(int seed) { - if (has_method("_get_prop")) { - return call("_get_prop", seed); +Ref WorldGeneratorPropData::get_prop() { + return _prop; +} +void WorldGeneratorPropData::set_prop(Ref value) { + _prop = value; +} + +Ref WorldGeneratorPropData::get_prop_seeded(int seed) { + if (has_method("_get_prop_seeded")) { + return call("_get_prop_seeded", seed); } - return Ref(NULL); + return Ref(); } #else -Ref WorldGeneratorPropData::get_prop(int seed) { - if (has_method("_get_prop")) { - return call("_get_prop", seed); +Ref WorldGeneratorPropData::get_prop() { + return _prop; +} +void WorldGeneratorPropData::set_prop(Ref value) { + _prop = value; +} + +Ref WorldGeneratorPropData::get_prop_seeded(int seed) { + if (has_method("_get_prop_seeded")) { + return call("_get_prop_seeded", seed); } - return Ref(NULL); + return Ref(); } #endif WorldGeneratorPropData::WorldGeneratorPropData() { } WorldGeneratorPropData::~WorldGeneratorPropData() { + _prop.unref(); } void WorldGeneratorPropData::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_can_spawn", PropertyInfo(Variant::INT, "seed"))); #ifdef VOXELMAN_PRESENT - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "_get_prop_seeded", PropertyInfo(Variant::INT, "seed"))); #else - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "_get_prop", PropertyInfo(Variant::INT, "seed"))); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "_get_prop_seeded", PropertyInfo(Variant::INT, "seed"))); +#endif + + ClassDB::bind_method(D_METHOD("get_prop"), &WorldGeneratorPropData::get_prop); + ClassDB::bind_method(D_METHOD("set_prop"), &WorldGeneratorPropData::set_prop); + +#ifdef VOXELMAN_PRESENT + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop"); +#else + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop"), "set_prop", "get_prop"); #endif ClassDB::bind_method(D_METHOD("can_spawn", "seed"), &WorldGeneratorPropData::can_spawn); - ClassDB::bind_method(D_METHOD("get_prop", "seed"), &WorldGeneratorPropData::get_prop); + ClassDB::bind_method(D_METHOD("get_prop_seeded", "seed"), &WorldGeneratorPropData::get_prop_seeded); } diff --git a/data/world_generator_prop_data.h b/data/world_generator_prop_data.h index b1cbbb4..af4c8f1 100644 --- a/data/world_generator_prop_data.h +++ b/data/world_generator_prop_data.h @@ -36,9 +36,15 @@ public: bool can_spawn(int seed); #ifdef VOXELMAN_PRESENT - Ref get_prop(int seed); + Ref get_prop(); + void set_prop(Ref value); + + Ref get_prop_seeded(int seed); #else - Ref get_prop(int seed); + Ref get_prop(); + void set_prop(Ref value); + + Ref get_prop_seeded(int seed); #endif WorldGeneratorPropData(); @@ -46,6 +52,12 @@ public: protected: static void _bind_methods(); + +#ifdef VOXELMAN_PRESENT + Ref _prop; +#else + Ref _prop; +#endif }; #endif diff --git a/main/biome.cpp b/main/biome.cpp index 8b6bee1..1c7af56 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -179,7 +179,18 @@ void Biome::_setup_library(Ref library) { Ref s = _data->get_liquid_voxel_surface(i); if (s.is_valid()) { - library->add_liquid_voxel_surface(s); + library->add_liquid_surface(s); + } + } + + for (int i = 0; i < _data->get_prop_data_count(); ++i) { + Ref s = _data->get_prop_data(i); + + if (s.is_valid()) { + Ref pd = s->get_prop(); + + if (pd.is_valid()) + library->add_prop(s->get_prop()); } } } diff --git a/main/dungeon.cpp b/main/dungeon.cpp index b67b3c5..777db98 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -257,7 +257,7 @@ void Dungeon::_setup_library(Ref library) { Ref s = _data->get_liquid_voxel_surface(i); if (s.is_valid()) { - library->add_liquid_voxel_surface(s); + library->add_liquid_surface(s); } } } diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index f86b426..bc16bd9 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -187,7 +187,18 @@ void DungeonRoom::_setup_library(Ref library) { Ref s = _data->get_liquid_voxel_surface(i); if (s.is_valid()) { - library->add_liquid_voxel_surface(s); + library->add_liquid_surface(s); + } + } + + for (int i = 0; i < _data->get_prop_data_count(); ++i) { + Ref s = _data->get_prop_data(i); + + if (s.is_valid()) { + Ref pd = s->get_prop(); + + if (pd.is_valid()) + library->add_prop(pd); } } } diff --git a/main/planet.cpp b/main/planet.cpp index ed1a272..8d294b7 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -132,7 +132,7 @@ void Planet::_setup_library(Ref library) { Ref s = _data->get_liquid_voxel_surface(i); if (s.is_valid()) { - library->add_liquid_voxel_surface(s); + library->add_liquid_surface(s); } } }