diff --git a/source/States/GameState.cpp b/source/States/GameState.cpp index ed3e889287829a162de27c8580ff9b1fe732b830..05957834466fd54c28c9432be886f3a71713ef59 100644 --- a/source/States/GameState.cpp +++ b/source/States/GameState.cpp @@ -40,6 +40,29 @@ void GameState::process_key_pressed(sf::Keyboard::Key key) { } } +void GameState::process_entities_interactions(IVisitor* visitor) { + std::unique_ptr<IGameEvent> static_event; + std::unique_ptr<IGameEvent> dynamic_event; + for (auto& obj : m_context_manager.get_current_context().static_objects) { + static_event = std::move(obj->accept(visitor)); + if (static_event) { + break; + } + } + for (auto& obj : m_context_manager.get_current_context().dynamic_objects) { + dynamic_event = std::move(obj->accept(visitor)); + if (dynamic_event) { + break; + } + } + if (static_event) { + static_event->handle(&m_context_manager.get_current_context()); + } + if (dynamic_event) { + dynamic_event->handle(&m_context_manager.get_current_context()); + } +} + void GameState::event_handling() {