Convert CombatDebugOverlay to IRenderAboveShroud.

This commit is contained in:
Paul Chote
2019-09-03 21:05:04 +01:00
committed by teinarss
parent c9ed749908
commit 60e42c1ea1
6 changed files with 51 additions and 63 deletions

View File

@@ -10,6 +10,7 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Primitives;
@@ -93,7 +94,7 @@ namespace OpenRA.Mods.Common.HitShapes
return DistanceFromEdge((pos - new WPos(actorPos.X, actorPos.Y, pos.Z)).Rotate(-actor.Orientation));
}
public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
IEnumerable<IRenderable> IHitShape.RenderDebugOverlay(WorldRenderer wr, Actor actor)
{
var actorPos = actor.CenterPosition;
@@ -107,18 +108,15 @@ namespace OpenRA.Mods.Common.HitShapes
var offset2 = new WVec(aa.Y - bb.Y, bb.X - aa.X, 0);
offset2 = offset2 * Radius.Length / offset2.Length;
var c = Color.Yellow;
RangeCircleRenderable.DrawRangeCircle(wr, a, Radius, 1, c, 0, c);
RangeCircleRenderable.DrawRangeCircle(wr, b, Radius, 1, c, 0, c);
wcr.DrawLine(new[] { wr.Screen3DPosition(a - offset1), wr.Screen3DPosition(b - offset1) }, 1, c);
wcr.DrawLine(new[] { wr.Screen3DPosition(a + offset1), wr.Screen3DPosition(b + offset1) }, 1, c);
RangeCircleRenderable.DrawRangeCircle(wr, aa, Radius, 1, c, 0, c);
RangeCircleRenderable.DrawRangeCircle(wr, bb, Radius, 1, c, 0, c);
wcr.DrawLine(new[] { wr.Screen3DPosition(aa - offset2), wr.Screen3DPosition(bb - offset2) }, 1, c);
wcr.DrawLine(new[] { wr.Screen3DPosition(aa + offset2), wr.Screen3DPosition(bb + offset2) }, 1, c);
RangeCircleRenderable.DrawRangeCircle(wr, actorPos, OuterRadius, 1, Color.LimeGreen, 0, Color.LimeGreen);
yield return new CircleAnnotationRenderable(a, Radius, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(b, Radius, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(aa, Radius, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(bb, Radius, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(actorPos, OuterRadius, 1, Color.LimeGreen);
yield return new LineAnnotationRenderable(a - offset1, b - offset1, 1, Color.Yellow);
yield return new LineAnnotationRenderable(a + offset1, b + offset1, 1, Color.Yellow);
yield return new LineAnnotationRenderable(aa - offset2, bb - offset2, 1, Color.Yellow);
yield return new LineAnnotationRenderable(aa + offset2, bb + offset2, 1, Color.Yellow);
}
}
}

View File

@@ -10,6 +10,7 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Primitives;
@@ -57,14 +58,11 @@ namespace OpenRA.Mods.Common.HitShapes
return DistanceFromEdge(pos - new WPos(actorPos.X, actorPos.Y, pos.Z));
}
public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
IEnumerable<IRenderable> IHitShape.RenderDebugOverlay(WorldRenderer wr, Actor actor)
{
var actorPos = actor.CenterPosition;
RangeCircleRenderable.DrawRangeCircle(
wr, actorPos + new WVec(0, 0, VerticalTopOffset), Radius, 1, Color.Yellow, 0, Color.Yellow);
RangeCircleRenderable.DrawRangeCircle(
wr, actorPos + new WVec(0, 0, VerticalBottomOffset), Radius, 1, Color.Yellow, 0, Color.Yellow);
yield return new CircleAnnotationRenderable(actorPos + new WVec(0, 0, VerticalTopOffset), Radius, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(actorPos + new WVec(0, 0, VerticalBottomOffset), Radius, 1, Color.Yellow);
}
}
}

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA.Mods.Common.HitShapes
@@ -21,6 +22,6 @@ namespace OpenRA.Mods.Common.HitShapes
WDist DistanceFromEdge(WPos pos, Actor actor);
void Initialize();
void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor);
IEnumerable<IRenderable> RenderDebugOverlay(WorldRenderer wr, Actor actor);
}
}

View File

@@ -10,6 +10,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
@@ -112,17 +113,17 @@ namespace OpenRA.Mods.Common.HitShapes
return DistanceFromEdge((pos - new WPos(actorPos.X, actorPos.Y, pos.Z)).Rotate(-orientation));
}
public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
IEnumerable<IRenderable> IHitShape.RenderDebugOverlay(WorldRenderer wr, Actor actor)
{
var actorPos = actor.CenterPosition;
var orientation = actor.Orientation + WRot.FromYaw(LocalYaw);
var vertsTop = combatOverlayVertsTop.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
var vertsBottom = combatOverlayVertsBottom.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);
var vertsTop = combatOverlayVertsTop.Select(v => actorPos + v.Rotate(orientation)).ToArray();
var vertsBottom = combatOverlayVertsBottom.Select(v => actorPos + v.Rotate(orientation)).ToArray();
RangeCircleRenderable.DrawRangeCircle(wr, actorPos, OuterRadius, 1, Color.LimeGreen, 0, Color.LimeGreen);
yield return new PolygonAnnotationRenderable(vertsTop, actorPos, 1, Color.Yellow);
yield return new PolygonAnnotationRenderable(vertsBottom, actorPos, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(actorPos, OuterRadius, 1, Color.LimeGreen);
}
}
}

View File

@@ -10,6 +10,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
@@ -107,17 +108,17 @@ namespace OpenRA.Mods.Common.HitShapes
return DistanceFromEdge((pos - new WPos(actorPos.X, actorPos.Y, pos.Z)).Rotate(-orientation));
}
public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
IEnumerable<IRenderable> IHitShape.RenderDebugOverlay(WorldRenderer wr, Actor actor)
{
var actorPos = actor.CenterPosition;
var orientation = actor.Orientation + WRot.FromYaw(LocalYaw);
var vertsTop = combatOverlayVertsTop.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
var vertsBottom = combatOverlayVertsBottom.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);
var vertsTop = combatOverlayVertsTop.Select(v => actorPos + v.Rotate(orientation)).ToArray();
var vertsBottom = combatOverlayVertsBottom.Select(v => actorPos + v.Rotate(orientation)).ToArray();
RangeCircleRenderable.DrawRangeCircle(wr, actorPos, OuterRadius, 1, Color.LimeGreen, 0, Color.LimeGreen);
yield return new PolygonAnnotationRenderable(vertsTop, actorPos, 1, Color.Yellow);
yield return new PolygonAnnotationRenderable(vertsBottom, actorPos, 1, Color.Yellow);
yield return new CircleAnnotationRenderable(actorPos, OuterRadius, 1, Color.LimeGreen);
}
}
}