From 70516badb3af376ff35f7c2d85b0e8c3b35a6d58 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 18 Jul 2019 20:39:32 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 47 +++++--------------------------------- server/gameserver/human.h | 1 - 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index b9d4122..8cc5101 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -269,41 +269,6 @@ void Human::RecalcSelfCollider() self_collider_->rad = meta->i->radius(); } -bool Human::IsCollision() -{ - if (room->OverBorder(pos, meta->i->radius())){ - return true; - } - - std::vector objects; - for (auto& grid : grid_list) { - for (Entity* entity : grid->entity_list) { - switch (entity->entity_type) { - case ET_Obstacle: - { - if (TestCollision(entity)){ - objects.push_back(entity); - } - } - break; - case ET_Building: - { - if (TestCollision(entity)) { - objects.push_back(entity); - } - } - break; - default: - { - - } - break; - } - } - } - return !objects.empty(); -} - bool Human::IsCollisionInMapService() { if (room->OverBorder(pos, meta->i->radius())){ @@ -341,34 +306,34 @@ void Human::FindPath() if (std::abs(up_dot) <= 0.001f) { //相互垂直 //向上 pos = old_pos + a8::Vec2::UP; - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } else { //向下 pos = old_pos + a8::Vec2::DOWN; - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } } } else if (up_dot > 0.001f) { //基本相同 pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT); - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } else { //向上 pos = old_pos + a8::Vec2::UP; - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } } } else if (up_dot < 0.001f) { //基本相反 pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT); - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } else { //向下 pos = old_pos + a8::Vec2::DOWN; - if (!IsCollision()) { + if (!IsCollisionInMapService()) { return; } } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index efd3073..40e851f 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -135,7 +135,6 @@ class Human : public Entity void Shot(); void DirectShot(MetaData::Equip* bullet_meta, int skill_id); void RecalcSelfCollider(); - bool IsCollision(); bool IsCollisionInMapService(); void FindPath(); void FindPathInMapService();