range circles for base defenses
This commit is contained in:
@@ -339,5 +339,32 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawRangeCircle(Actor selectedUnit)
|
||||
{
|
||||
if (selectedUnit.Owner != world.LocalPlayer)
|
||||
return;
|
||||
|
||||
var range = (int)selectedUnit.GetPrimaryWeapon().Range;
|
||||
var r2 = range * range;
|
||||
|
||||
var c = Color.FromArgb(128, Color.Yellow);
|
||||
|
||||
foreach (var t in world.FindTilesInCircle(selectedUnit.Location, range))
|
||||
{
|
||||
if ((selectedUnit.Location - t - new int2(-1, 0)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(1, 0)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1,0)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(0,-1)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1,0)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(0,1)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0,1)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c,c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,12 @@ namespace OpenRA.Orders
|
||||
|
||||
public void Render( World world )
|
||||
{
|
||||
foreach( var a in Game.controller.selection.Actors )
|
||||
world.WorldRenderer.DrawSelectionBox( a, Color.White, true );
|
||||
foreach (var a in Game.controller.selection.Actors)
|
||||
{
|
||||
world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
|
||||
if (a.traits.Contains<RenderRangeCircle>())
|
||||
world.WorldRenderer.DrawRangeCircle(a);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetCursor( World world, int2 xy, MouseInput mi )
|
||||
|
||||
@@ -64,4 +64,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : StatelessTraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user