MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / playMovementSound

Method playMovementSound

src/Battlescape/UnitWalkBState.cpp:546–590  ·  view source on GitHub ↗

* Handles the stepping sounds. */

Source from the content-addressed store, hash-verified

544 * Handles the stepping sounds.
545 */
546void UnitWalkBState::playMovementSound()
547{
548 if ((!_unit->getVisible() && !_parent->getSave()->getDebugMode()) || !_parent->getMap()->getCamera()->isOnScreen(_unit->getPosition(), true)) return;
549
550 if (_unit->getMoveSound() != -1)
551 {
552 // if a sound is configured in the ruleset, play that one
553 if (_unit->getWalkingPhase() == 0)
554 {
555 _parent->getResourcePack()->getSound("BATTLE.CAT", _unit->getMoveSound())->play();
556 }
557 }
558 else
559 {
560 if (_unit->getStatus() == STATUS_WALKING)
561 {
562 Tile *tile = _unit->getTile();
563 Tile *tileBelow = _parent->getSave()->getTile(tile->getPosition() + Position(0,0,-1));
564 // play footstep sound 1
565 if (_unit->getWalkingPhase() == 3)
566 {
567 if (tile->getFootstepSound(tileBelow))
568 {
569 _parent->getResourcePack()->getSound("BATTLE.CAT", 22 + (tile->getFootstepSound(tileBelow)*2))->play();
570 }
571 }
572 // play footstep sound 2
573 if (_unit->getWalkingPhase() == 7)
574 {
575 if (tile->getFootstepSound(tileBelow))
576 {
577 _parent->getResourcePack()->getSound("BATTLE.CAT", 23 + (tile->getFootstepSound(tileBelow)*2))->play();
578 }
579 }
580 }
581 else
582 {
583 // play default flying sound
584 if (_unit->getWalkingPhase() == 1 && !_falling)
585 {
586 _parent->getResourcePack()->getSound("BATTLE.CAT", 15)->play();
587 }
588 }
589 }
590}
591
592}

Callers

nothing calls this directly

Calls 15

getSaveMethod · 0.80
isOnScreenMethod · 0.80
getCameraMethod · 0.80
getWalkingPhaseMethod · 0.80
PositionClass · 0.70
getVisibleMethod · 0.45
getDebugModeMethod · 0.45
getMapMethod · 0.45
getPositionMethod · 0.45
getMoveSoundMethod · 0.45
playMethod · 0.45
getSoundMethod · 0.45

Tested by

no test coverage detected