Fix pathing across transit-only cells.

This commit is contained in:
Paul Chote
2020-03-06 18:15:33 +00:00
committed by abcdefg30
parent 44a7422375
commit 9acea56108

View File

@@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Traits
var otherActors = subCell == SubCell.FullCell ? world.ActorMap.GetActorsAt(cell) : world.ActorMap.GetActorsAt(cell, subCell); var otherActors = subCell == SubCell.FullCell ? world.ActorMap.GetActorsAt(cell) : world.ActorMap.GetActorsAt(cell, subCell);
foreach (var otherActor in otherActors) foreach (var otherActor in otherActors)
if (IsBlockedBy(actor, otherActor, ignoreActor, check, cellFlag)) if (IsBlockedBy(actor, otherActor, ignoreActor, cell, check, cellFlag))
return false; return false;
return true; return true;
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Traits
if (check > BlockedByActor.None) if (check > BlockedByActor.None)
{ {
Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, check, GetCache(cell).CellFlag); Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, cell, check, GetCache(cell).CellFlag);
if (!sharesCell) if (!sharesCell)
return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell, checkTransient) ? SubCell.Invalid : SubCell.FullCell; return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell, checkTransient) ? SubCell.Invalid : SubCell.FullCell;
@@ -336,7 +336,7 @@ namespace OpenRA.Mods.Common.Traits
return world.ActorMap.FreeSubCell(cell, preferredSubCell); return world.ActorMap.FreeSubCell(cell, preferredSubCell);
} }
bool IsBlockedBy(Actor actor, Actor otherActor, Actor ignoreActor, BlockedByActor check, CellFlag cellFlag) bool IsBlockedBy(Actor actor, Actor otherActor, Actor ignoreActor, CPos cell, BlockedByActor check, CellFlag cellFlag)
{ {
if (otherActor == ignoreActor) if (otherActor == ignoreActor)
return false; return false;
@@ -363,6 +363,14 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
} }
if (cellFlag.HasCellFlag(CellFlag.HasTransitOnlyActor))
{
// Transit only tiles should not block movement
var building = otherActor.TraitOrDefault<Building>();
if (building != null && building.TransitOnlyCells().Contains(cell))
return false;
}
// If we cannot crush the other actor in our way, we are blocked. // If we cannot crush the other actor in our way, we are blocked.
if (!cellFlag.HasCellFlag(CellFlag.HasCrushableActor) || Info.Crushes.IsEmpty) if (!cellFlag.HasCellFlag(CellFlag.HasCrushableActor) || Info.Crushes.IsEmpty)
return true; return true;