mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
setaicontroller: use Ids
get rid of duplicated mMoveDestination
This commit is contained in:
parent
201b7bf695
commit
2fe36a571b
|
|
@ -117,7 +117,7 @@ bool AIController::getAIMove(Move* movePtr)
|
|||
if (getAim()->mObj || getAim()->mPosSet)
|
||||
mMovement.mAimLocation = getAim()->getPosition();
|
||||
else
|
||||
mMovement.mAimLocation = mMovement.mMoveDestination;
|
||||
mMovement.mAimLocation = getNav()->mMoveDestination;
|
||||
|
||||
mControllerData->resolveYaw(this, location, movePtr);
|
||||
mControllerData->resolvePitch(this, location, movePtr);
|
||||
|
|
@ -232,8 +232,8 @@ void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* m
|
|||
// Move towards the destination
|
||||
if (obj->mMovement.mMoveState != AIController::ModeStop)
|
||||
{
|
||||
F32 xDiff = obj->mMovement.mMoveDestination.x - location.x;
|
||||
F32 yDiff = obj->mMovement.mMoveDestination.y - location.y;
|
||||
F32 xDiff = obj->getNav()->mMoveDestination.x - location.x;
|
||||
F32 yDiff = obj->getNav()->mMoveDestination.y - location.y;
|
||||
Point3F rotation = obj->getAIInfo()->mObj->getTransform().getForwardVector();
|
||||
|
||||
// Check if we should mMove, or if we are 'close enough'
|
||||
|
|
@ -246,22 +246,22 @@ void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* m
|
|||
{
|
||||
// Build move direction in world space
|
||||
if (mIsZero(xDiff))
|
||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
else
|
||||
if (mIsZero(yDiff))
|
||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
else
|
||||
if (mFabs(xDiff) > mFabs(yDiff))
|
||||
{
|
||||
F32 value = mFabs(yDiff / xDiff);
|
||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -value : value;
|
||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -value : value;
|
||||
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
F32 value = mFabs(xDiff / yDiff);
|
||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -value : value;
|
||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -value : value;
|
||||
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
}
|
||||
|
||||
// Rotate the move into object space (this really only needs
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ public:
|
|||
Point3F mLastLocation; // For stuck check
|
||||
S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck
|
||||
Point3F mAimLocation;
|
||||
Point3F mMoveDestination;
|
||||
// move triggers
|
||||
bool mMoveTriggers[MaxTriggerKeys];
|
||||
void stopMove();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
AINavigation::AINavigation(AIController* controller)
|
||||
{
|
||||
mControllerRef = controller;
|
||||
mJump = None;
|
||||
}
|
||||
|
||||
NavMesh* AINavigation::findNavMesh() const
|
||||
|
|
|
|||
|
|
@ -2259,7 +2259,7 @@ void Player::advanceTime(F32 dt)
|
|||
}
|
||||
}
|
||||
|
||||
bool Player::setAIController(const char* controller)
|
||||
bool Player::setAIController(S32 controller)
|
||||
{
|
||||
if (Sim::findObject(controller, mAIController))
|
||||
{
|
||||
|
|
@ -2271,7 +2271,7 @@ bool Player::setAIController(const char* controller)
|
|||
return false;
|
||||
}
|
||||
|
||||
DefineEngineMethod(Player, setAIController, bool, (const char* controller), , "")
|
||||
DefineEngineMethod(Player, setAIController, bool, (S32 controller), , "")
|
||||
{
|
||||
return object->setAIController(controller);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ public:
|
|||
void setMomentum(const Point3F &momentum) override;
|
||||
bool displaceObject(const Point3F& displaceVector) override;
|
||||
virtual bool getAIMove(Move*);
|
||||
bool setAIController(const char* controller);
|
||||
bool setAIController(S32 controller);
|
||||
AIController* getAIController() { return mAIController; };
|
||||
|
||||
bool checkDismountPosition(const MatrixF& oldPos, const MatrixF& newPos); ///< Is it safe to dismount here?
|
||||
|
|
|
|||
Loading…
Reference in a new issue