完成gridcell改造

This commit is contained in:
aozhiwei 2021-03-29 14:50:03 +08:00
parent f5208e0913
commit 4cf475dbd5
16 changed files with 134 additions and 256 deletions

View File

@ -177,7 +177,7 @@ void AndroidNewAI::DoMoveOldAI()
}
break;
}
hum->room->grid_service->MoveHuman(hum);
hum->room->grid_service->MoveCreature(hum);
}
}
}
@ -228,7 +228,7 @@ void AndroidNewAI::UpdateNewBieNpc()
int speed = std::max(1, (int)hum->GetSpeed());
for (int i = 0; i < speed; ++i) {
hum->SetPos(hum->GetPos() + hum->move_dir);
hum->room->grid_service->MoveHuman(hum);
hum->room->grid_service->MoveCreature(hum);
}
} else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 3) {
Human* enemy = hum->room->GetFirstNewBie();
@ -265,7 +265,7 @@ void AndroidNewAI::UpdateLastNpc()
a8::Vec2 old_pos = hum->GetPos();
hum->SetPos(hum->GetPos() + hum->move_dir);
if (!hum->room->OverBorder(hum->GetPos(), hum->meta->i->radius())) {
hum->room->grid_service->MoveHuman(hum);
hum->room->grid_service->MoveCreature(hum);
} else {
hum->SetPos(old_pos);
break;
@ -361,7 +361,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
}
}
hum->SetPos(pos);
hum->room->grid_service->MoveHuman(hum);
hum->room->grid_service->MoveCreature(hum);
hum->FindLocation();
hum->RefreshView();
}
@ -380,7 +380,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
speed *= 0.7;
for (int i = 0; i < speed; ++i) {
hum->SetPos(hum->GetPos() + hum->move_dir);
hum->room->grid_service->MoveHuman(hum);
hum->room->grid_service->MoveCreature(hum);
}
}
} else {

View File

@ -62,7 +62,7 @@ void Android::InternalUpdate(int delta_time)
}
if (HasBuffEffect(kBET_Fly)) {
SetPos(room->plane.curr_pos);
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
return;
}
ai->Update(delta_time);

View File

@ -8,7 +8,7 @@
#include "perfmonitor.h"
#include "typeconvert.h"
Car::Car():MoveableEntity()
Car::Car():Creature()
{
++PerfMonitor::Instance()->entity_num[ET_Car];
}
@ -20,7 +20,7 @@ Car::~Car()
void Car::Initialize()
{
MoveableEntity::Initialize();
Creature::Initialize();
hero_meta_ = MetaMgr::Instance()->GetPlayer(meta->i->heroid());
if (!hero_meta_) {
abort();
@ -172,9 +172,9 @@ void Car::SyncPos()
if (hum != driver_) {
hum->SetPos(GetPos());
hum->move_dir = move_dir;
room->grid_service->MoveHuman(hum);
room->grid_service->MoveCreature(hum);
}
}
room->grid_service->MoveCar(this);
room->grid_service->MoveCreature(this);
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "moveableentity.h"
#include "creature.h"
#include "cs_proto.pb.h"
@ -12,7 +12,7 @@ namespace MetaData
class Human;
class Room;
class Car : public MoveableEntity
class Car : public Creature
{
public:
int car_uniid = 0;

View File

@ -832,3 +832,18 @@ float Creature::GetAttrRate(int attr_id)
float attr_rate_val = GetBuffAttrRate(attr_id);
return attr_rate_val;
}
bool Creature::IsPlayer() const
{
return IsHuman() && IsEntitySubType(EST_Player);
}
bool Creature::IsAndroid() const
{
return IsHuman() && IsEntitySubType(EST_Android);
}
bool Creature::IsHuman() const
{
return IsEntityType(ET_Player);
}

View File

@ -71,8 +71,9 @@ class Creature : public MoveableEntity
virtual std::string GetName() { return "";};
virtual void SendDebugMsg(const std::string& debug_msg);
virtual void DropItems(Obstacle* obstacle) {};
virtual bool IsPlayer() const { return false;};
virtual bool IsAndroid() const { return false;};
bool IsPlayer() const;
bool IsAndroid() const;
bool IsHuman() const;
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) {};
RaceType_e GetRace() { return race_; }

