Refactored [sub-]cell availability logic in IPositionable & ActorMap

Moved the logic from IPositionable.CanEnterCell & integrated sub-cell selection.
Added IPositionable.IsMovingFrom(CPos location, int subCell = -1) - to detect transient actors
Renamed IPositionable.{GetDesiredSubcell => GetAvailableSubcell} - since it checks for available sub-cells
Reduced IPositionable.CanEnterCell to one method that usually uses IPositionable.GetAvailableSubcell
Added actor checking to ActorMap.{HasFreeSubCell, FreeSubCell, AnyUnitsAt} - used by [sub-]cell availability logic
This commit is contained in:
atlimit8
2014-08-10 19:43:45 -05:00
parent ff7ad53dee
commit b2c9064545
8 changed files with 117 additions and 64 deletions

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Activities
return cargo.CurrentAdjacentCells
.Shuffle(self.World.SharedRandom)
.Select(c => Pair.New(c, pos.GetDesiredSubcell(c, null)))
.Select(c => Pair.New(c, pos.GetAvailableSubcell(c, -1, null)))
.Cast<Pair<CPos, int>?>()
.FirstOrDefault(s => s.Value.Second >= 0);
}