add out_objids

This commit is contained in:
aozhiwei 2019-04-30 13:48:05 +08:00
parent c989b2573f
commit 68d2d372d0
4 changed files with 26 additions and 7 deletions

View File

@ -30,6 +30,9 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
for (auto& itr : hum->del_objects) {
msg->add_del_objids(itr);
}
for (auto& itr : hum->out_objects) {
msg->add_out_objids(itr);
}
for (int idx : hum->shots_) {
if (idx < room->frame_event.shots_.size()) {
auto& tuple = room->frame_event.shots_[idx];

View File

@ -553,6 +553,11 @@ void Human::RemoveObjects(Entity* entity)
del_objects.insert(entity->entity_uniid);
}
void Human::OutObjects(Entity* entity)
{
out_objects.insert(entity->entity_uniid);
}
bool Human::HasLiveTeammate()
{
if (team_members) {
@ -846,6 +851,7 @@ void Human::RefreshView()
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
{
AddToNewObjects(entity);
}
@ -878,6 +884,7 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
{
AddToNewObjects(entity);
}
@ -892,21 +899,18 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
}
for (GridCell* cell : dec_grid_list) {
for (Human* entity : cell->human_list) {
#if 0
if (!room->grid_service.HumanInGridList(entity, grid_list)) {
RemoveObjects(entity);
OutObjects(entity);
}
#endif
}
for (Entity* entity : cell->entity_list) {
if (!room->grid_service.EntityInGridList(entity, grid_list)) {
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
{
#if 0
RemoveObjects(entity);
#endif
OutObjects(entity);
}
break;
default:
@ -1310,6 +1314,15 @@ void Human::ClearFrameData()
}
del_objects.clear();
}
if (!out_objects.empty()) {
for (auto& itr : out_objects) {
Entity* entity = room->GetEntityByUniId(itr);
if (entity) {
part_objects.erase(entity);
}
}
del_objects.clear();
}
if (!shots_.empty()) {
shots_.clear();
}

View File

@ -135,6 +135,7 @@ class Human : public Entity
void AddToNewObjects(Entity* entity);
void AddToPartObjects(Entity* entity);
void RemoveObjects(Entity* entity);
void OutObjects(Entity* entity);
bool HasLiveTeammate();
void Land();
void DoJump();
@ -188,6 +189,7 @@ protected:
std::set<Entity*> new_objects;
std::set<Entity*> part_objects;
std::set<int> del_objects;
std::set<int> out_objects;
std::vector<int> shots_;
std::vector<int> emotes_;
std::vector<int> bullets_;

View File

@ -678,7 +678,8 @@ message SMPlayerInfo
//
message SMUpdate
{
repeated int32 del_objids = 2; //-()
repeated int32 out_objids = 1; //-
repeated int32 del_objids = 2; //-
repeated MFObjectFull full_objects = 3; //-()
repeated MFObjectPart part_objects = 4; //-()
optional int32 active_player_id = 5; //id(id)