Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit bb6a04f

Browse files
committed
Add support for looping stride sounds
1 parent 37f01df commit bb6a04f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Entities/ACrab.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,15 @@ void ACrab::Update()
24472447

24482448
// Reset the right-side walking stride if it's taking longer than it should.
24492449
if (m_StrideTimer[RIGHTSIDE].IsPastSimMS(static_cast<double>(m_Paths[RIGHTSIDE][FGROUND][WALK].GetTotalPathTime() * 1.1F))) { m_StrideStart[RIGHTSIDE] = true; }
2450-
2451-
if (restarted && m_StrideSound) { m_StrideSound->Play(m_Pos); }
2450+
2451+
if (m_StrideSound) {
2452+
m_StrideSound->SetPosition(m_Pos);
2453+
if (m_StrideSound->GetLoopSetting() < 0) {
2454+
if (!m_StrideSound->IsBeingPlayed()) { m_StrideSound->Play(); }
2455+
} else if (restarted) {
2456+
m_StrideSound->Play();
2457+
}
2458+
}
24522459
} else if (m_pLFGLeg || m_pLBGLeg || m_pRFGLeg || m_pRBGLeg) {
24532460
if (m_MoveState == JUMP) {
24542461
// TODO: Utilize jump paths in an intuitive way?
@@ -2498,6 +2505,9 @@ void ACrab::Update()
24982505

24992506
if (m_pRBGLeg) { m_pRBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pRBGLeg->GetParentOffset()), m_pRBGLeg->GetMaxLength(), m_PrevVel * m_pRBGLeg->GetJointStiffness(), m_AngularVel, m_pRBGLeg->GetMass(), deltaTime); }
25002507
}
2508+
if (m_MoveState != WALK && m_StrideSound && m_StrideSound->GetLoopSetting() < 0) {
2509+
m_StrideSound->Stop();
2510+
}
25012511

25022512
/////////////////////////////////
25032513
// Manage Attachable:s

Entities/AHuman.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,6 +3582,7 @@ void AHuman::Update()
35823582
}
35833583
bool climbing = m_ArmClimbing[FGROUND] || m_ArmClimbing[BGROUND];
35843584

3585+
}
35853586
if (restarted) {
35863587
if (!climbing) {
35873588
if (m_StrideSound) { m_StrideSound->Play(m_Pos); }
@@ -3732,6 +3733,9 @@ void AHuman::Update()
37323733

37333734
if (m_pBGLeg) { m_pBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pBGLeg->GetParentOffset()), m_pBGLeg->GetMaxLength(), m_PrevVel * m_pBGLeg->GetJointStiffness(), m_AngularVel, m_pBGLeg->GetMass(), deltaTime); }
37343735
}
3736+
if (m_MoveState != WALK && m_StrideSound && m_StrideSound->GetLoopSetting() < 0) {
3737+
m_StrideSound->Stop();
3738+
}
37353739

37363740
/////////////////////////////////
37373741
// Manage Attachables

0 commit comments

Comments
 (0)