diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 3edcb4b08c..83f0e85f4a 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -106,6 +106,9 @@ namespace OpenRA.Orders if (self.Owner != self.World.LocalPlayer) return null; + if (self.World.IsGameOver) + return null; + if (self.Disposed || !target.IsValidFor(self)) return null; diff --git a/OpenRA.Game/Selection.cs b/OpenRA.Game/Selection.cs index 7b47d03fe8..3c8be43f42 100644 --- a/OpenRA.Game/Selection.cs +++ b/OpenRA.Game/Selection.cs @@ -57,6 +57,16 @@ namespace OpenRA } } + foreach (var a in newSelection) + foreach (var sel in a.TraitsImplementing()) + sel.Selected(a); + + foreach (var ns in world.WorldActor.TraitsImplementing()) + ns.SelectionChanged(); + + if (world.IsGameOver) + return; + // Play the selection voice from one of the selected actors // TODO: This probably should only be considering the newly selected actors // TODO: Ship this into an INotifySelection trait to remove the engine dependency on Selectable @@ -72,12 +82,6 @@ namespace OpenRA actor.PlayVoice(selectable.Voice); break; } - - foreach (var a in newSelection) - foreach (var sel in a.TraitsImplementing()) - sel.Selected(a); - foreach (var ns in world.WorldActor.TraitsImplementing()) - ns.SelectionChanged(); } public IEnumerable Actors { get { return actors; } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index d65f31a443..3c35edf28d 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -232,13 +232,13 @@ namespace OpenRA.Widgets if (key == Game.Settings.Keys.PauseKey && World.LocalPlayer != null) // Disable pausing for spectators World.SetPauseState(!World.Paused); - else if (key == Game.Settings.Keys.SelectAllUnitsKey) + else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver) { // Select actors on the screen which belong to the current player var ownUnitsOnScreen = SelectActorsOnScreen(World, worldRenderer, null, player).SubsetWithHighestSelectionPriority(); World.Selection.Combine(World, ownUnitsOnScreen, false, false); } - else if (key == Game.Settings.Keys.SelectUnitsByTypeKey) + else if (key == Game.Settings.Keys.SelectUnitsByTypeKey && !World.IsGameOver) { // Get all the selected actors' selection classes var selectedClasses = World.Selection.Actors diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index eeb224692a..daabba3b35 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -52,12 +52,12 @@ namespace OpenRA public Player LocalPlayer { get; private set; } public event Action GameOver = () => { }; - bool gameOver; + public bool IsGameOver { get; private set; } public void EndGame() { - if (!gameOver) + if (!IsGameOver) { - gameOver = true; + IsGameOver = true; foreach (var t in WorldActor.TraitsImplementing()) t.GameOver(this); diff --git a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs index 0f5486baaa..d499ddb80f 100644 --- a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets return ToSelection(); // Put all functions that aren't unit-specific before this line! - if (!world.Selection.Actors.Any()) + if (!world.Selection.Actors.Any() || world.IsGameOver) return false; if (key == ks.AttackMoveKey)