diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 64cb45e..91f7e56 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -77,8 +77,8 @@ namespace gui { void FSM::MOVING(Event ) { // this should be an optional that returns a point - if($main_ui.play_move()) { - System::plan_motion(*$level.world, {size_t($main_ui.$camera.target_x), size_t($main_ui.$camera.target_y)}); + if(auto move_to = $main_ui.play_move()) { + System::plan_motion(*$level.world, *move_to); run_systems(); state(State::IDLE); } diff --git a/main_ui.cpp b/main_ui.cpp index c247248..0a2078f 100644 --- a/main_ui.cpp +++ b/main_ui.cpp @@ -90,8 +90,14 @@ namespace gui { } // this could be an optional that returs a Point - bool MainUI::play_move() { - return $camera.play_move($rayview); + std::optional MainUI::play_move() { + if($camera.play_move($rayview)) { + return std::make_optional({ + size_t($camera.target_x), + size_t($camera.target_y)}); + } else { + return std::nullopt; + } } void MainUI::plan_rotate(int dir) { diff --git a/main_ui.hpp b/main_ui.hpp index 347c94c..164ec33 100644 --- a/main_ui.hpp +++ b/main_ui.hpp @@ -5,6 +5,7 @@ #include "overlay_ui.hpp" #include "raycaster.hpp" #include "camera.hpp" +#include namespace gui { @@ -26,7 +27,7 @@ namespace gui { void draw_stats(); void draw_blood(); - bool play_move(); + std::optional play_move(); void plan_rotate(int dir); bool play_rotate(); Point plan_move(int dir, bool strafe);