View File

@ -7,50 +7,37 @@
#include "room.h"
#include "car.h"
#include "hero.h"
#include "creature.h"
GridCell::GridCell()
{
human_list_.reserve(MAX_ROOM_IDX);
entity_list_.reserve(MAX_ROOM_IDX);
bullet_list_.reserve(MAX_ROOM_IDX);
entitys_.reserve(MAX_ROOM_IDX);
bullets_.reserve(MAX_ROOM_IDX);
creatures_.reserve(MAX_ROOM_IDX);
for (int i = 0; i < MAX_ROOM_IDX; ++i) {
human_list_.push_back(std::set<Human*>());
entity_list_.push_back(std::set<Entity*>());
bullet_list_.push_back(std::set<Bullet*>());
car_list_.push_back(std::set<Car*>());
hero_list_.push_back(std::set<Hero*>());
entitys_.push_back(std::set<Entity*>());
bullets_.push_back(std::set<Bullet*>());
creatures_.push_back(std::set<Creature*>());
}
}
void GridCell::ClearRoomData(Room* room)
{
human_list_[room->GetRoomIdx()].clear();
entity_list_[room->GetRoomIdx()].clear();
bullet_list_[room->GetRoomIdx()].clear();
bullet_list_[room->GetRoomIdx()].clear();
}
void GridCell::AddHuman(Human* hum)
{
human_list_[hum->room->GetRoomIdx()].insert(hum);
}
void GridCell::RemoveHuman(Human* hum)
{
human_list_[hum->room->GetRoomIdx()].erase(hum);
}
bool GridCell::ExistsHuman(Human* hum)
{
return human_list_[hum->room->GetRoomIdx()].find(hum) != human_list_[hum->room->GetRoomIdx()].end();
entitys_[room->GetRoomIdx()].clear();
bullets_[room->GetRoomIdx()].clear();
creatures_[room->GetRoomIdx()].clear();
}
void GridCell::TouchHumanList(std::function<void (Human*, bool&)>& func,
int room_idx,
bool& stop)
{
for (Human* hum : human_list_[room_idx]) {
for (Creature* c : creatures_[room_idx]) {
if (!c->IsHuman()) {
continue;
}
Human* hum = (Human*)c;
func(hum, stop);
if (stop) {
return;
@ -67,62 +54,42 @@ void GridCell::TouchHumanListEx(std::function<void (Human*, bool&)> func,
void GridCell::AddBullet(Bullet* bullet)
{
bullet_list_[bullet->room->GetRoomIdx()].insert(bullet);
bullets_[bullet->room->GetRoomIdx()].insert(bullet);
}
void GridCell::RemoveBullet(Bullet* bullet)
{
bullet_list_[bullet->room->GetRoomIdx()].erase(bullet);
}
void GridCell::AddCar(Car* car)
{
car_list_[car->room->GetRoomIdx()].insert(car);
}
void GridCell::RemoveCar(Car* car)
{
car_list_[car->room->GetRoomIdx()].erase(car);
}
void GridCell::AddHero(Hero* hero)
{
hero_list_[hero->room->GetRoomIdx()].insert(hero);
}
void GridCell::RemoveHero(Hero* hero)
{
hero_list_[hero->room->GetRoomIdx()].erase(hero);
bullets_[bullet->room->GetRoomIdx()].erase(bullet);
}
void GridCell::AddPermanentEntity(Entity* entity)
{
entity_list_[0].insert(entity);
entitys_[0].insert(entity);
}
void GridCell::AddRoomEntity(Room* room, Entity* entity)
{
entity_list_[room->GetRoomIdx()].insert(entity);
entitys_[room->GetRoomIdx()].insert(entity);
}
void GridCell::RemoveRoomEntity(Room* room, Entity* entity)
{
entity_list_[room->GetRoomIdx()].erase(entity);
entitys_[room->GetRoomIdx()].erase(entity);
}
bool GridCell::ExistsEntity(Room* room, Entity* entity)
bool GridCell::EntityExists(Room* room, Entity* entity)
{
if (entity_list_[0].find(entity) != entity_list_[0].end()) {
if (entitys_[0].find(entity) != entitys_[0].end()) {
return true;
}
return entity_list_[room->GetRoomIdx()].find(entity) !=
entity_list_[room->GetRoomIdx()].end();
return entitys_[room->GetRoomIdx()].find(entity) !=
entitys_[room->GetRoomIdx()].end();
}
void GridCell::TouchLayer0EntityList(std::function<void (Entity*, bool&)>& func,
bool& stop)
{
for (Entity* entity : entity_list_[0]) {
for (Entity* entity : entitys_[0]) {
func(entity, stop);
if (stop) {
return;
@ -134,7 +101,7 @@ void GridCell::TouchLayer1EntityList(std::function<void (Entity*, bool&)>& func,
int room_idx,
bool& stop)
{
for (Entity* entity : entity_list_[room_idx]) {
for (Entity* entity : entitys_[room_idx]) {
func(entity, stop);
if (stop) {
return;
@ -151,3 +118,18 @@ void GridCell::TouchAllLayerEntityList(std::function<void (Entity*, bool&)>& fun
TouchLayer1EntityList(func, room_idx, stop);
}
}
void GridCell::AddCreature(Creature* c)
{
creatures_[c->room->GetRoomIdx()].insert(c);
}
void GridCell::RemoveCreature(Creature* c)
{
creatures_[c->room->GetRoomIdx()].erase(c);
}
bool GridCell::CreatureExists(Creature* c)
{
return creatures_[c->room->GetRoomIdx()].find(c) != creatures_[c->room->GetRoomIdx()].end();
}

View File

@ -4,8 +4,7 @@ class Entity;
class Human;
class Bullet;
class Room;
class Car;
class Hero;
class Creature;
class GridCell
{
@ -13,9 +12,7 @@ public:
GridCell();
void ClearRoomData(Room* room);
void AddHuman(Human* hum);
void RemoveHuman(Human* hum);
bool ExistsHuman(Human* hum);
void TouchHumanList(std::function<void (Human*, bool&)>& func,
int room_idx,
bool& stop);
@ -23,16 +20,15 @@ public:
int room_idx,
bool& stop);
void AddCreature(Creature* c);
void RemoveCreature(Creature* c);
bool CreatureExists(Creature* c);
void AddBullet(Bullet* bullet);
void RemoveBullet(Bullet* bullet);
void AddCar(Car* car);
void RemoveCar(Car* car);
void AddHero(Hero* hero);
void RemoveHero(Hero* hero);
void AddPermanentEntity(Entity* entity);
void AddRoomEntity(Room* room, Entity* entity);
void RemoveRoomEntity(Room* room, Entity* entity);
bool ExistsEntity(Room* room, Entity* Entity);
bool EntityExists(Room* room, Entity* Entity);
void TouchLayer0EntityList(std::function<void (Entity*, bool&)>& func,
bool& stop);
void TouchLayer1EntityList(std::function<void (Entity*, bool&)>& func,
@ -43,9 +39,7 @@ public:
bool& stop);
private:
std::vector<std::set<Human*>> human_list_;
std::vector<std::set<Entity*>> entity_list_;
std::vector<std::set<Bullet*>> bullet_list_;
std::vector<std::set<Car*>> car_list_;
std::vector<std::set<Hero*>> hero_list_;
std::vector<std::set<Entity*>> entitys_;
std::vector<std::set<Bullet*>> bullets_;
std::vector<std::set<Creature*>> creatures_;
};

View File

@ -5,8 +5,6 @@
#include "bullet.h"
#include "room.h"
#include "gridcell.h"
#include "car.h"
#include "hero.h"
/*
1 2 3
@ -102,25 +100,31 @@ void GridService::ClearRoomData(Room* room)
}
}
void GridService::AddHuman(Human* hum)
void GridService::AddCreature(Creature* c)
{
int x = (int)hum->GetX() + cell_width_;
int y = (int)hum->GetY() + cell_width_;
int x = (int)c->GetX() + cell_width_;
int y = (int)c->GetY() + cell_width_;
if (BroderOverFlow(x, y)) {
abort();
}
hum->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (hum->GetGridId() == 0 || hum->GetGridId() > max_grid_id_) {
c->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (c->GetGridId() == 0 || c->GetGridId() > max_grid_id_) {
abort();
}
cells_[hum->GetGridId()].AddHuman(hum);
GetAllCells(hum->room, hum->GetGridId(), hum->GetGridList());
cells_[c->GetGridId()].AddCreature(c);
GetAllCells(c->room, c->GetGridId(), c->GetGridList());
}
void GridService::MoveHuman(Human* hum)
void GridService::RemoveCreature(Creature* c)
{
int new_x = (int)hum->GetX() + cell_width_;
int new_y = (int)hum->GetY() + cell_width_;
GridCell& cell = cells_[c->GetGridId()];
cell.RemoveCreature(c);
}
void GridService::MoveCreature(Creature* c)
{
int new_x = (int)c->GetX() + cell_width_;
int new_y = (int)c->GetY() + cell_width_;
int new_grid_id = new_x/cell_width_ + (new_y/cell_width_) * cell_count_per_row_;
if (BroderOverFlow(new_x, new_y)) {
abort();
@ -128,20 +132,20 @@ void GridService::MoveHuman(Human* hum)
if (new_grid_id == 0 || new_grid_id > max_grid_id_) {
abort();
}
if (new_grid_id != hum->GetGridId()) {
if (new_grid_id != c->GetGridId()) {
std::set<GridCell*> inc_grid_list;
std::set<GridCell*> dec_grid_list;
std::set<GridCell*> old_grid_list = hum->GetGridList();
ComputeDiff(hum->room,
hum->GetGridId(),
std::set<GridCell*> old_grid_list = c->GetGridList();
ComputeDiff(c->room,
c->GetGridId(),
new_grid_id,
hum->GetGridList(),
c->GetGridList(),
inc_grid_list,
dec_grid_list);
cells_[hum->GetGridId()].RemoveHuman(hum);
cells_[new_grid_id].AddHuman(hum);
hum->SetGridId(new_grid_id);
hum->OnGridListChange(old_grid_list, inc_grid_list, dec_grid_list);
cells_[c->GetGridId()].RemoveCreature(c);
cells_[new_grid_id].AddCreature(c);
c->SetGridId(new_grid_id);
c->OnGridListChange(old_grid_list, inc_grid_list, dec_grid_list);
}
}
@ -193,104 +197,6 @@ void GridService::DelBullet(Bullet* bullet)
cell.RemoveBullet(bullet);
}
void GridService::AddCar(Car* car)
{
int x = (int)car->GetX() + cell_width_;
int y = (int)car->GetY() + cell_width_;
if (BroderOverFlow(x, y)) {
abort();
}
car->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (car->GetGridId() == 0 || car->GetGridId() > max_grid_id_) {
abort();
}
cells_[car->GetGridId()].AddCar(car);
GetAllCells(car->room, car->GetGridId(), car->GetGridList());
}
void GridService::MoveCar(Car* car)
{
int new_x = (int)car->GetX() + cell_width_;
int new_y = (int)car->GetY() + cell_width_;
int new_grid_id = new_x/cell_width_ + (new_y/cell_width_) * cell_count_per_row_;
if (BroderOverFlow(new_x, new_y)) {
abort();
}
if (new_grid_id == 0 || new_grid_id > max_grid_id_) {
abort();
}
if (new_grid_id != car->GetGridId()) {
std::set<GridCell*> inc_grid_list;
std::set<GridCell*> dec_grid_list;
std::set<GridCell*> old_grid_list = car->GetGridList();
ComputeDiff(car->room,
car->GetGridId(),
new_grid_id,
car->GetGridList(),
inc_grid_list,
dec_grid_list);
cells_[car->GetGridId()].RemoveCar(car);
cells_[new_grid_id].AddCar(car);
car->SetGridId(new_grid_id);
car->OnGridListChange(old_grid_list, inc_grid_list, dec_grid_list);
}
}
void GridService::DelCar(Car* car)
{
GridCell& cell = cells_[car->GetGridId()];
cell.RemoveCar(car);
}
void GridService::AddHero(Hero* hero)
{
int x = (int)hero->GetX() + cell_width_;
int y = (int)hero->GetY() + cell_width_;
if (BroderOverFlow(x, y)) {
abort();
}
hero->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (hero->GetGridId() == 0 || hero->GetGridId() > max_grid_id_) {
abort();
}
cells_[hero->GetGridId()].AddHero(hero);
GetAllCells(hero->room, hero->GetGridId(), hero->GetGridList());
}
void GridService::MoveHero(Hero* hero)
{
int new_x = (int)hero->GetX() + cell_width_;
int new_y = (int)hero->GetY() + cell_width_;
int new_grid_id = new_x/cell_width_ + (new_y/cell_width_) * cell_count_per_row_;
if (BroderOverFlow(new_x, new_y)) {
abort();
}
if (new_grid_id == 0 || new_grid_id > max_grid_id_) {
abort();
}
if (new_grid_id != hero->GetGridId()) {
std::set<GridCell*> inc_grid_list;
std::set<GridCell*> dec_grid_list;
std::set<GridCell*> old_grid_list = hero->GetGridList();
ComputeDiff(hero->room,
hero->GetGridId(),
new_grid_id,
hero->GetGridList(),
inc_grid_list,
dec_grid_list);
cells_[hero->GetGridId()].RemoveHero(hero);
cells_[new_grid_id].AddHero(hero);
hero->SetGridId(new_grid_id);
hero->OnGridListChange(old_grid_list, inc_grid_list, dec_grid_list);
}
}
void GridService::DelHero(Hero* hero)
{
GridCell& cell = cells_[hero->GetGridId()];
cell.RemoveHero(hero);
}
void GridService::AddRoomEntity(Room* room, Entity* entity)
{
assert(!entity->IsEntityType(ET_Player));
@ -327,10 +233,10 @@ void GridService::AddPermanentEntity(Entity* entity)
cells_[entity->GetGridId()].AddPermanentEntity(entity);
}
bool GridService::HumanInGridList(Human* hum, std::set<GridCell*>& grid_list)
bool GridService::CreatureInGridList(Creature* c, std::set<GridCell*>& grid_list)
{
for (auto& cell : grid_list) {
if (cell->ExistsHuman(hum)) {
if (cell->CreatureExists(c)) {
return true;
}
}
@ -340,7 +246,7 @@ bool GridService::HumanInGridList(Human* hum, std::set<GridCell*>& grid_list)
bool GridService::EntityInGridList(Room* room, Entity* entity, std::set<GridCell*>& grid_list)
{
for (auto& cell : grid_list) {
if (cell->ExistsEntity(room, entity)) {
if (cell->EntityExists(room, entity)) {
return true;
}
}
@ -484,7 +390,7 @@ void GridService::DeatchHuman(Human* target)
},
target->room->GetRoomIdx(),
stop);
cell->RemoveHuman(target);
cell->RemoveCreature(target);
}
target->SetGridId(0);
target->GetGridList().clear();

View File

@ -4,8 +4,7 @@ class Human;
class Entity;
class Room;
class Bullet;
class Car;
class Hero;
class Creature;
class GridCell;
class GridService
{
@ -21,27 +20,20 @@ class GridService
bool CanAdd(float x, float y);
void ClearRoomData(Room* room);
void AddHuman(Human* hum);
void MoveHuman(Human* hum);
void AddCreature(Creature* c);
void RemoveCreature(Creature* c);
void MoveCreature(Creature* c);
void AddBullet(Bullet* bullet);
void MoveBullet(Bullet* bullet);
void DelBullet(Bullet* bullet);
void AddCar(Car* car);
void MoveCar(Car* car);
void DelCar(Car* car);
void AddHero(Hero* hero);
void MoveHero(Hero* hero);
void DelHero(Hero* hero);
void AddRoomEntity(Room* room, Entity* entity);
void DelRoomEntity(Room* room, Entity* entity);
void AddPermanentEntity(Entity* entity);
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
bool CreatureInGridList(Creature* c, std::set<GridCell*>& grid_list);
bool EntityInGridList(Room* room, Entity* entity, std::set<GridCell*>& grid_list);
bool InView(int a_grid, int b_grid);
bool InView(int grid_id, float x, float y);

View File

@ -91,7 +91,7 @@ void Hero::InternalUpdateMove(float speed)
SetPos(new_pos);
if (!IsCollisionInMapService()) {
room->grid_service->MoveHero(this);
room->grid_service->MoveCreature(this);
} else {
if (on_move_collision && !on_move_collision()) {
SetPos(old_pos);

View File

@ -2133,7 +2133,7 @@ void Human::_InternalUpdateMove(float speed)
#if 1
SetPos(old_pos + a8::Vec2(nx, ny));
if (!IsCollisionInMapService()) {
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
return;
} else {
if (Global::last_collider && Global::last_collider->type == CT_Circle) {
@ -2148,7 +2148,7 @@ void Human::_InternalUpdateMove(float speed)
SetPos(GetPos() + new_dir);
}
if (!IsCollisionInMapService()) {
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
return;
}
}
@ -2174,7 +2174,7 @@ void Human::_InternalUpdateMove(float speed)
}
SetPos(old_pos + a8::Vec2(nx, ny));
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
}
void Human::ClearFrameData()
@ -2730,7 +2730,7 @@ void Human::FindLocationWithTarget(Entity* target)
float distance = (new_pos - old_pos).Norm();
for (int i = distance; i < 10000000; i += 5) {
SetPos(old_pos + new_pos_dir * i);
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
Entity* building = nullptr;
std::set<GridCell*> tmp_grids;
@ -2915,16 +2915,6 @@ void Human::DecItem(int item_id, int item_num)
}
}
bool Human::IsPlayer() const
{
return IsEntitySubType(EST_Player);
}
bool Human::IsAndroid() const
{
return IsEntitySubType(EST_Android);
}
void Human::DropItems(Obstacle* obstacle)
{
bool is_treasure_box = false;
@ -3101,7 +3091,7 @@ void Human::OnEnable()
{
a8::UnSetBitFlag(status, HS_Disable);
enable_frameno = room->GetFrameNo();
room->grid_service->AddHuman(this);
room->grid_service->MoveCreature(this);
FindLocation();
RefreshView();
}
@ -3191,7 +3181,7 @@ void Human::ProcIncGridList(std::set<GridCell*>& old_grids,
inc_grids,
[this, &old_grids] (Human* hum, bool& stop)
{
if (!room->grid_service->HumanInGridList(hum, old_grids)) {
if (!room->grid_service->CreatureInGridList(hum, old_grids)) {
hum->AddToNewObjects(this);
hum->AddToPartObjects(this);
hum->RemoveOutObjects(this);
@ -3233,7 +3223,7 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
dec_grids,
[this] (Human* hum, bool& stop)
{
if (!room->grid_service->HumanInGridList(hum, GetGridList())) {
if (!room->grid_service->CreatureInGridList(hum, GetGridList())) {
AddOutObjects(hum);
hum->AddOutObjects(this);
#ifdef DEBUG
@ -3476,7 +3466,7 @@ void Human::OnLand()
for (const a8::Vec2& dir : dirs) {
SetPos(old_pos + dir * i);
if (!IsCollisionInMapService()) {
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
return;
}
}

View File

@ -240,8 +240,6 @@ class Human : public Creature
int GetItemNum(int item_id);
void AddItem(int item_id, int item_num);
void DecItem(int item_id, int item_num);
virtual bool IsPlayer() const override;
virtual bool IsAndroid() const override;
virtual void DropItems(Obstacle* obstacle) override;
void ProcNewBieLogic();
void OnEnable();

View File

@ -46,7 +46,7 @@ void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
inc_grids,
[this, &old_grids] (Human* hum, bool& stop)
{
if (!room->grid_service->HumanInGridList(hum, old_grids)) {
if (!room->grid_service->CreatureInGridList(hum, old_grids)) {
hum->AddToNewObjects(this);
hum->AddToPartObjects(this);
hum->RemoveOutObjects(this);
@ -60,7 +60,7 @@ void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
dec_grids,
[this] (Human* hum, bool& stop)
{
if (!room->grid_service->HumanInGridList(hum, GetGridList())) {
if (!room->grid_service->CreatureInGridList(hum, GetGridList())) {
hum->AddOutObjects(this);
}
});

View File

@ -58,7 +58,7 @@ void Player::InternalUpdate(int delta_time)
}
if (HasBuffEffect(kBET_Fly)) {
SetPos(room->plane.curr_pos);
room->grid_service->MoveHuman(this);
room->grid_service->MoveCreature(this);
#ifdef DEBUG
if (GetCar() && GetCar()->IsDriver(this)) {
GetCar()->SyncPos();

View File

@ -237,7 +237,7 @@ void Room::AddPlayer(Player* hum)
alive_count_chged_frameno_ = GetFrameNo();
++PerfMonitor::Instance()->alive_count;
grid_service->AddHuman(hum);
grid_service->AddCreature(hum);
hum->FindLocation();
hum->RefreshView();
AddPlayerPostProc(hum);
@ -352,7 +352,7 @@ void Room::CreateAndroid(int robot_num)
} else {
AddToAliveHumanHash(hum);
AddToMoveableHash(hum);
grid_service->AddHuman(hum);
grid_service->AddCreature(hum);
hum->FindLocation();
hum->RefreshView();
}
@ -564,7 +564,7 @@ Car* Room::CreateCar(Human* driver,
}
car->Initialize();
AddToEntityHash(car);
grid_service->AddCar(car);
grid_service->AddCreature(car);
car->RefreshView();
car->BroadcastFullState(this);
return car;
@ -584,7 +584,7 @@ Hero* Room::CreateHero(Creature* master,
hero->Initialize();
AddToEntityHash(hero);
AddToMoveableHash(hero);
grid_service->AddHero(hero);
grid_service->AddCreature(hero);
hero->RefreshView();
return hero;
}
@ -618,7 +618,7 @@ void Room::RemoveObjectLater(RoomEntity* entity)
{
entity->RemoveFromAroundPlayers(entity->room);
entity->BroadcastDeleteState(entity->room);
entity->room->grid_service->DelCar((Car*)entity);
entity->room->grid_service->RemoveCreature((Car*)entity);
entity->room->RemoveFromMoveableHash((Car*)entity);
}
break;
@ -1685,7 +1685,7 @@ void Room::ShuaPlane()
pair.second->SetPos(plane.curr_pos);
pair.second->attack_dir = plane.dir;
pair.second->move_dir = plane.dir;
grid_service->MoveHuman(pair.second);
grid_service->MoveCreature(pair.second);
pair.second->AddToNewObjects(pair.second);
}
}
@ -3029,7 +3029,7 @@ void Room::CombineTeamBornPoint()
if (!a8::HasBitFlag(hum->status, HS_Disable)) {
hum->FindLocation();
hum->RefreshView();
grid_service->MoveHuman(hum);
grid_service->MoveCreature(hum);
} else if (room_type_ == RT_MidBrid && !hum->team_uuid.empty()){
EnableHuman(hum);
}
@ -3050,7 +3050,7 @@ void Room::ForceSetBornPoint(Human* hum, BornPoint* born_point)
}
hum->FindLocation();
hum->RefreshView();
grid_service->MoveHuman(hum);
grid_service->MoveCreature(hum);
}
}