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.unreal.communication.messages.UnrealId;
7   import cz.cuni.amis.utils.NullCheck;
8   
9   /**
10   * Select the player with the given unreal ID.
11   * 
12   * @author mpkorstanje
13   * 
14   */
15  public class APlayer extends ContextSelector {
16  
17  	protected final UnrealId id;
18  
19  	public APlayer(UnrealId id) {
20  		NullCheck.check(id, "id");
21  		this.id = id;
22  	}
23  
24  	@Override
25  	public ILocated select(Collection<? extends ILocated> c) {
26  		// Optimization: Selecting from map is faster then selecting from the
27  		// collection.
28  		return modules.getPlayers().getVisiblePlayers().get(id);
29  	}
30  
31  	/*
32  	 * (non-Javadoc)
33  	 * 
34  	 * @see java.lang.Object#toString()
35  	 */
36  	@Override
37  	public String toString() {
38  		return "APlayer [id=" + id + "]";
39  	}
40  }