A bit more cleaning up of the gui and fsm, probaby done.
This commit is contained in:
parent
dd4f77a106
commit
6c1d851e85
3 changed files with 12 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
10
main_ui.cpp
10
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<Point> MainUI::play_move() {
|
||||
if($camera.play_move($rayview)) {
|
||||
return std::make_optional<Point>({
|
||||
size_t($camera.target_x),
|
||||
size_t($camera.target_y)});
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void MainUI::plan_rotate(int dir) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "overlay_ui.hpp"
|
||||
#include "raycaster.hpp"
|
||||
#include "camera.hpp"
|
||||
#include <optional>
|
||||
|
||||
namespace gui {
|
||||
|
||||
|
@ -26,7 +27,7 @@ namespace gui {
|
|||
void draw_stats();
|
||||
void draw_blood();
|
||||
|
||||
bool play_move();
|
||||
std::optional<Point> play_move();
|
||||
void plan_rotate(int dir);
|
||||
bool play_rotate();
|
||||
Point plan_move(int dir, bool strafe);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue