diff --git a/sources/Component/Controllable/ControllableComponent.cpp b/sources/Component/Controllable/ControllableComponent.cpp index 6e0edf312..bbd60e753 100644 --- a/sources/Component/Controllable/ControllableComponent.cpp +++ b/sources/Component/Controllable/ControllableComponent.cpp @@ -20,4 +20,12 @@ namespace BBM : WAL::Component(entity), disabled(isDisabled) {} + + void ControllableComponent::disable() + { + this->disabled = true; + this->pause = false; + this->bomb = false; + this->move = Vector2f(); + } } \ No newline at end of file diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp index a545751f7..f9353ea39 100644 --- a/sources/Component/Controllable/ControllableComponent.hpp +++ b/sources/Component/Controllable/ControllableComponent.hpp @@ -45,6 +45,8 @@ namespace BBM //! @brief True if buttons should be triggered every frame where the key is down, false if the button should only be triggered once the key is released. bool fastClick = false; + void disable(); + //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; diff --git a/sources/Runner/GameScene.cpp b/sources/Runner/GameScene.cpp index 7d367b5d6..ea028df37 100644 --- a/sources/Runner/GameScene.cpp +++ b/sources/Runner/GameScene.cpp @@ -121,7 +121,7 @@ namespace BBM entity.removeComponent(); if (entity.hasComponent()) return; - entity.getComponent().disabled = true; + entity.getComponent().disable(); entity.addComponent(1s, [](WAL::Entity &ent, WAL::Wal &) { if (!ent.hasComponent()) return; diff --git a/sources/Runner/PauseMenuScene.cpp b/sources/Runner/PauseMenuScene.cpp index c0514c4da..df3fe06fa 100644 --- a/sources/Runner/PauseMenuScene.cpp +++ b/sources/Runner/PauseMenuScene.cpp @@ -63,9 +63,7 @@ namespace BBM entity.scheduleDeletion(); for (auto &[entity, controller, _] : gameScene->view()) { - controller.disabled = true; - controller.pause = false; - controller.bomb = false; + controller.disable(); } for (auto &[_, timer] : gameScene->view()) timer.disabled = true;