Have a way to detect the best rotation but it's still off a bit. Seems to choose wrong in simple situations. Look in System::shortest_rotate.

This commit is contained in:
Zed A. Shaw 2025-09-01 01:37:03 -04:00
parent f98cc543f6
commit d822cb3438
6 changed files with 32 additions and 48 deletions

View file

@ -3,7 +3,7 @@
#include "gui/ritual_ui.hpp"
#include "game_level.hpp"
#include "systems.hpp"
#define DEBUG
#define DEBUG 1
struct InventoryStats {
int healing = 0;
@ -36,19 +36,16 @@ Pathing compute_paths() {
System::multi_path<Comp>(level, paths, walls_copy);
auto pos = GameDB::player_position().location;
matrix::dump("compute_paths walls", walls_copy, pos.x, pos.y);
matrix::dump("compute_paths input", paths.$input, pos.x, pos.y);
matrix::dump("compute_paths paths", paths.$paths, pos.x, pos.y);
return paths;
}
DinkyECS::Entity Autowalker::camera_aim() {
auto& level = GameDB::current_level();
auto player_pos = GameDB::player_position();
// what happens if there's two things at that spot
if(level.collision->something_there(fsm.$main_ui.$rayview->aiming_at)) {
return level.collision->get(fsm.$main_ui.$rayview->aiming_at);
if(level.collision->something_there(player_pos.aiming_at)) {
return level.collision->get(player_pos.aiming_at);
} else {
return DinkyECS::NONE;
}
@ -129,8 +126,6 @@ bool Autowalker::path_player(Pathing& paths, Point& target_out) {
}
if(!level.map->can_move(target_out)) {
fmt::println("----- FAIL MAP IS, cell is {}", paths.$paths[target_out.y][target_out.x]);
level.map->dump(target_out.x, target_out.y);
path_fail("level_map->can_move", paths.$paths, target_out);
return false;
}
@ -139,11 +134,8 @@ bool Autowalker::path_player(Pathing& paths, Point& target_out) {
}
void Autowalker::rotate_player(Point target) {
// auto dir = facing > target_facing ? gui::Event::ROTATE_LEFT : gui::Event::ROTATE_RIGHT;
auto dir = gui::Event::ROTATE_LEFT;
fmt::println("ROTATE TO: {},{} aim is {},{}",
target.x, target.y, rayview->aiming_at.x, rayview->aiming_at.y);
auto player = GameDB::player_position();
auto dir = System::shortest_rotate(player.location, player.aiming_at, target);
while(rayview->aiming_at != target) {
send_event(dir);