This commit is contained in:
aozhiwei 2021-09-09 17:26:12 +08:00
parent c7d68e326a
commit fc5835eeb0
2 changed files with 13 additions and 6 deletions

View File

@ -380,10 +380,6 @@ void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int
void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id) void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
{ {
dead = true; dead = true;
room->TakeOnCarObject(GetUniId());
BroadcastDeleteState(room);
RemoveFromAroundPlayers(room);
room->grid_service->RemoveCreature(this);
if (hero_meta_->i->delay_remove() > 0) { if (hero_meta_->i->delay_remove() > 0) {
room->xtimer.AddDeadLineTimerAndAttach room->xtimer.AddDeadLineTimerAndAttach
( (
@ -392,11 +388,12 @@ void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
.SetSender(this), .SetSender(this),
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Car* c = (Car*)param.sender.GetUserData();
c->RemoveFromScene();
}, },
&xtimer_attacher.timer_list_); &xtimer_attacher.timer_list_);
} else { } else {
room->RemoveObjectLater(this); RemoveFromScene();
} }
int team_id = 0; int team_id = 0;
for (Human* passenger : passengers_) { for (Human* passenger : passengers_) {
@ -512,3 +509,12 @@ void Car::CheckCreatureCollision()
{ {
} }
void Car::RemoveFromScene()
{
room->TakeOnCarObject(GetUniId());
BroadcastDeleteState(room);
RemoveFromAroundPlayers(room);
room->grid_service->RemoveCreature(this);
room->RemoveObjectLater(this);
}

View File

@ -57,6 +57,7 @@ class Car : public Creature
void RecalcSelfCollider(); void RecalcSelfCollider();
bool NeedCreatureCollision(); bool NeedCreatureCollision();
void CheckCreatureCollision(); void CheckCreatureCollision();
void RemoveFromScene();
private: private:
long long born_frameno_ = 0; long long born_frameno_ = 0;