SuperTuxKart
|
This objects is permanently available in a kart and stores information about addons. More...
#include <attachment.hpp>
Public Member Functions | |
Attachment (AbstractKart *kart) | |
Initialises the attachment each kart has. | |
~Attachment () | |
Removes the attachment object. | |
void | clear () |
Removes any attachement currently on the kart. | |
void | hitBanana (ItemState *item) |
Selects the new attachment. | |
void | updateGraphics (float dt) |
void | update (int ticks) |
void | handleCollisionWithKart (AbstractKart *other) |
Updates the attachments in case of a kart-kart collision. | |
void | set (AttachmentType type, int ticks, AbstractKart *previous_kart=NULL, bool set_by_rewind_parachute=false) |
Sets the attachment a kart has. | |
void | rewindTo (BareNetworkString *buffer) |
Called from the kart rewinder when resetting to a certain state. | |
void | saveState (BareNetworkString *buffer) const |
Saves the attachment state. | |
void | set (AttachmentType type) |
Sets the type of the attachment, but keeps the old time left value. | |
AttachmentType | getType () const |
Returns the type of this attachment. | |
int16_t | getTicksLeft () const |
Returns how much time (in ticks) is left before this attachment is removed. | |
void | setTicksLeft (int16_t t) |
Sets how long this attachment will remain attached. | |
AbstractKart * | getPreviousOwner () const |
Returns the previous owner of this attachment, used in bombs that are being passed between karts. | |
float | weightAdjust () const |
Returns additional weight for the kart. | |
scene::IAnimatedMeshSceneNode * | getNode () |
Return the currently associated scene node (used by e.g the swatter) | |
void | reset () |
Private Attributes | |
AttachmentType | m_type |
Attachment type. | |
AttachmentType | m_graphical_type |
Graphical Attachment type (comparing in updateGraphics). | |
AbstractKart * | m_kart |
Kart the attachment is attached to. | |
int16_t | m_ticks_left |
Time left till attachment expires. | |
int16_t | m_initial_speed |
For parachutes only, stored in cm/s for networking. | |
int | m_scaling_end_ticks |
For zoom-in animation. | |
scene::IAnimatedMeshSceneNode * | m_node |
Scene node of the attachment, which will be attached to the kart's scene node. | |
AbstractKart * | m_previous_owner |
Used by bombs so that it's not passed back to previous owner. | |
AttachmentPlugin * | m_plugin |
An optional attachment - additional functionality can be implemented for certain attachments. | |
SFXBase * | m_bomb_sound |
Ticking sound for the bomb. | |
SFXBase * | m_bubble_explode_sound |
Sound for exploding bubble gum shield. | |
This objects is permanently available in a kart and stores information about addons.
If a kart has no attachment, this object will have the attachment type ATTACH_NOTHING. This way other tests for attachment in STK do not have to additionally test if there is an attachment, all tests for a type will always be valid. Certain attachments need additional coding, this is supported by a 'plugin' mechanism: This attachment will forward certain calls to (see attachment_pluging abstract class). Compared to normal subclassing (i.e. replacing the attachment object each time an attachment changes) this has less overhead (since the attachment class always creates a scene node).
Attachment::~Attachment | ( | ) |
Removes the attachment object.
It removes the scene node used to display the attachment, and stops any sfx from being played.
void Attachment::clear | ( | ) |
Removes any attachement currently on the kart.
As for the anvil attachment, takes care of resetting the owner kart's physics structures to account for the updated mass.
void Attachment::handleCollisionWithKart | ( | AbstractKart * | other | ) |
Updates the attachments in case of a kart-kart collision.
This must only be called for one of the karts in the collision, since it will update the attachment for both karts.
other | Pointer to the other kart hit. |
void Attachment::hitBanana | ( | ItemState * | item_state | ) |
Selects the new attachment.
In order to simplify synchronisation with the server, the new item is based on the current world time.
item | The item that was collected. |
void Attachment::rewindTo | ( | BareNetworkString * | buffer | ) |
Called from the kart rewinder when resetting to a certain state.
buffer | The kart rewinder's buffer with the attachment state next. |
void Attachment::saveState | ( | BareNetworkString * | buffer | ) | const |
Saves the attachment state.
Called as part of the kart saving its state.
buffer | The kart rewinder's state buffer. |
void Attachment::set | ( | AttachmentType | type, |
int | ticks, | ||
AbstractKart * | current_kart = NULL , |
||
bool | set_by_rewind_parachute = false |
||
) |
Sets the attachment a kart has.
This will also handle animation to be played, e.g. when a swatter replaces a bomb.
type | The type of the new attachment. |
time | How long this attachment should stay with the kart. |
current_kart | The kart from which an attachment is transferred. This is currently used for the bomb (to avoid that a bomb can be passed back to the previous owner). NULL if a no previous owner exists. |
float Attachment::weightAdjust | ( | ) | const |
Returns additional weight for the kart.
Return the additional weight of the attachment (some attachments slow karts down by also making them heavier).