Delay loading the observer UI until the game is actually over

This commit is contained in:
Oliver Brakmann
2015-07-25 00:06:41 +02:00
committed by deniz1a
parent a725d63b0c
commit a77e9c0d87
2 changed files with 13 additions and 11 deletions

View File

@@ -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();