This commit is contained in:
Chris Forbes
2010-03-22 20:35:57 +13:00
parent 7d0bd51ff4
commit 15ba89e957
2 changed files with 41 additions and 3 deletions

View File

@@ -126,7 +126,12 @@ namespace OpenRA.Graphics
bounds.Offset((int)Game.viewport.Location.X, (int)Game.viewport.Location.Y); bounds.Offset((int)Game.viewport.Location.X, (int)Game.viewport.Location.Y);
var renderables = world.Actors.SelectMany(a => a.Render()) var foos = world.Actors;
var bars = world.FindUnits(
new float2(bounds.Left, bounds.Top),
new float2(bounds.Right, bounds.Bottom));
var renderables = foos.SelectMany(a => a.Render())
.OrderBy(r => r, comparer); .OrderBy(r => r, comparer);
DrawSpriteList(bounds, renderables); DrawSpriteList(bounds, renderables);
@@ -149,14 +154,45 @@ namespace OpenRA.Graphics
renderer.Device.DisableScissor(); renderer.Device.DisableScissor();
foreach (var bar in bars)
{ {
var a = new float2( bounds.Left, bounds.Top ); var baz = bar.GetBounds(true);
var b = new float2( bounds.Right - a.X, 0);
var a = new float2(baz.Left, baz.Top);
var b = new float2(baz.Right - a.X, 0);
var c = new float2(0, baz.Bottom - a.Y);
lineRenderer.DrawLine(a, a + b, Color.Green, Color.Green);
lineRenderer.DrawLine(a + b, a + b + c, Color.Green, Color.Green);
lineRenderer.DrawLine(a + b + c, a + c, Color.Green, Color.Green);
lineRenderer.DrawLine(a, a + c, Color.Green, Color.Green);
}
{
var a = new float2(bounds.Left, bounds.Top);
var b = new float2(bounds.Right - a.X, 0);
var c = new float2(0, bounds.Bottom - a.Y); var c = new float2(0, bounds.Bottom - a.Y);
lineRenderer.DrawLine(a, a + b, Color.Red, Color.Red); lineRenderer.DrawLine(a, a + b, Color.Red, Color.Red);
lineRenderer.DrawLine(a + b, a + b + c, Color.Red, Color.Red); lineRenderer.DrawLine(a + b, a + b + c, Color.Red, Color.Red);
lineRenderer.DrawLine(a + b + c, a + c, Color.Red, Color.Red); lineRenderer.DrawLine(a + b + c, a + c, Color.Red, Color.Red);
lineRenderer.DrawLine(a, a + c, Color.Red, Color.Red); lineRenderer.DrawLine(a, a + c, Color.Red, Color.Red);
bounds = GetBoundsRect();
a = new float2(bounds.Left, bounds.Top);
b = new float2(bounds.Right - a.X, 0);
c = new float2(0, bounds.Bottom - a.Y);
lineRenderer.DrawLine(a, a + b, Color.Blue, Color.Blue);
lineRenderer.DrawLine(a + b, a + b + c, Color.Blue, Color.Blue);
lineRenderer.DrawLine(a + b + c, a + c, Color.Blue, Color.Blue);
lineRenderer.DrawLine(a, a + c, Color.Blue, Color.Blue);
}
{
for (var j = 0; j < Game.world.Map.MapSize;
j += Game.world.WorldActor.Info.Traits.Get<SpatialBinsInfo>().BinSize)
{
lineRenderer.DrawLine(new float2(0, j * 24), new float2(Game.world.Map.MapSize * 24, j * 24), Color.Black, Color.Black);
lineRenderer.DrawLine(new float2(j * 24, 0), new float2(j * 24, Game.world.Map.MapSize * 24), Color.Black, Color.Black);
}
} }
lineRenderer.Flush(); lineRenderer.Flush();

View File

@@ -52,6 +52,8 @@ namespace OpenRA.Traits
IEnumerable<Actor> ActorsInBins(int i1, int i2, int j1, int j2) IEnumerable<Actor> ActorsInBins(int i1, int i2, int j1, int j2)
{ {
if (bins[0, 0] == null) yield break; // hack
j1 = Math.Max(0, j1); j2 = Math.Min(j2, bins.GetUpperBound(1) - 1); j1 = Math.Max(0, j1); j2 = Math.Min(j2, bins.GetUpperBound(1) - 1);
i1 = Math.Max(0, i1); i2 = Math.Min(i2, bins.GetUpperBound(0) - 1); i1 = Math.Max(0, i1); i2 = Math.Min(i2, bins.GetUpperBound(0) - 1);
for (var j = j1; j <= j2; j++) for (var j = j1; j <= j2; j++)