new range circle renderer; faster minefield renderer
This commit is contained in:
@@ -353,34 +353,33 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void DrawLocus(Color c, int2[] cells)
|
public void DrawLocus(Color c, int2[] cells)
|
||||||
{
|
{
|
||||||
foreach (var t in cells)
|
var dict = cells.ToDictionary(a => a, a => 0);
|
||||||
|
foreach (var t in dict.Keys)
|
||||||
{
|
{
|
||||||
if (!cells.Contains(t + new int2(-1, 0)))
|
if (!dict.ContainsKey(t + new int2(-1, 0)))
|
||||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
|
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
|
||||||
c, c);
|
c, c);
|
||||||
if (!cells.Contains(t + new int2(1, 0)))
|
if (!dict.ContainsKey(t + new int2(1, 0)))
|
||||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1, 0)), Game.CellSize * (t + new int2(1, 1)),
|
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1, 0)), Game.CellSize * (t + new int2(1, 1)),
|
||||||
c, c);
|
c, c);
|
||||||
if (!cells.Contains(t + new int2(0, -1)))
|
if (!dict.ContainsKey(t + new int2(0, -1)))
|
||||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1, 0)),
|
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1, 0)),
|
||||||
c, c);
|
c, c);
|
||||||
if (!cells.Contains(t + new int2(0, 1)))
|
if (!dict.ContainsKey(t + new int2(0, 1)))
|
||||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0, 1)), Game.CellSize * (t + new int2(1, 1)),
|
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0, 1)), Game.CellSize * (t + new int2(1, 1)),
|
||||||
c, c);
|
c, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRangeCircle(Color c, int2 location, int range)
|
public void DrawRangeCircle(Color c, float2 location, int range)
|
||||||
{
|
{
|
||||||
DrawLocus(c, world.FindTilesInCircle(location, range).ToArray());
|
var prev = location + Game.CellSize * range * float2.FromAngle(0);
|
||||||
}
|
for (var i = 1; i <= 32; i++)
|
||||||
|
|
||||||
public void DrawRangeCircle(Actor selectedUnit)
|
|
||||||
{
|
{
|
||||||
if (selectedUnit.Owner == world.LocalPlayer)
|
var pos = location + Game.CellSize * range * float2.FromAngle((float)(Math.PI * i) / 8);
|
||||||
DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
lineRenderer.DrawLine(prev, pos, c, c);
|
||||||
selectedUnit.Location,
|
prev = pos;
|
||||||
(int)selectedUnit.GetPrimaryWeapon().Range);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ namespace OpenRA.Orders
|
|||||||
{
|
{
|
||||||
if (a.traits.Contains<RenderRangeCircle>())
|
if (a.traits.Contains<RenderRangeCircle>())
|
||||||
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
||||||
a.Location, (int)a.GetPrimaryWeapon().Range);
|
a.CenterLocation, (int)a.GetPrimaryWeapon().Range);
|
||||||
|
|
||||||
if (a.traits.Contains<DetectCloaked>())
|
if (a.traits.Contains<DetectCloaked>())
|
||||||
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),
|
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),
|
||||||
a.Location, a.Info.Traits.Get<DetectCloakedInfo>().Range);
|
a.CenterLocation, a.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user