diff options
-rw-r--r-- | src/renderer.cpp | 4 | ||||
-rw-r--r-- | src/simulation.cpp | 22 | ||||
-rw-r--r-- | src/simulation.h | 10 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index 5580073..286a530 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
@@ -83,9 +83,7 @@ void Renderer::render(const Simulation& sim) | |||
83 | ranges::view::for_each( | 83 | ranges::view::for_each( |
84 | renderOrder, | 84 | renderOrder, |
85 | [&] (Layer layer) { | 85 | [&] (Layer layer) { |
86 | return sim.getActive() | | 86 | return sim.entityRange() | views::isOnLayer(layer); |
87 | sim.entityView() | | ||
88 | views::isOnLayer(layer); | ||
89 | }), | 87 | }), |
90 | [&] (const Entity& entity) { | 88 | [&] (const Entity& entity) { |
91 | SDL_SetRenderDrawColor(ren_.get(), entity.colorVal, entity.colorVal, 65, 255); | 89 | SDL_SetRenderDrawColor(ren_.get(), entity.colorVal, entity.colorVal, 65, 255); |
diff --git a/src/simulation.cpp b/src/simulation.cpp index 98687b6..326526f 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp | |||
@@ -94,8 +94,7 @@ void Simulation::tick( | |||
94 | { | 94 | { |
95 | // Control | 95 | // Control |
96 | for (Entity& entity : | 96 | for (Entity& entity : |
97 | active_ | | 97 | entityRange() | |
98 | entityView() | | ||
99 | views::isControllable() | | 98 | views::isControllable() | |
100 | views::isNotMoving()) | 99 | views::isNotMoving()) |
101 | { | 100 | { |
@@ -123,8 +122,7 @@ void Simulation::tick( | |||
123 | vec2s lookPos = posInDir(entity.gridPos, lookDir); | 122 | vec2s lookPos = posInDir(entity.gridPos, lookDir); |
124 | 123 | ||
125 | for (Entity& block : | 124 | for (Entity& block : |
126 | active_ | | 125 | entityRange() | |
127 | entityView() | | ||
128 | views::atGridPos(lookPos) | | 126 | views::atGridPos(lookPos) | |
129 | views::isNotMoving() | | 127 | views::isNotMoving() | |
130 | views::canBePushedBy(entity.colliderType) | | 128 | views::canBePushedBy(entity.colliderType) | |
@@ -171,14 +169,12 @@ void Simulation::tick( | |||
171 | if (schedule_.step()) | 169 | if (schedule_.step()) |
172 | { | 170 | { |
173 | for (Entity& entity : | 171 | for (Entity& entity : |
174 | active_ | | 172 | entityRange() | |
175 | entityView() | | ||
176 | views::isScheduled() | | 173 | views::isScheduled() | |
177 | views::isNotMoving()) | 174 | views::isNotMoving()) |
178 | { | 175 | { |
179 | auto tracks = | 176 | auto tracks = |
180 | active_ | | 177 | entityRange() | |
181 | entityView() | | ||
182 | views::atGridPos(entity.gridPos) | | 178 | views::atGridPos(entity.gridPos) | |
183 | views::isTrack(); | 179 | views::isTrack(); |
184 | 180 | ||
@@ -214,9 +210,7 @@ void Simulation::tick( | |||
214 | 210 | ||
215 | 211 | ||
216 | // Movement | 212 | // Movement |
217 | for (Entity& entity : | 213 | for (Entity& entity : entityRange()) |
218 | active_ | | ||
219 | entityView()) | ||
220 | { | 214 | { |
221 | if (entity.moving) | 215 | if (entity.moving) |
222 | { | 216 | { |
@@ -331,8 +325,7 @@ bool Simulation::moveEntityOnGrid( | |||
331 | 325 | ||
332 | // Can't move into a space that something else is already moving into. | 326 | // Can't move into a space that something else is already moving into. |
333 | if (!ranges::empty( | 327 | if (!ranges::empty( |
334 | active_ | | 328 | entityRange() | |
335 | entityView() | | ||
336 | views::isMovingTo(shouldMoveTo) | | 329 | views::isMovingTo(shouldMoveTo) | |
337 | views::isOnLayer(entity.layer))) | 330 | views::isOnLayer(entity.layer))) |
338 | { | 331 | { |
@@ -340,8 +333,7 @@ bool Simulation::moveEntityOnGrid( | |||
340 | } | 333 | } |
341 | 334 | ||
342 | for (Entity& block : | 335 | for (Entity& block : |
343 | active_ | | 336 | entityRange() | |
344 | entityView() | | ||
345 | views::atGridPos(shouldMoveTo) | | 337 | views::atGridPos(shouldMoveTo) | |
346 | views::isOnLayer(entity.layer)) | 338 | views::isOnLayer(entity.layer)) |
347 | { | 339 | { |
diff --git a/src/simulation.h b/src/simulation.h index 096377c..abff3da 100644 --- a/src/simulation.h +++ b/src/simulation.h | |||
@@ -59,6 +59,16 @@ public: | |||
59 | }); | 59 | }); |
60 | } | 60 | } |
61 | 61 | ||
62 | auto entityRange() | ||
63 | { | ||
64 | return active_ | entityView(); | ||
65 | } | ||
66 | |||
67 | auto entityRange() const | ||
68 | { | ||
69 | return active_ | entityView(); | ||
70 | } | ||
71 | |||
62 | private: | 72 | private: |
63 | 73 | ||
64 | 74 | ||