OpenXcom  1.0
Open-source clone of the original X-Com
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 (Mod *mod, SavedBattleGame *save, BattleAction action, Position origin, Position target, BattleItem *ammo)
 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 () const
 Gets the Position of origin for the projectile. More...
 
Position getTarget () const
 Gets the targetted tile for the projectile. More...
 
bool isReversed () const
 Is this projectile being drawn back-to-front or front-to-back? More...
 
void addVaporCloud ()
 adds a cloud of particles at the projectile's location 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

◆ Projectile()

OpenXcom::Projectile::Projectile ( Mod mod,
SavedBattleGame save,
BattleAction  action,
Position  origin,
Position  targetVoxel,
BattleItem ammo 
)

Creates a new Projectile.

Sets up a UnitSprite with the specified size and position.

Parameters
modPointer to mod.
savePointer to battlesavegame.
actionAn action.
originPosition the projectile originates from.
targetVoxelPosition the projectile is targeting.
ammothe ammo that produced this projectile, where applicable.

◆ ~Projectile()

OpenXcom::Projectile::~Projectile ( )

Cleans up the Projectile.

Deletes the Projectile.

Member Function Documentation

◆ addVaporCloud()

void OpenXcom::Projectile::addVaporCloud ( )

adds a cloud of particles at the projectile's location

adds a cloud of vapor at the projectile's current position.

◆ calculateThrow()

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.

◆ calculateTrajectory()

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).

◆ getItem()

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.

◆ getOrigin()

Position OpenXcom::Projectile::getOrigin ( ) const

Gets the Position of origin for the projectile.

Returns
origin as a tile position.

◆ getParticle()

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.

◆ getPosition()

Position OpenXcom::Projectile::getPosition ( int  offset = 0) const

Gets the current position in voxel space.

Parameters
offsetOffset.
Returns
Position in voxel space.

◆ getSprite()

Surface * OpenXcom::Projectile::getSprite ( ) const

Gets the sprite.

Gets the bullet sprite.

Returns
Pointer to Surface.

◆ getTarget()

Position OpenXcom::Projectile::getTarget ( ) const

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.

◆ isReversed()

bool OpenXcom::Projectile::isReversed ( ) const

Is this projectile being drawn back-to-front or front-to-back?

Is this projectile drawn back to front or front to back?

Returns
return if this is to be drawn in reverse order.

◆ move()

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.

◆ skipTrajectory()

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: