diff options
| author | untodesu <kirill@untode.su> | 2025-12-11 15:14:26 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-12-11 15:14:26 +0500 |
| commit | f40d09cb8f712e87691af4912f3630d92d692779 (patch) | |
| tree | 7ac3a4168ff722689372fd489c6f94d0a2546e8f /src/game/shared/world/dimension.hh | |
| parent | 8bcbd2729388edc63c82d77d314b583af1447c49 (diff) | |
| download | voxelius-f40d09cb8f712e87691af4912f3630d92d692779.tar.bz2 voxelius-f40d09cb8f712e87691af4912f3630d92d692779.zip | |
Shuffle stuff around
- Use the new and improved hierarchy I figured out when making Prospero chat
- Re-add NSIS scripts, again from Prospero
- Update most build and utility scripts with their most recent versions
Diffstat (limited to 'src/game/shared/world/dimension.hh')
| -rw-r--r-- | src/game/shared/world/dimension.hh | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/game/shared/world/dimension.hh b/src/game/shared/world/dimension.hh new file mode 100644 index 0000000..6549bf6 --- /dev/null +++ b/src/game/shared/world/dimension.hh @@ -0,0 +1,101 @@ +#pragma once + +#include "shared/const.hh" +#include "shared/types.hh" + +namespace io +{ +class ConfigMap; +} // namespace io + +namespace world +{ +class Chunk; +class Voxel; +class VoxelStorage; +} // namespace world + +namespace world +{ +using dimension_entropy_map = std::array<std::uint64_t, CHUNK_AREA>; +using dimension_height_map = std::array<voxel_pos::value_type, CHUNK_AREA>; +} // namespace world + +namespace world +{ +class Dimension { +public: + explicit Dimension(std::string_view name, float gravity); + virtual ~Dimension(void); + + std::string_view get_name(void) const; + float get_gravity(void) const; + +public: + Chunk* create_chunk(const chunk_pos& cpos); + Chunk* find_chunk(entt::entity entity) const; + Chunk* find_chunk(const chunk_pos& cpos) const; + + void remove_chunk(entt::entity entity); + void remove_chunk(const chunk_pos& cpos); + void remove_chunk(Chunk* chunk); + +public: + const Voxel* get_voxel(const voxel_pos& vpos) const; + const Voxel* get_voxel(const chunk_pos& cpos, const local_pos& lpos) const; + + bool set_voxel(const Voxel* voxel, const voxel_pos& vpos); + bool set_voxel(const Voxel* voxel, const chunk_pos& cpos, const local_pos& lpos); + +public: + virtual void init(io::ConfigMap& config); + virtual void init_late(std::uint64_t global_seed); + virtual bool generate(const chunk_pos& cpos, VoxelStorage& voxels); + +public: + entt::registry chunks; + entt::registry entities; + +private: + std::string m_name; + emhash8::HashMap<chunk_pos, Chunk*> m_chunkmap; + float m_gravity; +}; +} // namespace world + +namespace world +{ +struct ChunkComponent final { + chunk_pos cpos; + Chunk* chunk; +}; +} // namespace world + +namespace world +{ +struct ChunkCreateEvent final { + Dimension* dimension; + chunk_pos cpos; + Chunk* chunk; +}; + +struct ChunkDestroyEvent final { + Dimension* dimension; + chunk_pos cpos; + Chunk* chunk; +}; + +struct ChunkUpdateEvent final { + Dimension* dimension; + chunk_pos cpos; + Chunk* chunk; +}; + +struct VoxelSetEvent final { + Dimension* dimension; + const Voxel* voxel; + chunk_pos cpos; + local_pos lpos; + Chunk* chunk; +}; +} // namespace world |
