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

Public Member Functions

 Swatter (AbstractKart *kart, int16_t bomb_ticks, int ticks, Attachment *attachment)
 Constructor: creates a swatter at a given attachment for a kart. More...
 
virtual ~Swatter ()
 Destructor, stops any playing sfx.
 
void updateGraphics (float dt) OVERRIDE
 
bool updateAndTestFinished (int ticks) OVERRIDE
 Updates an armed swatter: it checks for any karts that are close enough and not invulnerable, it swats the kart. More...
 
bool isSwatterReady () const
 Returns if the swatter is currently aiming, i.e. More...
 
virtual void restoreState (BareNetworkString *buffer) OVERRIDE
 
virtual void saveState (BareNetworkString *buffer) const OVERRIDE
 
- Public Member Functions inherited from AttachmentPlugin
 AttachmentPlugin (AbstractKart *kart, Attachment *attachment)
 Constructor for a plugin. More...
 

Private Types

enum  AnimationPhase : uint8_t { SWATTER_AIMING = 0, SWATTER_TO_TARGET = 1, SWATTER_FROM_TARGET = 2 }
 State of the animation, the swatter is successively: More...
 

Private Member Functions

void chooseTarget ()
 Determine the nearest kart or item and update the current target accordingly.
 
void pointToTarget ()
 If there is a current target, point to it, otherwise adopt the default position. More...
 
void squashThingsAround ()
 Squash karts or items that are around the end position (determined using a joint) of the swatter.
 

Private Attributes

AnimationPhase m_animation_phase
 
AbstractKartm_closest_kart
 The kart the swatter is aiming at. More...
 
SFXBasem_swat_sound
 
scene::IAnimatedMeshSceneNode * m_scene_node
 Set the end ticks to complete the removing an attached bomb animation. More...
 
scene::IAnimatedMeshSceneNode * m_bomb_scene_node
 The scene node where a bomb is saved (in case that the swatter replaces a bomb. More...
 
int m_discard_ticks
 
int m_swatter_duration
 
int16_t m_bomb_remaining
 Set the bomb remaing ticks so we can set the timer on the removing bomb animation. More...
 
int16_t m_swatter_animation_ticks
 
bool m_discard_now
 True if the swatter will be discarded now. More...
 
bool m_played_swatter_animation
 True if the swatter animation has been played. More...
 

Additional Inherited Members

- Protected Attributes inherited from AttachmentPlugin
AbstractKartm_kart
 Kart the attachment is attached to. More...
 
Attachmentm_attachment
 

Member Enumeration Documentation

◆ AnimationPhase

enum Swatter::AnimationPhase : uint8_t
private

State of the animation, the swatter is successively:

  • aiming (default state) => it's turning to the nearest target
  • going down to the target
  • going up from the target

Constructor & Destructor Documentation

◆ Swatter()

Swatter::Swatter ( AbstractKart kart,
int16_t  bomb_ticks,
int  ticks,
Attachment attachment 
)

Constructor: creates a swatter at a given attachment for a kart.

If there was a bomb attached, it triggers the replace bomb animations.

Parameters
attachmentThe attachment instance where the swatter is attached to.
kartThe kart to which the swatter is attached.
bomb_ticksRemaining bomb time in ticks, -1 if none.
ticksSwatter duration.
attachmentclass attachment from karts.

Member Function Documentation

◆ isSwatterReady()

bool Swatter::isSwatterReady ( ) const
inline

Returns if the swatter is currently aiming, i.e.

can be used to swat an incoming projectile.

◆ pointToTarget()

void Swatter::pointToTarget ( )
private

If there is a current target, point to it, otherwise adopt the default position.

If there is a current target, point in its direction, otherwise adopt the default position.

◆ updateAndTestFinished()

bool Swatter::updateAndTestFinished ( int  ticks)
virtual

Updates an armed swatter: it checks for any karts that are close enough and not invulnerable, it swats the kart.

Parameters
ticksTime step size.
Returns
True if the attachment should be discarded.

Implements AttachmentPlugin.

Member Data Documentation

◆ m_bomb_remaining

int16_t Swatter::m_bomb_remaining
private

Set the bomb remaing ticks so we can set the timer on the removing bomb animation.

◆ m_bomb_scene_node

scene::IAnimatedMeshSceneNode* Swatter::m_bomb_scene_node
private

The scene node where a bomb is saved (in case that the swatter replaces a bomb.

◆ m_closest_kart

AbstractKart* Swatter::m_closest_kart
private

The kart the swatter is aiming at.

◆ m_discard_now

bool Swatter::m_discard_now
private

True if the swatter will be discarded now.

◆ m_played_swatter_animation

bool Swatter::m_played_swatter_animation
private

True if the swatter animation has been played.

◆ m_scene_node

scene::IAnimatedMeshSceneNode* Swatter::m_scene_node
private

Set the end ticks to complete the removing an attached bomb animation.

The scene node of the attachment.


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