View Javadoc

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