diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 84d88bead6..d6be741ade 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -33,12 +33,13 @@ namespace OpenRa.Game foreach( var traitName in unitInfo.Traits ) { var type = typeof( Traits.Mobile ).Assembly.GetType( typeof( Traits.Mobile ).Namespace + "." + traitName, true, false ); - var ctor = type.GetConstructor( new Type[] { typeof( Actor ) } ); + var ctor = type.GetConstructor( new[] { typeof( Actor ) } ); traits.Add( type, ctor.Invoke( new object[] { this } ) ); } } else - throw new InvalidOperationException( "No Actor traits for " + unitInfo.Name + "; add Traits= to units.ini for appropriate unit" ); + throw new InvalidOperationException( "No Actor traits for " + unitInfo.Name + + "; add Traits= to units.ini for appropriate unit" ); } public Actor( TreeReference tree, TreeCache treeRenderer, int2 mapOffset ) @@ -65,8 +66,7 @@ namespace OpenRa.Game { return traits.WithInterface() .Select( x => x.Order( this, xy ) ) - .Where( x => x != null ) - .FirstOrDefault(); + .FirstOrDefault( x => x != null ); } public RectangleF Bounds @@ -83,9 +83,9 @@ namespace OpenRa.Game { /* todo: auto-retaliate, etc */ /* todo: death sequence for infantry based on inflictor */ - /* todo: start smoking if < conditionYellow and took damage, and not already smoking + /* todo: start smoking if < conditionYellow and took damage, and not already smoking */ - if (Health <= 0) return; /* overkill! */ + if (Health <= 0) return; /* overkill! don't count extra hits as more kills! */ Health -= damage; if (Health <= 0) diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index ae00256998..ac8f42f9af 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -26,23 +26,26 @@ namespace OpenRa.Game public List FindUnitPath( int2 unitLocation, Func estimator ) { - int2 startLocation = unitLocation + map.Offset; + var startLocation = unitLocation + map.Offset; - CellInfo[ , ] cellInfo = new CellInfo[ 128, 128 ]; + var cellInfo = new CellInfo[ 128, 128 ]; for( int x = 0 ; x < 128 ; x++ ) for( int y = 0 ; y < 128 ; y++ ) cellInfo[ x, y ] = new CellInfo( double.PositiveInfinity, new int2( x, y ), false ); - return FindUnitPath( startLocation, estimator, map.Offset, cellInfo ); + return FindUnitPath( new[] {startLocation}, estimator, map.Offset, cellInfo ); } - List FindUnitPath(int2 startLocation, Func estimator, int2 offset, CellInfo[,] cellInfo) + List FindUnitPath(IEnumerable startLocations, Func estimator, int2 offset, CellInfo[,] cellInfo) { - PriorityQueue queue = new PriorityQueue(); + var queue = new PriorityQueue(); - queue.Add( new PathDistance( estimator( startLocation - offset ), startLocation ) ); - cellInfo[ startLocation.X, startLocation.Y ].MinCost = 0; + foreach (var sl in startLocations) + { + queue.Add(new PathDistance(estimator(sl - offset), sl)); + cellInfo[sl.X, sl.Y].MinCost = 0; + } while( !queue.Empty ) {