View Javadoc

1   package nl.tudelft.goal.ut2004.selector;
2   
3   import java.util.Collection;
4   
5   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
6   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
7   
8   /**
9    * Selects the closest friendly {@link Player}.
10   * 
11   * @author mpkorstanje
12   * 
13   */
14  public final class NearestFriendly extends ContextSelector {
15  
16  	/* (non-Javadoc)
17  	 * @see java.lang.Object#toString()
18  	 */
19  	@Override
20  	public String toString() {
21  		return "NearestFriendly";
22  	}
23  
24  	@Override
25  	public ILocated select(Collection<? extends ILocated> targets) {
26  		//Optimization, faster then selecting from collection.
27  		return modules.getPlayers().getNearestVisibleFriend();
28  	}
29  
30  }