nl.tudelft.pogamut.ut2004.agent.module.shooting
Class AbstractWeaponShooting

Package class diagram package AbstractWeaponShooting
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT>
      extended by cz.cuni.amis.pogamut.base.agent.module.SensorModule<UT2004Bot>
          extended by nl.tudelft.pogamut.ut2004.agent.module.shooting.AbstractWeaponShooting
All Implemented Interfaces:
cz.cuni.amis.pogamut.base.component.IComponent, WeaponShooting
Direct Known Subclasses:
AssaultRifleShooting, BioRifleShooting, FlakCannonShooting, GenericWeaponShooting, IonPainterShooting, LigthningGunShooting, LinkGunShooting, MinigunShooting, ReedeemerShooting, RocketLauncherShooting, ShieldGunShooting, ShockRifleShooting

public abstract class AbstractWeaponShooting
extends cz.cuni.amis.pogamut.base.agent.module.SensorModule<UT2004Bot>
implements WeaponShooting

Base class for all shootings. Handles setting of target and weapon prefs and automates calling of shoot().

Author:
mpkorstanje

Field Summary
protected static cz.cuni.amis.pogamut.base3d.worldview.object.Location ABOVE_PLAYER_OFFSET
          Height of player, aim this much above player to shoot around shield.
protected  boolean active
          If this shooting has been activated.
protected static cz.cuni.amis.pogamut.base3d.worldview.object.Location BELOW_PLAYER_OFFSET
          Half of height of player, aim this much below player to shoot at feet.
protected  nl.tudelft.pogamut.ut2004.agent.module.shooting.AbstractWeaponShooting.EndMessageListener endMessageListener
          EndMessage listener
protected static double FACING_ANGLE
           
protected  FocusProvider focus
          Where the shooting would like the bot to look.
protected  AgentInfo info
          Reference to AgentInfo module.
protected  ImprovedShooting shoot
          Reference to ImprovedShooting module.
protected  cz.cuni.amis.pogamut.base3d.worldview.object.ILocated target
          Our target to shoot.
protected  WeaponPref weaponPref
          Weapon pref indicates which firing mode to use.
protected  Weaponry weaponry
          Reference to Weaponry module.
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensorModule
worldView
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
agent, controller, eventBus, log
 
Constructor Summary
AbstractWeaponShooting(UT2004Bot<?,?,?> agent, AgentInfo info, ImprovedShooting shoot, Weaponry weaponry)
          Creates an abstract WeaponShooting.
 
Method Summary
protected abstract  WeaponPref getDefaultWeaponPref()
           
 cz.cuni.amis.pogamut.base3d.worldview.object.ILocated getFocus()
          Where the shooting would like the agent to look.
 ItemType getWeaponType()
          The weapon type this module can do the shooting for.
 boolean hasTarget()
           
 boolean isActive()
          True when this module has been activated and is managing a weapon.
protected  boolean isWeaponReady()
           
protected  void setFocus(cz.cuni.amis.pogamut.base3d.worldview.object.ILocated focus)
          Sets where the shooting would like to look.
protected abstract  void shoot()
           Shoot will be called after every end message.
 void shoot(WeaponPref weaponPref, cz.cuni.amis.pogamut.base3d.worldview.object.ILocated target)
          Set target to shoot at, actual shooting is deferred to next end message.
 void stopShoot()
          Stops the shooting.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FACING_ANGLE

protected static final double FACING_ANGLE
See Also:
Constant Field Values

BELOW_PLAYER_OFFSET

protected static final cz.cuni.amis.pogamut.base3d.worldview.object.Location BELOW_PLAYER_OFFSET
Half of height of player, aim this much below player to shoot at feet.


ABOVE_PLAYER_OFFSET

protected static final cz.cuni.amis.pogamut.base3d.worldview.object.Location ABOVE_PLAYER_OFFSET
Height of player, aim this much above player to shoot around shield.


target

protected cz.cuni.amis.pogamut.base3d.worldview.object.ILocated target
Our target to shoot. May be null, in which case we may charge a weapon.


weaponPref

protected WeaponPref weaponPref
Weapon pref indicates which firing mode to use.


shoot

protected ImprovedShooting shoot
Reference to ImprovedShooting module.


weaponry

protected Weaponry weaponry
Reference to Weaponry module.


info

protected AgentInfo info
Reference to AgentInfo module.


active

protected boolean active
If this shooting has been activated.


focus

protected FocusProvider focus
Where the shooting would like the bot to look.


endMessageListener

protected nl.tudelft.pogamut.ut2004.agent.module.shooting.AbstractWeaponShooting.EndMessageListener endMessageListener
EndMessage listener

Constructor Detail

AbstractWeaponShooting

public AbstractWeaponShooting(UT2004Bot<?,?,?> agent,
                              AgentInfo info,
                              ImprovedShooting shoot,
                              Weaponry weaponry)
Creates an abstract WeaponShooting.

Parameters:
agent - the bot that does the shooting.
info - the info module for the bot.
shoot - the shooting module for the bot.
weaponry - the weaponry module for the bot.
Method Detail

shoot

public void shoot(WeaponPref weaponPref,
                  cz.cuni.amis.pogamut.base3d.worldview.object.ILocated target)
Set target to shoot at, actual shooting is deferred to next end message.
Callers should ensure that weapon used by is available and has sufficient ammunition.

Specified by:
shoot in interface WeaponShooting
Parameters:
player -

getDefaultWeaponPref

protected abstract WeaponPref getDefaultWeaponPref()
Returns:
the default weapon preference.

stopShoot

public void stopShoot()
Stops the shooting.

Specified by:
stopShoot in interface WeaponShooting

setFocus

protected void setFocus(cz.cuni.amis.pogamut.base3d.worldview.object.ILocated focus)
Sets where the shooting would like to look.

Parameters:
focus - where we want to look.

getFocus

public cz.cuni.amis.pogamut.base3d.worldview.object.ILocated getFocus()
Where the shooting would like the agent to look.

Specified by:
getFocus in interface WeaponShooting
Returns:
a focus indicating where the owner wants to focus.

hasTarget

public boolean hasTarget()
Returns:
true iff we have target.

getWeaponType

public ItemType getWeaponType()
The weapon type this module can do the shooting for.

Specified by:
getWeaponType in interface WeaponShooting
Returns:
the weapon type we'll shoot with.

isActive

public boolean isActive()
Description copied from interface: WeaponShooting
True when this module has been activated and is managing a weapon.

Specified by:
isActive in interface WeaponShooting
Returns:
true if the shooting has been activated.

isWeaponReady

protected boolean isWeaponReady()
Returns:
if we have the WeaponShooting.getWeaponType().

shoot

protected abstract void shoot()

Shoot will be called after every end message.

Implementing subclasses should make a best effort attempt to shoot the given target using the given weapon preference if possible. Subclasses should take care to note that a target may not always be present. e.g. target == null.



Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.