Delay loading the observer UI until the game is actually over
This commit is contained in:
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class MissionObjectives : INotifyObjectivesUpdated, ISync, IResolveOrder
|
||||
{
|
||||
readonly MissionObjectivesInfo info;
|
||||
public readonly MissionObjectivesInfo Info;
|
||||
readonly List<MissionObjective> objectives = new List<MissionObjective>();
|
||||
public ReadOnlyList<MissionObjective> Objectives;
|
||||
|
||||
@@ -64,9 +64,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// The player's WinState is only updated when his allies have all completed their objective as well.
|
||||
public WinState WinStateCooperative { get; private set; }
|
||||
|
||||
public MissionObjectives(World world, MissionObjectivesInfo moInfo)
|
||||
public MissionObjectives(World world, MissionObjectivesInfo info)
|
||||
{
|
||||
info = moInfo;
|
||||
Info = info;
|
||||
Objectives = new ReadOnlyList<MissionObjective>(objectives);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var gameOver = players.All(p => p.WinState != WinState.Undefined || !p.HasObjectives);
|
||||
if (gameOver)
|
||||
Game.RunAfterDelay(info.GameOverDelay, () =>
|
||||
Game.RunAfterDelay(Info.GameOverDelay, () =>
|
||||
{
|
||||
player.World.EndGame();
|
||||
player.World.SetPauseState(true);
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var players = player.World.Players.Where(p => !p.NonCombatant);
|
||||
var enemies = players.Where(p => !p.IsAlliedWith(player));
|
||||
|
||||
if (info.Cooperative)
|
||||
if (Info.Cooperative)
|
||||
{
|
||||
WinStateCooperative = WinState.Won;
|
||||
var allies = players.Where(p => p.IsAlliedWith(player));
|
||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
p.World.OnPlayerWinStateChanged(p);
|
||||
}
|
||||
|
||||
if (info.EarlyGameOver)
|
||||
if (Info.EarlyGameOver)
|
||||
foreach (var p in enemies)
|
||||
p.PlayerActor.Trait<MissionObjectives>().ForceDefeat(p);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
player.WinState = WinState.Won;
|
||||
player.World.OnPlayerWinStateChanged(player);
|
||||
|
||||
if (info.EarlyGameOver)
|
||||
if (Info.EarlyGameOver)
|
||||
foreach (var p in enemies)
|
||||
p.PlayerActor.Trait<MissionObjectives>().ForceDefeat(p);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var players = player.World.Players.Where(p => !p.NonCombatant);
|
||||
var enemies = players.Where(p => !p.IsAlliedWith(player));
|
||||
|
||||
if (info.Cooperative)
|
||||
if (Info.Cooperative)
|
||||
{
|
||||
WinStateCooperative = WinState.Lost;
|
||||
var allies = players.Where(p => p.IsAlliedWith(player));
|
||||
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
p.World.OnPlayerWinStateChanged(p);
|
||||
}
|
||||
|
||||
if (info.EarlyGameOver)
|
||||
if (Info.EarlyGameOver)
|
||||
foreach (var p in enemies)
|
||||
p.PlayerActor.Trait<MissionObjectives>().ForceDefeat(p);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
player.WinState = WinState.Lost;
|
||||
player.World.OnPlayerWinStateChanged(player);
|
||||
|
||||
if (info.EarlyGameOver)
|
||||
if (Info.EarlyGameOver)
|
||||
foreach (var p in enemies)
|
||||
{
|
||||
p.WinState = WinState.Won;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Scripting;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -29,12 +30,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
|
||||
var sidebarTicker = playerWidgets.Get<LogicTickerWidget>("SIDEBAR_TICKER");
|
||||
var objectives = world.LocalPlayer.PlayerActor.TraitOrDefault<MissionObjectives>();
|
||||
|
||||
sidebarTicker.OnTick = () =>
|
||||
{
|
||||
// Switch to observer mode after win/loss
|
||||
if (world.LocalPlayer.WinState != WinState.Undefined)
|
||||
Game.RunAfterTick(() =>
|
||||
Game.RunAfterDelay(objectives != null ? objectives.Info.GameOverDelay : 0, () =>
|
||||
{
|
||||
world.LocalPlayer.Spectating = true;
|
||||
playerRoot.RemoveChildren();
|
||||
|
||||
Reference in New Issue
Block a user