| 2395 | } |
| 2396 | |
| 2397 | void Map::EmitProcedureSound( const MapData::Procedure& procedure ) |
| 2398 | { |
| 2399 | if( procedure.sfx_id == 0u ) |
| 2400 | return; |
| 2401 | |
| 2402 | if( !procedure.sfx_pos.empty() ) |
| 2403 | { |
| 2404 | // Add single sound at average sfx_pos. |
| 2405 | // TODO - maybe emit multiple sounds? |
| 2406 | m_Vec2 avg_pos( 0.0f, 0.0f ); |
| 2407 | for( const MapData::Procedure::Pos& pos : procedure.sfx_pos ) |
| 2408 | { |
| 2409 | avg_pos.x+= float(pos.x); |
| 2410 | avg_pos.y+= float(pos.y); |
| 2411 | } |
| 2412 | const float count= procedure.sfx_pos.size(); |
| 2413 | avg_pos= m_Vec2( avg_pos.x / count + 0.5f, avg_pos.y / count + 0.5f ); |
| 2414 | |
| 2415 | PlayMapEventSound( m_Vec3( avg_pos, GameConstants::walls_height * 0.5f ), procedure.sfx_id ); |
| 2416 | } |
| 2417 | else |
| 2418 | { |
| 2419 | // Add single sound at position of related walls. |
| 2420 | // TODO - maybe emit multiple sounds? |
| 2421 | m_Vec3 avg_pos( 0.0f, 0.0f, 0.0f ); |
| 2422 | unsigned int pos_count= 0u; |
| 2423 | for( const MapData::Procedure::ActionCommand& command : procedure.action_commands ) |
| 2424 | { |
| 2425 | using Command= MapData::Procedure::ActionCommandId; |
| 2426 | switch(command.id) |
| 2427 | { |
| 2428 | case Command::Move: |
| 2429 | case Command::XMove: |
| 2430 | case Command::YMove: |
| 2431 | case Command::Rotate: |
| 2432 | case Command::Up: |
| 2433 | { |
| 2434 | const unsigned int x= static_cast<unsigned int>(command.args[0]); |
| 2435 | const unsigned int y= static_cast<unsigned int>(command.args[1]); |
| 2436 | if( x < MapData::c_map_size && y < MapData::c_map_size ) |
| 2437 | { |
| 2438 | const MapData::IndexElement& index_element= map_data_->map_index[ x + y * MapData::c_map_size ]; |
| 2439 | if( index_element.type == MapData::IndexElement::DynamicWall ) |
| 2440 | { |
| 2441 | const DynamicWall& wall= dynamic_walls_[ index_element.index ]; |
| 2442 | avg_pos+= m_Vec3( ( wall.vert_pos[0] + wall.vert_pos[1] ) * 0.5f, GameConstants::walls_height * 0.5f ); |
| 2443 | pos_count++; |
| 2444 | } |
| 2445 | else if( index_element.type == MapData::IndexElement::StaticModel ) |
| 2446 | { |
| 2447 | avg_pos+= static_models_[ index_element.index ].pos; |
| 2448 | pos_count++; |
| 2449 | } |
| 2450 | } |
| 2451 | } |
| 2452 | break; |
| 2453 | |
| 2454 | case Command::Lock: case Command::Unlock: |
nothing calls this directly
no outgoing calls
no test coverage detected