18#ifndef HEADER_WORLD_STATUS_HPP
19#define HEADER_WORLD_STATUS_HPP
21#include "utils/cpp2011.hpp"
24enum ProcessType :
unsigned int;
52 WAIT_FOR_SERVER_PHASE,
120 bool m_play_track_intro_sound;
121 bool m_play_ready_set_go_sounds;
122 std::atomic<Phase> m_phase;
137 int m_start_music_ticks;
141 int m_live_join_ticks;
147 bool m_engines_started;
149 bool m_live_join_world;
157 virtual void reset(
bool restart);
159 virtual void update(
int ticks);
160 void startReadySetGo();
161 virtual void pause(Phase phase);
165 void setTime(
const float time);
170 bool isStartPhase()
const {
return m_phase<GO_PHASE; }
172 bool isRacePhase()
const {
return m_phase>=GO_PHASE &&
173 m_phase<FINISH_PHASE; }
175 bool isActiveRacePhase()
const {
return m_phase>=GO_PHASE &&
176 m_phase<DELAY_FINISH_PHASE; }
181 (m_phase==IN_GAME_MENU_PHASE &&
230 bool isLiveJoinWorld()
const {
return m_live_join_world; }
232 void setLiveJoinWorld(
bool val) { m_live_join_world = val; }
234 int getMusicDescriptionTicks()
const
236 return m_live_join_ticks == -1 ?
The base class for sound effects.
Definition: sfx_base.hpp:43
A class that manages the clock (countdown, chrono, etc.) Also manages stuff like the 'ready/set/go' t...
Definition: world_status.hpp:33
void endLiveJoinWorld(int ticks_now)
Base on the network timer set current world count up ticks to tick_now.
Definition: world_status.cpp:574
float getTime() const
Returns the current race time.
Definition: world_status.hpp:204
double m_time
Elasped/remaining time in seconds.
Definition: world_status.hpp:94
virtual void onGo()
Called when the race actually starts.
Definition: world_status.hpp:222
virtual ~WorldStatus()
Destructor of WorldStatus.
Definition: world_status.cpp:122
SFXBase * m_start_sound
The third sound to be played in ready, set, go.
Definition: world_status.hpp:112
void setClockMode(const ClockType mode, const float initial_time=0.0f)
Call to specify what kind of clock you want.
Definition: world_status.cpp:158
int m_time_ticks
Time in number of ticks (in terms of physics time steps).
Definition: world_status.hpp:97
virtual void unpause()
Switches back from a pause state to the previous state.
Definition: world_status.cpp:554
virtual void update(int ticks)
Update, called once per frame.
Definition: world_status.cpp:199
uint64_t getStart() const
Returns the start time.
Definition: world_status.hpp:208
int getClockMode() const
Returns the current clock mode.
Definition: world_status.hpp:200
virtual void reset(bool restart)
Resets all status information, used when starting a new race.
Definition: world_status.cpp:73
ClockType m_clock_mode
The clock mode: normal counting forwards, or countdown.
Definition: world_status.hpp:118
void setTicks(int ticks)
Sets a new time for the world time, measured in ticks.
Definition: world_status.cpp:507
void setTime(const float time)
Sets the time for the clock.
Definition: world_status.cpp:496
int m_count_up_ticks
Special counter to count ticks since start (in terms of physics timestep size).
Definition: world_status.hpp:145
virtual void enterRaceOverState()
Called when the race is finished, but it still leaves some time for an end of race animation,...
Definition: world_status.cpp:170
virtual void terminateRace()
Called when it's really over (delay over if any).
Definition: world_status.cpp:190
int getTicksSinceStart() const
Get the ticks since start regardless of which way the clock counts.
Definition: world_status.hpp:226
void setPhase(Phase phase)
Sets the current race phase.
Definition: world_status.hpp:190
bool isFinishPhase() const
While the race menu is being displayed, m_phase is limbo, and m_previous_phase is finish.
Definition: world_status.hpp:180
virtual void updateTime(int ticks)
Updates the world time and clock (which might be running backwards), and all status information,...
Definition: world_status.cpp:209
ClockType
Different clock types for a race.
Definition: world_status.hpp:37
const ProcessType m_process_type
Process type of this world (main or child).
Definition: world_status.hpp:103
void startEngines()
Starts the kart engines.
Definition: world_status.cpp:140
int m_auxiliary_ticks
Counts time during the initial 'ready/set/go' phase, or at the end of a race.
Definition: world_status.hpp:135
bool m_play_racestart_sounds
If the start race should be played, disabled in cutscenes.
Definition: world_status.hpp:100
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.
Definition: world_status.hpp:108
Phase m_previous_phase
Remember previous phase e.g.
Definition: world_status.hpp:129
virtual void countdownReachedZero()
Will be called to notify your derived class that the clock, which is in COUNTDOWN mode,...
Definition: world_status.hpp:218
const Phase getPhase() const
Returns the current race phase.
Definition: world_status.hpp:185
SFXBase * m_prestart_sound
Sound used for the first two 'beeps' in ready, set, go.
Definition: world_status.hpp:110
int getTimeTicks() const
Returns the current race time in time ticks (i.e.
Definition: world_status.hpp:213
uint64_t m_started_at
(Unix) time when we started
Definition: world_status.hpp:115
virtual void pause(Phase phase)
Pauses the game and switches to the specified phase.
Definition: world_status.cpp:534
void setTicksForRewind(int ticks)
Sets a new time for the world time (used by rewind), measured in ticks.
Definition: world_status.cpp:517