-
Notifications
You must be signed in to change notification settings - Fork 0
AquilaMain
This is the main class that runs the pathfinding system. This contains all of the nodes and connections that are part of the system; you should be able to instantiate as many as you want at a single time.
For information about the nodes in the network, see AquilaNode.
Constructor
Create a pathfinding network. No other initial setup is needed.
Returns: AquilaNode
Parameter | Type | Description |
---|---|---|
data | * | Data to attach to each node |
Create a node in the network. data
may be whatever you want - a string, or a GameMaker instance, or a struct, or something else - but in order for this to be useful it should probably be something which is meaningful to the game, such as an instance representing a waypoint on a map. The new AquilaNode is returned.
Nodes must both be part of the network in order to have operations performed on them; these functions will show an error in the console otherwise.
Returns: N/A
Parameter | Type | Description |
---|---|---|
node | AquilaNode | The node to remove from the network |
Removes an existing AquilaNode from the network. It will no longer be used for pathfinding.
Returns: N/A
Removes every node from the network. (References to existing nodes will still exist, but will not be very useful anymore.)
Returns: N/A
Parameter | Type | Description |
---|---|---|
a | AquilaNode | The first node of the connection you want to create |
b | AquilaNode | The second node of the connection you want to create |
cost | number | The cost of the connection between the two nodes (optional, defaults to 1) |
bidirectional | boolean | Whether the connection should be one-way (a has a connection to b , but b does not have a connection to a ) or two-way |
Connect two nodes in the network. The nodes must belong to the same network. Node connections with a higher cost will be given low priority by the pathfinding algorithm in favor of connections with a lower cost. A bidirectional connection will create a connection between both nodes, whereas setting that argument to false will only create a connection from the first node to the second. You can think of it as a one-way road in a city.
Returns: N/A
Parameter | Type | Description |
---|---|---|
a | AquilaNode | The first node of the connection you want to break |
b | AquilaNode | The second node of the connection you want to break |
Breaks the connection between two nodes.
Returns: integer
Returns the number of nodes in a network.
Returns: array of AquilaNode
Returns an array of every node in the network.
Returns: { route, stops, total_cost } or undefined
Parameter | Type | Description |
---|---|---|
source | AquilaNode | The node in the network you would like to start navigating from |
destination | AquilaNode | The node in the network you would like to navigate to |
Navigate from one node in the network to another. Both nodes must be part of the same network. The route with the lowest total cost will be returned if a route exists; if no route between the two nodes exists, it will return undefined
instead.
Non-undefined return values will be a struct containing several values:
-
route
is an array containing nodes in the graph; see AquilaNode for information on what they contain -
stops
is the number of nodes in the path, equivalent toarray_length(route)
-
total_cost
is the total cost of the route, equal to the sum of the costs between each node in theroute
array