Merge pull request #7416 from atimoschenkow/adjust-nudge
Adjust nudging for cases where no enterable cell is found
This commit is contained in:
@@ -579,8 +579,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
notStupidCells.Add(p);
|
notStupidCells.Add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) :
|
var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) : (CPos?)null;
|
||||||
notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (CPos?)null;
|
|
||||||
|
|
||||||
if (moveTo.HasValue)
|
if (moveTo.HasValue)
|
||||||
{
|
{
|
||||||
@@ -592,9 +591,31 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.ActorID, self.Location, moveTo.Value);
|
self.ActorID, self.Location, moveTo.Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
var cellInfo = notStupidCells
|
||||||
|
.SelectMany(c => self.World.ActorMap.GetUnitsAt(c)
|
||||||
|
.Where(a => a.IsIdle && a.HasTrait<Mobile>()),
|
||||||
|
(c, a) => new { Cell = c, Actor = a })
|
||||||
|
.RandomOrDefault(self.World.SharedRandom);
|
||||||
|
|
||||||
|
if (cellInfo != null)
|
||||||
|
{
|
||||||
|
self.CancelActivity();
|
||||||
|
var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell));
|
||||||
|
var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell));
|
||||||
|
var move = new Move(self, cellInfo.Cell);
|
||||||
|
self.QueueActivity(Util.SequenceActivities(notifyBlocking, waitFor, move));
|
||||||
|
|
||||||
|
Log.Write("debug", "OnNudge (notify next blocking actor, wait and move) #{0} from {1} to {2}",
|
||||||
|
self.ActorID, self.Location, cellInfo.Cell);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Log.Write("debug", "OnNudge #{0} refuses at {1}",
|
Log.Write("debug", "OnNudge #{0} refuses at {1}",
|
||||||
self.ActorID, self.Location);
|
self.ActorID, self.Location);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MoveOrderTargeter : IOrderTargeter
|
class MoveOrderTargeter : IOrderTargeter
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user