This commit is contained in:
Brian Roberts 2026-01-18 23:51:38 +00:00 committed by GitHub
commit d0232de88b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 1 deletions

View file

@ -180,6 +180,11 @@ bool AIController::getAIMove(Move* movePtr)
if (obj->getContainer()->castRay(start, end, StaticShapeObjectType, &info))
{
getNav()->repath();
mMovement.mInAir = false;
}
else
{
mMovement.mInAir = true;
}
obj->enableCollision();
getGoal()->mInRange = false;
@ -307,6 +312,13 @@ void AIController::Movement::onStuck()
#endif
}
bool AIController::Movement::isInWater()
{
ShapeBase* sbo = dynamic_cast<ShapeBase*>(getCtrl()->getAIInfo()->mObj.getPointer());
if (!sbo) return false;
return sbo->getWaterCoverage() > 0.0f;
}
DefineEngineMethod(AIController, setMoveSpeed, void, (F32 speed), ,
"@brief Sets the move speed for an AI object.\n\n"
@ -335,6 +347,23 @@ DefineEngineMethod(AIController, stop, void, (), ,
object->mMovement.stopMove();
}
DefineEngineMethod(AIController, isStopped, bool, (), ,
"@brief is the player moving?.\n\n")
{
return object->mMovement.isStopped();
}
DefineEngineMethod(AIController, isInAir, bool, (), ,
"@brief is the player moving?.\n\n")
{
return object->mMovement.isInAir();
}
DefineEngineMethod(AIController, isInWater, bool, (), ,
"@brief is the player in water?.\n\n")
{
return object->mMovement.isInWater();
}
/**
* Set the state of a movement trigger.

View file

@ -85,10 +85,11 @@ public:
AIController* mControllerRef;
AIController* getCtrl() { return mControllerRef; };
MoveState mMoveState;
bool mInAir = false;
F32 mMoveSpeed = 1.0;
void setMoveSpeed(F32 speed) { mMoveSpeed = speed; };
F32 getMoveSpeed() { return mMoveSpeed; };
bool mMoveSlowdown; // Slowdown as we near the destination
bool mMoveSlowdown = false; // Slowdown as we near the destination
Point3F mLastLocation; // For stuck check
S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck
Point3F mAimLocation;
@ -96,6 +97,9 @@ public:
bool mMoveTriggers[MaxTriggerKeys];
void stopMove();
void onStuck();
bool isStopped() { return mMoveState == ModeStop; };
bool isInAir() { return mInAir; };
bool isInWater();
} mMovement;
struct TriggerState