Lodestone.Level
Loading...
Searching...
No Matches
LevelChunk.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 10/14/25 using zPc-i2.
3//
4#ifndef LODESTONE_LEVELCHUNK_H
5#define LODESTONE_LEVELCHUNK_H
7#include <memory>
8
11 public:
13 explicit LevelChunk(int height);
14
15 // TODO we should replace height with some vec2i which includes floor maybe, and make it section based
22 LevelChunk(int height,
24
25 ChunkType type() override;
26
27 [[nodiscard]] int getChunkHeight() const override;
28
31 [[nodiscard]] bool hasSection(const coords::SectionCoordinates &sectionY) const;
32
36
39 [[nodiscard]] section::Section *getSection(const coords::SectionCoordinates &sectionY) const override;
40
41 void calculateHeightmap() override;
42
43 void calculateHeightmapAtColumn(int localX, int localZ, int startHeight) override;
44
45 [[nodiscard]] const block::instance::BlockInstance &
46 getBlock(const int localX, const int blockY, const int localZ) const override;
47
48 void setBlock(block::instance::BlockInstance &&block, int localX, int y,
49 int localZ) override;
50
51 void setBlockRaw(block::instance::BlockInstance &&block, int localX, int y,
52 int localZ) override;
53
54 int getSectionCount() const override;
55
56 protected:
63 std::vector<std::unique_ptr<section::Section>> m_sections;
64 };
65} // namespace lodestone::level::chunk
66
67#endif // LODESTONE_LEVELCHUNK_H
#define LODESTONE_API
Wraps a block with runtime-modifiable properties.
Definition BlockInstance.h:19
Holds chunks.
Definition ChunkContainer.h:17
Chunk()
Definition Chunk.cpp:11
section::Section * getSectionCreate(const coords::SectionCoordinates &sectionY) override
Gets/Creates a section at the given section relative y level (NOT BLOCK Y).
Definition LevelChunk.cpp:46
section::Section * getSection(const coords::SectionCoordinates &sectionY) const override
Creates a section at the given section relative y level (NOT BLOCK Y).
Definition LevelChunk.cpp:38
void setBlockRaw(block::instance::BlockInstance &&block, int localX, int y, int localZ) override
Sets a block at the given X, Y, and Z coordinates.
Definition LevelChunk.cpp:109
ChunkType type() override
Definition LevelChunk.cpp:25
const block::instance::BlockInstance & getBlock(const int localX, const int blockY, const int localZ) const override
Definition LevelChunk.cpp:53
void calculateHeightmapAtColumn(int localX, int localZ, int startHeight) override
Definition LevelChunk.cpp:67
bool hasSection(const coords::SectionCoordinates &sectionY) const
Checks if a section at the given section relative y level exists (NOT BLOCK Y).
Definition LevelChunk.cpp:31
LevelChunk(int height)
Creates a new LevelChunk with preallocated chunk section array for the given height.
Definition LevelChunk.cpp:11
int getSectionCount() const override
Definition LevelChunk.cpp:114
void setBlock(block::instance::BlockInstance &&block, int localX, int y, int localZ) override
Sets a block at the given X, Y, and Z coordinates.
Definition LevelChunk.cpp:78
int getChunkHeight() const override
Gets the height of the chunk in Sections, can be used for getting section count.
Definition LevelChunk.cpp:29
void calculateHeightmap() override
Definition LevelChunk.cpp:57
std::vector< std::unique_ptr< section::Section > > m_sections
Chunk Sections.
Definition LevelChunk.h:63
Definition ChunkCoordinates.h:16
Definition SectionCoordinates.h:15
Definition Block.cpp:6
Definition Chunk.cpp:10
ChunkType
Definition Chunk.h:23
Definition ItemContainer.cpp:6
Definition ChunkCoordinates.cpp:10