diff options
Diffstat (limited to 'Artist.cpp')
-rw-r--r-- | Artist.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -3,15 +3,21 @@ #include "Artist.h" #include "Museum.h" +using namespace std; + Artist::Artist(Museum & museum, ArtistData data) : museum(museum) { this->data = data; this->data.vx /= 5; this->data.vy /= 5; } -void Artist::update() { - this->update_edge_collision(); - this->update_movement(); +void Artist::update(bool tick) { + if (tick) { + this->update_edge_collision(); + this->update_movement(); + } + // Artist<->Artist collisions are marked by CollisionChecker + this->update_path_collision(); this->update_color(); } @@ -38,6 +44,17 @@ void Artist::update_movement() { if (abs(int(last_y) - int(this->data.y)) > 0) this->step = true; } +void Artist::update_path_collision() { + PathfindingContext & ctx = this->museum.pathfinding; + if (!ctx.has_collision) return; + Pathfinder & solver = ctx.get_solver(); + bool is_solution = solver.is_solution({ + static_cast<int>(this->data.x), + static_cast<int>(this->data.y), + }); + if (is_solution) this->colliding = true; +} + void Artist::update_color() { if (this->colliding) { this->color = { |