Adapt for web, make CharacterState class

This commit is contained in:
Vladislav Khorev committed 2026-06-18 20:02:59 +03:00
1 parent c891161d69
commit 0eb9d0be25
88 files changed
+810 -102277

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#include "CharacterState.h"
namespace ZL {
bool CharacterState::isMoving() const {
Eigen::Vector3f toTarget = walkTarget - position;
toTarget.y() = 0.f;
return !pathWaypoints.empty() || toTarget.norm() > kWalkThreshold;
}
Eigen::Vector3f CharacterState::getCurrentNavigationTarget() const {
if (!pathWaypoints.empty() && currentWaypointIndex < pathWaypoints.size()) {
return pathWaypoints[currentWaypointIndex];
}
return walkTarget;
}
void CharacterState::stopInPlace() {
walkTarget = Eigen::Vector3f(position.x(), 0.f, position.z());
requestedWalkTarget = walkTarget;
pathWaypoints.clear();
currentWaypointIndex = 0;
onArrivedCallback = nullptr;
}
void CharacterState::setHp(float newHp) {
hp = newHp;
if (hp < 0.f) hp = 0.f;
if (onHpChanged) onHpChanged(hp, initialHp);
}
} // namespace ZL