66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include "precompile.h"
|
|
#include "moveableentity.h"
|
|
#include "room.h"
|
|
#include "human.h"
|
|
|
|
void MoveableEntity::TraverseAllLayerEntityList(std::function<void (Entity*, bool&)> func)
|
|
{
|
|
room->grid_service->TraverseAllLayerEntityList(room->GetRoomIdx(), grid_list_, func);
|
|
}
|
|
|
|
void MoveableEntity::TraverseAllLayerHumanList(std::function<void (Human*, bool&)> func)
|
|
{
|
|
room->grid_service->TraverseAllLayerHumanList(room->GetRoomIdx(), grid_list_, func);
|
|
}
|
|
|
|
void MoveableEntity::RefreshView()
|
|
{
|
|
TraverseAllLayerHumanList
|
|
(
|
|
[this] (Human* hum, bool& stop)
|
|
{
|
|
hum->AddToNewObjects(this);
|
|
hum->AddToPartObjects(this);
|
|
});
|
|
}
|
|
|
|
void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
|
|
std::set<GridCell*>& inc_grids,
|
|
std::set<GridCell*>& dec_grids
|
|
)
|
|
{
|
|
room->grid_service->TraverseAllLayerHumanList
|
|
(
|
|
room->GetRoomIdx(),
|
|
inc_grids,
|
|
[this, &old_grids] (Human* hum, bool& stop)
|
|
{
|
|
if (!room->grid_service->CreatureInGridList(hum, old_grids)) {
|
|
hum->AddToNewObjects(this);
|
|
hum->AddToPartObjects(this);
|
|
hum->RemoveOutObjects(this);
|
|
}
|
|
});
|
|
|
|
room->grid_service->TraverseAllLayerHumanList
|
|
(
|
|
room->GetRoomIdx(),
|
|
dec_grids,
|
|
[this] (Human* hum, bool& stop)
|
|
{
|
|
if (!room->grid_service->CreatureInGridList(hum, GetGridList())) {
|
|
hum->AddOutObjects(this);
|
|
}
|
|
});
|
|
}
|
|
|
|
void MoveableEntity::SyncAroundPlayers(const char* file, int line, const char* func)
|
|
{
|
|
TraverseAllLayerHumanList
|
|
(
|
|
[this, file, line, func] (Human* hum, bool& stop)
|
|
{
|
|
hum->AddToNewObjects(this);
|
|
});
|
|
}
|