This commit is contained in:
aozhiwei 2019-06-10 17:16:09 +08:00
parent 1d405bd088
commit 6ad0a30010
2 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,8 @@ void MovementComponent::RayDetection()
} else if (owner->entity_type == ET_Player) {
Human* hum = (Human*)owner;
start_point = hum->pos;
target_point = hum->pos + hum->move_dir * (MAP_CELL_WIDTH - 64);
target_distance = (target_point - start_point).Norm();
{
Vector2D left_dir = hum->move_dir;
left_dir.Rotate(-90);

View File

@ -727,11 +727,15 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
if (std::abs(msg.move_dir().x()) > FLT_EPSILON ||
std::abs(msg.move_dir().y()) > FLT_EPSILON
) {
Vector2D old_move_dir;
move_dir.FromPB(&msg.move_dir());
move_dir.Normalize();
moving = true;
#ifdef RAY_DETECTION
movement->RayDetection();
if (std::abs(move_dir.x - old_move_dir.x) > 0.00001f ||
std::abs(move_dir.y - old_move_dir.y) > 0.00001f) {
movement->RayDetection();
}
#endif
}
}