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