Working on stuff
This commit is contained in:
1 parent
17d903fd52
commit
07f45ad1e1
11 files changed
+176
-70
No files matched your search
+7
-3
@@ -109,7 +109,7 @@ std::unique_ptr<Character> Character::createFromState(CharacterState st, Rendere
|
||||
return c;
|
||||
}
|
||||
|
||||
void Character::setTarget(const Eigen::Vector3f& target, std::function<void()> onArrived) {
|
||||
void Character::setTarget(const Eigen::Vector3f& target, std::function<void()> onArrived, std::string callbackName) {
|
||||
Eigen::Vector3f normalizedTarget(target.x(), 0.f, target.z());
|
||||
|
||||
const bool sameRequestedTarget =
|
||||
@@ -123,8 +123,9 @@ void Character::setTarget(const Eigen::Vector3f& target, std::function<void()> o
|
||||
return;
|
||||
}
|
||||
|
||||
state.requestedWalkTarget = normalizedTarget;
|
||||
state.onArrivedCallback = std::move(onArrived);
|
||||
state.requestedWalkTarget = normalizedTarget;
|
||||
state.onArrivedCallback = std::move(onArrived);
|
||||
state.onArrivedCallbackName = std::move(callbackName);
|
||||
|
||||
if (pathPlanner) {
|
||||
state.pathWaypoints = pathPlanner(state.position, normalizedTarget);
|
||||
@@ -140,6 +141,7 @@ void Character::setTarget(const Eigen::Vector3f& target, std::function<void()> o
|
||||
|
||||
state.walkTarget = Eigen::Vector3f(state.position.x(), 0.f, state.position.z());
|
||||
state.onArrivedCallback = nullptr;
|
||||
state.onArrivedCallbackName.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,6 +180,7 @@ void Character::forceReplan() {
|
||||
|
||||
state.walkTarget = Eigen::Vector3f(state.position.x(), 0.f, state.position.z());
|
||||
state.onArrivedCallback = nullptr;
|
||||
state.onArrivedCallbackName.clear();
|
||||
}
|
||||
|
||||
void Character::setTexture(std::shared_ptr<ZL::Texture> texture) {
|
||||
@@ -294,6 +297,7 @@ void Character::update(int64_t deltaMs, const CharacterResolver& resolver) {
|
||||
if (!hasNextWaypoint && state.onArrivedCallback) {
|
||||
auto cb = std::move(state.onArrivedCallback);
|
||||
state.onArrivedCallback = nullptr;
|
||||
state.onArrivedCallbackName.clear();
|
||||
cb();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user