add a looping sound trait

This commit is contained in:
Matthias Mailänder
2015-04-05 11:08:07 +02:00
parent 3f48c649f0
commit 7cbdc07ca3
3 changed files with 42 additions and 6 deletions

View File

@@ -101,7 +101,7 @@ namespace OpenRA
soundEngine.SetListenerPosition(position);
}
static ISound Play(Player player, string name, bool headRelative, WPos pos, float volumeModifier)
static ISound Play(Player player, string name, bool headRelative, WPos pos, float volumeModifier = 1f, bool loop = false)
{
if (string.IsNullOrEmpty(name))
return null;
@@ -109,16 +109,18 @@ namespace OpenRA
return null;
return soundEngine.Play2D(sounds[name],
false, headRelative, pos,
loop, headRelative, pos,
InternalSoundVolume * volumeModifier, true);
}
public static ISound Play(string name) { return Play(null, name, true, WPos.Zero, 1); }
public static ISound Play(string name, WPos pos) { return Play(null, name, false, pos, 1); }
public static ISound Play(string name) { return Play(null, name, true, WPos.Zero, 1f); }
public static ISound Play(string name, WPos pos) { return Play(null, name, false, pos, 1f); }
public static ISound Play(string name, float volumeModifier) { return Play(null, name, true, WPos.Zero, volumeModifier); }
public static ISound Play(string name, WPos pos, float volumeModifier) { return Play(null, name, false, pos, volumeModifier); }
public static ISound PlayToPlayer(Player player, string name) { return Play(player, name, true, WPos.Zero, 1); }
public static ISound PlayToPlayer(Player player, string name, WPos pos) { return Play(player, name, false, pos, 1); }
public static ISound PlayToPlayer(Player player, string name) { return Play(player, name, true, WPos.Zero, 1f); }
public static ISound PlayToPlayer(Player player, string name, WPos pos) { return Play(player, name, false, pos, 1f); }
public static ISound PlayLooped(string name) { return PlayLooped(name, WPos.Zero); }
public static ISound PlayLooped(string name, WPos pos) { return Play(null, name, true, pos, 1f, true); }
public static void PlayVideo(byte[] raw, int channels, int sampleBits, int sampleRate)
{