SuperTuxKart
Public Member Functions | Private Attributes | List of all members
Powerup Class Reference
Inheritance diagram for Powerup:
Inheritance graph
[legend]

Public Member Functions

 Powerup (AbstractKart *kart_)
 Constructor, stores the kart to which this powerup belongs. More...
 
 ~Powerup ()
 Frees the memory for the sound effects.
 
void set (PowerupManager::PowerupType _type, int n=1)
 Sets the collected items. More...
 
void reset ()
 Resets the powerup, called at begin of a race.
 
MaterialgetIcon () const
 Returns the icon for the currently collected powerup. More...
 
void adjustSound ()
 Does the sound configuration.
 
void use ()
 Use (fire) this powerup.
 
void hitBonusBox (const ItemState &item)
 This function is called when a bnous box is it. More...
 
void saveState (BareNetworkString *buffer) const
 Save the powerup state. More...
 
void rewindTo (BareNetworkString *buffer)
 Restore a powerup state. More...
 
void update (int ticks)
 
int getNum () const
 Returns the number of powerups. More...
 
PowerupManager::PowerupType getType () const
 Returns the type of this powerup. More...
 

Private Attributes

SFXBasem_sound_use
 Sound effect that is being played. More...
 
PowerupManager::PowerupType m_type
 The powerup type. More...
 
int m_number
 Number of collected powerups. More...
 
AbstractKartm_kart
 The owner (kart) of this powerup. More...
 
std::set< int > m_played_sound_ticks
 

Constructor & Destructor Documentation

◆ Powerup()

Powerup::Powerup ( AbstractKart kart)

Constructor, stores the kart to which this powerup belongs.

Parameters
kartThe kart to which this powerup belongs.

Member Function Documentation

◆ getIcon()

Material * Powerup::getIcon ( ) const

Returns the icon for the currently collected powerup.

Used in the race_gui to display the collected item.

◆ getNum()

int Powerup::getNum ( ) const
inline

Returns the number of powerups.

◆ getType()

PowerupManager::PowerupType Powerup::getType ( ) const
inline

Returns the type of this powerup.

◆ hitBonusBox()

void Powerup::hitBonusBox ( const ItemState item_state)

This function is called when a bnous box is it.

This function can be called on a server (in which case item and add_info are not used), or on a client, in which case the item and additional info is used to make sure server and clients are synched correctly.

Parameters
n
item_stateThe item_state (bonux box) that was hit. This is necessary for servers so that the clients can be informed which item was collected.

◆ rewindTo()

void Powerup::rewindTo ( BareNetworkString buffer)

Restore a powerup state.

Called from the kart rewinder when restoring a state.

Parameters
bufferBuffer with the state of this powerup object.

◆ saveState()

void Powerup::saveState ( BareNetworkString buffer) const

Save the powerup state.

Called from the kart rewinder when saving the kart state or when a new powerup even is saved.

Parameters
bufferThe buffer into which to save the state.

◆ set()

void Powerup::set ( PowerupManager::PowerupType  type,
int  n = 1 
)

Sets the collected items.

The number of items is increased if the same item is currently collected, otherwise replaces the existing item. It also sets item specific sounds.

Parameters
typeThew new type.
nNumber of items of the given type.

Member Data Documentation

◆ m_kart

AbstractKart* Powerup::m_kart
private

The owner (kart) of this powerup.

◆ m_number

int Powerup::m_number
private

Number of collected powerups.

◆ m_sound_use

SFXBase* Powerup::m_sound_use
private

Sound effect that is being played.

◆ m_type

PowerupManager::PowerupType Powerup::m_type
private

The powerup type.


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