Fix ICustomTerrain to also work for resources

This commit is contained in:
Paul Chote
2010-04-17 20:06:14 +12:00
committed by Chris Forbes
parent 70e26bb047
commit 4a6c32bd9c
10 changed files with 84 additions and 61 deletions

View File

@@ -69,12 +69,9 @@ namespace OpenRA
{
var p = queue.Pop();
cellInfo[ p.Location.X, p.Location.Y ].Seen = true;
var custom2 = world.customTerrain[p.Location.X, p.Location.Y];
var thisCost = (custom2 != null)
? custom2.GetCost(p.Location, umt)
: passableCost[(int)umt][p.Location.X, p.Location.Y];
thisCost *= resources.GetPathCost(umt, p.Location);
var thisCost = passableCost[(int)umt][p.Location.X, p.Location.Y]*
world.WorldActor.traits.WithInterface<ICustomTerrain>().Aggregate(1f, (a, x) => a * x.GetCost(p.Location,umt));
if (thisCost == float.PositiveInfinity)
return p.Location;
@@ -87,9 +84,9 @@ namespace OpenRA
if( cellInfo[ newHere.X, newHere.Y ].Seen )
continue;
var custom = world.customTerrain[newHere.X, newHere.Y];
var costHere = (custom != null) ? custom.GetCost(newHere, umt) : passableCost[(int)umt][newHere.X, newHere.Y];
costHere *= resources.GetPathCost(umt, newHere);
var costHere = passableCost[(int)umt][newHere.X, newHere.Y]*
world.WorldActor.traits.WithInterface<ICustomTerrain>().Aggregate(1f, (a, x) => a * x.GetCost(p.Location,umt));
if (costHere == float.PositiveInfinity)
continue;