Convert range circle rendering to world coords.
This commit is contained in:
@@ -190,25 +190,25 @@ namespace OpenRA.Graphics
|
|||||||
selectable.DrawRollover(this);
|
selectable.DrawRollover(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRangeCircle(Color c, float2 location, float range)
|
public void DrawRangeCircle(WPos pos, WRange range, Color c)
|
||||||
{
|
{
|
||||||
|
var offset = new WVec(range.Range, 0, 0);
|
||||||
for (var i = 0; i < 32; i++)
|
for (var i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
var start = location + Game.CellSize * range * float2.FromAngle((float)(Math.PI * i) / 16);
|
var pa = pos + offset.Rotate(WRot.FromFacing(8 * i));
|
||||||
var end = location + Game.CellSize * range * float2.FromAngle((float)(Math.PI * (i + 0.7)) / 16);
|
var pb = pos + offset.Rotate(WRot.FromFacing(8 * i + 6));
|
||||||
|
Game.Renderer.WorldLineRenderer.DrawLine(ScreenPosition(pa), ScreenPosition(pb), c, c);
|
||||||
Game.Renderer.WorldLineRenderer.DrawLine(start, end, c, c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRangeCircleWithContrast(Color fg, float2 location, float range, Color bg)
|
public void DrawRangeCircleWithContrast(WPos pos, WRange range, Color fg, Color bg)
|
||||||
{
|
{
|
||||||
var wlr = Game.Renderer.WorldLineRenderer;
|
var wlr = Game.Renderer.WorldLineRenderer;
|
||||||
var oldWidth = wlr.LineWidth;
|
var oldWidth = wlr.LineWidth;
|
||||||
wlr.LineWidth = 3;
|
wlr.LineWidth = 3;
|
||||||
DrawRangeCircle(bg, location, range);
|
DrawRangeCircle(pos, range, bg);
|
||||||
wlr.LineWidth = 1;
|
wlr.LineWidth = 1;
|
||||||
DrawRangeCircle(fg, location, range);
|
DrawRangeCircle(pos, range, fg);
|
||||||
wlr.LineWidth = oldWidth;
|
wlr.LineWidth = oldWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,11 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
self.CenterPosition,
|
||||||
|
WRange.FromCells(Info.Range),
|
||||||
Color.FromArgb(128, Ready() ? Color.White : Color.Red),
|
Color.FromArgb(128, Ready() ? Color.White : Color.Red),
|
||||||
wr.ScreenPxPosition(self.CenterPosition), Info.Range,
|
Color.FromArgb(96, Color.Black)
|
||||||
Color.FromArgb(96, Color.Black));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selection bar
|
// Selection bar
|
||||||
|
|||||||
@@ -152,9 +152,12 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.Owner != self.World.LocalPlayer)
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wr.DrawRangeCircle(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
self.CenterPosition,
|
||||||
|
WRange.FromCells(self.Trait<ChronoshiftDeploy>().Info.JumpDistance),
|
||||||
Color.FromArgb(128, Color.DeepSkyBlue),
|
Color.FromArgb(128, Color.DeepSkyBlue),
|
||||||
wr.ScreenPxPosition(self.CenterPosition), (int)self.Trait<ChronoshiftDeploy>().Info.JumpDistance);
|
Color.FromArgb(96, Color.Black)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (health.Value != null)
|
if (health.Value != null)
|
||||||
wr.DrawRangeCircle(Color.Red, wr.ScreenPxPosition(self.CenterPosition), health.Value.Info.Radius / Game.CellSize);
|
{
|
||||||
|
var range = new WRange((int)(health.Value.Info.Radius * 1024 / Game.CellSize));
|
||||||
|
wr.DrawRangeCircle(self.CenterPosition, range, Color.Red);
|
||||||
|
}
|
||||||
|
|
||||||
var wlr = Game.Renderer.WorldLineRenderer;
|
var wlr = Game.Renderer.WorldLineRenderer;
|
||||||
var c = Color.White;
|
var c = Color.White;
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
self.CenterPosition,
|
||||||
|
WRange.FromCells(self.Info.Traits.Get<DetectCloakedInfo>().Range),
|
||||||
Color.FromArgb(128, Color.LimeGreen),
|
Color.FromArgb(128, Color.LimeGreen),
|
||||||
wr.ScreenPxPosition(self.CenterPosition), self.Info.Traits.Get<DetectCloakedInfo>().Range,
|
|
||||||
Color.FromArgb(96, Color.Black));
|
Color.FromArgb(96, Color.Black));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,10 +58,11 @@ namespace OpenRA.Mods.RA
|
|||||||
public static void DrawRangeCircle(WorldRenderer wr, WPos pos, int range, Color color)
|
public static void DrawRangeCircle(WorldRenderer wr, WPos pos, int range, Color color)
|
||||||
{
|
{
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
pos,
|
||||||
|
WRange.FromCells(range),
|
||||||
Color.FromArgb(128, color),
|
Color.FromArgb(128, color),
|
||||||
wr.ScreenPxPosition(pos),
|
Color.FromArgb(96, Color.Black)
|
||||||
range,
|
);
|
||||||
Color.FromArgb(96, Color.Black));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,15 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
|
var range = ai.Traits.WithInterface<ArmamentInfo>()
|
||||||
|
.Select(a => Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max();
|
||||||
|
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
Color.FromArgb(128, Color.Yellow), wr.ScreenPxPosition(centerPosition),
|
centerPosition,
|
||||||
ai.Traits.WithInterface<ArmamentInfo>()
|
new WRange((int)(1024 * range)),
|
||||||
.Select(a => Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max(),
|
Color.FromArgb(128, Color.Yellow),
|
||||||
Color.FromArgb(96, Color.Black));
|
Color.FromArgb(96, Color.Black)
|
||||||
|
);
|
||||||
|
|
||||||
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
|
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
|
||||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||||
@@ -52,12 +56,12 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.Owner != self.World.LocalPlayer)
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Hack: Convert world coords to cells
|
|
||||||
var pxRange = self.Trait<AttackBase>().GetMaximumRange().Range / 1024f;
|
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
self.CenterPosition,
|
||||||
|
self.Trait<AttackBase>().GetMaximumRange(),
|
||||||
Color.FromArgb(128, Color.Yellow),
|
Color.FromArgb(128, Color.Yellow),
|
||||||
wr.ScreenPxPosition(self.CenterPosition), pxRange,
|
Color.FromArgb(96, Color.Black)
|
||||||
Color.FromArgb(96, Color.Black));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
centerPosition,
|
||||||
|
WRange.FromCells(ai.Traits.Get<CreatesShroudInfo>().Range),
|
||||||
Color.FromArgb(128, Color.Cyan),
|
Color.FromArgb(128, Color.Cyan),
|
||||||
wr.ScreenPxPosition(centerPosition),
|
Color.FromArgb(96, Color.Black)
|
||||||
ai.Traits.Get<CreatesShroudInfo>().Range,
|
);
|
||||||
Color.FromArgb(96, Color.Black));
|
|
||||||
|
|
||||||
foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
|
foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
|
||||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||||
@@ -44,9 +45,11 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wr.DrawRangeCircleWithContrast(
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
self.CenterPosition,
|
||||||
|
WRange.FromCells(self.Info.Traits.Get<CreatesShroudInfo>().Range),
|
||||||
Color.FromArgb(128, Color.Cyan),
|
Color.FromArgb(128, Color.Cyan),
|
||||||
wr.ScreenPxPosition(self.CenterPosition), self.Info.Traits.Get<CreatesShroudInfo>().Range,
|
Color.FromArgb(96, Color.Black)
|
||||||
Color.FromArgb(96, Color.Black));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user