33 std::vector<EmptyEntity*> visible_emptyEntities;
34 std::vector<NodeEntity*> visible_nodes;
35 std::vector<LinkEntity*> visible_links;
37 Grid(
int width,
int height,
int depth,
int cellSize);
40 void setSize(
int cellSize);
41 void init(
int width,
int height,
int depth,
int cellSize);
43 void createCells(Grid::Level size);
45 void addLink(
LinkEntity* link, Grid::Level m_level);
46 std::vector<Cell*> getLinkCells(
const LinkEntity& link, Grid::Level m_level);
47 void addLink(
LinkEntity* link, std::vector<Cell*> cell);
49 void addEmpty(
EmptyEntity* entity, Grid::Level m_level);
51 void addNode(
NodeEntity* entity, Grid::Level m_level);
55 Cell* getCell(
int x,
int y,
int z, Grid::Level m_level);
56 Cell* getCell(
const Entity& position, Grid::Level m_level);
57 std::vector<Cell*> getAdjacentCells(
int x,
int y,
int z, Grid::Level m_level);
58 std::vector<Cell*> getAdjacentCells(
const Entity& entity, Grid::Level m_level);
59 std::vector<Cell>& getCells(Grid::Level m_level);
65 bool setIntersectedCameraCells(
ICamera& camera);
67 std::vector<Cell*> getIntersectedCameraCells(
ICamera& camera);
71 std::vector<T*> getRevealedEntitiesInCameraCells() {
72 std::vector<T*> result;
74 if constexpr (std::is_same_v<T, NodeEntity>) {
75 for (
auto& cell : _interceptedCells) {
76 for (
auto& entity : cell->nodes) {
77 if (!entity->isHidden()) {
78 result.push_back(entity);
80 for (
auto* port : entity->children) {
81 if (port && !port->isHidden()) {
82 visible_emptyEntities.push_back(port);
85 for (
auto& portSlots : port->GetComponent<
PortComponent>().portSlots)
86 visible_emptyEntities.push_back(portSlots);
94 else if constexpr (std::is_same_v<T, EmptyEntity>) {
95 for (
auto& cell : _interceptedCells) {
96 for (
auto& entity : cell->emptyEntities) {
97 if (!entity->isHidden()) {
98 result.push_back(entity);
103 else if constexpr (std::is_same_v<T, LinkEntity>) {
104 std::map<unsigned int, LinkEntity*> uniqueEntities;
106 for (
auto& cell : _interceptedCells) {
107 for (
auto& link : cell->links) {
108 if (!link->isHidden()) {
109 unsigned int linkId = link->getId();
111 if (uniqueEntities.find(linkId) == uniqueEntities.end()) {
112 uniqueEntities[linkId] = link;
117 for (
auto& entry : uniqueEntities) {
118 result.push_back(entry.second);
122 static_assert(
sizeof(T) == 0,
"Unsupported entity type.");
129 template <
typename T>
130 std::vector<T*> getEntitiesInCameraCells() {
131 std::vector<T*> result;
133 if constexpr (std::is_same_v<T, NodeEntity>) {
134 for (
auto& cell : _interceptedCells) {
135 result.insert(result.end(), cell->nodes.begin(), cell->nodes.end());
138 for (
auto& cell : _interceptedCells) {
139 for (
auto& entity : cell->nodes) {
140 if (!entity->isHidden()) {
142 for (
auto* port : entity->children) {
143 if (port && !port->isHidden()) {
144 visible_emptyEntities.push_back(port);
147 for (
auto& portSlots : port->GetComponent<
PortComponent>().portSlots)
148 visible_emptyEntities.push_back(portSlots);
157 else if constexpr (std::is_same_v<T, EmptyEntity>) {
158 for (
auto& cell : _interceptedCells) {
159 result.insert(result.end(), cell->emptyEntities.begin(), cell->emptyEntities.end());
163 static_assert(
sizeof(T) == 0,
"Unsupported entity type.");
168 std::vector<LinkEntity*> getLinksInCameraCells();
171 bool gridLevelChanged();
173 Level getGridLevel();
174 void setGridLevel(Level newLevel);
176 int getLevelCellScale();
178 int getLevelCellScale(Level level);
180 std::vector<Cell*> _interceptedCells;
182 std::vector<Cell> _cells;
183 std::vector<Cell> _parentCells;
184 std::vector<Cell> _superParentCells;
197 std::map<Level, GridLevelData> gridLevelsData;
199 std::map<Level, int> gridLevels = {
205 Level _level = Level::Basic;
206 Level _lastLevel = Level::Basic;