From ed6147ce0bb3fa83f58d73b5f6d2bd7fa4fe3808 Mon Sep 17 00:00:00 2001 From: Pizzaoverhead Date: Sat, 15 Feb 2014 19:17:21 +0000 Subject: [PATCH] Fixes order lines not being shown after reselect once their lifetime has expired. Adds INotifyBecomingIdle. --- CHANGELOG | 1 + OpenRA.Game/Actor.cs | 4 ++++ OpenRA.Game/Selection.cs | 5 +++++ OpenRA.Game/Traits/DrawLineToTarget.cs | 14 +++++++++++++- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index cae86bc86a..7ed2ef641b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ NEW: Added Ctrl+T shortcut for selection of all units matching the types of the currently selected ones across the screen and map. Added a toggle spectators to multiplayer. Removed the ability of commandos to plant C4 on walls. + Order lines are now shown on unit selection. Dune 2000: Added the Atreides grenadier from the 1.06 patch. Added randomized tiles for Sand and Rock terrain. diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 1067e1ad7a..9a916d0b72 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -94,7 +94,11 @@ namespace OpenRA public void Tick() { + var wasIdle = IsIdle; currentActivity = Traits.Util.RunActivity(this, currentActivity); + if (!wasIdle && IsIdle) + foreach (var n in TraitsImplementing()) + n.OnBecomingIdle(this); } public bool IsIdle diff --git a/OpenRA.Game/Selection.cs b/OpenRA.Game/Selection.cs index 7e59fc9753..e4bd22d589 100644 --- a/OpenRA.Game/Selection.cs +++ b/OpenRA.Game/Selection.cs @@ -22,6 +22,8 @@ namespace OpenRA public void Add(World w, Actor a) { actors.Add(a); + foreach (var sel in a.TraitsImplementing()) + sel.Selected(a); foreach (var ns in w.WorldActor.TraitsImplementing()) ns.SelectionChanged(); } @@ -47,6 +49,9 @@ namespace OpenRA if (voicedUnit != null) Sound.PlayVoice("Select", voicedUnit, voicedUnit.Owner.Country.Race); + foreach (var a in newSelection) + foreach (var sel in a.TraitsImplementing()) + sel.Selected(a); foreach (var ns in world.WorldActor.TraitsImplementing()) ns.SelectionChanged(); } diff --git a/OpenRA.Game/Traits/DrawLineToTarget.cs b/OpenRA.Game/Traits/DrawLineToTarget.cs index bbe127aa82..3448cc9165 100644 --- a/OpenRA.Game/Traits/DrawLineToTarget.cs +++ b/OpenRA.Game/Traits/DrawLineToTarget.cs @@ -21,7 +21,7 @@ namespace OpenRA.Traits public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.self, this); } } - public class DrawLineToTarget : IPostRenderSelection + public class DrawLineToTarget : IPostRenderSelection, INotifySelected, INotifyBecomingIdle { Actor self; DrawLineToTargetInfo Info; @@ -49,6 +49,12 @@ namespace OpenRA.Traits lifetime = Info.Ticks; } + public void Selected(Actor a) + { + // Reset the order line timeout. + lifetime = Info.Ticks; + } + public void RenderAfterWorld(WorldRenderer wr) { var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt); @@ -70,6 +76,12 @@ namespace OpenRA.Traits wr.DrawTargetMarker(c, to); } } + + public void OnBecomingIdle(Actor a) + { + if (a.IsIdle) + targets = null; + } } public static class LineTargetExts diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 4ec93f80e9..a05f8893d3 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -184,6 +184,7 @@ namespace OpenRA.Traits public interface Requires where T : class { } public interface UsesInit where T : IActorInit { } + public interface INotifySelected { void Selected(Actor self); } public interface INotifySelection { void SelectionChanged(); } public interface IWorldLoaded { void WorldLoaded(World w, WorldRenderer wr); } public interface ICreatePlayers { void CreatePlayers(World w); } @@ -196,6 +197,7 @@ namespace OpenRA.Traits } public interface IRenderOverlay { void Render(WorldRenderer wr); } + public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); } public interface INotifyIdle { void TickIdle(Actor self); } public interface IBlocksBullets { }