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
|
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 WPos centerPosition;
|
||||||
readonly WDist radius;
|
readonly WDist radius;
|
||||||
readonly int zOffset;
|
readonly int zOffset;
|
||||||
@@ -43,13 +47,25 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var wlr = Game.Renderer.WorldLineRenderer;
|
DrawRangeCircle(wr, centerPosition, radius, 1, color, 3, contrastColor);
|
||||||
var oldWidth = wlr.LineWidth;
|
}
|
||||||
wlr.LineWidth = 3;
|
|
||||||
wr.DrawRangeCircle(centerPosition, radius, contrastColor);
|
public static void DrawRangeCircle(WorldRenderer wr, WPos centerPosition, WDist radius,
|
||||||
wlr.LineWidth = 1;
|
float width, Color color, float contrastWidth, Color contrastColor)
|
||||||
wr.DrawRangeCircle(centerPosition, radius, color);
|
{
|
||||||
wlr.LineWidth = oldWidth;
|
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) { }
|
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user