SuperTuxKart
|
A class that manages the clock (countdown, chrono, etc.) Also manages stuff like the 'ready/set/go' text at the beginning or the delay at the end of a race. More...
#include <world_status.hpp>
Public Types | |
enum | ClockType { CLOCK_NONE , CLOCK_CHRONO , CLOCK_COUNTDOWN } |
Different clock types for a race. | |
enum | Phase { TRACK_INTRO_PHASE , SETUP_PHASE , WAIT_FOR_SERVER_PHASE , SERVER_READY_PHASE , READY_PHASE , SET_PHASE , GO_PHASE , MUSIC_PHASE , RACE_PHASE , DELAY_FINISH_PHASE , RESULT_DISPLAY_PHASE , FINISH_PHASE , IN_GAME_MENU_PHASE , UNDEFINED_PHASE } |
Public Member Functions | |
virtual | ~WorldStatus () |
Destructor of WorldStatus. | |
virtual void | reset (bool restart) |
Resets all status information, used when starting a new race. | |
virtual void | updateTime (int ticks) |
Updates the world time and clock (which might be running backwards), and all status information, called once per frame at the end of the main loop. | |
virtual void | update (int ticks) |
Update, called once per frame. | |
void | startReadySetGo () |
virtual void | pause (Phase phase) |
Pauses the game and switches to the specified phase. | |
virtual void | unpause () |
Switches back from a pause state to the previous state. | |
virtual void | enterRaceOverState () |
Called when the race is finished, but it still leaves some time for an end of race animation, and potentially let some more AI karts finish the race. | |
virtual void | terminateRace () |
Called when it's really over (delay over if any). | |
void | setTime (const float time) |
Sets the time for the clock. | |
void | setTicks (int ticks) |
Sets a new time for the world time, measured in ticks. | |
void | setTicksForRewind (int ticks) |
Sets a new time for the world time (used by rewind), measured in ticks. | |
bool | isStartPhase () const |
bool | isRacePhase () const |
bool | isActiveRacePhase () const |
bool | isFinishPhase () const |
While the race menu is being displayed, m_phase is limbo, and m_previous_phase is finish. | |
const Phase | getPhase () const |
Returns the current race phase. | |
void | setPhase (Phase phase) |
Sets the current race phase. | |
void | setClockMode (const ClockType mode, const float initial_time=0.0f) |
Call to specify what kind of clock you want. | |
int | getClockMode () const |
Returns the current clock mode. | |
float | getTime () const |
Returns the current race time. | |
uint64_t | getStart () const |
Returns the start time. | |
int | getTimeTicks () const |
Returns the current race time in time ticks (i.e. | |
virtual void | countdownReachedZero () |
Will be called to notify your derived class that the clock, which is in COUNTDOWN mode, has reached zero. | |
virtual void | onGo () |
Called when the race actually starts. | |
int | getTicksSinceStart () const |
Get the ticks since start regardless of which way the clock counts. | |
int | getAuxiliaryTicks () const |
bool | isLiveJoinWorld () const |
void | setLiveJoinWorld (bool val) |
int | getMusicDescriptionTicks () const |
void | endLiveJoinWorld (int ticks_now) |
Base on the network timer set current world count up ticks to tick_now. | |
Private Member Functions | |
void | startEngines () |
Starts the kart engines. | |
Private Attributes | |
SFXBase * | m_track_intro_sound |
Sound to play at the beginning of a race, during which a a camera intro of the track can be shown. | |
SFXBase * | m_prestart_sound |
Sound used for the first two 'beeps' in ready, set, go. | |
SFXBase * | m_start_sound |
The third sound to be played in ready, set, go. | |
uint64_t | m_started_at |
(Unix) time when we started | |
ClockType | m_clock_mode |
The clock mode: normal counting forwards, or countdown. | |
Phase | m_previous_phase |
Remember previous phase e.g. | |
int | m_auxiliary_ticks |
Counts time during the initial 'ready/set/go' phase, or at the end of a race. | |
int | m_start_music_ticks |
int | m_race_ticks |
int | m_live_join_ticks |
int | m_count_up_ticks |
Special counter to count ticks since start (in terms of physics timestep size). | |
bool | m_engines_started |
bool | m_live_join_world |
A class that manages the clock (countdown, chrono, etc.) Also manages stuff like the 'ready/set/go' text at the beginning or the delay at the end of a race.
|
inlinevirtual |
Will be called to notify your derived class that the clock, which is in COUNTDOWN mode, has reached zero.
Reimplemented in FollowTheLeaderRace, FreeForAll, LapTrial, and SoccerWorld.
|
virtual |
Called when the race is finished, but it still leaves some time for an end of race animation, and potentially let some more AI karts finish the race.
Reimplemented in ProfileWorld, CutsceneWorld, DemoWorld, SoccerWorld, and ThreeStrikesBattle.
|
inline |
Returns the current race time in time ticks (i.e.
based on the physics time step size).
|
inline |
While the race menu is being displayed, m_phase is limbo, and m_previous_phase is finish.
So we have to test this case, too.
|
inlinevirtual |
Called when the race actually starts.
Reimplemented in SoccerWorld, and World.
|
virtual |
Pauses the game and switches to the specified phase.
phase | Phase to switch to. |
Reimplemented in World.
|
virtual |
Resets all status information, used when starting a new race.
Reimplemented in CaptureTheFlag, CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, LinearWorld, SoccerWorld, ThreeStrikesBattle, World, and WorldWithRank.
void WorldStatus::setClockMode | ( | const ClockType | mode, |
const float | initial_time = 0.0f |
||
) |
Call to specify what kind of clock you want.
Sets the clock mode and the initial time of the world clock.
The second argument can be used to specify the initial time value (especially useful for countdowns).
mode | The new clock mode. |
initial_time | The new initial time for the world clock. |
|
inline |
Sets the current race phase.
Canbe used to e.g. avoid the count down etc.
void WorldStatus::setTicks | ( | int | ticks | ) |
Sets a new time for the world time, measured in ticks.
ticks | New time in ticks to set. |
void WorldStatus::setTicksForRewind | ( | int | ticks | ) |
Sets a new time for the world time (used by rewind), measured in ticks.
ticks | New time in ticks to set (always count upwards). |
void WorldStatus::setTime | ( | const float | time | ) |
Sets the time for the clock.
time | New time to set. |
|
virtual |
Called when it's really over (delay over if any).
This function must be called after all stats were updated from the different modes!
Reimplemented in EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, SoccerWorld, ThreeStrikesBattle, and World.
|
virtual |
Switches back from a pause state to the previous state.
Reimplemented in World.
|
virtual |
Update, called once per frame.
Called early on before physics are updated.
dt | Time step. |
Reimplemented in ProfileWorld, CaptureTheFlag, CutsceneWorld, DemoWorld, EasterEggHunt, FreeForAll, LapTrial, LinearWorld, OverWorld, SoccerWorld, ThreeStrikesBattle, and World.
|
virtual |
Updates the world time and clock (which might be running backwards), and all status information, called once per frame at the end of the main loop.
ticks | Number of ticks (physics time steps) - should be 1. |
|
private |
Counts time during the initial 'ready/set/go' phase, or at the end of a race.
This timer basically kicks in when we need to calculate non-race time like labels.
|
private |
Remember previous phase e.g.
on pause