33 Grid(
int width,
int height,
int depth,
int cellSize);
36 void setSize(
int cellSize);
37 void init(
int width,
int height,
int depth,
int cellSize);
39 void createCells(Grid::Level size);
41 void addLink(
LinkEntity* link, Grid::Level m_level);
42 std::vector<Cell*> getLinkCells(
const LinkEntity& link, Grid::Level m_level);
43 void addLink(
LinkEntity* link, std::vector<Cell*> cell);
45 void addEmpty(
EmptyEntity* entity, Grid::Level m_level);
47 void addNode(
NodeEntity* entity, Grid::Level m_level);
51 Cell* getCell(
int x,
int y,
int z, Grid::Level m_level);
52 Cell* getCell(
const Entity& position, Grid::Level m_level);
53 std::vector<Cell*> getAdjacentCells(
int x,
int y,
int z, Grid::Level m_level);
54 std::vector<Cell*> getAdjacentCells(
const Entity& entity, Grid::Level m_level);
55 std::vector<Cell>& getCells(Grid::Level m_level);
61 bool setIntersectedCameraCells(
ICamera& camera);
63 std::vector<Cell*> getIntersectedCameraCells(
ICamera& camera);
66 std::vector<T*> getRevealedEntitiesInCameraCells() {
67 std::vector<T*> result;
69 if constexpr (std::is_same_v<T, NodeEntity>) {
70 for (
auto& cell : _interceptedCells) {
71 for (
auto& entity : cell->nodes) {
72 if (!entity->isHidden()) {
73 result.push_back(entity);
78 else if constexpr (std::is_same_v<T, EmptyEntity>) {
79 for (
auto& cell : _interceptedCells) {
80 for (
auto& entity : cell->emptyEntities) {
81 if (!entity->isHidden()) {
82 result.push_back(entity);
87 else if constexpr (std::is_same_v<T, LinkEntity>) {
88 std::map<unsigned int, LinkEntity*> uniqueEntities;
90 for (
auto& cell : _interceptedCells) {
91 for (
auto& link : cell->links) {
92 if (!link->isHidden()) {
93 unsigned int linkId = link->getId();
95 if (uniqueEntities.find(linkId) == uniqueEntities.end()) {
96 uniqueEntities[linkId] = link;
101 for (
auto& entry : uniqueEntities) {
102 result.push_back(entry.second);
106 static_assert(
sizeof(T) == 0,
"Unsupported entity type.");
112 template <
typename T>
113 std::vector<T*> getEntitiesInCameraCells() {
114 std::vector<T*> result;
116 if constexpr (std::is_same_v<T, NodeEntity>) {
117 for (
auto& cell : _interceptedCells) {
118 result.insert(result.end(), cell->nodes.begin(), cell->nodes.end());
121 else if constexpr (std::is_same_v<T, EmptyEntity>) {
122 for (
auto& cell : _interceptedCells) {
123 result.insert(result.end(), cell->emptyEntities.begin(), cell->emptyEntities.end());
127 static_assert(
sizeof(T) == 0,
"Unsupported entity type.");
132 std::vector<LinkEntity*> getLinksInCameraCells();
135 bool gridLevelChanged();
137 Level getGridLevel();
138 void setGridLevel(Level newLevel);
140 int getLevelCellScale();
142 int getLevelCellScale(Level level);
144 std::vector<Cell*> _interceptedCells;
146 std::vector<Cell> _cells;
147 std::vector<Cell> _parentCells;
148 std::vector<Cell> _superParentCells;
161 std::map<Level, GridLevelData> gridLevelsData;
163 std::map<Level, int> gridLevels = {
169 Level _level = Level::Basic;
170 Level _lastLevel = Level::Basic;