16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Merge pull request #22 from mrozigor/master

FS#124 Added sound entry for engine shutdown event.
This commit is contained in:
Milek7
2018-06-19 00:56:22 +02:00
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -5677,6 +5677,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// odpalanie silnika
m_powertrainsounds.engine_ignition.deserialize( parser, sound_type::single );
m_powertrainsounds.engine_ignition.owner( this );
} else if (token == "shutdown:") {
m_powertrainsounds.engine_shutdown.deserialize(parser, sound_type::single);
m_powertrainsounds.engine_shutdown.owner(this);
}
else if( token == "engageslippery:" ) {
// tarcie tarcz sprzegla:
@@ -6383,7 +6386,7 @@ TDynamicObject::powertrain_sounds::position( glm::vec3 const Location ) {
std::vector<sound_source *> enginesounds = {
&inverter,
&motor_relay, &dsbWejscie_na_bezoporow, &motor_parallel, &motor_shuntfield, &rsWentylator,
&engine, &engine_ignition, &engine_revving, &engine_turbo, &oil_pump, &radiator_fan, &radiator_fan_aux,
&engine, &engine_ignition, &engine_shutdown, &engine_revving, &engine_turbo, &oil_pump, &radiator_fan, &radiator_fan_aux,
&transmission, &rsEngageSlippery
};
for( auto sound : enginesounds ) {
@@ -6414,19 +6417,21 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
// engine sounds
// ignition
if( engine_state_last != Vehicle.Mains ) {
if( true == Vehicle.Mains ) {
if (engine_state_last != Vehicle.Mains) {
if (Vehicle.Mains) {
// main circuit/engine activation
// TODO: separate engine and main circuit
engine_shutdown.stop();
engine_ignition
.pitch( engine_ignition.m_frequencyoffset + engine_ignition.m_frequencyfactor * 1.f )
.gain( engine_ignition.m_amplitudeoffset + engine_ignition.m_amplitudefactor * 1.f )
.play( sound_flags::exclusive );
}
else {
} else {
// main circuit/engine deactivation
engine_ignition.stop();
engine_shutdown.pitch( engine_shutdown.m_frequencyoffset + engine_shutdown.m_frequencyfactor * 1.f )
.gain( engine_shutdown.m_amplitudeoffset + engine_shutdown.m_amplitudefactor * 1.f )
.play( sound_flags::exclusive );
}
engine_state_last = Vehicle.Mains;
}

View File

@@ -335,6 +335,7 @@ private:
sound_source rsWentylator { sound_placement::engine }; // McZapkie-030302
sound_source engine { sound_placement::engine }; // generally diesel engine
sound_source engine_ignition { sound_placement::engine }; // moved from cab
sound_source engine_shutdown { sound_placement::engine };
bool engine_state_last { false }; // helper, cached previous state of the engine
double engine_volume { 0.0 }; // MC: pomocnicze zeby gladziej silnik buczal
sound_source engine_revving { sound_placement::engine }; // youBy