navigation: setPathdestination now takes a replace bool to preserve the goal

also killed a few now extraneous  clearfollow calls
This commit is contained in:
AzaezelX 2025-04-17 17:51:31 -05:00
parent c72c3068f8
commit f84bf058c9
3 changed files with 6 additions and 9 deletions

View file

@ -174,15 +174,14 @@ void AINavigation::onReachDestination()
}
}
bool AINavigation::setPathDestination(const Point3F& pos)
bool AINavigation::setPathDestination(const Point3F& pos, bool replace)
{
AIGoal* curgoal = getCtrl()->getGoal();
if (!curgoal || !curgoal->mObj.isValid())
if (replace)
getCtrl()->setGoal(pos, getCtrl()->mControllerData->mMoveTolerance);
if (!mNavMesh)
updateNavMesh();
// If we can't find a mesh, just move regularly.
if (!mNavMesh)
{
@ -213,7 +212,6 @@ bool AINavigation::setPathDestination(const Point3F& pos)
// Clear any current path we might have.
clearPath();
getCtrl()->clearCover();
clearFollow();
// Store new path.
mPathData.path = path;
mPathData.owned = true;
@ -260,7 +258,6 @@ void AINavigation::followNavPath(NavPath* path)
// Get rid of our current path.
clearPath();
getCtrl()->clearCover();
clearFollow();
// Follow new path.
mPathData.path = path;
@ -316,7 +313,7 @@ DefineEngineMethod(AIController, setPathDestination, bool, (Point3F goal), ,
"@see getPathDestination()\n"
"@see setMoveDestination()\n")
{
return object->getNav()->setPathDestination(goal);
return object->getNav()->setPathDestination(goal,true);
}

View file

@ -82,7 +82,7 @@ struct AINavigation
/// Clear out the current path.
void clearPath();
bool setPathDestination(const Point3F& pos);
bool setPathDestination(const Point3F& pos, bool replace = false);
Point3F getPathDestination() const;
void repath();

View file

@ -418,7 +418,7 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
if (po->getAIController())
{
if (po->getAIController()->mControllerData)
po->getAIController()->getNav()->setPathDestination(ri.point);
po->getAIController()->getNav()->setPathDestination(ri.point,true);
}
}
}