Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for flashlight on/off sounds #1149

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/xrGame/Torch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ void CTorch::Load(LPCSTR section)
light_trace_bone = pSettings->r_string(section, "light_trace_bone");

m_bNightVisionEnabled = !!pSettings->r_bool(section, "night_vision");

if (pSettings->line_exist(section, "snd_turn_on"))
m_sounds.LoadSound(section, "snd_turn_on", "sndTurnOn", false, SOUND_TYPE_ITEM_USING);
if (pSettings->line_exist(section, "snd_turn_off"))
m_sounds.LoadSound(section, "snd_turn_off", "sndTurnOff", false, SOUND_TYPE_ITEM_USING);
}

void CTorch::SwitchNightVision()
Expand Down Expand Up @@ -170,6 +175,21 @@ void CTorch::Switch()

void CTorch::Switch(bool light_on)
{
CActor* pActor = smart_cast<CActor*>(H_Parent());
if (pActor)
{
if (light_on && !m_switched_on)
{
if (m_sounds.FindSoundItem("SndTurnOn", false))
m_sounds.PlaySound("SndTurnOn", pActor->Position(), NULL, !!pActor->HUDview());
}
else if (!light_on && m_switched_on)
{
if (m_sounds.FindSoundItem("SndTurnOff", false))
m_sounds.PlaySound("SndTurnOff", pActor->Position(), NULL, !!pActor->HUDview());
}
}

m_switched_on = light_on;
if (can_use_dynamic_lights())
{
Expand Down