added player ship delete event and for missiles too.
This commit is contained in:
parent
8ec3f47276
commit
dc5cc89792
1 changed files with 17 additions and 0 deletions
|
@ -165,9 +165,16 @@ namespace game {
|
||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
for (Missile *missile : player->missiles) {
|
for (Missile *missile : player->missiles) {
|
||||||
missile->player = nullptr;
|
missile->player = nullptr;
|
||||||
|
m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->ship != nullptr) {
|
||||||
|
ships.remove(player->ship);
|
||||||
|
m_nextEvents.push_back(new ShipEvent(LifeCycle::Destroy, player->ship));
|
||||||
|
}
|
||||||
|
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
|
delete(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,6 +541,16 @@ namespace game {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EventType::Ship:
|
||||||
|
{
|
||||||
|
auto *se = static_cast<ShipEvent*>(evt);
|
||||||
|
//std::cout<<"got missile delete event, finally deleting missile #"
|
||||||
|
// << me->object()->id << std::endl;
|
||||||
|
|
||||||
|
delete(se->object());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EventType::Missile:
|
case EventType::Missile:
|
||||||
{
|
{
|
||||||
auto *me = static_cast<MissileEvent*>(evt);
|
auto *me = static_cast<MissileEvent*>(evt);
|
||||||
|
|
Loading…
Reference in a new issue