playSfx method

void playSfx(
  1. SfxType type
)

Implementation

void playSfx(SfxType type) {
  final muted = _settings?.muted.value ?? true;
  if (muted) {
    return;
  }
  final soundsOn = _settings?.soundsOn.value ?? false;
  if (!soundsOn) {
    return;
  }

  final options = soundTypeToFilename(type);
  final filename = options[_random.nextInt(options.length)];
  _sfxCache.play(filename, volume: soundTypeToVolume(type));
  _currentSfxPlayer = (_currentSfxPlayer + 1) % _sfxPlayers.length;
  _sfxCache.fixedPlayer = _sfxPlayers[_currentSfxPlayer];
}