more tweaks

This commit is contained in:
Chris Forbes
2010-01-19 10:38:50 +13:00
parent f0b26e8ee2
commit e82a398091
2 changed files with 17 additions and 13 deletions

View File

@@ -51,11 +51,11 @@ namespace OpenRa
continue;
var custom = Game.world.customTerrain[newHere.X, newHere.Y];
if (custom != null
&& custom.GetCost(newHere, umt) == float.PositiveInfinity)
continue;
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
var costHere = (custom != null) ? custom.GetCost(newHere, umt) : passableCost[(int)umt][newHere.X, newHere.Y];
if (costHere == float.PositiveInfinity)
continue;
if (!Game.world.BuildingInfluence.CanMoveHere(newHere) &&
Game.world.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
continue;
@@ -73,10 +73,7 @@ namespace OpenRa
if( est == float.PositiveInfinity )
continue;
float cellCost = ((d.X * d.Y != 0) ? 1.414213563f : 1.0f) *
(custom != null
? custom.GetCost(newHere, umt) :
passableCost[(int)umt][newHere.X, newHere.Y]);
float cellCost = ((d.X * d.Y != 0) ? 1.414213563f : 1.0f) * costHere;
float newCost = cellInfo[ p.Location.X, p.Location.Y ].MinCost + cellCost;
if( newCost >= cellInfo[ newHere.X, newHere.Y ].MinCost )

View File

@@ -22,10 +22,8 @@ namespace OpenRa.Traits
public Bridge(Actor self) { self.RemoveOnDeath = false; }
static Cache<TileReference, Sprite> Sprites =
new Cache<TileReference, Sprite>(
x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x),
new Size(Game.CellSize, Game.CellSize)));
static string cachedTheater;
static Cache<TileReference, Sprite> sprites;
public IEnumerable<Renderable> Render(Actor self)
{
@@ -42,13 +40,22 @@ namespace OpenRa.Traits
foreach (var t in replacedTiles.Keys)
Game.world.customTerrain[t.X, t.Y] = this;
if (cachedTheater != Game.world.Map.Theater)
{
cachedTheater = Game.world.Map.Theater;
sprites = new Cache<TileReference, Sprite>(
x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x),
new Size(Game.CellSize, Game.CellSize)));
}
TileSprites = replacedTiles.ToDictionary(
a => a.Key,
a => Sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]);
a => sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]);
}
public float GetCost(int2 p, UnitMovementType umt)
{
throw new NotImplementedException();
var origTile = Tiles[p]; // if this explodes, then SetTiles did something horribly wrong.
return float.PositiveInfinity;
}