TazGraph Project v0.1.0
Loading...
Searching...
No Matches
Grid.h
1#pragma once
2
3#include "../../pch.h"
4
5#include "../GECS/Core/GECSEntity.h"
6#include "../GECS/Components.h"
7
8#include "../AABB/AABB.h"
9
10
11constexpr int CELL_SIZE = 10;
12constexpr int AXIS_CELLS = 80;
13constexpr int DEPTH_AXIS_CELLS = 4;
14constexpr int ROW_CELL_SIZE = AXIS_CELLS * CELL_SIZE;
15constexpr int COLUMN_CELL_SIZE = AXIS_CELLS * CELL_SIZE;
16constexpr int DEPTH_CELL_SIZE = DEPTH_AXIS_CELLS * CELL_SIZE;
17
18
20 int numXCells, numYCells, numZCells = 0;
21 int startX, endX, startY, endY, startZ, endZ = 0;
22 float cameraMargin = 0.0f;
23};
24
25class Grid {
26public:
27 enum Level {
28 Basic,
29 Outer1,
30 Outer2
31 };
32
33
34
35 Grid(int width, int height, int depth, int cellSize);
36 ~Grid();
37
38 void setSize(int cellSize);
39 void init(int width, int height, int depth, int cellSize);
40
41 void createCells(Grid::Level size);
42
43 void addLink(LinkEntity* link, Grid::Level m_level);
44 std::vector<Cell*> getLinkCells(LinkEntity* link, Grid::Level m_level);
45 void addLink(LinkEntity* link, std::vector<Cell*> cell);
46
47 void addEmpty(EmptyEntity* entity, Grid::Level m_level);
48
49 void addNode(NodeEntity* entity, Grid::Level m_level);
50 void addEmpty(EmptyEntity* entity, Cell* cell);
51 void addNode(NodeEntity* entity, Cell* cell);
52
53 Cell* getCell(int x, int y, int z, Grid::Level m_level);
54 Cell* getCell(const Entity& position, Grid::Level m_level);
55 std::vector<Cell*> getAdjacentCells(int x, int y, int z, Grid::Level m_level);
56 std::vector<Cell*> getAdjacentCells(const Entity& entity, Grid::Level m_level);
57 std::vector<Cell*>& getCells(Grid::Level m_level);
58 int getCellSize();
59 int getNumXCells();
60 int getNumYCells();
61 int getNumZCells();
62
63 bool setIntersectedCameraCells(ICamera& camera);
64
65 std::vector<Cell*> getIntersectedCameraCells(ICamera& camera);
66
67 bool gridLevelChanged();
68
69 Level getGridLevel();
70 void setGridLevel(Level newLevel);
71
72 int getLevelCellScale();
73
74 int getLevelCellScale(Level level);
75 std::vector<Cell*> interceptedCells;
76private:
77
78 std::vector<Cell*> _cells;
79 std::vector<Cell*> _parentCells;
80 std::vector<Cell*> _superParentCells;
81
82 int _cellSize;
83
84 int _width;
85 int _height;
86 int _depth;
87
88 int _numXCells;
89 int _numYCells;
90 int _numZCells;
91
92 // can change between different scenes/managers
93 std::map<Level, GridLevelData> gridLevelsData;
94
95 std::map<Level, int> gridLevels = {
96 {Level::Basic, 1},
97 {Level::Outer1, 2},
98 {Level::Outer2, 4}
99 };
100
101 Level _level = Level::Basic;
102 Level _lastLevel = Level::Basic;
103};
Definition GECSEntity.h:7
Definition GECS.h:224
Definition Grid.h:25
Definition ICamera.h:10
Definition GECSEntity.h:108
Definition GECSEntity.h:40
Definition CellEntity.h:6
Definition Grid.h:19