From 33693738797a4911584d6c23a7cceda0005e8828 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 8 Feb 2011 18:20:25 +1300 Subject: [PATCH] initial setup for decorating the PlaceBuilding OG --- OpenRA.Mods.RA/AttackBase.cs | 1 - .../Orders/PlaceBuildingOrderGenerator.cs | 6 +++++- OpenRA.Mods.RA/RenderRangeCircle.cs | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index 32ef09d81c..d8f9bd567d 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -12,7 +12,6 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Linq; -using OpenRA.Effects; using OpenRA.FileFormats; using OpenRA.Traits; diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 65686e9d52..83f2d12fed 100755 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -12,8 +12,8 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.RA.Buildings; -using OpenRA.Traits; using OpenRA.Mods.RA.Render; +using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders { @@ -70,6 +70,10 @@ namespace OpenRA.Mods.RA.Orders { var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2(); var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo ); + + var actorInfo = Rules.Info[Building]; + foreach (var dec in actorInfo.Traits.WithInterface()) + dec.Render(wr, world, actorInfo, Traits.Util.CenterOfCell(position)); /* hack hack */ var cells = new Dictionary(); // Linebuild for walls. diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index 561cfc6b43..4c1ec48434 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -14,7 +14,23 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class RenderRangeCircleInfo : TraitInfo { } + public interface IPlaceBuildingDecoration + { + void Render(WorldRenderer wr, World w, ActorInfo ai, int2 centerLocation); + } + + class RenderRangeCircleInfo : TraitInfo, IPlaceBuildingDecoration + { + public readonly string RangeCircleType; + + public void Render(WorldRenderer wr, World w, ActorInfo ai, int2 centerLocation) + { + wr.DrawRangeCircle( + Color.FromArgb(128, Color.Yellow), + centerLocation, 3 /* hack: get this from the ActorInfo, but it's nontrivial currently */); + } + } + class RenderRangeCircle : IPreRenderSelection { public void RenderBeforeWorld(WorldRenderer wr, Actor self)