SuperTuxKart
Loading...
Searching...
No Matches
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.
 
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.
 
bool isSwatterReady () const
 Returns if the swatter is currently aiming, i.e.
 
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.
 
virtual void updateGraphics (float dt)=0
 
virtual bool updateAndTestFinished (int ticks)=0
 Updates a plugin.
 
virtual void restoreState (BareNetworkString *buffer)
 
virtual void saveState (BareNetworkString *buffer) const
 

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.
 
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.
 
SFXBasem_swat_sound
 
scene::IAnimatedMeshSceneNode * m_scene_node
 Set the end ticks to complete the removing an attached bomb animation.
 
scene::IAnimatedMeshSceneNode * m_bomb_scene_node
 The scene node where a bomb is saved (in case that the swatter replaces a bomb.
 
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.
 
int16_t m_swatter_animation_ticks
 
bool m_discard_now
 True if the swatter will be discarded now.
 
bool m_played_swatter_animation
 True if the swatter animation has been played.
 

Additional Inherited Members

- Protected Attributes inherited from AttachmentPlugin
AbstractKartm_kart
 Kart the attachment is attached to.
 
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.

◆ restoreState()

void Swatter::restoreState ( BareNetworkString buffer)
virtual

Reimplemented from AttachmentPlugin.

◆ saveState()

void Swatter::saveState ( BareNetworkString buffer) const
virtual

Reimplemented from AttachmentPlugin.

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

◆ updateGraphics()

void Swatter::updateGraphics ( float  dt)
virtual

Implements AttachmentPlugin.

Member Data Documentation

◆ 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: