diff --git a/OpenRA.Mods.RA/UnitStances/UnitStance.cs b/OpenRA.Mods.RA/UnitStances/UnitStance.cs index fc05a57e67..93623d4e1f 100644 --- a/OpenRA.Mods.RA/UnitStances/UnitStance.cs +++ b/OpenRA.Mods.RA/UnitStances/UnitStance.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -22,7 +24,7 @@ namespace OpenRA.Mods.RA #endregion } - public abstract class UnitStance : ITick, IResolveOrder, ISelectionColorModifier + public abstract class UnitStance : ITick, IResolveOrder, ISelectionColorModifier, IPostRenderSelection { [Sync] public int NextScanTime; @@ -213,5 +215,58 @@ namespace OpenRA.Mods.RA return Active ? SelectionColor : defaultColor; } + + public void RenderAfterWorld(WorldRenderer wr, Actor self) + { + if (!Active) return; + if (!self.IsInWorld) return; + if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] != Stance.Ally) + return; + + RenderStance(self); + } + + protected virtual string Shape + { + get { return "xxxx\nx x\nx x\nxxxx"; } + } + + private void RenderStance(Actor self) + { + var bounds = self.GetBounds(true); + var loc = new float2(bounds.Left, bounds.Top) + new float2(1, 2); + var max = Math.Max(bounds.Height, bounds.Width); + + var shape = Shape; + + // 'Resize' for large actors + if (max >= Game.CellSize) + { + shape = shape.Replace(" ", " "); + shape = shape.Replace("x", "xx"); + } + + int y = 0; + var shapeLines = shape.Split('\n'); + + foreach (var shapeLine in shapeLines) + { + for (int yt = 0; yt < ((max >= Game.CellSize) ? 2 : 1); yt++) + { + int x = 0; + + foreach (var shapeKey in shapeLine) + { + if (shapeKey == 'x') + { + Game.Renderer.LineRenderer.DrawLine(loc + new float2(x, y), loc + new float2(x + 1f, y),SelectionColor, SelectionColor); + } + + x++; + } + y++; + } + } + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/UnitStances/UnitStanceAggressive.cs b/OpenRA.Mods.RA/UnitStances/UnitStanceAggressive.cs index ade82d0de5..ae13556943 100644 --- a/OpenRA.Mods.RA/UnitStances/UnitStanceAggressive.cs +++ b/OpenRA.Mods.RA/UnitStances/UnitStanceAggressive.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Drawing; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -12,14 +14,18 @@ namespace OpenRA.Mods.RA /// /// Inherits the Return Fire damage handler! /// - public class UnitStanceAggressive : UnitStance, INotifyDamage, ISelectionColorModifier + public class UnitStanceAggressive : UnitStance, INotifyDamage { public UnitStanceAggressive(Actor self, UnitStanceAggressiveInfo info) : base(self, info) { + RankAnim = new Animation("rank"); + RankAnim.PlayFetchIndex("rank", () => 3 - 1); } + protected Animation RankAnim { get; set; } + public override string OrderString { get { return "StanceAggressive"; } @@ -57,5 +63,10 @@ namespace OpenRA.Mods.RA { get { return Color.Red; } } + + protected override string Shape + { + get { return "x x\n xx \n xx \nx x"; } + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/UnitStances/UnitStanceGuard.cs b/OpenRA.Mods.RA/UnitStances/UnitStanceGuard.cs index efc06d90d0..4e4b8ab642 100644 --- a/OpenRA.Mods.RA/UnitStances/UnitStanceGuard.cs +++ b/OpenRA.Mods.RA/UnitStances/UnitStanceGuard.cs @@ -56,5 +56,10 @@ namespace OpenRA.Mods.RA { get { return Color.Yellow; } } + + protected override string Shape + { + get { return "xxx\nx x\nx x\nxxx"; } + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/UnitStances/UnitStanceHoldFire.cs b/OpenRA.Mods.RA/UnitStances/UnitStanceHoldFire.cs index 6cc806c8ce..0f75b24b80 100644 --- a/OpenRA.Mods.RA/UnitStances/UnitStanceHoldFire.cs +++ b/OpenRA.Mods.RA/UnitStances/UnitStanceHoldFire.cs @@ -39,5 +39,10 @@ namespace OpenRA.Mods.RA { get { return Color.SpringGreen; } } + + protected override string Shape + { + get { return " xx \nxxxx\n xx "; } + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs b/OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs index 0a2133260c..c62b74cf84 100644 --- a/OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs +++ b/OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs @@ -39,5 +39,9 @@ namespace OpenRA.Mods.RA { get { return Color.Orange; } } + protected override string Shape + { + get { return "xxx\nxxx\nxxx\n x \n x \n\nxxx \nxxx "; } + } } } \ No newline at end of file