移动优化
This commit is contained in:
parent
d0db4e8aff
commit
9dc884d02d
@ -1860,7 +1860,7 @@ bool Human::InWalkZone()
|
||||
if (pos.y + meta->i->radius() > walk_zone_center.y + walk_zone->_max.y - delta) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Human::ClearWalkZone()
|
||||
@ -1884,6 +1884,8 @@ void Human::UpdateMoveInWalkZone(int speed)
|
||||
} else {
|
||||
ClearWalkZone();
|
||||
pos = old_pos;
|
||||
movement->RayDetection();
|
||||
App::Instance()->perf.params[5]++;
|
||||
UpdateMoveInMap(speed - i);
|
||||
return;
|
||||
}
|
||||
@ -1896,11 +1898,17 @@ void Human::UpdateMoveInMap(int speed)
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (IsCollision()) {
|
||||
if (movement->TestCollision()) {
|
||||
pos = old_pos;
|
||||
GenerateWalkZone();
|
||||
UpdateMoveInWalkZone(speed - i);
|
||||
return;
|
||||
} else {
|
||||
movement->passed_distance += 1;
|
||||
if (movement->passed_distance + 10 > movement->target_distance) {
|
||||
movement->RayDetection();
|
||||
App::Instance()->perf.params[5]++;
|
||||
}
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
|
@ -122,51 +122,6 @@ void Player::UpdateMove()
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
int speed = std::max(1, (int)GetSpeed());
|
||||
#ifdef RAY_DETECTION
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (movement->TestCollision()) {
|
||||
App::Instance()->perf.params[0]++;
|
||||
pos = old_pos;
|
||||
FindPath();
|
||||
movement->RayDetection();
|
||||
if (rand() % 3 == 0) {
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
movement->passed_distance += 1;
|
||||
if (movement->passed_distance + 10 > movement->target_distance) {
|
||||
movement->RayDetection();
|
||||
App::Instance()->perf.params[5]++;
|
||||
}
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (IsCollision()) {
|
||||
pos = old_pos;
|
||||
#if 1
|
||||
FindPath();
|
||||
if (rand() % 3 == 0) {
|
||||
i += 1;
|
||||
}
|
||||
#else
|
||||
if (i == 0) {
|
||||
FindPath();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (in_walk_zone) {
|
||||
UpdateMoveInWalkZone(std::max(1, (int)GetSpeed()));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user