diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index 54b050fe11..10514752ff 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -72,8 +72,6 @@ namespace OpenRa.Game continue; if (Game.BuildingInfluence.GetBuildingAt(newHere - offset) != null) continue; - //if (Game.UnitInfluence.GetUnitAt(newHere - offset) != null) - // continue; double cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563 : 1.0 ) * passableCost[(int)umt][ newHere.X, newHere.Y ]; double newCost = cellInfo[ here.X, here.Y ].MinCost + cellCost; diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 1cc2c5abe5..3f64f2e213 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -130,6 +130,12 @@ namespace OpenRa.Game.Traits public MoveTo( int2 destination ) { this.destination = destination; + } + + bool CanEnterCell(int2 c, Actor self) + { + var u = Game.UnitInfluence.GetUnitAt(c); + return u == null || u == self; } public void Tick( Actor self, Mobile mobile ) @@ -161,9 +167,8 @@ namespace OpenRa.Game.Traits mobile.currentAction = new Turn( firstFacing ) { NextAction = this }; else { - var unitAtDest = Game.UnitInfluence.GetUnitAt(nextCell); - if ( unitAtDest != null && unitAtDest != self ) - return; /* todo: repath, sometimes */ + if (!CanEnterCell(nextCell, self)) return; /* todo: repath, sometimes */ + mobile.toCell = nextCell; path.RemoveAt( path.Count - 1 ); moveFractionTotal = ( dir.X != 0 && dir.Y != 0 ) ? 35 : 25;