1
This commit is contained in:
parent
a8e99b62d5
commit
2b3dcd723e
@ -44,7 +44,9 @@ bool Movement::UpdatePosition()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if 0
|
||||||
curr_point.tar_pos.SetY(curr_point.curr_pos.GetY());
|
curr_point.tar_pos.SetY(curr_point.curr_pos.GetY());
|
||||||
|
#endif
|
||||||
owner_->SetPos(curr_point.tar_pos);
|
owner_->SetPos(curr_point.tar_pos);
|
||||||
++path_index_;
|
++path_index_;
|
||||||
if (path_index_ < paths_.size()) {
|
if (path_index_ < paths_.size()) {
|
||||||
@ -245,5 +247,22 @@ bool Movement::FindPath(const glm::vec3& target_pos, float distance)
|
|||||||
owner_->SetAttackDir(paths_.at(0).dir);
|
owner_->SetAttackDir(paths_.at(0).dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AdjustLastPath(distance);
|
||||||
return !paths_.empty();
|
return !paths_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Movement::AdjustLastPath(float distance)
|
||||||
|
{
|
||||||
|
if (paths_.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (distance < 0.01f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MovePathPoint& point = paths_.at(paths_.size() - 1);
|
||||||
|
if (point.distance + 3 < distance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
point.distance -= distance;
|
||||||
|
point.tar_pos.FromGlmVec3(point.src_pos.ToGlmVec3() + point.dir * point.distance);
|
||||||
|
}
|
||||||
|
@ -29,6 +29,9 @@ class Movement
|
|||||||
bool IsFindPath() { return is_find_path_; }
|
bool IsFindPath() { return is_find_path_; }
|
||||||
bool FindPath(const glm::vec3& target_pos, float distance);
|
bool FindPath(const glm::vec3& target_pos, float distance);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void AdjustLastPath(float distance);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<MovePathPoint> paths_;
|
std::vector<MovePathPoint> paths_;
|
||||||
int path_index_ = 0;
|
int path_index_ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user