Improved pathfinding logic

This commit is contained in:
Vladislav Khorev committed 2026-05-21 11:48:18 +03:00
1 parent 2659951d8e
commit 3a73f3fbde
36 files changed
+458337 -871

No files matched your search

+14
View File
@@ -61,6 +61,10 @@ public:
const Eigen::Vector3f& getRequestedWalkTarget() const { return requestedWalkTarget; }
Eigen::Vector3f getCurrentNavigationTarget() const;
void forceReplan();
// Cancels any active walk target and clears waypoints so the character
// stays at its current position. Used when an external push moves the
// character and we don't want it to walk back to where it was.
void stopInPlace();
// attackDirection is a world-space horizontal vector pointing from the
@@ -110,6 +114,13 @@ public:
float hp = 200.f;
float initialHp = 200.f;
// The position the NPC should return to if pushed too far away.
// Initialised to the spawn position; updated whenever a script walk command is issued.
Eigen::Vector3f homePosition = Eigen::Vector3f::Zero();
// Maximum allowed drift from homePosition before a return walk is triggered (metres).
// Set to 0 to disable drift recovery for this character.
float maxHomeDrift = 3.0f;
int battle_state = 0;
bool resetAnim = false;
@@ -163,6 +174,9 @@ private:
static constexpr float WALK_THRESHOLD = 0.05f;
static constexpr float TARGET_REPLAN_THRESHOLD = 0.25f;
static constexpr float HOME_DRIFT_CHECK_INTERVAL = 5.0f;
float homeDriftCheckTimer = HOME_DRIFT_CHECK_INTERVAL;
// Returns the animation state to actually play/draw, falling back to IDLE
// if the requested state has no loaded animation.