View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.bot.command;
2   
3   import java.util.logging.Logger;
4   
5   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
6   import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
7   import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
8   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Shoot;
9   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.StopShooting;
10  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
11  
12  /**
13   * Class providing Pogamut2 UT2004 simple shooting commands for the bot
14   * 
15   * @author Michal 'Knight' Bida
16   */
17  public class SimpleShooting extends BotCommands {
18  
19  	/**
20  	 * Bot will start shooting his current weapon (Issues GB SHOOT command)
21  	 * 
22  	 * @see stopShoot()
23  	 * @see shoot(UnrealId)
24  	 * @see shoot(ILocated)
25  	 */
26  	public void shoot() {
27  		agent.getAct().act(new Shoot());
28  	}
29  
30  	/**
31  	 * Bot will start shooting his current weapon to a specified location (Issues GB SHOOT command).
32  	 * 
33  	 * @param location
34  	 * 
35  	 * @see stopShoot()
36  	 * @see shoot(UnrealId);
37  	 */
38  	public void shoot(ILocated location) {
39  		if (location instanceof Player) {
40  			shoot((Player)location);
41  		} else {
42  			agent.getAct().act(new Shoot().setLocation(location.getLocation()));
43  		}
44  	}
45  	
46  	/**
47  	 * Bot will start shooting with his current weapon at the target provided.
48  	 * (Issues GB SHOOT command) Note that the bot will track the target while
49  	 * shooting. If not interrupted by other command that will change bot target
50  	 * or that will change bot focus too much.
51  	 * 
52  	 * @param target
53  	 *            Target (that should be ILocated) the bot will shoot at. Bot
54  	 *            will track the target, but see note above.
55  	 * 
56  	 * @see stopShoot()
57  	 * @see shoot()
58  	 */
59  	public void shoot(UnrealId target) {
60  		agent.getAct().act(new Shoot().setTarget(target));
61  	}
62  	
63  	/**
64  	 * Bot will start shooting with his current weapon at the target provided.
65  	 * (Issues GB SHOOT command) Note that the bot will track the target while
66  	 * shooting. If not interrupted by other command that will change bot target
67  	 * or that will change bot focus too much.
68  	 * 
69  	 * @param target
70  	 *            Player the bot wants to shoot at.
71  	 * 
72  	 * @see stopShoot()
73  	 * @see shoot()
74  	 */
75  	public void shoot(Player target) {
76  		agent.getAct().act(new Shoot().setTarget(target.getId()));
77  	}
78  
79  	/**
80  	 * Bot will stop shooting his current weapon (Issues GB STOPSHOOT command)
81  	 * 
82  	 * Use {@link SimpleShooting#stopShooting()} instead!
83  	 * 
84  	 * @see shoot()
85  	 * @see shoot(UnrealId)
86  	 */
87  	@Deprecated
88  	public void stopShoot() {
89  		agent.getAct().act(new StopShooting());
90  	}
91  	
92  	/**
93  	 * Bot will stop shooting his current weapon (Issues GB STOPSHOOT command)
94  	 * 
95  	 * @see shoot()
96  	 * @see shoot(UnrealId)
97  	 */
98  	public void stopShooting() {
99  		agent.getAct().act(new StopShooting());
100 	}
101 
102 	/**
103 	 * Constructor. Setups the command module based on given agent and logger.
104 	 * 
105 	 * @param agent
106 	 *            AbstractUT2004Bot we will send commands for
107 	 * @param log
108 	 *            Logger to be used for logging runtime/debug info.
109 	 */
110 	public SimpleShooting(UT2004Bot agent, Logger log) {
111 		super(agent, log);
112 	}
113 
114 }