This commit is contained in:
aozhiwei 2021-05-20 19:51:27 +08:00
parent cf7431a597
commit e9baeff236
7 changed files with 42 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class Bullet;
class Entity
{
public:
long long delete_frameno = 0;
Entity();
virtual ~Entity();
@ -32,6 +33,8 @@ class Entity
virtual void OnPreCollision(Room* room) {};
virtual void RecalcSelfCollider() {};
virtual void OnBulletHit(Bullet* bullet) {};
virtual void OnAddToTargetPartObject(Entity* target) {};
virtual void OnRemoveFromTargetPartObject(Entity* target) {};
int GetEntityUniId() const { return entity_uniid_; }
EntityType_e GetEntityType() const { return entity_type_; }
EntitySubType_e GetEntitySubType() const { return entity_subtype_; }

View File

@ -306,6 +306,24 @@ void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
hero->RemoveFromAroundPlayers(hero->room);
hero->room->grid_service->RemoveCreature(hero);
hero->room->RemoveObjectLater(hero);
hero->delete_frameno = hero->room->GetFrameNo();
std::vector<Human*> watch_list;
hero->room->GetPartObjectWatchList(hero, watch_list);
if (watch_list.empty()) {
}
},
&xtimer_attacher.timer_list_);
}
void Hero::OnAddToTargetPartObject(Entity* target)
{
if (delete_frameno > 0) {
abort();
}
}
void Hero::OnRemoveFromTargetPartObject(Entity* target)
{
}

View File

@ -35,6 +35,8 @@ public:
virtual float GetHitRadius() override;
virtual void GetAabbBox(AabbCollider& aabb_box) override;
virtual void GetHitAabbBox(AabbCollider& aabb_box) override;
virtual void OnAddToTargetPartObject(Entity* target) override;
virtual void OnRemoveFromTargetPartObject(Entity* target) override;
void SetAiLevel(int ai_level);
void DetachFromMaster();

View File

@ -967,12 +967,15 @@ void Human::AddToPartObjects(Entity* entity)
part_obj.entity_uniid = entity->GetEntityUniId();
part_obj.entity_type = entity->GetEntityType();
part_obj.entity_subtype = entity->GetEntitySubType();
part_obj.add_frameno = room->GetFrameNo();
part_objects[entity] = part_obj;
entity->OnAddToTargetPartObject(this);
}
void Human::RemovePartObjects(Entity* entity)
{
part_objects.erase(entity);
entity->OnRemoveFromTargetPartObject(this);
}
void Human::ClearPartObjects()

View File

@ -36,6 +36,7 @@ struct PartObject
int entity_uniid = 0;
int entity_type = 0;
int entity_subtype = 0;
long long add_frameno = 0;
};
struct xtimer_list;

View File

@ -3887,3 +3887,17 @@ void Room::ShuaMon(const a8::Vec2& center, std::vector<int>& airdrop_mon_list, f
}//end if
}//end for hero_id
}
void Room::GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list)
{
TouchHumanList
(
a8::XParams(),
[&watch_list, entity] (Human* hum, a8::XParams& param) -> bool
{
if (hum->InPartObjects(entity)) {
watch_list.push_back(hum);
}
return true;
});
}

View File

@ -177,6 +177,7 @@ public:
int AllocUniid();
Incubator* GetIncubator() { return incubator_;};
void ShuaMon(const a8::Vec2& center, std::vector<int>& airdrop_mon_list, float radius);
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
private:
void ShuaAndroid();