View Javadoc

1   package nl.tudelft.pogamut.unreal.agent.module.shooting.util;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
7   import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
8   
9   /**
10   * A list of focus providers. First provider to provide a non-null location be
11   * used.
12   * 
13   * @author mpkorstanje
14   * 
15   */
16  public final class OrderedFocusProvider implements ILocated {
17  
18  	protected List<ILocated> providers = new ArrayList<ILocated>();
19  
20  	public void add(ILocated provider) {
21  		providers.add(provider);
22  	}
23  
24  	@Override
25  	public Location getLocation() {
26  		for (ILocated focus : providers) {
27  			if (focus.getLocation() != null) {
28  				return focus.getLocation();
29  			}
30  		}
31  
32  		return null;
33  	}
34  
35  }