Fix OnObjective(Completed|Failed) not being called for secondary objectives
This commit is contained in:
@@ -79,8 +79,8 @@ namespace OpenRA.Mods.RA
|
||||
objectives.Insert(newID, new MissionObjective(type, description));
|
||||
|
||||
ObjectiveAdded(player);
|
||||
foreach (var imo in player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>())
|
||||
imo.OnObjectiveAdded(player, newID);
|
||||
foreach (var inou in player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>())
|
||||
inou.OnObjectiveAdded(player, newID);
|
||||
|
||||
return newID;
|
||||
}
|
||||
@@ -90,22 +90,23 @@ namespace OpenRA.Mods.RA
|
||||
if (objectiveID >= objectives.Count || objectives[objectiveID].State == ObjectiveState.Completed)
|
||||
return;
|
||||
|
||||
var inous = player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>();
|
||||
|
||||
objectives[objectiveID].State = ObjectiveState.Completed;
|
||||
foreach (var inou in inous)
|
||||
inou.OnObjectiveCompleted(player, objectiveID);
|
||||
|
||||
if (objectives[objectiveID].Type == ObjectiveType.Primary)
|
||||
{
|
||||
var playerWon = objectives.Where(o => o.Type == ObjectiveType.Primary).All(o => o.State == ObjectiveState.Completed);
|
||||
|
||||
foreach (var imo in player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>())
|
||||
{
|
||||
imo.OnObjectiveCompleted(player, objectiveID);
|
||||
|
||||
if (playerWon)
|
||||
imo.OnPlayerWon(player);
|
||||
}
|
||||
|
||||
if (playerWon)
|
||||
{
|
||||
foreach (var inou in inous)
|
||||
inou.OnPlayerWon(player);
|
||||
|
||||
CheckIfGameIsOver(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,22 +115,23 @@ namespace OpenRA.Mods.RA
|
||||
if (objectiveID >= objectives.Count || objectives[objectiveID].State == ObjectiveState.Failed)
|
||||
return;
|
||||
|
||||
var inous = player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>();
|
||||
|
||||
objectives[objectiveID].State = ObjectiveState.Failed;
|
||||
foreach (var inou in inous)
|
||||
inou.OnObjectiveFailed(player, objectiveID);
|
||||
|
||||
if (objectives[objectiveID].Type == ObjectiveType.Primary)
|
||||
{
|
||||
var playerLost = objectives.Where(o => o.Type == ObjectiveType.Primary).Any(o => o.State == ObjectiveState.Failed);
|
||||
|
||||
foreach (var imo in player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>())
|
||||
{
|
||||
imo.OnObjectiveFailed(player, objectiveID);
|
||||
|
||||
if (playerLost)
|
||||
imo.OnPlayerLost(player);
|
||||
}
|
||||
|
||||
if (playerLost)
|
||||
{
|
||||
foreach (var inou in inous)
|
||||
inou.OnPlayerLost(player);
|
||||
|
||||
CheckIfGameIsOver(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,14 +141,12 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var gameOver = players.All(p => p.WinState != WinState.Undefined);
|
||||
if (gameOver)
|
||||
{
|
||||
Game.RunAfterDelay(info.GameOverDelay, () =>
|
||||
{
|
||||
player.World.EndGame();
|
||||
player.World.SetPauseState(true);
|
||||
player.World.PauseStateLocked = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPlayerWon(Player player)
|
||||
|
||||
Reference in New Issue
Block a user