From bd603e58152d0b84f72c5461012fab9046411fc8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 23 Feb 2019 17:52:58 -0500 Subject: active_ | entityView() -> entityRange() --- src/renderer.cpp | 4 +--- src/simulation.cpp | 22 +++++++--------------- 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) ranges::view::for_each( renderOrder, [&] (Layer layer) { - return sim.getActive() | - sim.entityView() | - views::isOnLayer(layer); + return sim.entityRange() | views::isOnLayer(layer); }), [&] (const Entity& entity) { 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( { // Control for (Entity& entity : - active_ | - entityView() | + entityRange() | views::isControllable() | views::isNotMoving()) { @@ -123,8 +122,7 @@ void Simulation::tick( vec2s lookPos = posInDir(entity.gridPos, lookDir); for (Entity& block : - active_ | - entityView() | + entityRange() | views::atGridPos(lookPos) | views::isNotMoving() | views::canBePushedBy(entity.colliderType) | @@ -171,14 +169,12 @@ void Simulation::tick( if (schedule_.step()) { for (Entity& entity : - active_ | - entityView() | + entityRange() | views::isScheduled() | views::isNotMoving()) { auto tracks = - active_ | - entityView() | + entityRange() | views::atGridPos(entity.gridPos) | views::isTrack(); @@ -214,9 +210,7 @@ void Simulation::tick( // Movement - for (Entity& entity : - active_ | - entityView()) + for (Entity& entity : entityRange()) { if (entity.moving) { @@ -331,8 +325,7 @@ bool Simulation::moveEntityOnGrid( // Can't move into a space that something else is already moving into. if (!ranges::empty( - active_ | - entityView() | + entityRange() | views::isMovingTo(shouldMoveTo) | views::isOnLayer(entity.layer))) { @@ -340,8 +333,7 @@ bool Simulation::moveEntityOnGrid( } for (Entity& block : - active_ | - entityView() | + entityRange() | views::atGridPos(shouldMoveTo) | views::isOnLayer(entity.layer)) { 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: }); } + auto entityRange() + { + return active_ | entityView(); + } + + auto entityRange() const + { + return active_ | entityView(); + } + private: -- cgit 1.4.1