Convert CombatDebugOverlay to IRenderAboveShroud.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -24,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new CombatDebugOverlay(init.Self); }
|
||||
}
|
||||
|
||||
public class CombatDebugOverlay : IRenderAboveWorld, INotifyDamage, INotifyCreated
|
||||
public class CombatDebugOverlay : IRenderAboveShroud, INotifyDamage, INotifyCreated
|
||||
{
|
||||
static readonly WVec TargetPosHLine = new WVec(0, 128, 0);
|
||||
static readonly WVec TargetPosVLine = new WVec(128, 0, 0);
|
||||
@@ -50,10 +52,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
allBlockers = self.TraitsImplementing<IBlocksProjectiles>().ToArray();
|
||||
}
|
||||
|
||||
void IRenderAboveWorld.RenderAboveWorld(Actor self, WorldRenderer wr)
|
||||
IEnumerable<IRenderable> IRenderAboveShroud.RenderAboveShroud(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (debugVis == null || !debugVis.CombatGeometry)
|
||||
return;
|
||||
if (debugVis == null || !debugVis.CombatGeometry || self.World.FogObscures(self))
|
||||
yield break;
|
||||
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
var iz = 1 / wr.Viewport.Zoom;
|
||||
@@ -61,37 +63,31 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var blockers = allBlockers.Where(Exts.IsTraitEnabled).ToList();
|
||||
if (blockers.Count > 0)
|
||||
{
|
||||
var hc = Color.Orange;
|
||||
var height = new WVec(0, 0, blockers.Max(b => b.BlockingHeight.Length));
|
||||
var ha = wr.Screen3DPosition(self.CenterPosition);
|
||||
var hb = wr.Screen3DPosition(self.CenterPosition + height);
|
||||
wcr.DrawLine(ha, hb, iz, hc);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
|
||||
yield return new LineAnnotationRenderable(self.CenterPosition, self.CenterPosition + height, 1, Color.Orange);
|
||||
}
|
||||
|
||||
var activeShapes = shapes.Where(Exts.IsTraitEnabled);
|
||||
foreach (var s in activeShapes)
|
||||
s.Info.Type.DrawCombatOverlay(wr, wcr, self);
|
||||
foreach (var r in s.Info.Type.RenderDebugOverlay(wr, self))
|
||||
yield return r;
|
||||
|
||||
var tc = Color.Lime;
|
||||
var positions = Target.FromActor(self).Positions;
|
||||
foreach (var p in positions)
|
||||
{
|
||||
var center = wr.Screen3DPosition(p);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, tc, center);
|
||||
wcr.DrawLine(wr.Screen3DPosition(p - TargetPosHLine), wr.Screen3DPosition(p + TargetPosHLine), iz, tc);
|
||||
wcr.DrawLine(wr.Screen3DPosition(p - TargetPosVLine), wr.Screen3DPosition(p + TargetPosVLine), iz, tc);
|
||||
yield return new LineAnnotationRenderable(p - TargetPosHLine, p + TargetPosHLine, 1, Color.Lime);
|
||||
yield return new LineAnnotationRenderable(p - TargetPosVLine, p + TargetPosVLine, 1, Color.Lime);
|
||||
}
|
||||
|
||||
foreach (var attack in self.TraitsImplementing<AttackBase>().Where(x => !x.IsTraitDisabled))
|
||||
DrawArmaments(self, attack, wr, wcr, iz);
|
||||
foreach (var r in RenderArmaments(self, attack, wr, wcr, iz))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
void DrawArmaments(Actor self, AttackBase attack, WorldRenderer wr, RgbaColorRenderer wcr, float iz)
|
||||
{
|
||||
var c = Color.White;
|
||||
bool IRenderAboveShroud.SpatiallyPartitionable { get { return true; } }
|
||||
|
||||
IEnumerable<IRenderable> RenderArmaments(Actor self, AttackBase attack, WorldRenderer wr, RgbaColorRenderer wcr, float iz)
|
||||
{
|
||||
// Fire ports on garrisonable structures
|
||||
var garrison = attack as AttackGarrisoned;
|
||||
if (garrison != null)
|
||||
@@ -103,14 +99,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var da = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw + p.Cone)).Rotate(bodyOrientation));
|
||||
var db = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw - p.Cone)).Rotate(bodyOrientation));
|
||||
|
||||
var o = wr.Screen3DPosition(pos);
|
||||
var a = wr.Screen3DPosition(pos + da * 224 / da.Length);
|
||||
var b = wr.Screen3DPosition(pos + db * 224 / db.Length);
|
||||
wcr.DrawLine(o, a, iz, c);
|
||||
wcr.DrawLine(o, b, iz, c);
|
||||
yield return new LineAnnotationRenderable(pos, pos + da * 224 / da.Length, 1, Color.White);
|
||||
yield return new LineAnnotationRenderable(pos, pos + db * 224 / da.Length, 1, Color.White);
|
||||
}
|
||||
|
||||
return;
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var a in attack.Armaments)
|
||||
@@ -122,11 +115,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
|
||||
var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));
|
||||
|
||||
var sm = wr.Screen3DPosition(muzzle);
|
||||
var sd = wr.Screen3DPosition(muzzle + dirOffset);
|
||||
wcr.DrawLine(sm, sd, iz, c);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, c, sm);
|
||||
yield return new LineAnnotationRenderable(muzzle, muzzle + dirOffset, 1, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user