19#ifndef HEADER_MAX_SPEED_HPP
20#define HEADER_MAX_SPEED_HPP
37 enum {MS_INCREASE_MIN,
38 MS_INCREASE_ZIPPER = MS_INCREASE_MIN,
39 MS_INCREASE_SLIPSTREAM,
43 MS_INCREASE_RED_SKIDDING,
48 enum {MS_DECREASE_MIN,
49 MS_DECREASE_TERRAIN = MS_DECREASE_MIN,
97 m_duration = std::numeric_limits<int16_t>::min();
168 int getTimeLeft()
const {
return m_duration; }
189 float engine_force,
int duration,
192 float add_speed,
float speed_boost,
193 float engine_force,
int duration,
195 void setSlowdown(
unsigned int category,
float max_speed_fraction,
196 int fade_in_time,
int duration=-1);
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: kart_rewinder.hpp:30
An internal class to store and handle speed decrease related data.
Definition: max_speed.hpp:129
float m_current_fraction
The current slowdown fraction, taking the fade-in time into account.
Definition: max_speed.hpp:135
void rewindTo(BareNetworkString *buffer, bool is_active)
Restores a previously saved state for an active speed decrease category.
Definition: max_speed.cpp:351
void saveState(BareNetworkString *buffer) const
Saves the state of an (active) speed decrease category.
Definition: max_speed.cpp:340
SpeedDecrease()
The constructor initialises the data with data that won't affect top speed at all.
Definition: max_speed.hpp:146
bool isActive() const
Returns if this speed decrease is active atm.
Definition: max_speed.hpp:172
void reset()
Resets the state to be inactive.
Definition: max_speed.hpp:152
float getSlowdownFraction() const
Returns the current slowdown fracftion, taking a 'fade in' into account.
Definition: max_speed.hpp:166
int16_t m_fade_in_ticks
How long it should take for the full slowdown to take effect.
Definition: max_speed.hpp:138
uint16_t m_max_speed_fraction
The maximum slowdown to apply, 3 digits precision.
Definition: max_speed.hpp:132
int16_t m_duration
How long the effect should last.
Definition: max_speed.hpp:142
void update(int ticks)
Handles the speed increase for a certain category.
Definition: max_speed.cpp:307
An internal class to store and handle speed increase related data.
Definition: max_speed.hpp:71
float m_current_speedup
The current max speed increase value, updated with duration.
Definition: max_speed.hpp:83
bool isActive() const
Returns if this speed increase is active atm.
Definition: max_speed.hpp:123
int16_t m_duration
How long this speed will apply.
Definition: max_speed.hpp:79
int getTimeLeft() const
Returns the remaining time till the fade out time starts.
Definition: max_speed.hpp:114
float getSpeedIncrease() const
Returns the current speedup for this category.
Definition: max_speed.hpp:108
uint16_t m_max_add_speed
The maximum additional speed allowed, 3 digits precision.
Definition: max_speed.hpp:74
int16_t m_fade_out_time
The fadeout time.
Definition: max_speed.hpp:81
uint16_t m_engine_force
Additional engine force, 1 digit precision.
Definition: max_speed.hpp:85
SpeedIncrease()
The constructor initialised the values with a no-increase entry, i.e.
Definition: max_speed.hpp:88
void update(int ticks)
Handles the update of speed increase objects.
Definition: max_speed.cpp:195
float getEngineForce() const
Returns the additional engine force for this speed increase.
Definition: max_speed.hpp:117
void reset()
Resets this increase category to be not active.
Definition: max_speed.hpp:94
Definition: max_speed.hpp:31
float m_min_speed
If >0 then the minimum speed a kart should have (used for zippers).
Definition: max_speed.hpp:66
int getSpeedIncreaseTicksLeft(unsigned int category)
Returns how much increased speed time is left over in the given category.
Definition: max_speed.cpp:371
void instantSpeedIncrease(unsigned int category, float add_speed, float speed_boost, float engine_force, int duration, int fade_out_time)
This adjusts the top speed using increaseMaxSpeed, but additionally causes an instant speed boost,...
Definition: max_speed.cpp:166
float m_current_max_speed
The current maximum speed.
Definition: max_speed.hpp:60
SpeedIncrease m_speed_increase[MS_INCREASE_MAX]
Stores all speed increase related information for each possible category.
Definition: max_speed.hpp:182
int isSpeedIncreaseActive(unsigned int category)
Returns if increased speed is active in the given category.
Definition: max_speed.cpp:380
SpeedDecrease m_speed_decrease[MS_DECREASE_MAX]
Stores all speed decrease related information for each possible category.
Definition: max_speed.hpp:178
AbstractKart * m_kart
A pointer to the kart to which this speed handling object belongs.
Definition: max_speed.hpp:57
float getCurrentMaxSpeed() const
Returns the current maximum speed for this kart.
Definition: max_speed.hpp:212
int isSpeedDecreaseActive(unsigned int category)
Returns if decreased speed is active in the given category.
Definition: max_speed.cpp:389
void reset()
Reset to prepare for a restart.
Definition: max_speed.cpp:66
float m_add_engine_force
Additional engine force, summed from all SpeedIncrease engine forces.
Definition: max_speed.hpp:63
void rewindTo(BareNetworkString *buffer)
Restore a saved state.
Definition: max_speed.cpp:507
void setSlowdown(unsigned int category, float max_speed_fraction, int fade_in_time, int duration=-1)
Defines a slowdown, which is in fraction of top speed.
Definition: max_speed.cpp:257
void setMinSpeed(float s)
Sets the minimum speed a kart should have.
Definition: max_speed.hpp:209
void increaseMaxSpeed(unsigned int category, float add_speed, float engine_force, int duration, int fade_out_time)
Sets an increased maximum speed for a category.
Definition: max_speed.cpp:93
float getCurrentAdditionalEngineForce() const
Returns the additional engine force.
Definition: max_speed.hpp:215
void saveState(BareNetworkString *buffer) const
Saves the speed data in a network string for rewind.
Definition: max_speed.cpp:458
void update(int ticks)
Updates all speed increase and decrease objects, and determines the current maximum speed.
Definition: max_speed.cpp:401
Declares the general types that are used by the network.