From 8e46f99ab9b13d1118f90decabfe11282dbe1c5e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 16 May 2010 12:53:20 +1200 Subject: [PATCH] make it actually sortof work --- OpenRA.Game/Orders/UnitOrderGenerator.cs | 2 +- OpenRA.Game/PathFinder.cs | 14 +++++++------- OpenRA.Game/Traits/Activities/Move.cs | 6 +++--- mods/ra/system.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index fff3814362..9f5f5f56d5 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -35,7 +35,7 @@ namespace OpenRA.Orders .Where(o => o != null) .ToArray(); - var actorsInvolved = orders.Select(o => o.TargetActor).Distinct(); + var actorsInvolved = orders.Select(o => o.Subject).Distinct(); if (actorsInvolved.Any()) yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray())); diff --git a/OpenRA.Game/PathFinder.cs b/OpenRA.Game/PathFinder.cs index 72a6f48df9..176f09f5e2 100644 --- a/OpenRA.Game/PathFinder.cs +++ b/OpenRA.Game/PathFinder.cs @@ -60,7 +60,7 @@ namespace OpenRA List CachedPaths = new List(); const int MaxPathAge = 50; /* x 40ms ticks */ - public List FindUnitPath(int2 from, int2 target, UnitMovementType umt) + public List FindUnitPath(int2 from, int2 target, UnitMovementType umt, Actor self) { using (new PerfSample("find_unit_path")) { @@ -73,9 +73,9 @@ namespace OpenRA var pb = FindBidiPath( PathSearch.FromPoint(world, target, from, umt, true) - .WithCustomBlocker(AvoidUnitsNear(from, 4)), + .WithCustomBlocker(AvoidUnitsNear(from, 4, self)), PathSearch.FromPoint(world, from, target, umt, true) - .WithCustomBlocker(AvoidUnitsNear(from, 4)) + .WithCustomBlocker(AvoidUnitsNear(from, 4, self)) .InReverse()); CheckSanePath2(pb, from, target); @@ -86,7 +86,7 @@ namespace OpenRA } } - public List FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range ) + public List FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range, Actor self ) { using( new PerfSample( "find_unit_path_multiple_src" ) ) { @@ -94,19 +94,19 @@ namespace OpenRA .Where( t => world.IsPathableCell( t, umt ) ); var path = FindPath( PathSearch.FromPoints( world, tilesInRange, src, umt, false ) - .WithCustomBlocker(AvoidUnitsNear(src, 4)) + .WithCustomBlocker(AvoidUnitsNear(src, 4, self)) .InReverse()); path.Reverse(); return path; } } - public Func AvoidUnitsNear(int2 p, int dist) + public Func AvoidUnitsNear(int2 p, int dist, Actor self) { return q => p != q && ((p - q).LengthSquared < dist * dist) && - (world.WorldActor.traits.Get().GetUnitsAt(q).Any()); + (world.WorldActor.traits.Get().GetUnitsAt(q).Any(a => a.Group != self.Group)); } public List FindPath( PathSearch search ) diff --git a/OpenRA.Game/Traits/Activities/Move.cs b/OpenRA.Game/Traits/Activities/Move.cs index 1f98265668..775492f40a 100755 --- a/OpenRA.Game/Traits/Activities/Move.cs +++ b/OpenRA.Game/Traits/Activities/Move.cs @@ -54,7 +54,7 @@ namespace OpenRA.Traits.Activities { this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPath( self.Location, destination, - mobile.GetMovementType() ); + mobile.GetMovementType(), self ); this.destination = destination; this.nearEnough = nearEnough; } @@ -65,7 +65,7 @@ namespace OpenRA.Traits.Activities this.getPath = (self, mobile) => self.World.PathFinder.FindPath( 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 )); this.destination = destination; @@ -78,7 +78,7 @@ namespace OpenRA.Traits.Activities { this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPathToRange( self.Location, target.Location, - mobile.GetMovementType(), range ); + mobile.GetMovementType(), range, self ); this.destination = null; this.nearEnough = range; } diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index e3abcc6663..d5962afd07 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -1,6 +1,6 @@ Player: ProductionQueue: - BuildSpeed: .4 + BuildSpeed: .04 LowPowerSlowdown: 3 PlaceBuilding: GpsPower: