OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::Projectile Class Reference

A class that represents a projectile. More...

#include <Projectile.h>

Public Member Functions

 Projectile (ResourcePack *res, SavedBattleGame *save, BattleAction action, Position origin, Position target)
 Creates a new Projectile. More...
 
 ~Projectile ()
 Cleans up the Projectile. More...
 
int calculateTrajectory (double accuracy)
 Calculates the trajectory for a straight path. More...
 
int calculateThrow (double accuracy)
 Calculates the trajectory for a curved path. More...
 
bool move ()
 Moves the projectile one step in its trajectory. More...
 
Position getPosition (int offset=0) const
 Gets the current position in voxel space. More...
 
int getParticle (int i) const
 Gets a particle from the particle array. More...
 
BattleItemgetItem () const
 Gets the item. More...
 
SurfacegetSprite () const
 Gets the sprite. More...
 
void skipTrajectory ()
 Skips the bullet flight. More...
 
Position getOrigin ()
 Gets the Position of origin for the projectile. More...
 
Position getTarget ()
 Gets the targetted tile for the projectile. More...
 

Detailed Description

A class that represents a projectile.

Map is the owner of an instance of this class during its short life. It calculates its own trajectory and then moves along this precalculated trajectory in voxel space.

Constructor & Destructor Documentation

OpenXcom::Projectile::Projectile ( ResourcePack res,
SavedBattleGame save,
BattleAction  action,
Position  origin,
Position  targetVoxel 
)

Creates a new Projectile.

Sets up a UnitSprite with the specified size and position.

Parameters
resPointer to resourcepack.
savePointer to battlesavegame.
actionAn action.
originPosition the projectile originates from.
targetVoxelPosition the projectile is targeting.
OpenXcom::Projectile::~Projectile ( )

Cleans up the Projectile.

Deletes the Projectile.

Member Function Documentation

int OpenXcom::Projectile::calculateThrow ( double  accuracy)

Calculates the trajectory for a curved path.

Parameters
accuracyThe unit's accuracy.
Returns
True when a trajectory is possible.
int OpenXcom::Projectile::calculateTrajectory ( double  accuracy)

Calculates the trajectory for a straight path.

Parameters
accuracyThe unit's accuracy.
Returns
The objectnumber(0-3) or unit(4) or out of map (5) or -1 (no line of fire).
BattleItem * OpenXcom::Projectile::getItem ( ) const

Gets the item.

Gets the project tile item.

Returns 0 when there is no item thrown.

Returns
Pointer to BattleItem.
Position OpenXcom::Projectile::getOrigin ( )

Gets the Position of origin for the projectile.

Returns
origin as a tile position.
int OpenXcom::Projectile::getParticle ( int  i) const

Gets a particle from the particle array.

Gets a particle reference from the projectile surfaces.

Parameters
iIndex.
Returns
Particle id.
Position OpenXcom::Projectile::getPosition ( int  offset = 0) const

Gets the current position in voxel space.

Parameters
offsetOffset.
Returns
Position in voxel space.
Surface * OpenXcom::Projectile::getSprite ( ) const

Gets the sprite.

Gets the bullet sprite.

Returns
Pointer to Surface.
Position OpenXcom::Projectile::getTarget ( )

Gets the targetted tile for the projectile.

Gets the INTENDED target for this projectile it is important to note that we do not use the final position of the projectile here, but rather the targetted tile.

Returns
target as a tile position.
bool OpenXcom::Projectile::move ( )

Moves the projectile one step in its trajectory.

Moves further in the trajectory.

Returns
false if the trajectory is finished - no new position exists in the trajectory.
void OpenXcom::Projectile::skipTrajectory ( )

Skips the bullet flight.

Skips to the end of the trajectory.


The documentation for this class was generated from the following files: