unhack that a bit

This commit is contained in:
Chris Forbes
2010-03-28 16:56:13 +13:00
parent c6804dff9c
commit d5a9c76d42
3 changed files with 7 additions and 8 deletions

View File

@@ -39,14 +39,13 @@ namespace OpenRA
BuildingInfluence buildingInfluence;
UnitInfluence unitInfluence;
public PathSearch()
public PathSearch(World world)
{
cellInfo = InitCellInfo();
queue = new PriorityQueue<PathDistance>();
// hack: should be passing in World, not using Game.world.
buildingInfluence = Game.world.WorldActor.traits.Get<BuildingInfluence>();
unitInfluence = Game.world.WorldActor.traits.Get<UnitInfluence>();
buildingInfluence = world.WorldActor.traits.Get<BuildingInfluence>();
unitInfluence = world.WorldActor.traits.Get<UnitInfluence>();
}
public PathSearch WithCustomBlocker(Func<int2, bool> customBlock)
@@ -140,7 +139,7 @@ namespace OpenRA
public static PathSearch FromPoint( World world, int2 from, int2 target, UnitMovementType umt, bool checkForBlocked )
{
var search = new PathSearch {
var search = new PathSearch(world) {
heuristic = DefaultEstimator( target ),
umt = umt,
checkForBlocked = checkForBlocked };
@@ -151,7 +150,7 @@ namespace OpenRA
public static PathSearch FromPoints(World world, IEnumerable<int2> froms, int2 target, UnitMovementType umt, bool checkForBlocked)
{
var search = new PathSearch
var search = new PathSearch(world)
{
heuristic = DefaultEstimator(target),
umt = umt,

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Traits.Activities
{
var mobile = self.traits.Get<Mobile>();
var search = new PathSearch
var search = new PathSearch(self.World)
{
heuristic = PathSearch.DefaultEstimator(self.Location),
umt = mobile.GetMovementType(),

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Traits.Activities
self.QueueActivity(new Move(
() =>
{
var search = new PathSearch
var search = new PathSearch(self.World)
{
heuristic = loc => (res.GetResource(loc) != null
&& harv.Resources.Contains( res.GetResource(loc).Name )) ? 0 : 1,