1
This commit is contained in:
parent
d820668b49
commit
8f2bfd1a15
@ -17,43 +17,18 @@ MoveHelper::MoveHelper(Creature* owner)
|
||||
|
||||
bool MoveHelper::GetMovePosition(glm::vec3& out_pos)
|
||||
{
|
||||
// 999
|
||||
#if 1
|
||||
#else
|
||||
Creature* c = owner_;
|
||||
if (path_index_ < paths_.size()) {
|
||||
a8::Vec2 src_pos;
|
||||
a8::Vec2 tar_pos;
|
||||
a8::Vec2 curr_pos;
|
||||
a8::Vec2 dir;
|
||||
|
||||
auto& point = paths_[path_index_];
|
||||
src_pos.x = point.src_pos.x;
|
||||
src_pos.y = point.src_pos.z;
|
||||
|
||||
curr_pos.x = point.curr_pos.x;
|
||||
curr_pos.y = point.curr_pos.z;
|
||||
|
||||
tar_pos.x = point.tar_pos.x;
|
||||
tar_pos.y = point.tar_pos.z;
|
||||
|
||||
dir.x = point.dir.x;
|
||||
dir.y = point.dir.z;
|
||||
|
||||
curr_pos = (curr_pos + dir * owner_->GetSpeed() * 1);
|
||||
point.curr_pos.x = curr_pos.x;
|
||||
point.curr_pos.z = curr_pos.y;
|
||||
owner_->SetPos(curr_pos);
|
||||
if (owner_->GetPos().Distance(src_pos) - point.distance >= 0.0001f) {
|
||||
owner_->SetPos(tar_pos);
|
||||
if (path_index_ >= paths_.size()) {
|
||||
ClearPath();
|
||||
return false;
|
||||
}
|
||||
MovePathPoint& curr_point = paths_[path_index_];
|
||||
owner_->SetPos(curr_point.curr_pos);
|
||||
if (owner_->GetPos().Distance2D2(curr_point.src_pos) - curr_point.distance >= 0.0001f) {
|
||||
owner_->SetPos(curr_point.tar_pos);
|
||||
++path_index_;
|
||||
if (path_index_ < paths_.size()) {
|
||||
auto& next_point = paths_[path_index_];
|
||||
|
||||
a8::Vec2 v2;
|
||||
v2.x = next_point.tar_pos.x;
|
||||
v2.y = next_point.tar_pos.z;
|
||||
a8::Vec2 dir = (v2 - owner_->GetPos());
|
||||
MovePathPoint& next_point = paths_[path_index_];
|
||||
a8::Vec2 dir = owner_->GetPos().CalcDir2D(next_point.tar_pos);
|
||||
dir.Normalize();
|
||||
next_point.dir.x = dir.x;
|
||||
next_point.dir.z = dir.y;
|
||||
@ -64,11 +39,6 @@ bool MoveHelper::GetMovePosition(glm::vec3& out_pos)
|
||||
abort();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
ClearPath();
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void MoveHelper::CalcTargetPos(float distance)
|
||||
|
Loading…
x
Reference in New Issue
Block a user