misc cleanups

This commit is contained in:
AzaezelX 2025-04-17 10:38:36 -05:00
parent a10169accf
commit eaa6a62b0c
2 changed files with 21 additions and 20 deletions

View file

@ -398,14 +398,15 @@ void AIControllerData::resolveStuck(AIController* obj)
ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj->getAIInfo()->mObj.getPointer()); ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj->getAIInfo()->mObj.getPointer());
// Don't check for ai stuckness if animation during // Don't check for ai stuckness if animation during
// an anim-clip effect override. // an anim-clip effect override.
if (sbo->getDamageState() == ShapeBase::Enabled && !(sbo->anim_clip_flags & ShapeBase::ANIM_OVERRIDDEN) && !sbo->isAnimationLocked()) { if (sbo->getDamageState() == ShapeBase::Enabled && !(sbo->anim_clip_flags & ShapeBase::ANIM_OVERRIDDEN) && !sbo->isAnimationLocked())
{
if (obj->mMovement.mMoveStuckTestCountdown > 0) if (obj->mMovement.mMoveStuckTestCountdown > 0)
--obj->mMovement.mMoveStuckTestCountdown; --obj->mMovement.mMoveStuckTestCountdown;
else else
{ {
// We should check to see if we are stuck... // We should check to see if we are stuck...
F32 locationDelta = (obj->getAIInfo()->getPosition() - obj->getAIInfo()->mLastPos).len(); F32 locationDelta = (obj->getAIInfo()->getPosition() - obj->getAIInfo()->mLastPos).len();
if (locationDelta < mMoveStuckTolerance && (sbo->getDamageState() == ShapeBase::Enabled)) if (locationDelta < mMoveStuckTolerance)
{ {
// If we are slowing down, then it's likely that our location delta will be less than // If we are slowing down, then it's likely that our location delta will be less than
// our move stuck tolerance. Because we can be both slowing and stuck // our move stuck tolerance. Because we can be both slowing and stuck

View file

@ -115,12 +115,12 @@ void AINavigation::repath()
if (mPathData.path.isNull() || !mPathData.owned) if (mPathData.path.isNull() || !mPathData.owned)
return; return;
if (!mControllerRef->getGoal()) return; if (!getCtrl()->getGoal()) return;
// If we're following, get their position. // If we're following, get their position.
mPathData.path->mTo = mControllerRef->getGoal()->getPosition(); mPathData.path->mTo = getCtrl()->getGoal()->getPosition();
// Update from position and replan. // Update from position and replan.
mPathData.path->mFrom = mControllerRef->getAIInfo()->getPosition(); mPathData.path->mFrom = getCtrl()->getAIInfo()->getPosition();
mPathData.path->plan(); mPathData.path->plan();
// Move to first node (skip start pos). // Move to first node (skip start pos).
moveToNode(1); moveToNode(1);
@ -137,9 +137,9 @@ Point3F AINavigation::getPathDestination() const
void AINavigation::setMoveDestination(const Point3F& location, bool slowdown) void AINavigation::setMoveDestination(const Point3F& location, bool slowdown)
{ {
mMoveDestination = location; mMoveDestination = location;
mControllerRef->mMovement.mMoveState = AIController::ModeMove; getCtrl()->mMovement.mMoveState = AIController::ModeMove;
mControllerRef->mMovement.mMoveSlowdown = slowdown; getCtrl()->mMovement.mMoveSlowdown = slowdown;
mControllerRef->mMovement.mMoveStuckTestCountdown = mControllerRef->mControllerData->mMoveStuckTestDelay; getCtrl()->mMovement.mMoveStuckTestCountdown = getCtrl()->mControllerData->mMoveStuckTestDelay;
} }
void AINavigation::onReachDestination() void AINavigation::onReachDestination()
@ -184,7 +184,7 @@ bool AINavigation::setPathDestination(const Point3F& pos)
if (!mNavMesh) if (!mNavMesh)
{ {
//setMoveDestination(pos); //setMoveDestination(pos);
mControllerRef->throwCallback("onPathFailed"); getCtrl()->throwCallback("onPathFailed");
return false; return false;
} }
@ -192,11 +192,11 @@ bool AINavigation::setPathDestination(const Point3F& pos)
NavPath* path = new NavPath(); NavPath* path = new NavPath();
path->mMesh = mNavMesh; path->mMesh = mNavMesh;
path->mFrom = mControllerRef->getAIInfo()->getPosition(); path->mFrom = getCtrl()->getAIInfo()->getPosition();
path->mTo = pos; path->mTo = pos;
path->mFromSet = path->mToSet = true; path->mFromSet = path->mToSet = true;
path->mAlwaysRender = true; path->mAlwaysRender = true;
path->mLinkTypes = mControllerRef->mControllerData->mLinkTypes; path->mLinkTypes = getCtrl()->mControllerData->mLinkTypes;
path->mXray = true; path->mXray = true;
// Paths plan automatically upon being registered. // Paths plan automatically upon being registered.
if (!path->registerObject()) if (!path->registerObject())
@ -209,14 +209,14 @@ bool AINavigation::setPathDestination(const Point3F& pos)
{ {
// Clear any current path we might have. // Clear any current path we might have.
clearPath(); clearPath();
mControllerRef->clearCover(); getCtrl()->clearCover();
clearFollow(); clearFollow();
// Store new path. // Store new path.
mPathData.path = path; mPathData.path = path;
mPathData.owned = true; mPathData.owned = true;
// Skip node 0, which we are currently standing on. // Skip node 0, which we are currently standing on.
moveToNode(1); moveToNode(1);
mControllerRef->throwCallback("onPathSuccess"); getCtrl()->throwCallback("onPathSuccess");
return true; return true;
} }
else else
@ -224,7 +224,7 @@ bool AINavigation::setPathDestination(const Point3F& pos)
// Just move normally if we can't path. // Just move normally if we can't path.
//setMoveDestination(pos, true); //setMoveDestination(pos, true);
//return; //return;
mControllerRef->throwCallback("onPathFailed"); getCtrl()->throwCallback("onPathFailed");
path->deleteObject(); path->deleteObject();
return false; return false;
} }
@ -232,31 +232,31 @@ bool AINavigation::setPathDestination(const Point3F& pos)
void AINavigation::followObject() void AINavigation::followObject()
{ {
if ((mControllerRef->getGoal()->mLastPos - mControllerRef->getAIInfo()->getPosition()).len() < mControllerRef->mControllerData->mMoveTolerance) if (getCtrl()->getGoal()->getDist() < getCtrl()->mControllerData->mMoveTolerance)
return; return;
if (setPathDestination(mControllerRef->getGoal()->getPosition())) if (setPathDestination(getCtrl()->getGoal()->getPosition()))
{ {
mControllerRef->clearCover(); getCtrl()->clearCover();
} }
} }
void AINavigation::followObject(SceneObject* obj, F32 radius) void AINavigation::followObject(SceneObject* obj, F32 radius)
{ {
mControllerRef->setGoal(obj, radius); getCtrl()->setGoal(obj, radius);
followObject(); followObject();
} }
void AINavigation::clearFollow() void AINavigation::clearFollow()
{ {
mControllerRef->clearGoal(); getCtrl()->clearGoal();
} }
void AINavigation::followNavPath(NavPath* path) void AINavigation::followNavPath(NavPath* path)
{ {
// Get rid of our current path. // Get rid of our current path.
clearPath(); clearPath();
mControllerRef->clearCover(); getCtrl()->clearCover();
clearFollow(); clearFollow();
// Follow new path. // Follow new path.