2019-06-07 01:33:41 +02:00
|
|
|
#ifndef VOXEL_WORLD_H
|
|
|
|
#define VOXEL_WORLD_H
|
|
|
|
|
2019-10-05 22:53:48 +02:00
|
|
|
#include "scene/3d/navigation.h"
|
2019-06-07 01:33:41 +02:00
|
|
|
#include "core/hash_map.h"
|
|
|
|
|
|
|
|
#include "../math/vector3i.h"
|
2019-08-12 13:12:42 +02:00
|
|
|
#include "../library/voxelman_library.h"
|
2019-09-03 13:52:32 +02:00
|
|
|
#include "../level_generator/voxelman_level_generator.h"
|
2019-06-07 01:33:41 +02:00
|
|
|
#include "voxel_buffer.h"
|
|
|
|
|
2019-08-12 20:40:05 +02:00
|
|
|
class VoxelChunk;
|
|
|
|
|
2019-10-05 22:53:48 +02:00
|
|
|
class VoxelWorld : public Navigation {
|
|
|
|
GDCLASS(VoxelWorld, Navigation);
|
2019-06-07 01:33:41 +02:00
|
|
|
|
|
|
|
public:
|
2019-08-12 13:12:42 +02:00
|
|
|
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<VoxelmanLibrary> get_library() const;
|
2019-08-12 20:40:05 +02:00
|
|
|
void set_library(const Ref<VoxelmanLibrary> library);
|
2019-09-03 13:52:32 +02:00
|
|
|
|
|
|
|
Ref<VoxelmanLevelGenerator> get_level_generator() const;
|
|
|
|
void set_level_generator(const Ref<VoxelmanLevelGenerator> level_generator);
|
2019-08-12 20:40:05 +02:00
|
|
|
|
|
|
|
float get_voxel_scale() const;
|
|
|
|
void set_voxel_scale(const float value);
|
|
|
|
|
|
|
|
int get_chunk_spawn_range() const;
|
|
|
|
void set_chunk_spawn_range(const int value);
|
|
|
|
|
2019-06-07 01:33:41 +02:00
|
|
|
NodePath get_player_path();
|
|
|
|
void set_player_path(NodePath player_path);
|
2019-08-12 13:12:42 +02:00
|
|
|
|
2019-08-12 20:40:05 +02:00
|
|
|
Spatial *get_player() const;
|
|
|
|
void set_player(Spatial *player);
|
|
|
|
void set_player_bind(Node *player);
|
|
|
|
|
|
|
|
void add_chunk(Ref<VoxelChunk> chunk, const int x, const int y, const int z);
|
|
|
|
Ref<VoxelChunk> get_chunk(const int x, const int y, const int z) const;
|
|
|
|
Ref<VoxelChunk> remove_chunk(const int x, const int y, const int z);
|
|
|
|
|
|
|
|
Ref<VoxelChunk> get_chunk_index(const int index);
|
|
|
|
int get_chunk_count() const;
|
|
|
|
|
|
|
|
void clear_chunks();
|
2019-06-07 01:33:41 +02:00
|
|
|
|
2019-08-12 13:12:42 +02:00
|
|
|
VoxelWorld();
|
2019-06-07 19:13:07 +02:00
|
|
|
~VoxelWorld();
|
2019-06-07 01:33:41 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
private:
|
2019-08-12 13:12:42 +02:00
|
|
|
Vector3i _chunk_size;
|
|
|
|
Ref<VoxelmanLibrary> _library;
|
2019-09-03 13:52:32 +02:00
|
|
|
Ref<VoxelmanLevelGenerator> _level_generator;
|
2019-08-12 20:40:05 +02:00
|
|
|
float _voxel_scale;
|
|
|
|
int _chunk_spawn_range;
|
2019-08-12 13:12:42 +02:00
|
|
|
|
2019-08-12 20:40:05 +02:00
|
|
|
HashMap<Vector3i, Ref<VoxelChunk>, Vector3iHasher> _chunks;
|
|
|
|
Vector<Ref<VoxelChunk> > _chunks_vector;
|
2019-06-07 01:33:41 +02:00
|
|
|
|
|
|
|
NodePath _player_path;
|
|
|
|
Spatial *_player;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|