Use RgbaColorRenderer for range circle rendering.
This commit is contained in:
@@ -15,6 +15,10 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
public struct RangeCircleRenderable : IRenderable, IFinalizedRenderable
|
||||
{
|
||||
const int RangeCircleSegments = 32;
|
||||
static readonly int[][] RangeCircleStartRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i).AsMatrix());
|
||||
static readonly int[][] RangeCircleEndRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i + 6).AsMatrix());
|
||||
|
||||
readonly WPos centerPosition;
|
||||
readonly WDist radius;
|
||||
readonly int zOffset;
|
||||
@@ -43,13 +47,25 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
var wlr = Game.Renderer.WorldLineRenderer;
|
||||
var oldWidth = wlr.LineWidth;
|
||||
wlr.LineWidth = 3;
|
||||
wr.DrawRangeCircle(centerPosition, radius, contrastColor);
|
||||
wlr.LineWidth = 1;
|
||||
wr.DrawRangeCircle(centerPosition, radius, color);
|
||||
wlr.LineWidth = oldWidth;
|
||||
DrawRangeCircle(wr, centerPosition, radius, 1, color, 3, contrastColor);
|
||||
}
|
||||
|
||||
public static void DrawRangeCircle(WorldRenderer wr, WPos centerPosition, WDist radius,
|
||||
float width, Color color, float contrastWidth, Color contrastColor)
|
||||
{
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
var offset = new WVec(radius.Length, 0, 0);
|
||||
for (var i = 0; i < RangeCircleRenderable.RangeCircleSegments; i++)
|
||||
{
|
||||
var a = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleRenderable.RangeCircleStartRotations[i]));
|
||||
var b = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleRenderable.RangeCircleEndRotations[i]));
|
||||
|
||||
if (contrastWidth > 0)
|
||||
wcr.DrawLine(a, b, contrastWidth / wr.Viewport.Zoom, contrastColor);
|
||||
|
||||
if (width > 0)
|
||||
wcr.DrawLine(a, b, width / wr.Viewport.Zoom, color);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
Reference in New Issue
Block a user