You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

9 years ago
#pragma once
#include <map>
#include "App.h"
#include <unordered_map>
#include "node.h"
9 years ago
class Pather {
9 years ago
public:
// Constructor
9 years ago
Pather(Map* map_);
~Pather();
// Reference to the map data
9 years ago
Map* map;
// Containers for the loop, probably inefficient as hell
std::unordered_map<node*, double> open_list;
std::unordered_map<node*, double> closed_list;
// A stack allocated 2d array from a template I stole from stackOverflow
MultiArray<int, Map::CELLS_WIDTH , Map::CELLS_HEIGHT> visited_map;
// Return a deque with the movement info to path to the end position from the start position
std::deque<int> getPathTo(sf::Vector2i start, sf::Vector2i end);
// Returns the end node of the current path
sf::Vector2i getEndNodePosition();
9 years ago
// Returns the current active node
node* getActiveNode();
9 years ago
private:
// Whether we couldn't find a path
9 years ago
bool no_path = false;
// If we found the path and can exit early
9 years ago
bool early_exit;
// Calculate the return path from back tracing the active nodes
std::deque<int> returnPath();
9 years ago
// The main iterative loop for a*
std::deque<int> loop();
9 years ago
// Movement list for the Explorer
9 years ago
std::deque<int> path_list;
// Start positions node
node* start_node;
// Current positions node
node* active_node;
// End positions node
9 years ago
node* end_node;
};