1
This commit is contained in:
parent
b57ea5055c
commit
3003180710
@ -93,7 +93,6 @@ void AndroidAI::DoMove()
|
||||
if (hum->IsCollisionInMapService()) {
|
||||
hum->pos = old_pos;
|
||||
if (i == 0) {
|
||||
hum->FindPathInMapService();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -210,91 +210,6 @@ bool Human::IsCollisionInMapService()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Human::FindPathInMapService()
|
||||
{
|
||||
a8::Vec2 old_pos = pos;
|
||||
ColliderComponent* last_collider = Global::last_collider;
|
||||
if (last_collider) {
|
||||
switch (last_collider->type) {
|
||||
case CT_Aabb:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case CT_Circle:
|
||||
{
|
||||
a8::Vec2 extend_dir = pos - last_collider->owner->pos;
|
||||
if (std::abs(extend_dir.x) > FLT_EPSILON ||
|
||||
std::abs(extend_dir.y) > FLT_EPSILON) {
|
||||
extend_dir.Normalize();
|
||||
{
|
||||
#if 0
|
||||
a8::Vec2 extend_dir_inverse(extend_dir.y, extend_dir.x);
|
||||
float angle = extend_dir_inverse.CalcAngle(move_dir);
|
||||
if (angle > 0.001f) {
|
||||
extend_dir.Rotate(-1/180.0f);
|
||||
} else {
|
||||
extend_dir.Rotate(1/180.0f);
|
||||
}
|
||||
#endif
|
||||
extend_dir.Rotate(1/180.0f);
|
||||
}
|
||||
#if 0
|
||||
float distance = ((CircleCollider*)last_collider)->rad + meta->i->radius();
|
||||
pos = last_collider->owner->pos + extend_dir * (distance + 1);
|
||||
if (IsCollisionInMapService()) {
|
||||
pos = old_pos;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
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 (!IsCollisionInMapService()) {
|
||||
return;
|
||||
} else {
|
||||
//向下
|
||||
pos = old_pos + a8::Vec2::DOWN;
|
||||
if (!IsCollisionInMapService()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (up_dot > 0.001f) { //基本相同
|
||||
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
||||
if (!IsCollisionInMapService()) {
|
||||
return;
|
||||
} else {
|
||||
//向上
|
||||
pos = old_pos + a8::Vec2::UP;
|
||||
if (!IsCollisionInMapService()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (up_dot < 0.001f) { //基本相反
|
||||
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
||||
if (!IsCollisionInMapService()) {
|
||||
return;
|
||||
} else {
|
||||
//向下
|
||||
pos = old_pos + a8::Vec2::DOWN;
|
||||
if (!IsCollisionInMapService()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pos = old_pos;
|
||||
}
|
||||
|
||||
float Human::GetRadius()
|
||||
{
|
||||
#if 1
|
||||
@ -421,25 +336,6 @@ bool Human::HasLiveTeammate()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Human::FindLocation()
|
||||
{
|
||||
Entity* target = nullptr;
|
||||
for (auto& grid : grid_list) {
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
#if 0
|
||||
switch (entity->entity_type) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (target) {
|
||||
FindLocationWithTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::RefreshView()
|
||||
{
|
||||
for (auto& cell : grid_list) {
|
||||
@ -725,12 +621,6 @@ void Human::_UpdateMove(int speed)
|
||||
pos = pos + move_dir;
|
||||
if (IsCollisionInMapService()) {
|
||||
pos = old_pos;
|
||||
FindPathInMapService();
|
||||
#if 0
|
||||
if (rand() % 3 == 0) {
|
||||
i += 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
@ -847,10 +737,6 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
params->SetVal("rank_score", stats.rank_score);
|
||||
}
|
||||
|
||||
void Human::DeadDrop()
|
||||
{
|
||||
}
|
||||
|
||||
void Human::SendBattleReport()
|
||||
{
|
||||
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
||||
@ -896,71 +782,6 @@ void Human::SendBattleReport()
|
||||
delete params;
|
||||
}
|
||||
|
||||
void Human::FindLocationWithTarget(Entity* target)
|
||||
{
|
||||
a8::Vec2 old_pos = pos;
|
||||
a8::Vec2 new_pos = pos;
|
||||
AabbCollider a_collider;
|
||||
GetAabbBox(a_collider);
|
||||
AabbCollider target_collider;
|
||||
target->GetAabbBox(target_collider);
|
||||
{
|
||||
bool ret = a_collider.CalcSafePoint(&target_collider, new_pos);
|
||||
if (!ret) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
a8::Vec2 new_pos_dir = new_pos - old_pos;
|
||||
new_pos_dir.Normalize();
|
||||
float distance = (new_pos - old_pos).Norm();
|
||||
for (int i = distance; i < 10000000; i += 5) {
|
||||
pos = old_pos + new_pos_dir * i;
|
||||
room->grid_service.MoveHuman(this);
|
||||
|
||||
Entity* building = nullptr;
|
||||
std::set<GridCell*> new_grid_list;
|
||||
room->grid_service.GetAllCellsByXy(pos.x, pos.y, new_grid_list);
|
||||
for (auto& grid : new_grid_list) {
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
#if 0
|
||||
switch (entity->entity_type) {
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(entity)) {
|
||||
building = entity;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (building) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (building) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!building) {
|
||||
bool is_collision = false;
|
||||
std::set<ColliderComponent*> colliders;
|
||||
room->map_service.GetColliders(pos.x, pos.y, colliders);
|
||||
for (ColliderComponent* collider : colliders) {
|
||||
if (TestCollision(collider)) {
|
||||
is_collision = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_collision) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::OnDie()
|
||||
{
|
||||
room->OnHumanDie(this);
|
||||
|
@ -71,7 +71,6 @@ class Human : public Entity
|
||||
void FillMFTeamData(cs::MFTeamData* team_data);
|
||||
void RecalcSelfCollider();
|
||||
bool IsCollisionInMapService();
|
||||
void FindPathInMapService();
|
||||
float GetRadius();
|
||||
void SyncAroundPlayers(const char* file, int line, const char* func);
|
||||
void BeKill(int killer_id, const std::string& killer_name);
|
||||
@ -82,7 +81,6 @@ class Human : public Entity
|
||||
void AddOutObjects(Entity* entity);
|
||||
void RemoveOutObjects(Entity* entity);
|
||||
bool HasLiveTeammate();
|
||||
void FindLocation();
|
||||
void RefreshView();
|
||||
void OnGridListChange(std::set<GridCell*>& old_grid_list,
|
||||
std::set<GridCell*>& inc_grid_list,
|
||||
@ -114,10 +112,8 @@ protected:
|
||||
private:
|
||||
void ClearFrameData();
|
||||
void GenBattleReportData(a8::MutableXObject* params);
|
||||
void DeadDrop();
|
||||
void FillSMGameOver(cs::SMGameOver& msg);
|
||||
void SendBattleReport();
|
||||
void FindLocationWithTarget(Entity* target);
|
||||
void OnDie();
|
||||
void Revive();
|
||||
|
||||
|
@ -165,7 +165,6 @@ void Room::AddPlayer(Player* hum)
|
||||
++alive_count_;
|
||||
++App::Instance()->perf.alive_count;
|
||||
grid_service.AddHuman(hum);
|
||||
hum->FindLocation();
|
||||
hum->RefreshView();
|
||||
MatchTeam(hum);
|
||||
while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
namespace MetaData
|
||||
{
|
||||
struct Map;
|
||||
struct MapTplThing;
|
||||
}
|
||||
|
||||
struct timer_list;
|
||||
|
Loading…
x
Reference in New Issue
Block a user