diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 93bbf7102d..84e24bd260 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -98,6 +98,13 @@ namespace OpenRA.Graphics Game.Renderer.Device.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height); terrainRenderer.Draw(Game.viewport); + + if (Game.controller.orderGenerator != null) + Game.controller.orderGenerator.RenderBeforeWorld(world); + + Game.Renderer.SpriteRenderer.Flush(); + Game.Renderer.LineRenderer.Flush(); + foreach (var image in worldSprites) Game.Renderer.SpriteRenderer.DrawSprite(image.Sprite, image.Pos, image.Palette); uiOverlay.Draw(world); @@ -105,7 +112,7 @@ namespace OpenRA.Graphics DrawBandBox(); if (Game.controller.orderGenerator != null) - Game.controller.orderGenerator.Render(world); + Game.controller.orderGenerator.RenderAfterWorld(world); if (world.LocalPlayer != null) world.LocalPlayer.Shroud.Draw(); diff --git a/OpenRA.Game/Orders/GenericSelectTarget.cs b/OpenRA.Game/Orders/GenericSelectTarget.cs index 9f64bf8a6d..14e458e370 100644 --- a/OpenRA.Game/Orders/GenericSelectTarget.cs +++ b/OpenRA.Game/Orders/GenericSelectTarget.cs @@ -40,7 +40,8 @@ namespace OpenRA.Orders } public virtual void Tick(World world) { } - public void Render(World world) { } + public void RenderAfterWorld(World world) { } + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; } } diff --git a/OpenRA.Game/Orders/IOrderGenerator.cs b/OpenRA.Game/Orders/IOrderGenerator.cs index f08e603611..da47eed1f6 100644 --- a/OpenRA.Game/Orders/IOrderGenerator.cs +++ b/OpenRA.Game/Orders/IOrderGenerator.cs @@ -14,9 +14,10 @@ namespace OpenRA { public interface IOrderGenerator { - IEnumerable Order( World world, int2 xy, MouseInput mi ); - void Tick( World world ); - void Render( World world ); - string GetCursor( World world, int2 xy, MouseInput mi ); + IEnumerable Order(World world, int2 xy, MouseInput mi); + void Tick(World world); + void RenderBeforeWorld(World world); + void RenderAfterWorld(World world); + string GetCursor(World world, int2 xy, MouseInput mi); } } diff --git a/OpenRA.Game/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Game/Orders/PlaceBuildingOrderGenerator.cs index efe1d34bfd..1eea88be95 100644 --- a/OpenRA.Game/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Game/Orders/PlaceBuildingOrderGenerator.cs @@ -61,11 +61,13 @@ namespace OpenRA.Orders Game.controller.CancelInputMode(); } - public void Render( World world ) + public void RenderAfterWorld( World world ) { world.WorldRenderer.uiOverlay.DrawBuildingGrid( world, Building, BuildingInfo ); } + public void RenderBeforeWorld(World world) { } + public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; } } } diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index e66c0d8a9a..cc79cc4428 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -35,13 +35,18 @@ namespace OpenRA.Orders public void Tick( World world ) {} - public void Render( World world ) + public void RenderBeforeWorld(World world) { foreach (var a in Game.controller.selection.Actors) - { - foreach (var t in a.traits.WithInterface()) - t.Render(a); - } + foreach (var t in a.traits.WithInterface()) + t.RenderBeforeWorld(a); + } + + public void RenderAfterWorld( World world ) + { + foreach (var a in Game.controller.selection.Actors) + foreach (var t in a.traits.WithInterface()) + t.RenderAfterWorld(a); } public string GetCursor( World world, int2 xy, MouseInput mi ) diff --git a/OpenRA.Game/Traits/DrawLineToTarget.cs b/OpenRA.Game/Traits/DrawLineToTarget.cs index ca3f407a2d..4d767f8994 100644 --- a/OpenRA.Game/Traits/DrawLineToTarget.cs +++ b/OpenRA.Game/Traits/DrawLineToTarget.cs @@ -19,7 +19,7 @@ namespace OpenRA.Traits public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(this); } } - public class DrawLineToTarget :IRenderSelection + public class DrawLineToTarget :IPostRenderSelection { DrawLineToTargetInfo Info; public DrawLineToTarget(DrawLineToTargetInfo info) @@ -44,7 +44,7 @@ namespace OpenRA.Traits this.c = c; } - public void Render (Actor self) + public void RenderAfterWorld (Actor self) { var force = Game.controller.GetModifiers().HasModifier(Modifiers.Alt); if ((lifetime <= 0 || --lifetime <= 0) && !force) diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 6d636702cd..0364a07d8e 100755 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -23,13 +23,13 @@ namespace OpenRA.Traits public readonly float Radius = 10; } - public class Selectable : IRenderSelection + public class Selectable : IPostRenderSelection { // depends on the order of pips in TraitsInterfaces.cs! static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray" }; static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" }; - public void Render (Actor self) + public void RenderAfterWorld (Actor self) { var bounds = self.GetBounds(true); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index f1367d3e4a..6aa1c1c8ba 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -165,7 +165,8 @@ namespace OpenRA.Traits public interface IBlocksBullets { } - public interface IRenderSelection { void Render(Actor self); } + public interface IPostRenderSelection { void RenderAfterWorld(Actor self); } + public interface IPreRenderSelection { void RenderBeforeWorld(Actor self); } public struct Target // a target: either an actor, or a fixed location. { diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index b718957106..9607654613 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA public readonly string[] RearmBuildings = { "fix" }; } - class Minelayer : IIssueOrder, IResolveOrder, IOrderCursor, IRenderSelection + class Minelayer : IIssueOrder, IResolveOrder, IOrderCursor, IPostRenderSelection { /* [Sync] when sync can cope with arrays! */ public int2[] minefield = null; @@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA } int2 lastMousePos; - public void Render(World world) + public void RenderAfterWorld(World world) { var ml = minelayer.traits.Get(); var movement = minelayer.traits.Get(); @@ -130,10 +130,12 @@ namespace OpenRA.Mods.RA Game.world.WorldRenderer.DrawLocus(Color.Cyan, minefield); } + public void RenderBeforeWorld(World world) { } + public string GetCursor(World world, int2 xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* todo */ } - public void Render(Actor self) + public void RenderAfterWorld(Actor self) { if (self.Owner != self.World.LocalPlayer) return; diff --git a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs index e0fc8dec02..06e1a1535d 100755 --- a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs @@ -38,7 +38,8 @@ namespace OpenRA.Mods.RA.Orders } public void Tick(World world) { } - public void Render(World world) { } + public void RenderAfterWorld(World world) { } + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs index 9f8f55f766..d9120daba3 100755 --- a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs @@ -53,7 +53,8 @@ namespace OpenRA.Mods.RA.Orders .Any(); } - public void Render( World world ) {} + public void RenderAfterWorld( World world ) {} + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs index 21c916f322..258b0082ba 100755 --- a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs @@ -41,7 +41,8 @@ namespace OpenRA.Mods.RA.Orders } public void Tick( World world ) {} - public void Render( World world ) {} + public void RenderAfterWorld( World world ) {} + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs b/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs index 365d9675fe..ee329be462 100644 --- a/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs +++ b/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs @@ -36,11 +36,13 @@ namespace OpenRA.Mods.RA.Orders } public void Tick( World world ) { } - public void Render( World world ) + public void RenderAfterWorld( World world ) { world.WorldRenderer.DrawSelectionBox(self, Color.White); } + public void RenderBeforeWorld(World world) { } + public string GetCursor(World world, int2 xy, MouseInput mi) { if (!world.LocalPlayer.Shroud.IsExplored(xy)) diff --git a/OpenRA.Mods.RA/RenderDetectionCircle.cs b/OpenRA.Mods.RA/RenderDetectionCircle.cs index d08c3de885..496745436b 100644 --- a/OpenRA.Mods.RA/RenderDetectionCircle.cs +++ b/OpenRA.Mods.RA/RenderDetectionCircle.cs @@ -14,9 +14,9 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { class RenderDetectionCircleInfo : TraitInfo { } - class RenderDetectionCircle : IRenderSelection + class RenderDetectionCircle : IPostRenderSelection { - public void Render(Actor self) + public void RenderAfterWorld(Actor self) { if (self.Owner != self.World.LocalPlayer) return; diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index c8dcc5a31f..f98b96429e 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -14,9 +14,9 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { class RenderRangeCircleInfo : TraitInfo { } - class RenderRangeCircle : IRenderSelection + class RenderRangeCircle : IPostRenderSelection { - public void Render(Actor self) + public void RenderAfterWorld(Actor self) { if (self.Owner != self.World.LocalPlayer) return; diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index 04518a6dd4..16710efe29 100755 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -93,7 +93,8 @@ namespace OpenRA.Mods.RA // TODO: Check if the selected unit is still alive } - public void Render( World world ) { } + public void RenderAfterWorld( World world ) { } + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { @@ -133,11 +134,13 @@ namespace OpenRA.Mods.RA // TODO: Check if the selected unit is still alive } - public void Render(World world) + public void RenderAfterWorld(World world) { world.WorldRenderer.DrawSelectionBox(self, Color.Red); } + public void RenderBeforeWorld(World world) { } + public string GetCursor(World world, int2 xy, MouseInput mi) { if (!world.LocalPlayer.Shroud.IsExplored(xy)) diff --git a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs index 818dac426a..0fb4974d1b 100755 --- a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs @@ -95,7 +95,8 @@ namespace OpenRA.Mods.RA Game.controller.CancelInputMode(); } - public void Render(World world) { } + public void RenderAfterWorld(World world) { } + public void RenderBeforeWorld(World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) {