| 2185 | } |
| 2186 | |
| 2187 | void Battle::handleProjectileHit(GameState &state, sp<Projectile> projectile, bool displayDoodad, |
| 2188 | bool playSound, bool expired) |
| 2189 | { |
| 2190 | if (projectile->damageType->explosive) |
| 2191 | { |
| 2192 | auto explosion = |
| 2193 | addExplosion(state, projectile->position, projectile->doodadType, |
| 2194 | projectile->damageType, projectile->damage, projectile->depletionRate, |
| 2195 | projectile->firerUnit->owner, projectile->firerUnit); |
| 2196 | } |
| 2197 | if (displayDoodad && projectile->doodadType) |
| 2198 | { |
| 2199 | this->placeDoodad(projectile->doodadType, projectile->position); |
| 2200 | } |
| 2201 | if (playSound && projectile->impactSfx && |
| 2202 | (!expired || projectile->splitIntoTypesBattle.empty())) |
| 2203 | { |
| 2204 | fw().soundBackend->playSample(projectile->impactSfx, projectile->position); |
| 2205 | } |
| 2206 | if (expired) |
| 2207 | { |
| 2208 | std::set<sp<Sample>> fireSounds; |
| 2209 | for (auto &p : projectile->splitIntoTypesBattle) |
| 2210 | { |
| 2211 | auto direction = (float)randBoundsInclusive(state.rng, 0, 628) / 100.0f; |
| 2212 | auto velocity = glm::normalize( |
| 2213 | VehicleType::directionToVector(VehicleType::getDirectionLarge(direction))); |
| 2214 | velocity *= p->speed * PROJECTILE_VELOCITY_MULTIPLIER; |
| 2215 | auto newProj = mksp<Projectile>( |
| 2216 | p->guided ? Projectile::Type::Missile : Projectile::Type::Beam, |
| 2217 | projectile->firerUnit, projectile->trackedUnit, projectile->targetPosition, |
| 2218 | projectile->position, velocity, p->turn_rate, p->ttl, p->damage, 0, 0, p->tail_size, |
| 2219 | p->projectile_sprites, p->impact_sfx, p->explosion_graphic, p->damage_type); |
| 2220 | map->addObjectToMap(newProj); |
| 2221 | projectiles.insert(newProj); |
| 2222 | fireSounds.insert(p->fire_sfx); |
| 2223 | } |
| 2224 | for (auto &s : fireSounds) |
| 2225 | { |
| 2226 | fw().soundBackend->playSample(s, projectile->position); |
| 2227 | } |
| 2228 | } |
| 2229 | projectiles.erase(projectile); |
| 2230 | } |
| 2231 | |
| 2232 | void Battle::queuePathfindingRefresh(Vec3<int> tile) |
| 2233 | { |
nothing calls this directly
no test coverage detected