Added: Rendering of 'SelectionColor'ed shapes at top left of the selection rectangle (using a simple format to define shapes)
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Inherits the Return Fire damage handler!
|
||||
/// </summary>
|
||||
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"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,5 +56,10 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
get { return Color.Yellow; }
|
||||
}
|
||||
|
||||
protected override string Shape
|
||||
{
|
||||
get { return "xxx\nx x\nx x\nxxx"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,5 +39,10 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
get { return Color.SpringGreen; }
|
||||
}
|
||||
|
||||
protected override string Shape
|
||||
{
|
||||
get { return " xx \nxxxx\n xx "; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 "; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user