-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgridded_graph.hpp
49 lines (32 loc) · 1.24 KB
/
gridded_graph.hpp
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
#pragma once
#include "scene/main/node.h"
#include "character_parameters.hpp"
#include "grid.hpp"
#include "pathfinding/graph.hpp"
class GriddedGraph : public Node {
GDCLASS(GriddedGraph, Node)
pathfinding::Graph _graph;
Ref<Grid> _grid;
void _add_masses(const Vector<Rect2>& rect);
protected:
static void _bind_methods();
public:
GriddedGraph() : _grid(RES()) { _grid.instance(); }
void refresh_static_masses();
void grid_set(Ref<Grid> grid)
{
_grid = grid;
if (_grid.is_null()) {
_grid.instance();
}
_change_notify("grid");
}
Ref<Grid> grid_get() const { return _grid; }
Vector2 find_floor(Ref<CharacterParameters> character_parameters, Vector2 graph_position, int depth = 10) const;
Vector2 world_to_graph(Vector2 world_position) const;
Vector2 graph_to_world(Vector2 graph_position, bool use_middle) const;
Vector2 world_units(Vector2 graph_units) const;
Vector2 graph_units(Vector2 world_units) const;
const pathfinding::Graph& graph() const { return _graph; }
PoolVector2Array get_closest_free_cell_in_world_cover(Ref<CharacterParameters> character_parameters, Vector2 point, Array regions, bool prefer_floor = false) const;
};