A bit more cleaning up of the gui and fsm, probaby done.

master
Zed A. Shaw 2 weeks ago
parent dd4f77a106
commit 6c1d851e85
  1. 4
      gui_fsm.cpp
  2. 10
      main_ui.cpp
  3. 3
      main_ui.hpp

@ -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);
}

@ -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…
Cancel
Save