ScummVM API documentation
PathfindingGrid.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
/*
23
* This code is based on the CRAB engine
24
*
25
* Copyright (c) Arvind Raja Yadav
26
*
27
* Licensed under MIT
28
*
29
*/
30
31
#ifndef CRAB_PATHFINDINGGRID_H
32
#define CRAB_PATHFINDINGGRID_H
33
34
#include "crab/PathfindingGraphNode.h"
35
36
namespace
Crab
{
37
38
namespace
TMX {
39
class
TMXMap;
40
}
41
42
// This is the grid of pathfinding nodes that is formed for the level (SZ)
43
class
PathfindingGrid
{
44
friend
class
PathfindingGraphNode
;
45
46
PathfindingGraphNode
**_nodes;
// 2D array of nodes (size is [dimensions.x][dimensions.y]
47
48
Vector2i
_dimensions;
// rows and columns of nodes.
49
Vector2f
_cellSize;
// size of a cell in width and height
50
51
// Neighbor node1 to node2.
52
void
connectNodes(
PathfindingGraphNode
*node1,
PathfindingGraphNode
*node2);
53
54
public
:
55
// these are the default graph node costs.
56
// they can be overwritten by values stored in the level's file.(SZ)
57
static
const
int
BLOCKED = -1;
58
static
const
int
OPEN = 1;
59
static
const
int
STAIRS = 5;
60
61
// These are the actual data members used to assign costs. (SZ)
62
int
_blockedCost;
63
int
_openCost;
64
int
_stairsCost;
65
66
PathfindingGrid
();
67
~
PathfindingGrid
();
68
69
void
reset();
70
71
void
setupNodes(
const
TMX::TMXMap
&map);
72
73
// Return the node at the given point (SZ)
74
PathfindingGraphNode
*getNodeAtPoint(
Vector2f
point);
75
// Return the node at the given coordinates (SZ)
76
PathfindingGraphNode
*getNodeAtCoords(
int
x,
int
y) {
77
return
&_nodes[x][y];
78
}
79
80
Vector2i
getDimensions() {
81
return
_dimensions;
82
}
83
84
Vector2f
getCellSize() {
85
return
_cellSize;
86
}
87
88
// Returns the nearest open node to the compare spot, starting with the given nodePos
89
// and iterating through its neighbors. (SZ)
90
PathfindingGraphNode
*getNearestOpenNode(
Vector2f
nodePos,
Vector2f
comparePos);
91
92
// Return true if two nodes share and adjacency to the same blocked node.
93
// Can be used to find corners that shouldn't be cut.
94
Common::Array<PathfindingGraphNode *>
cornerCheck(
const
PathfindingGraphNode
*node1,
const
PathfindingGraphNode
*node2);
95
};
96
97
}
// End of namespace Crab
98
99
#endif // CRAB_PATHFINDINGGRID_H
Crab::TMX::TMXMap
Definition:
TMXMap.h:47
Common::Array
Definition:
array.h:52
Crab::PathfindingGrid
Definition:
PathfindingGrid.h:43
Crab
Definition:
moveeffect.h:37
Crab::Vector2D< int >
Crab::PathfindingGraphNode
Definition:
PathfindingGraphNode.h:41
engines
crab
PathfindingGrid.h
Generated on Fri Nov 22 2024 09:13:56 for ScummVM API documentation by
1.8.13