use of bwta.Region in project BWJSAL by RobinsonMann.
the class EnemyBaseTracker method possibleEnemyStartingLocation.
/**
* Will return a base location belonging to the enemy if the given building
* is inside of a region that also contains a starting location that could contain
* an enemy base.
*/
private Optional<BaseLocation> possibleEnemyStartingLocation(final Unit building) {
// Find the region that this building belongs to.
final Region unitRegion = this.bwta.getRegion(building.getTilePosition());
final List<BaseLocation> baseLocationsInsideRegion = unitRegion.getBaseLocations();
// starting locations that could contain the enemy. If so, return.
for (final BaseLocation baseLocationInsideRegion : baseLocationsInsideRegion) {
if (this.startLocationsThatCouldContainEnemy.contains(baseLocationInsideRegion)) {
return Optional.of(baseLocationInsideRegion);
}
}
return Optional.empty();
}
Aggregations