| 33 | } |
| 34 | |
| 35 | void BattleExplosion::die(GameState &state) |
| 36 | { |
| 37 | auto this_shared = shared_from_this(); |
| 38 | state.current_battle->explosions.erase(this_shared); |
| 39 | // Deal damage |
| 40 | if (damageInTheEnd) |
| 41 | { |
| 42 | auto &map = *state.current_battle->map; |
| 43 | for (auto &pos : locationsToDamage) |
| 44 | { |
| 45 | damage(state, map, pos.first, pos.second); |
| 46 | } |
| 47 | } |
| 48 | // Hack to make all hazards update at once |
| 49 | auto &map = *state.current_battle->map; |
| 50 | for (auto &pos : locationsVisited) |
| 51 | { |
| 52 | auto tile = map.getTile(pos.x, pos.y, pos.z); |
| 53 | sp<BattleHazard> existingHazard; |
| 54 | for (auto &obj : tile->ownedObjects) |
| 55 | { |
| 56 | if (obj->getType() == TileObject::Type::Hazard) |
| 57 | { |
| 58 | existingHazard = std::static_pointer_cast<TileObjectBattleHazard>(obj)->getHazard(); |
| 59 | break; |
| 60 | } |
| 61 | } |
| 62 | if (existingHazard) |
| 63 | { |
| 64 | existingHazard->nextUpdateTicksAccumulated = 0; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void BattleExplosion::update(GameState &state, unsigned int ticks) |
| 70 | { |