From 5eb52491473ebd85852339aed53bf9f8f3adbc0f Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 3 Sep 2019 13:52:32 +0200 Subject: [PATCH] Level generator skeleton class. --- SCsub | 2 ++ level_generator/voxelman_level_generator.cpp | 10 ++++++++++ level_generator/voxelman_level_generator.h | 19 +++++++++++++++++++ register_types.cpp | 4 ++++ world/voxel_world.cpp | 13 ++++++++++++- world/voxel_world.h | 5 +++++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 level_generator/voxelman_level_generator.cpp create mode 100644 level_generator/voxelman_level_generator.h diff --git a/SCsub b/SCsub index b0e5534..a6a93bd 100644 --- a/SCsub +++ b/SCsub @@ -24,3 +24,5 @@ env.add_source_files(env.modules_sources,"meshers/cubic_mesher/voxel_cube_points env.add_source_files(env.modules_sources,"props/voxelman_prop_data.cpp") env.add_source_files(env.modules_sources,"props/voxelman_prop.cpp") + +env.add_source_files(env.modules_sources,"level_generator/voxelman_level_generator.cpp") diff --git a/level_generator/voxelman_level_generator.cpp b/level_generator/voxelman_level_generator.cpp new file mode 100644 index 0000000..b64ad27 --- /dev/null +++ b/level_generator/voxelman_level_generator.cpp @@ -0,0 +1,10 @@ +#include "voxelman_level_generator.h" + +VoxelmanLevelGenerator::VoxelmanLevelGenerator() { +} + +VoxelmanLevelGenerator::~VoxelmanLevelGenerator() { +} + +void VoxelmanLevelGenerator::_bind_methods() { +} diff --git a/level_generator/voxelman_level_generator.h b/level_generator/voxelman_level_generator.h new file mode 100644 index 0000000..d2834bd --- /dev/null +++ b/level_generator/voxelman_level_generator.h @@ -0,0 +1,19 @@ +#ifndef VOXELMAN_LEVEL_GENERATOR_H +#define VOXELMAN_LEVEL_GENERATOR_H + +#include "core/resource.h" + +class VoxelmanLevelGenerator : public Resource { + GDCLASS(VoxelmanLevelGenerator, Resource); + +public: + VoxelmanLevelGenerator(); + ~VoxelmanLevelGenerator(); + +protected: + static void _bind_methods(); + +}; + +#endif + diff --git a/register_types.cpp b/register_types.cpp index 14adc1e..e6f6e83 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -18,6 +18,8 @@ #include "props/voxelman_prop_data.h" #include "props/voxelman_prop.h" +#include "level_generator/voxelman_level_generator.h" + void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); @@ -39,6 +41,8 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); + + ClassDB::register_class(); } void unregister_voxelman_types() { diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index fb039eb..b0461c5 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -30,6 +30,13 @@ void VoxelWorld::set_library(const Ref library) { _library = library; } +Ref VoxelWorld::get_level_generator() const { + return _level_generator; +} +void VoxelWorld::set_level_generator(const Ref level_generator) { + _level_generator = level_generator; +} + float VoxelWorld::get_voxel_scale() const { return _voxel_scale; } @@ -141,7 +148,11 @@ void VoxelWorld::_bind_methods() { ClassDB::bind_method(D_METHOD("get_library"), &VoxelWorld::get_library); ClassDB::bind_method(D_METHOD("set_library", "library"), &VoxelWorld::set_library); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"), "set_library", "get_library"); - + + ClassDB::bind_method(D_METHOD("get_level_generator"), &VoxelWorld::get_level_generator); + ClassDB::bind_method(D_METHOD("set_level_generator", "level_generator"), &VoxelWorld::set_level_generator); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "level_generator", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLevelGenerator"), "set_level_generator", "get_level_generator"); + ClassDB::bind_method(D_METHOD("get_voxel_scale"), &VoxelWorld::get_voxel_scale); ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &VoxelWorld::set_voxel_scale); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); diff --git a/world/voxel_world.h b/world/voxel_world.h index a44a1c5..300062c 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -6,6 +6,7 @@ #include "../math/vector3i.h" #include "../library/voxelman_library.h" +#include "../level_generator/voxelman_level_generator.h" #include "voxel_buffer.h" class VoxelChunk; @@ -25,6 +26,9 @@ public: Ref get_library() const; void set_library(const Ref library); + + Ref get_level_generator() const; + void set_level_generator(const Ref level_generator); float get_voxel_scale() const; void set_voxel_scale(const float value); @@ -57,6 +61,7 @@ protected: private: Vector3i _chunk_size; Ref _library; + Ref _level_generator; float _voxel_scale; int _chunk_spawn_range;