Pathfinder uses a MobileInfo instead of a specific actor

This commit is contained in:
Paul Chote
2010-09-09 23:25:58 +12:00
parent 706adb6d0b
commit f9445cb282
7 changed files with 50 additions and 38 deletions

View File

@@ -62,11 +62,11 @@ namespace OpenRA.Mods.RA.Activities
{
var res = self.World.WorldActor.Trait<ResourceLayer>();
var harv = self.Info.Traits.Get<HarvesterInfo>();
var mobileInfo = self.Info.Traits.Get<MobileInfo>();
self.QueueActivity(new Move(
() =>
{
return self.World.PathFinder.FindPath(PathSearch.Search(self, true)
return self.World.PathFinder.FindPath(PathSearch.Search(self.World, mobileInfo, true)
.WithHeuristic(loc => (res.GetResource(loc) != null && harv.Resources.Contains( res.GetResource(loc).info.Name )) ? 0 : 1)
.FromPoint(self.Location));
}));

View File

@@ -63,8 +63,8 @@ namespace OpenRA.Mods.RA
var refs = self.World.Queries.OwnedBy[self.Owner]
.Where(x => x != ignore && x.HasTrait<IAcceptOre>())
.ToList();
var path = self.World.PathFinder.FindPath(PathSearch.FromPoints(self,
var mi = self.Info.Traits.Get<MobileInfo>();
var path = self.World.PathFinder.FindPath(PathSearch.FromPoints(self.World, mi,
refs.Select(r => r.Location + r.Trait<IAcceptOre>().DeliverOffset),
self.Location,
false));