@Override protected void collectJobs(ImmutableBag<Entity> entities, LinkedList<Job> jobs) { final Array<Routable> routables = new Array<>(entities.size()); for (int a = 0, size = entities.size(); a < size; a++) { // set index, this is required for the pathfinding logic. final Routable routable = mRoutable.get(entities.get(a)); routables.add(routable); routable.setIndex(a); } for (Team team : Team.values()) { final DefaultIndexedGraph<Routable> graph = new TeamDefaultIndexedGraph(team, routables); for (int a = 0, size = entities.size(); a < size; a++) { for (int b = a + 1; b < size; b++) { jobs.add(new CalculatePreferredRoute(team, graph, entities.get(a), entities.get(b))); } } } }
public CalculatePreferredRoute(Team team, DefaultIndexedGraph<Routable> graph, Entity entityA, Entity entityB) { this.team = team; this.graph = graph; this.entityA = entityA; this.entityB = entityB; finder = new IndexedAStarPathFinder<>(graph); }