Adapt for web, make CharacterState class
This commit is contained in:
1 parent
c891161d69
commit
0eb9d0be25
88 files changed
+810
-102277
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user