Perf fixes for low unit-counts. Added sanity checks - not enabled by default.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System.Drawing;
|
||||
using OpenRa.Game.Graphics;
|
||||
using System;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.GameRules;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRa.Game
|
||||
@@ -9,8 +9,8 @@ namespace OpenRa.Game
|
||||
class UiOverlay
|
||||
{
|
||||
SpriteRenderer spriteRenderer;
|
||||
Sprite buildOk, buildBlocked, unitDebug;
|
||||
|
||||
Sprite buildOk, buildBlocked, unitDebug;
|
||||
|
||||
public static bool ShowUnitDebug = false;
|
||||
|
||||
public UiOverlay(SpriteRenderer spriteRenderer)
|
||||
@@ -18,7 +18,7 @@ namespace OpenRa.Game
|
||||
this.spriteRenderer = spriteRenderer;
|
||||
|
||||
buildOk = SynthesizeTile(0x80);
|
||||
buildBlocked = SynthesizeTile(0xe6);
|
||||
buildBlocked = SynthesizeTile(0xe6);
|
||||
unitDebug = SynthesizeTile(0x7c);
|
||||
}
|
||||
|
||||
@@ -34,22 +34,22 @@ namespace OpenRa.Game
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (ShowUnitDebug)
|
||||
for (var j = 0; j < 128; j++)
|
||||
for (var i = 0; i < 128; i++)
|
||||
if (Game.UnitInfluence.GetUnitAt(new int2(i, j)) != null)
|
||||
{
|
||||
if (ShowUnitDebug)
|
||||
for (var j = 0; j < 128; j++)
|
||||
for (var i = 0; i < 128; i++)
|
||||
if (Game.UnitInfluence.GetUnitAt(new int2(i, j)) != null)
|
||||
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
||||
|
||||
if (!hasOverlay) return;
|
||||
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name];
|
||||
|
||||
var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */
|
||||
var tooFarFromBase = !Footprint.Tiles(bi, position).Any(
|
||||
t => Game.GetDistanceToBase(t, Game.LocalPlayer) < maxDistance);
|
||||
|
||||
foreach( var t in Footprint.Tiles( bi, position ) )
|
||||
if (!hasOverlay) return;
|
||||
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name];
|
||||
|
||||
var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */
|
||||
var tooFarFromBase = !Footprint.Tiles(bi, position).Any(
|
||||
t => Game.GetDistanceToBase(t, Game.LocalPlayer) < maxDistance);
|
||||
|
||||
foreach( var t in Footprint.Tiles( bi, position ) )
|
||||
spriteRenderer.DrawSprite( !tooFarFromBase && Game.IsCellBuildable( t, bi.WaterBound
|
||||
? UnitMovementType.Float : UnitMovementType.Wheel )
|
||||
? buildOk : buildBlocked, Game.CellSize * t, 0 );
|
||||
|
||||
Reference in New Issue
Block a user