Add wiper sounds (from/to park)

This commit is contained in:
2025-09-30 21:43:25 +02:00
parent 7b8fa3f226
commit d928148fd0
2 changed files with 19 additions and 2 deletions

View File

@@ -4178,21 +4178,35 @@ bool TDynamicObject::Update(double dt, double dt1)
if (dWiperPos[i] < 1.0 && !wiperDirection[i] && wiperParkTimer[i] > currentWiperParams.interval)
// go out
{
if (!sWiperFromParkPlayed)
{
sWiperFromPark.play(sound_flags::exclusive);
sWiperFromParkPlayed = true;
}
dWiperPos[i] = std::min(1.0, dWiperPos[i] + (1.f / currentWiperParams.WiperSpeed) * dt1);
}
if (dWiperPos[i] > 0.0 && wiperDirection[i] && wiperOutTimer[i] > currentWiperParams.outBackDelay)
// return back
{
if (!sWiperToParkPlayed)
{
sWiperToPark.play(sound_flags::exclusive);
sWiperToParkPlayed = true;
}
dWiperPos[i] = std::max(0.0, dWiperPos[i] - (1.f / currentWiperParams.WiperSpeed) * dt1);
}
if (dWiperPos[i] == 1.0) // we reached end
{
sWiperFromPark.stop();
sWiperFromParkPlayed = false;
wiperParkTimer[i] = 0.0;
wiperDirection[i] = true; // switch direction
}
if (dWiperPos[i] == 0.0)
{
// when in park position
sWiperToPark.stop();
sWiperToParkPlayed = false;
wiperOutTimer[i] = 0.0;
wiperDirection[i] = false;
workingSwitchPos[i] = MoverParameters->wiperSwitchPos; // update configuration
@@ -6738,12 +6752,12 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
}
// dzwieki wycieraczkuf
else if (token == "wiperFromPark:")
else if (token == "wiperfrompark:")
{
sWiperFromPark.deserialize(parser, sound_type::single);
sWiperFromPark.owner(this);
}
else if (token == "wiperToPark:")
else if (token == "wipertopark:")
{
sWiperToPark.deserialize(parser, sound_type::single);
sWiperToPark.owner(this);

View File

@@ -547,7 +547,10 @@ private:
sound_source rsSlippery { sound_placement::external, EU07_SOUND_BRAKINGCUTOFFRANGE }; // moved from cab
sound_source sSand { sound_placement::external };
sound_source sWiperToPark { sound_placement::internal };
bool sWiperToParkPlayed{false};
sound_source sWiperFromPark { sound_placement::internal };
bool sWiperFromParkPlayed{false};
// moving part and other external sounds
sound_source m_startjolt { sound_placement::general }; // movement start jolt, played once on initial acceleration at slow enough speed
bool m_startjoltplayed { false };