/// Once called the <see cref="Destroyed"/> property will return true and subsequent calls to this method will not do anything.
///
/// Note: Assumes the current active AstarPath instance is the same one that created this node.
///
/// Warning: Should only be called by graph classes on their own nodes
/// </summary>
publicvoidDestroy(){
if(Destroyed)return;
ClearConnections(true);
if(AstarPath.active!=null){
AstarPath.active.DestroyNode(this);
}
NodeIndex=DestroyedNodeIndex;
}
publicboolDestroyed{
[IgnoredByDeepProfiler]
get{
returnNodeIndex==DestroyedNodeIndex;
}
}
// If anyone creates more than about 200 million nodes then things will not go so well, however at that point one will certainly have more pressing problems, such as having run out of RAM
/// You must call this method if you change the connectivity or walkability of the node without going through the high level methods
/// such as the <see cref="Walkable"/> property or the <see cref="Connect"/> method. For example if your manually change the <see cref="Pathfinding.MeshNode.connections"/> array you need to call this method.
/// You can add all connected nodes to a list like this
/// <code>
/// var connections = new List<GraphNode>();
/// node.GetConnections(connections.Add);
/// </code>
/// </summary>
/// <param name="action">The delegate which will be called once for every connection.</param>
/// <param name="connectionFilter">A bitmask of which connection types will be included. You may pass any combination of \reflink{Connection.OutgoingConnection} and \reflink{Connection.IncomingConnection}.
/// Defaults to only outgoing connections. Unless one-way links are added to a graph, all connections will typically be bidirectional.</param>
/// You can add all connected nodes to a list like this
/// <code>
/// var connections = new List<GraphNode>();
/// node.GetConnections(connections.Add);
/// </code>
/// </summary>
/// <param name="action">The delegate which will be called once for every connection.
/// The first parameter to the delegate is the connection and the second parameter is the custom data passed to this method.</param>
/// <param name="data">Custom data which will be passed to the delegate.</param>
/// <param name="connectionFilter">A bitmask of which connection types will be included. A connection can either be incoming, outgoing, or both (bidirectional). You may pass any combination of \reflink{Connection.OutgoingConnection} and \reflink{Connection.IncomingConnection}.
/// Defaults to only outgoing connections. Unless one-way links are added to a graph, all connections will typically be bidirectional.</param>
/// If the nodes already have a connection to each other, that connection will be updated with the new cost.
///
/// Note that some graphs have a special representation for some connections which is more efficient.
/// For example grid graphs can represent connections to its 8 neighbours more efficiently.
/// But to use that efficient representation you'll need to call <see cref="GridNode.SetConnectionInternal"/> instead of this method.
///
/// This is different from an off-mesh link. An off-mesh link contains more metadata about the connection and is in many cases preferable to use instead of this method.
/// This is a much lower-level method which is used by off-mesh links internally.
///
/// Movement scripts such as the <see cref="RichAI"/> or <see cref="FollowerEntity"/> may get confused if they try to follow a connection made using this method
/// as it does not contain any information about how to traverse the connection.
///
/// Internally, both nodes keep track of the connection to the other node, even for a one-way connection.
/// This is done to make sure the connection can always be removed later on, if for example one of the nodes is destroyed.
///
/// <code>
/// // Connect two nodes
/// var node1 = AstarPath.active.GetNearest(transform.position, NNConstraint.None).node;
/// var node2 = AstarPath.active.GetNearest(transform.position + Vector3.right, NNConstraint.None).node;
/// var cost = (uint)(node2.position - node1.position).costMagnitude;
/// See: <see cref="AddPartialConnection"/> which is a lower level method. But if you use it, you need to handle invariants yourself.
/// </summary>
/// <param name="lhs">First node to connect.</param>
/// <param name="rhs">Second node to connect</param>
/// <param name="cost">Cost of the connection. A cost of 1000 corresponds approximately to the cost of moving one world unit. See \reflink{Int3.Precision}.</param>
/// <param name="directionality">Determines if both lhs->rhs and rhs->lhs connections will be created, or if only a connection from lhs->rhs should be created.</param>
/// Warning: In almost all cases, you should be using the <see cref="Connect"/> method instead. If you use this method, you must ensure that you preserve the required invariants of connections.
/// Notably: If a connection exists from A to B, then there must also exist a connection from B to A. And their outgoing and incoming connection flags must be set symmetrically.
///
/// Some graphs have a special representation for some connections which is more efficient.
/// For example grid graphs can represent connections to its 8 neighbours more efficiently.
/// But to use that efficient representation you'll need to call <see cref="GridNode.SetConnectionInternal"/> instead of this method.
/// Removes any connection from this node to the specified node.
/// If no such connection exists, nothing will be done.
///
/// Warning: In almost all cases, you should be using the <see cref="Disconnect"/> method instead. If you use this method, you must ensure that you preserve the required invariants of connections.
/// Notably: If a connection exists from A to B, then there must also exist a connection from B to A. And their outgoing and incoming connection flags must be set symmetrically.
/// Graphs sometimes use this method directly to improve performance in some situations.
/// Remove all connections between this node and other nodes.
///
/// Warning: If you pass false to the alsoReverse parameter, you must ensure that you preserve the required invariants of connections. See <see cref="RemovePartialConnection"/>.
/// </summary>
/// <param name="alsoReverse">if true, neighbours will be requested to remove connections to this node.</param>
/// Add a portal from this node to the specified node.
/// This function should add a portal to the left and right lists which is connecting the two nodes (this and other).
///
/// Returns: True if the call was deemed successful. False if some unknown case was encountered and no portal could be added.
/// If both calls to node1.GetPortal (node2,...) and node2.GetPortal (node1,...) return false, the funnel modifier will fall back to adding to the path
/// the positions of the node.
///
/// The default implementation simply returns false.
///
/// This function may add more than one portal if necessary.
/// Deprecated: Use GetPortal(GraphNode, out Vector3, out Vector3) instead
/// </summary>
/// <param name="other">The node which is on the other side of the portal (strictly speaking it does not actually have to be on the other side of the portal though).</param>
/// <param name="left">List of portal points on the left side of the funnel</param>
/// <param name="right">List of portal points on the right side of the funnel</param>
/// <param name="backwards">If this is true, the call was made on a node with the other node as the node before this one in the path.
/// In this case you may choose to do nothing since a similar call will be made to the other node with this node referenced as other (but then with backwards = true).
/// You do not have to care about switching the left and right lists, that is done for you already.</param>
[System.Obsolete("Use GetPortal(GraphNode, out Vector3, out Vector3) instead")]
/// Add a portal from this node to the specified node.
/// This function returns a portal which connects this node to the given adjacenet node.
///
/// Returns: True if the call was deemed successful. False if some unknown case was encountered and no portal could be added.
/// If both calls to node1.GetPortal (node2,...) and node2.GetPortal (node1,...) return false, the funnel modifier will fall back to adding to the path
/// the positions of the node.
///
/// The default implementation simply returns false.
/// Note: If you modify this array or the contents of it you must call <see cref="SetConnectivityDirty"/>.
///
/// May be null if the node has no connections.
/// </summary>
publicConnection[]connections;
/// <summary>Get a vertex of this node.</summary>
/// <param name="i">vertex index. Must be between 0 and #GetVertexCount (exclusive). Typically between 0 and 3.</param>
publicabstractInt3GetVertex(inti);
/// <summary>
/// Number of corner vertices that this node has.
/// For example for a triangle node this will return 3.
/// </summary>
publicabstractintGetVertexCount();
/// <summary>
/// Closest point on the surface of this node when seen from above.
/// This is usually very similar to <see cref="ClosestPointOnNode"/> but when the node is in a slope this can be significantly different.
/// [Open online documentation to see images]
/// When the blue point in the above image is used as an argument this method call will return the green point while the <see cref="ClosestPointOnNode"/> method will return the red point.
/// Add a connection from this node to the specified node.
///
/// If the connection already exists, the cost will simply be updated and
/// no extra connection added.
///
/// Warning: In almost all cases, you should be using the <see cref="Connect"/> method instead. If you use this method, you must ensure that you preserve the required invariants of connections.
/// Notably: If a connection exists from A to B, then there must also exist a connection from B to A. And their outgoing and incoming connection flags must be set symmetrically.
/// </summary>
/// <param name="node">Node to add a connection to</param>
/// <param name="cost">Cost of traversing the connection. A cost of 1000 corresponds approximately to the cost of moving 1 world unit.</param>
/// <param name="shapeEdgeInfo">Info about how the edge is which edge on the shape of this node to use or \reflink{Connection.NoSharedEdge} if no edge is used. See \reflink{Connection.PackShapeEdgeInfo(byte,byte,bool,bool,bool)}.</param>