View Javadoc

1   package nl.tudelft.goal.ut2004.selector;
2   
3   import java.util.Collection;
4   
5   import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObject;
6   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
7   import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
8   import cz.cuni.amis.utils.NullCheck;
9   
10  /**
11   * Select the player with the given unreal ID.
12   * 
13   * @author mpkorstanje
14   * 
15   */
16  public class PlayerOrNavpoint extends ContextSelector {
17  
18  	protected final UnrealId id;
19  
20  	public PlayerOrNavpoint(UnrealId id) {
21  		NullCheck.check(id, "id");
22  		this.id = id;
23  	}
24  
25  	@Override
26  	public ILocated select(Collection<? extends ILocated> c) {
27  		// We want to select something with the given id.
28  		IWorldObject object = modules.getWorld().get(id);
29  		if(object instanceof ILocated)
30  			return (ILocated) object;
31  		
32  		return null;
33  	}
34  
35  	/*
36  	 * (non-Javadoc)
37  	 * 
38  	 * @see java.lang.Object#toString()
39  	 */
40  	@Override
41  	public String toString() {
42  		return "APlayer [id=" + id + "]";
43  	}
44  }