diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index b591a55..7ffa8c7 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -1,5 +1,33 @@ #include "voxel_world.h" +int VoxelWorld::get_chunk_size_x() const { + return _chunk_size.x; +} +void VoxelWorld::set_chunk_size_x(const int value) { + _chunk_size.x = value; +} + +int VoxelWorld::get_chunk_size_y() const { + return _chunk_size.y; +} +void VoxelWorld::set_chunk_size_y(const int value) { + _chunk_size.y = value; +} + +int VoxelWorld::get_chunk_size_z() const { + return _chunk_size.z; +} +void VoxelWorld::set_chunk_size_z(const int value) { + _chunk_size.z = value; +} + +Ref VoxelWorld::get_library() const { + return _library; +} +void VoxelWorld::set_library(const ref library) { + _library = library; +} + NodePath VoxelWorld::get_player_path() { return _player_path; } @@ -8,11 +36,32 @@ void VoxelWorld::set_player_path(NodePath player_path) { _player_path = player_path; } +VoxelWorld::VoxelWorld() { + _chunk_size = Vector3i(16, 16, 16); +} + VoxelWorld ::~VoxelWorld() { _chunks.clear(); + _library.unref(); } void VoxelWorld::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_chunk_size_x"), &VoxelWorld::get_chunk_size_x); + ClassDB::bind_method(D_METHOD("set_chunk_size_x", "value"), &VoxelWorld::set_chunk_size_x); + ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_x"), "set_chunk_size_x", "get_chunk_size_x"); + + ClassDB::bind_method(D_METHOD("get_chunk_size_y"), &VoxelWorld::get_chunk_size_y); + ClassDB::bind_method(D_METHOD("set_chunk_size_y", "value"), &VoxelWorld::set_chunk_size_y); + ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_y"), "set_chunk_size_y", "get_chunk_size_y"); + + ClassDB::bind_method(D_METHOD("get_chunk_size_z"), &VoxelWorld::get_chunk_size_z); + ClassDB::bind_method(D_METHOD("set_chunk_size_z", "value"), &VoxelWorld::set_chunk_size_z); + ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_z"), "set_chunk_size_z", "get_chunk_size_z"); + + ClassDB::bind_method(D_METHOD("get_library"), &VoxelWorld::get_library); + ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelWorld::set_library); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE), "set_library", "get_library"); + ClassDB::bind_method(D_METHOD("get_player_path"), &VoxelWorld::get_player_path); ClassDB::bind_method(D_METHOD("set_player_path", "value"), &VoxelWorld::set_player_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "player_path"), "set_player_path", "get_player_path"); diff --git a/world/voxel_world.h b/world/voxel_world.h index 20b9dc2..0b35308 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -5,23 +5,42 @@ #include "core/hash_map.h" #include "../math/vector3i.h" +#include "../library/voxelman_library.h" #include "voxel_buffer.h" class VoxelWorld : public Spatial { GDCLASS(VoxelWorld, Spatial); public: + int get_chunk_size_x() const; + void set_chunk_size_x(const int value); + + int get_chunk_size_y() const; + void set_chunk_size_y(const int value); + + int get_chunk_size_z() const; + void set_chunk_size_z(const int value); + + Ref get_library() const; + void set_library(const ref library); + NodePath get_player_path(); void set_player_path(NodePath player_path); + + - VoxelWorld() {} + VoxelWorld(); ~VoxelWorld(); protected: static void _bind_methods(); private: + Vector3i _chunk_size; + Ref _library; + HashMap > _chunks; + Vector > _chunks_vector; NodePath _player_path; Spatial *_player;