From aed9564e82376dda87b1ff5c0e186c1364a45f4e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 23 Sep 2019 16:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 110 ------------------------------------- server/gameserver/human.h | 2 - 2 files changed, 112 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 0e132b4..1c87284 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -372,71 +372,6 @@ void Human::RecalcSelfCollider() } } -bool Human::IsCollision() -{ - if (room->OverBorder(pos, meta->i->radius())){ - return true; - } - - if (a8::HasBitFlag(status, HS_Jump)) { - return false; - } - - std::vector objects; - for (auto& grid : grid_list) { - for (Entity* entity : grid->entity_list) { - switch (entity->entity_type) { - case ET_Obstacle: - { - if ( - (last_collision_door == nullptr || last_collision_door != entity) && - TestCollision(entity) - ){ - Obstacle* obstacle = (Obstacle*)entity; - if (!obstacle->dead && - obstacle->meta->i->attack_type() == 1 && - obstacle->meta->i->drop() != 0 && - room->gas_data.gas_mode != GasInactive && - !a8::HasBitFlag(status, HS_Fly) && - !a8::HasBitFlag(status, HS_Jump) - ) { - obstacle->health = 0; - obstacle->dead = obstacle->health <= 0.01f; - obstacle->dead_frameno = room->frame_no; - if (obstacle->dead) { - #if 0 - if (obstacle->meta->i->damage_dia() > 0.01f && - obstacle->meta->i->damage() > 0.01f) { - obstacle->Explosion(this); - } - #endif - room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop()); - } - obstacle->BroadcastFullState(); - } else { - 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())){ @@ -500,51 +435,6 @@ bool Human::IsCollisionInMapService() return false; } -void Human::FindPath() -{ - a8::Vec2 old_pos = pos; - { - float up_dot = a8::Vec2::UP.Dot(move_dir); - bool at_left_side = a8::Vec2::LEFT.Dot(move_dir) > 0.0001f; - if (std::abs(up_dot) <= 0.001f) { //相互垂直 - //向上 - pos = old_pos + a8::Vec2::UP; - if (!IsCollision()) { - return; - } else { - //向下 - pos = old_pos + a8::Vec2::DOWN; - if (!IsCollision()) { - return; - } - } - } else if (up_dot > 0.001f) { //基本相同 - pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT); - if (!IsCollision()) { - return; - } else { - //向上 - pos = old_pos + a8::Vec2::UP; - if (!IsCollision()) { - return; - } - } - } else if (up_dot < 0.001f) { //基本相反 - pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT); - if (!IsCollision()) { - return; - } else { - //向下 - pos = old_pos + a8::Vec2::DOWN; - if (!IsCollision()) { - return; - } - } - } - } - pos = old_pos; -} - void Human::FindPathInMapService() { a8::Vec2 old_pos = pos; diff --git a/server/gameserver/human.h b/server/gameserver/human.h index e7c0995..dd3750a 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -142,9 +142,7 @@ class Human : public Entity void Shot(a8::Vec2& target_dir); void TankShot(a8::Vec2& target_dir); void RecalcSelfCollider(); - bool IsCollision(); bool IsCollisionInMapService(); - void FindPath(); void FindPathInMapService(); float GetRadius(); float GetMaxHP();