62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
/*
|
|
PolyGun
|
|
|
|
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
|
|
#ifndef POLYGUN_WORLD_CHUNK_MANAGER_BASE_HPP
|
|
#define POLYGUN_WORLD_CHUNK_MANAGER_BASE_HPP
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
#include "common/math/rect3d.hpp"
|
|
#include "common/world/chunk.hpp"
|
|
|
|
namespace polygun::world {
|
|
class ChunkManagerBase {
|
|
public:
|
|
struct LoadedChunk {
|
|
math::Vector3i m_pos;
|
|
time_t m_last_accessed;
|
|
bool m_modified;
|
|
std::unique_ptr<world::Chunk> m_chunk;
|
|
};
|
|
|
|
public:
|
|
virtual ~ChunkManagerBase() = default;
|
|
|
|
void add_node(uint16_t node, const math::Vector3i& node_pos);
|
|
// Note: Copying Vector3i is intended here
|
|
void fill_node(uint16_t node, math::Vector3i from, math::Vector3i to);
|
|
uint16_t get_node(const math::Vector3i& node_pos);
|
|
LoadedChunk& get_chunk_with_node(const math::Vector3i& node_pos);
|
|
math::Rect3D get_node_bbox(const math::Vector3i& node_pos);
|
|
|
|
virtual LoadedChunk& get_chunk(const math::Vector3i& pos) = 0;
|
|
|
|
protected:
|
|
std::vector<LoadedChunk> m_loaded_chunks;
|
|
};
|
|
}
|
|
|
|
#endif // POLYGUN_WORLD_CHUNK_MANAGER_BASE_HPP
|