From 16ae08568ad9a64de3e91c6dc844da97f1d8b982 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 24 Sep 2019 02:42:42 +0200 Subject: [PATCH] Simple skeleton bingings. --- SCsub | 12 ++++++++ data/biome_data.cpp | 25 +++++++++-------- data/biome_data.h | 25 +++++++++-------- data/dungeon_data.cpp | 25 +++++++++-------- data/dungeon_data.h | 19 ++++++------- data/dungeon_room_data.cpp | 22 +++++++++++++++ data/dungeon_room_data.h | 18 ++++++------ data/dungeon_room_data.h.cpp | 21 -------------- data/planet_data.cpp | 15 ++++++---- data/planet_data.h | 17 ++++++----- main/biome.cpp | 28 +++++++++++-------- main/biome.h | 23 ++++++++------- main/dungeon.cpp | 23 ++++++++------- main/dungeon.h | 19 +++++++------ main/dungeon_room.cpp | 23 ++++++++------- main/dungeon_room.h | 22 +++++++-------- main/planet.cpp | 23 ++++++++------- main/planet.h | 19 ++++++------- register_types.cpp | 24 +++++++++++++++- ...world_generator.cpp => world_generator.cpp | 20 +++++++------ data/world_generator.h => world_generator.h | 9 +++--- 21 files changed, 240 insertions(+), 192 deletions(-) create mode 100644 data/dungeon_room_data.cpp delete mode 100644 data/dungeon_room_data.h.cpp rename data/world_generator.cpp => world_generator.cpp (74%) rename data/world_generator.h => world_generator.h (83%) diff --git a/SCsub b/SCsub index a7ee051..68a922d 100644 --- a/SCsub +++ b/SCsub @@ -1,4 +1,16 @@ Import('env') env.add_source_files(env.modules_sources,"register_types.cpp") + +env.add_source_files(env.modules_sources,"main/dungeon_room.cpp") +env.add_source_files(env.modules_sources,"main/dungeon.cpp") +env.add_source_files(env.modules_sources,"main/biome.cpp") +env.add_source_files(env.modules_sources,"main/planet.cpp") + +env.add_source_files(env.modules_sources,"data/dungeon_room_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,"world_generator.cpp") diff --git a/data/biome_data.cpp b/data/biome_data.cpp index 29f46e9..d48c545 100644 --- a/data/biome_data.cpp +++ b/data/biome_data.cpp @@ -1,21 +1,22 @@ -#include "voxelman_prop_entry.h" +#include "biome_data.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +Ref BiomeData::setup_biome(int seed) { + if (has_method("_setup_biome")) { + return call("_setup_biome", seed); + } + + return Ref(NULL); } -VoxelmanPropEntry::VoxelmanPropEntry() { +BiomeData::BiomeData() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +BiomeData::~BiomeData() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void BiomeData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "Biome"), "_setup_biome", PropertyInfo(Variant::INT, "seed"))); + + ClassDB::bind_method(D_METHOD("setup_biome", "seed"), &BiomeData::setup_biome); } diff --git a/data/biome_data.h b/data/biome_data.h index db2e20d..ee2b6e1 100644 --- a/data/biome_data.h +++ b/data/biome_data.h @@ -1,28 +1,29 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef BIOME_DATA_H +#define BIOME_DATA_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../main/biome.h" + +class BiomeData : public Resource { + GDCLASS(BiomeData, Resource); public: - Ref setup_biome(); + Ref setup_biome(int seed); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + BiomeData(); + ~BiomeData(); protected: static void _bind_methods(); private: - Vector2 _humidity_range; - Vector2 _temperature_range; - Vector _dungeon_datas; - Vector > _props; + //Vector2 _humidity_range; + //Vector2 _temperature_range; + //Vector _dungeon_datas; + //Vector > _props; }; #endif diff --git a/data/dungeon_data.cpp b/data/dungeon_data.cpp index 29f46e9..19a28cf 100644 --- a/data/dungeon_data.cpp +++ b/data/dungeon_data.cpp @@ -1,21 +1,22 @@ -#include "voxelman_prop_entry.h" +#include "dungeon_data.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +Ref DungeonData::setup_dungeon(int seed) { + if (has_method("_setup_dungeon")) { + return call("_setup_dungeon", seed); + } + + return Ref(NULL); } -VoxelmanPropEntry::VoxelmanPropEntry() { +DungeonData::DungeonData() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +DungeonData::~DungeonData() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void DungeonData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "Dungeon"), "_setup_dungeon", PropertyInfo(Variant::INT, "seed"))); + + ClassDB::bind_method(D_METHOD("setup_dungeon", "seed"), &DungeonData::setup_dungeon); } diff --git a/data/dungeon_data.h b/data/dungeon_data.h index 4590441..7172f6e 100644 --- a/data/dungeon_data.h +++ b/data/dungeon_data.h @@ -1,25 +1,24 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef DUNGEON_DATA_H +#define DUNGEON_DATA_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../main/dungeon.h" + +class DungeonData : public Resource { + GDCLASS(DungeonData, Resource); public: - Ref setup_dungeon(int seed); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + DungeonData(); + ~DungeonData(); protected: static void _bind_methods(); private: - - Vector > _rooms; + //Vector > _rooms; }; #endif diff --git a/data/dungeon_room_data.cpp b/data/dungeon_room_data.cpp new file mode 100644 index 0000000..731f1ee --- /dev/null +++ b/data/dungeon_room_data.cpp @@ -0,0 +1,22 @@ +#include "dungeon_room_data.h" + +Ref DungeonRoomData::setup_room(int seed) { + if (has_method("_setup_room")) { + return call("_setup_room", seed); + } + + return Ref(NULL); +} + +DungeonRoomData::DungeonRoomData() { + +} +DungeonRoomData::~DungeonRoomData() { + +} + +void DungeonRoomData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "room", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"), "_setup_room", PropertyInfo(Variant::INT, "seed"))); + + ClassDB::bind_method(D_METHOD("setup_room", "seed"), &DungeonRoomData::setup_room); +} diff --git a/data/dungeon_room_data.h b/data/dungeon_room_data.h index ab228ca..536fdd0 100644 --- a/data/dungeon_room_data.h +++ b/data/dungeon_room_data.h @@ -1,25 +1,25 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef DUNGEON_ROOM_DATA_H +#define DUNGEON_ROOM_DATA_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../main/dungeon_room.h" + +class DungeonRoomData : public Resource { + GDCLASS(DungeonRoomData, Resource); public: Ref setup_room(int seed); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + DungeonRoomData(); + ~DungeonRoomData(); protected: static void _bind_methods(); private: - - Vector _props; + //Vector _props; }; #endif diff --git a/data/dungeon_room_data.h.cpp b/data/dungeon_room_data.h.cpp deleted file mode 100644 index 29f46e9..0000000 --- a/data/dungeon_room_data.h.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "voxelman_prop_entry.h" - -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; -} - -VoxelmanPropEntry::VoxelmanPropEntry() { - -} -VoxelmanPropEntry::~VoxelmanPropEntry() { - -} - -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); -} diff --git a/data/planet_data.cpp b/data/planet_data.cpp index 4c2a367..6d30330 100644 --- a/data/planet_data.cpp +++ b/data/planet_data.cpp @@ -1,10 +1,11 @@ -#include "voxelman_prop_entry.h" +#include "planet_data.h" -Transform PlanetData::get_transform() const { - return _transform; -} -void PlanetData::set_transform(const Transform value) { - _transform = value; +Ref PlanetData::setup_planet(int seed) { + if (has_method("_setup_planet")) { + return call("_setup_planet", seed); + } + + return Ref(NULL); } PlanetData::PlanetData() { @@ -15,5 +16,7 @@ PlanetData::~PlanetData() { } void PlanetData::_bind_methods() { + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "biome", PROPERTY_HINT_RESOURCE_TYPE, "Planet"), "_setup_planet", PropertyInfo(Variant::INT, "seed"))); + ClassDB::bind_method(D_METHOD("setup_planet", "seed"), &PlanetData::setup_planet); } diff --git a/data/planet_data.h b/data/planet_data.h index 700eb9f..4ca0093 100644 --- a/data/planet_data.h +++ b/data/planet_data.h @@ -1,13 +1,15 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef PLANET_DATA_H +#define PLANET_DATA_H #include "core/resource.h" -#include "core/math/transform.h" + +#include "../main/planet.h" class PlanetData : public Resource { GDCLASS(PlanetData, Resource); public: + /* Ref get_planet_data(const int index) const; void set_planet_data(const int index, const Ref planet_data); void add_planet_data(const Ref planet_data); @@ -17,6 +19,7 @@ public: Vector get_planet_datas(); void set_planet_datas(const Vector &planet_datas); + */ Ref setup_planet(int seed); @@ -28,10 +31,10 @@ protected: private: - int _id; - Vector _biome_datas; - Ref _humidity_noise_params; - Ref _temperature_noise_params; + //int _id; + //Vector _biome_datas; + //Ref _humidity_noise_params; + //Ref _temperature_noise_params; }; #endif diff --git a/main/biome.cpp b/main/biome.cpp index 29f46e9..c06537f 100644 --- a/main/biome.cpp +++ b/main/biome.cpp @@ -1,21 +1,27 @@ -#include "voxelman_prop_entry.h" +#include "biome.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; +void Biome::generate_chunk(Ref chunk) { + if (has_method("_generate")) { + call("_generate", chunk); + } } -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +void Biome::generate_stack(Ref chunk, int x, int z) { + if (has_method("_generate")) { + call("_generate", chunk, x, z); + } } -VoxelmanPropEntry::VoxelmanPropEntry() { +Biome::Biome() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +Biome::~Biome() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void Biome::_bind_methods() { + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + BIND_VMETHOD(MethodInfo("_generate_stack", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"))); + + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Biome::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z"), &Biome::generate_stack); } diff --git a/main/biome.h b/main/biome.h index 3b2612d..948b97a 100644 --- a/main/biome.h +++ b/main/biome.h @@ -1,27 +1,26 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef BIOME_H +#define BIOME_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../../voxelman/world/voxel_chunk.h" + +class Biome : public Resource { + GDCLASS(Biome, Resource); public: - void generate_chunk(Ref chunk); - void generate_stack(int x, int z, Ref chunk); + void generate_stack(Ref chunk, int x, int z); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + Biome(); + ~Biome(); protected: static void _bind_methods(); private: - - Vector > _props; - Vector > _dungeons; + //Vector > _props; + //Vector > _dungeons; }; #endif diff --git a/main/dungeon.cpp b/main/dungeon.cpp index 29f46e9..3245dca 100644 --- a/main/dungeon.cpp +++ b/main/dungeon.cpp @@ -1,21 +1,20 @@ -#include "voxelman_prop_entry.h" +#include "dungeon.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +void Dungeon::generate(Ref structure) { + if (has_method("_generate")) { + call("_generate", structure); + } } -VoxelmanPropEntry::VoxelmanPropEntry() { +Dungeon::Dungeon() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +Dungeon::~Dungeon() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void Dungeon::_bind_methods() { + BIND_VMETHOD(MethodInfo("_generate", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); + + ClassDB::bind_method(D_METHOD("generate", "structure"), &Dungeon::generate); } diff --git a/main/dungeon.h b/main/dungeon.h index 2199c9e..5037c43 100644 --- a/main/dungeon.h +++ b/main/dungeon.h @@ -1,25 +1,26 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef DUNGEON_H +#define DUNGEON_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../../voxelman/world/voxel_structure.h" + +class Dungeon : public Reference { + GDCLASS(Dungeon, Reference); public: - Ref generate_dungeon(); + void generate(Ref structure); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + Dungeon(); + ~Dungeon(); protected: static void _bind_methods(); private: - Vector > _rooms; + //Vector > _rooms; }; #endif diff --git a/main/dungeon_room.cpp b/main/dungeon_room.cpp index 29f46e9..bbd604e 100644 --- a/main/dungeon_room.cpp +++ b/main/dungeon_room.cpp @@ -1,21 +1,20 @@ -#include "voxelman_prop_entry.h" +#include "dungeon_room.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +void DungeonRoom::generate_room(Ref structure) { + if (has_method("_generate_room")) { + call("_generate_room", structure); + } } -VoxelmanPropEntry::VoxelmanPropEntry() { +DungeonRoom::DungeonRoom() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +DungeonRoom::~DungeonRoom() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void DungeonRoom::_bind_methods() { + BIND_VMETHOD(MethodInfo("_generate_room", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStructure"))); + + ClassDB::bind_method(D_METHOD("generate_room", "structure"), &DungeonRoom::generate_room); } diff --git a/main/dungeon_room.h b/main/dungeon_room.h index 904a16f..0d3207b 100644 --- a/main/dungeon_room.h +++ b/main/dungeon_room.h @@ -1,26 +1,26 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef DUNGEON_ROOM_H +#define DUNGEON_ROOM_H -#include "core/resource.h" -#include "core/math/transform.h" +#include "core/reference.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../../voxelman/world/voxel_structure.h" + +class DungeonRoom : public Reference { + GDCLASS(DungeonRoom, Reference); public: - void write_room(Ref structure, Vector3i position, Vector3i size); - void generate_room(Ref structure); + void generate_room(Ref structure); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + DungeonRoom(); + ~DungeonRoom(); protected: static void _bind_methods(); private: - Vector > _props; + //Vector > _props; }; #endif diff --git a/main/planet.cpp b/main/planet.cpp index 29f46e9..4c549f0 100644 --- a/main/planet.cpp +++ b/main/planet.cpp @@ -1,21 +1,20 @@ -#include "voxelman_prop_entry.h" +#include "planet.h" -Transform VoxelmanPropEntry::get_transform() const { - return _transform; -} -void VoxelmanPropEntry::set_transform(const Transform value) { - _transform = value; +void Planet::generate_chunk(Ref chunk) { + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk); + } } -VoxelmanPropEntry::VoxelmanPropEntry() { +Planet::Planet() { } -VoxelmanPropEntry::~VoxelmanPropEntry() { +Planet::~Planet() { } -void VoxelmanPropEntry::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); +void Planet::_bind_methods() { + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk); } diff --git a/main/planet.h b/main/planet.h index a2e52a8..5c67388 100644 --- a/main/planet.h +++ b/main/planet.h @@ -1,25 +1,24 @@ -#ifndef VOXELMAN_PROP_DATA_H -#define VOXELMAN_PROP_DATA_H +#ifndef PLANET_H +#define PLANET_H #include "core/resource.h" -#include "core/math/transform.h" -class VoxelmanPropEntry : public Resource { - GDCLASS(VoxelmanPropEntry, Resource); +#include "../../voxelman/world/voxel_chunk.h" + +class Planet : public Resource { + GDCLASS(Planet, Resource); public: - void generate_chunk(Ref chunk); - VoxelmanPropEntry(); - ~VoxelmanPropEntry(); + Planet(); + ~Planet(); protected: static void _bind_methods(); private: - - Vector > _biomes; + //Vector > _biomes; }; #endif diff --git a/register_types.cpp b/register_types.cpp index 0c7b43e..d0ccca5 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,7 +1,29 @@ #include "register_types.h" +#include "data/dungeon_room_data.h" +#include "data/dungeon_data.h" +#include "data/biome_data.h" +#include "data/planet_data.h" + +#include "main/dungeon_room.h" +#include "main/dungeon.h" +#include "main/biome.h" +#include "main/planet.h" + +#include "world_generator.h" + 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(); + ClassDB::register_class(); + ClassDB::register_class(); + + ClassDB::register_class(); } void unregister_world_generator_types() { diff --git a/data/world_generator.cpp b/world_generator.cpp similarity index 74% rename from data/world_generator.cpp rename to world_generator.cpp index cbd64ff..7279c88 100644 --- a/data/world_generator.cpp +++ b/world_generator.cpp @@ -39,7 +39,7 @@ void WorldGenerator::set_planet_datas(const Vector &planet_datas) { } } -Ref WorldGenerator::setup_planet() { +Ref WorldGenerator::setup_planet(int seed) { if (has_method("_setup_planet")) { return call("_setup_planet"); } @@ -55,16 +55,18 @@ WorldGenerator::~WorldGenerator() { } void WorldGenerator::_bind_methods() { - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "planet", PROPERTY_HINT_RESOURCE_TYPE, "Planet") , "_setup_planet")); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "planet", PROPERTY_HINT_RESOURCE_TYPE, "Planet"), "_setup_planet", PropertyInfo(Variant::INT, "seed"))); - ClassDB::bind_method(D_METHOD("get_planet_data", "index"), &VoxelmanProp::get_planet_data); - ClassDB::bind_method(D_METHOD("set_planet_data", "index", "data"), &VoxelmanProp::set_planet_data); - ClassDB::bind_method(D_METHOD("add_planet_data", "planet_data"), &VoxelmanProp::add_planet_data); - ClassDB::bind_method(D_METHOD("remove_planet_data", "index"), &VoxelmanProp::remove_planet_data); + ClassDB::bind_method(D_METHOD("setup_planet", "seed"), &WorldGenerator::setup_planet); - ClassDB::bind_method(D_METHOD("get_planet_data_count"), &VoxelmanProp::get_planet_data_count); + ClassDB::bind_method(D_METHOD("get_planet_data", "index"), &WorldGenerator::get_planet_data); + ClassDB::bind_method(D_METHOD("set_planet_data", "index", "data"), &WorldGenerator::set_planet_data); + ClassDB::bind_method(D_METHOD("add_planet_data", "planet_data"), &WorldGenerator::add_planet_data); + ClassDB::bind_method(D_METHOD("remove_planet_data", "index"), &WorldGenerator::remove_planet_data); - ClassDB::bind_method(D_METHOD("get_planet_datas"), &VoxelmanProp::get_planet_datas); - ClassDB::bind_method(D_METHOD("set_planet_datas", "planet_datas"), &VoxelmanProp::set_planet_datas); + ClassDB::bind_method(D_METHOD("get_planet_data_count"), &WorldGenerator::get_planet_data_count); + + ClassDB::bind_method(D_METHOD("get_planet_datas"), &WorldGenerator::get_planet_datas); + ClassDB::bind_method(D_METHOD("set_planet_datas", "planet_datas"), &WorldGenerator::set_planet_datas); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "planet_datas", PROPERTY_HINT_NONE, "17/17:PlanetData", PROPERTY_USAGE_DEFAULT, "PlanetData"), "set_planet_datas", "get_planet_datas"); } diff --git a/data/world_generator.h b/world_generator.h similarity index 83% rename from data/world_generator.h rename to world_generator.h index d9ddd8f..668c79c 100644 --- a/data/world_generator.h +++ b/world_generator.h @@ -4,8 +4,9 @@ #include "core/resource.h" #include "core/vector.h" -#include "planet_data.h" -#include "../main/planet.h" +#include "data/planet_data.h" + +#include "main/planet.h" class WorldGenerator : public Resource { @@ -22,7 +23,7 @@ public: Vector get_planet_datas(); void set_planet_datas(const Vector &planet_datas); - Ref setup_planet(); + Ref setup_planet(int seed); WorldGenerator(); ~WorldGenerator(); @@ -32,7 +33,7 @@ protected: private: - Vector _planet_datas; + Vector > _planet_datas; }; #endif