Same unit command sounds wont overlap anymore
Responding to Travis inquiries Changed Hashtable for Ditctionary + avoiding code duplication More small code nits another nit
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
@@ -39,6 +40,7 @@ namespace OpenRA
|
|||||||
ISound music;
|
ISound music;
|
||||||
ISound video;
|
ISound video;
|
||||||
MusicInfo currentMusic;
|
MusicInfo currentMusic;
|
||||||
|
Dictionary<uint, ISound> currentSounds = new Dictionary<uint, ISound>();
|
||||||
|
|
||||||
public Sound(IPlatform platform, SoundSettings soundSettings)
|
public Sound(IPlatform platform, SoundSettings soundSettings)
|
||||||
{
|
{
|
||||||
@@ -348,9 +350,18 @@ namespace OpenRA
|
|||||||
var name = prefix + clip + suffix;
|
var name = prefix + clip + suffix;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
||||||
soundEngine.Play2D(sounds[name],
|
{
|
||||||
|
var sound = soundEngine.Play2D(sounds[name],
|
||||||
false, relative, pos,
|
false, relative, pos,
|
||||||
InternalSoundVolume * volumeModifier, attenuateVolume);
|
InternalSoundVolume * volumeModifier, attenuateVolume);
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
if (currentSounds.ContainsKey(id))
|
||||||
|
soundEngine.StopSound(currentSounds[id]);
|
||||||
|
|
||||||
|
currentSounds[id] = sound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user