make it actually sortof work

This commit is contained in:
Chris Forbes
2010-05-16 12:53:20 +12:00
parent c20a1cc70a
commit 8e46f99ab9
4 changed files with 12 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Orders
.Where(o => o != null) .Where(o => o != null)
.ToArray(); .ToArray();
var actorsInvolved = orders.Select(o => o.TargetActor).Distinct(); var actorsInvolved = orders.Select(o => o.Subject).Distinct();
if (actorsInvolved.Any()) if (actorsInvolved.Any())
yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor,
string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray())); string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray()));

View File

@@ -60,7 +60,7 @@ namespace OpenRA
List<CachedPath> CachedPaths = new List<CachedPath>(); List<CachedPath> CachedPaths = new List<CachedPath>();
const int MaxPathAge = 50; /* x 40ms ticks */ const int MaxPathAge = 50; /* x 40ms ticks */
public List<int2> FindUnitPath(int2 from, int2 target, UnitMovementType umt) public List<int2> FindUnitPath(int2 from, int2 target, UnitMovementType umt, Actor self)
{ {
using (new PerfSample("find_unit_path")) using (new PerfSample("find_unit_path"))
{ {
@@ -73,9 +73,9 @@ namespace OpenRA
var pb = FindBidiPath( var pb = FindBidiPath(
PathSearch.FromPoint(world, target, from, umt, true) PathSearch.FromPoint(world, target, from, umt, true)
.WithCustomBlocker(AvoidUnitsNear(from, 4)), .WithCustomBlocker(AvoidUnitsNear(from, 4, self)),
PathSearch.FromPoint(world, from, target, umt, true) PathSearch.FromPoint(world, from, target, umt, true)
.WithCustomBlocker(AvoidUnitsNear(from, 4)) .WithCustomBlocker(AvoidUnitsNear(from, 4, self))
.InReverse()); .InReverse());
CheckSanePath2(pb, from, target); CheckSanePath2(pb, from, target);
@@ -86,7 +86,7 @@ namespace OpenRA
} }
} }
public List<int2> FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range ) public List<int2> FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range, Actor self )
{ {
using( new PerfSample( "find_unit_path_multiple_src" ) ) using( new PerfSample( "find_unit_path_multiple_src" ) )
{ {
@@ -94,19 +94,19 @@ namespace OpenRA
.Where( t => world.IsPathableCell( t, umt ) ); .Where( t => world.IsPathableCell( t, umt ) );
var path = FindPath( PathSearch.FromPoints( world, tilesInRange, src, umt, false ) var path = FindPath( PathSearch.FromPoints( world, tilesInRange, src, umt, false )
.WithCustomBlocker(AvoidUnitsNear(src, 4)) .WithCustomBlocker(AvoidUnitsNear(src, 4, self))
.InReverse()); .InReverse());
path.Reverse(); path.Reverse();
return path; return path;
} }
} }
public Func<int2, bool> AvoidUnitsNear(int2 p, int dist) public Func<int2, bool> AvoidUnitsNear(int2 p, int dist, Actor self)
{ {
return q => return q =>
p != q && p != q &&
((p - q).LengthSquared < dist * dist) && ((p - q).LengthSquared < dist * dist) &&
(world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(q).Any()); (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(q).Any(a => a.Group != self.Group));
} }
public List<int2> FindPath( PathSearch search ) public List<int2> FindPath( PathSearch search )

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Traits.Activities
{ {
this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPath( this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPath(
self.Location, destination, self.Location, destination,
mobile.GetMovementType() ); mobile.GetMovementType(), self );
this.destination = destination; this.destination = destination;
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
@@ -65,7 +65,7 @@ namespace OpenRA.Traits.Activities
this.getPath = (self, mobile) => this.getPath = (self, mobile) =>
self.World.PathFinder.FindPath( self.World.PathFinder.FindPath(
PathSearch.FromPoint( self.World, self.Location, destination, mobile.GetMovementType(), false ) PathSearch.FromPoint( self.World, self.Location, destination, mobile.GetMovementType(), false )
.WithCustomBlocker( self.World.PathFinder.AvoidUnitsNear( self.Location, 4 )) .WithCustomBlocker( self.World.PathFinder.AvoidUnitsNear( self.Location, 4, self ))
.WithIgnoredBuilding( ignoreBuilding )); .WithIgnoredBuilding( ignoreBuilding ));
this.destination = destination; this.destination = destination;
@@ -78,7 +78,7 @@ namespace OpenRA.Traits.Activities
{ {
this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPathToRange( this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPathToRange(
self.Location, target.Location, self.Location, target.Location,
mobile.GetMovementType(), range ); mobile.GetMovementType(), range, self );
this.destination = null; this.destination = null;
this.nearEnough = range; this.nearEnough = range;
} }

View File

@@ -1,6 +1,6 @@
Player: Player:
ProductionQueue: ProductionQueue:
BuildSpeed: .4 BuildSpeed: .04
LowPowerSlowdown: 3 LowPowerSlowdown: 3
PlaceBuilding: PlaceBuilding:
GpsPower: GpsPower: