-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathfinding.h
More file actions
76 lines (53 loc) · 1.49 KB
/
Pathfinding.h
File metadata and controls
76 lines (53 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#ifndef PATHFINDING
#define PATHFINDING
// Includes
#include "Node.h"
#include <vector>
#include <CoreStructures\GUVector4.h>
// Typedef for function pointer
typedef bool (*checkMap)(int x, int z);
// ---------------------------------------------------------------------
// Pathfinding - Used to find paths across the map
// ---------------------------------------------------------------------
class Pathfinding
{
private:
// ATTRIBUTES
Node *start;
Node *end;
std::vector<Node*> open;
std::vector<Node*> closed;
std::vector<CoreStructures::GUVector4*> path;
int current;
// METHODS
void SetStartAndEnd(Node startNode, Node endNode);
void PathOpened(int x, int z, float newCost, Node* parent);
Node* GetNextNode();
void ContinuePath();
// Map Checker function
checkMap isCellBlocked;
public:
// ATTRIBUTES
// Has the start node been initialised?
bool startInitComplete;
// Has the end node been found?
bool endFound;
// METHODS
// Constructor/Deconstructor
Pathfinding();
~Pathfinding();
// Find a path from the start to the end
void FindPath(CoreStructures::GUVector4 currentPos, CoreStructures::GUVector4 endPos);
// Return the next path position
CoreStructures::GUVector4 GetNextPosition();
// Reset to the start of the path
void ResetPath();
// Clear lists
void ClearOpenList() { open.clear(); }
void ClearClosedList() { closed.clear(); }
void ClearPath() { path.clear(); }
// Attach checker function
void attachMapCheck(checkMap func);
};
#endif