protected override void ReturnPath () {
if (error) {
// Call all callbacks
if (callbacks != null) {
for (int i = 0; i < callbacks.Length; i++)
if (callbacks[i] != null) callbacks[i] (this);
}
if (callback != null) callback(this);
return;
}
bool anySucceded = false;
// Set the end point to the start point
// since the path is reversed
// (the start point will be set individually for each path)
if (inverted) {
endPoint = startPoint;
endNode = startNode;
originalEndPoint = originalStartPoint;
}
for (int i = 0; i < nodePaths.Length; i++) {
if (nodePaths[i] != null) {
// Note that we use the lowercase 'completeState' here.
// The property (CompleteState) will ensure that the complete state is never
// changed away from the error state but in this case we don't want that behaviour.
completeState = PathCompleteState.Complete;
anySucceded = true;
} else {
completeState = PathCompleteState.Error;
}
if (callbacks != null && callbacks[i] != null) {
SetPathParametersForReturn(i);
callbacks[i] (this);
// In case a modifier changed the vectorPath, update the array of all vectorPaths
vectorPaths[i] = vectorPath;
}
}
if (anySucceded) {
completeState = PathCompleteState.Complete;
SetPathParametersForReturn(chosenTarget);
} else {
completeState = PathCompleteState.Error;
}
if (callback != null) {
callback(this);
}
}