Improve the music-playing code - crash prevention and some polish
This commit is contained in:
@@ -102,10 +102,6 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!Sound.MusicPlaying)
|
||||
{
|
||||
PlayMusic();
|
||||
}
|
||||
if (allies.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
@@ -297,14 +293,19 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
FlyTanyaToInsertionLZ();
|
||||
SendPatrol();
|
||||
PlayMusic();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void PlayMusic()
|
||||
{
|
||||
if (!Rules.InstalledMusic.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var track = Rules.InstalledMusic.Random(Game.CosmeticRandom);
|
||||
Sound.PlayMusic(track.Value);
|
||||
Sound.PlayMusicThen(track.Value, PlayMusic);
|
||||
}
|
||||
|
||||
void StopMusic(OrderManager orderManager)
|
||||
|
||||
@@ -134,10 +134,6 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!Sound.MusicPlaying)
|
||||
{
|
||||
PlayMusic();
|
||||
}
|
||||
if (allies1.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
@@ -441,13 +437,18 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
Game.MoveViewport(allies2BasePoint.Location.ToFloat2());
|
||||
}
|
||||
PlayMusic();
|
||||
Game.ConnectionStateChanged += StopMusic;
|
||||
}
|
||||
|
||||
void PlayMusic()
|
||||
{
|
||||
if (!Rules.InstalledMusic.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var track = Rules.InstalledMusic.Random(Game.CosmeticRandom);
|
||||
Sound.PlayMusic(track.Value);
|
||||
Sound.PlayMusicThen(track.Value, PlayMusic);
|
||||
}
|
||||
|
||||
void StopMusic(OrderManager orderManager)
|
||||
|
||||
Reference in New Issue
Block a user