SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MaxSpeed::SpeedDecrease Class Reference

An internal class to store and handle speed decrease related data. More...

Public Member Functions

 SpeedDecrease ()
 The constructor initialises the data with data that won't affect top speed at all.
 
void reset ()
 Resets the state to be inactive.
 
void update (int ticks)
 Handles the speed increase for a certain category.
 
void saveState (BareNetworkString *buffer) const
 Saves the state of an (active) speed decrease category.
 
void rewindTo (BareNetworkString *buffer, bool is_active)
 Restores a previously saved state for an active speed decrease category.
 
float getSlowdownFraction () const
 Returns the current slowdown fracftion, taking a 'fade in' into account.
 
int getTimeLeft () const
 
bool isActive () const
 Returns if this speed decrease is active atm.
 

Public Attributes

uint16_t m_max_speed_fraction
 The maximum slowdown to apply, 3 digits precision.
 
float m_current_fraction
 The current slowdown fraction, taking the fade-in time into account.
 
int16_t m_fade_in_ticks
 How long it should take for the full slowdown to take effect.
 
int16_t m_duration
 How long the effect should last.
 

Detailed Description

An internal class to store and handle speed decrease related data.

Member Function Documentation

◆ isActive()

bool MaxSpeed::SpeedDecrease::isActive ( ) const
inline

Returns if this speed decrease is active atm.

A duration of -1 indicates an ongoing effect.

◆ saveState()

void MaxSpeed::SpeedDecrease::saveState ( BareNetworkString buffer) const

Saves the state of an (active) speed decrease category.

It is not called if the speed decrease is not active.

Parameters
bufferBuffer which will store the state information.

◆ update()

void MaxSpeed::SpeedDecrease::update ( int  ticks)

Handles the speed increase for a certain category.

Parameters
dtTime step size.

Member Data Documentation

◆ m_duration

int16_t MaxSpeed::SpeedDecrease::m_duration

How long the effect should last.

A -1 as value indicates that this effect stays active till it is changed back.


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