Reduce mission music code duplication

This commit is contained in:
Scott_NZ
2012-12-31 17:37:54 +13:00
parent c8e84b3a11
commit 82809f27f7
6 changed files with 30 additions and 106 deletions

View File

@@ -34,11 +34,12 @@ namespace OpenRA.Mods.RA.Missions
Dictionary<int, Objective> objectives = new Dictionary<int, Objective>
{
{ InfiltrateID, new Objective(ObjectiveType.Primary, "", ObjectiveStatus.InProgress) },
{ DestroyID, new Objective(ObjectiveType.Primary, "Secure the laboratory and destroy the rest of the Soviet base. Ensure that the laboratory is not destroyed.", ObjectiveStatus.Inactive) }
{ DestroyID, new Objective(ObjectiveType.Primary, Destroy, ObjectiveStatus.Inactive) }
};
const int InfiltrateID = 0;
const int DestroyID = 1;
const string Destroy = "Secure the laboratory and destroy the rest of the Soviet base. Ensure that the laboratory is not destroyed.";
const string Infiltrate = "The Soviets are currently developing a new defensive system named the \"Iron Curtain\" at their main research laboratory. Get our {0} into the laboratory undetected.";
Actor lstEntryPoint;
@@ -415,27 +416,7 @@ namespace OpenRA.Mods.RA.Missions
OnObjectivesUpdated(false);
SetupSubStances();
Game.MoveViewport(lstEntryPoint.Location.ToFloat2());
PlayMusic();
Game.ConnectionStateChanged += StopMusic;
}
void PlayMusic()
{
if (!Rules.InstalledMusic.Any())
{
return;
}
var track = Rules.InstalledMusic.Random(Game.CosmeticRandom);
Sound.PlayMusicThen(track.Value, PlayMusic);
}
void StopMusic(OrderManager orderManager)
{
if (!orderManager.GameStarted)
{
Sound.StopMusic();
Game.ConnectionStateChanged -= StopMusic;
}
MissionUtils.PlayMissionMusic();
}
}