Loaded sounds are properly freed, ObjectProperty optimization, expanded skill effects (rangedweapon accuracy, welding efficiency, electrical shocks), armored wearables + ballistic vest & helmet
This commit is contained in:
@@ -71,22 +71,22 @@ namespace Subsurface
|
||||
{
|
||||
|
||||
|
||||
startDrone = Sound.Load("Content/Sounds/startDrone.ogg");
|
||||
startDrone = Sound.Load("Content/Sounds/startDrone.ogg", false);
|
||||
startDrone.Play();
|
||||
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
|
||||
waterAmbiences[0] = Sound.Load("Content/Sounds/Water/WaterAmbience1.ogg");
|
||||
waterAmbiences[0] = Sound.Load("Content/Sounds/Water/WaterAmbience1.ogg", false);
|
||||
yield return CoroutineStatus.Running;
|
||||
waterAmbiences[1] = Sound.Load("Content/Sounds/Water/WaterAmbience2.ogg");
|
||||
waterAmbiences[1] = Sound.Load("Content/Sounds/Water/WaterAmbience2.ogg", false);
|
||||
yield return CoroutineStatus.Running;
|
||||
flowSounds[0] = Sound.Load("Content/Sounds/Water/FlowSmall.ogg");
|
||||
flowSounds[0] = Sound.Load("Content/Sounds/Water/FlowSmall.ogg", false);
|
||||
yield return CoroutineStatus.Running;
|
||||
flowSounds[1] = Sound.Load("Content/Sounds/Water/FlowMedium.ogg");
|
||||
flowSounds[1] = Sound.Load("Content/Sounds/Water/FlowMedium.ogg", false);
|
||||
yield return CoroutineStatus.Running;
|
||||
flowSounds[2] = Sound.Load("Content/Sounds/Water/FlowLarge.ogg");
|
||||
flowSounds[2] = Sound.Load("Content/Sounds/Water/FlowLarge.ogg", false);
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml("Content/Sounds/sounds.xml");
|
||||
@@ -124,7 +124,7 @@ namespace Subsurface
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
Sound sound = Sound.Load(ToolBox.GetAttributeString(element, "file", ""));
|
||||
Sound sound = Sound.Load(ToolBox.GetAttributeString(element, "file", ""), false);
|
||||
if (sound == null) continue;
|
||||
|
||||
DamageSoundType damageSoundType = DamageSoundType.None;
|
||||
@@ -155,13 +155,10 @@ namespace Subsurface
|
||||
{
|
||||
UpdateMusic();
|
||||
|
||||
if (startDrone!=null)
|
||||
if (startDrone!=null && !startDrone.IsPlaying)
|
||||
{
|
||||
if (!startDrone.IsPlaying)
|
||||
{
|
||||
startDrone.Remove();
|
||||
startDrone = null;
|
||||
}
|
||||
startDrone.Remove();
|
||||
startDrone = null;
|
||||
}
|
||||
|
||||
float ambienceVolume = 0.6f;
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Subsurface
|
||||
string filePath;
|
||||
|
||||
private int alSourceId;
|
||||
|
||||
private bool destroyOnGameEnd;
|
||||
|
||||
|
||||
//public float Volume
|
||||
@@ -28,6 +30,25 @@ namespace Subsurface
|
||||
// set { SoundManager.Volume(sourceIndex, value); }
|
||||
//}
|
||||
|
||||
private Sound(string file, bool destroyOnGameEnd)
|
||||
{
|
||||
filePath = file;
|
||||
|
||||
foreach (Sound loadedSound in loadedSounds)
|
||||
{
|
||||
if (loadedSound.filePath == file) oggSound = loadedSound.oggSound;
|
||||
}
|
||||
|
||||
if (oggSound == null)
|
||||
{
|
||||
oggSound = OggSound.Load(file);
|
||||
}
|
||||
|
||||
this.destroyOnGameEnd = destroyOnGameEnd;
|
||||
|
||||
loadedSounds.Add(this);
|
||||
}
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get { return filePath; }
|
||||
@@ -43,32 +64,15 @@ namespace Subsurface
|
||||
SoundManager.Init();
|
||||
}
|
||||
|
||||
public static Sound Load(string file)
|
||||
public static Sound Load(string file, bool destroyOnGameEnd = true)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
DebugConsole.ThrowError("File ''" + file + "'' not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
Sound s = new Sound();
|
||||
|
||||
s.filePath = file;
|
||||
|
||||
foreach (Sound loadedSound in loadedSounds)
|
||||
{
|
||||
if (loadedSound.filePath == file) s.oggSound = loadedSound.oggSound;
|
||||
}
|
||||
|
||||
if (s.oggSound == null)
|
||||
{
|
||||
s.oggSound = OggSound.Load(file);
|
||||
|
||||
}
|
||||
|
||||
loadedSounds.Add(s);
|
||||
|
||||
return s;
|
||||
return new Sound(file, destroyOnGameEnd);
|
||||
}
|
||||
|
||||
public int Play(float volume = 1.0f)
|
||||
@@ -212,12 +216,27 @@ namespace Subsurface
|
||||
//{
|
||||
// SoundManager.Stop(this);
|
||||
//}
|
||||
|
||||
public static void OnGameEnd()
|
||||
{
|
||||
List<Sound> removableSounds = loadedSounds.FindAll(s => s.destroyOnGameEnd);
|
||||
|
||||
foreach (Sound sound in removableSounds)
|
||||
{
|
||||
sound.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
loadedSounds.Remove(this);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(AlBufferId);
|
||||
System.Diagnostics.Debug.WriteLine("Removing sound " + filePath + " (buffer id" + AlBufferId + ")");
|
||||
|
||||
if (alSourceId>0 && SoundManager.IsPlaying(alSourceId))
|
||||
{
|
||||
SoundManager.Stop(alSourceId);
|
||||
}
|
||||
|
||||
foreach (Sound s in loadedSounds)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user