SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
World Class Referenceabstract

base class for all game modes This class is responsible for running the actual race. More...

#include <world.hpp>

Inheritance diagram for World:
Inheritance graph
[legend]

Public Types

typedef std::vector< std::shared_ptr< AbstractKart > > KartList
 
- Public Types inherited from WorldStatus
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

 World ()
 The main world class is used to handle the track and the karts.
 
virtual const std::string & getIdent () const =0
 Each game mode should have a unique identifier.
 
virtual unsigned int getNumberOfRescuePositions () const
 Returns the number of rescue positions on a given track and game mode.
 
virtual unsigned int getRescuePositionIndex (AbstractKart *kart)=0
 Determines the rescue position index of the specified kart.
 
virtual btTransform getRescueTransform (unsigned int index) const
 Returns the bullet transformation for the specified rescue index.
 
virtual void moveKartAfterRescue (AbstractKart *kart)
 Places a kart that is rescued.
 
virtual bool raceHasLaps ()=0
 Called when it is needed to know whether this kind of race involves counting laps.
 
virtual bool showLapsTarget ()
 If true lap counter shows lap count in format: 4/20 or if false then in format: 4.
 
virtual int getFinishedLapsOfKart (unsigned int kart_index) const
 Returns the number of laps for a given kart.
 
virtual void getKartsDisplayInfo (std::vector< RaceGUIBase::KartIconDisplayInfo > *info)=0
 Called by the code that draws the list of karts on the race GUI to know what needs to be drawn in the current mode.
 
virtual void init ()
 This function is called after instanciating.
 
virtual void updateGraphics (float dt)
 This updates all only graphical elements.
 
virtual void terminateRace () OVERRIDE
 Called at the end of a race.
 
virtual void reset (bool restart=false) OVERRIDE
 This function is called before a race is started (i.e.
 
virtual void pause (Phase phase) OVERRIDE
 Pauses the music (and then pauses WorldStatus).
 
virtual void unpause () OVERRIDE
 Switches back from a pause state to the previous state.
 
virtual void getDefaultCollectibles (int *collectible_type, int *amount)
 Called to determine the default collectibles to give each player at the start for this kind of race.
 
virtual void collectedItem (const AbstractKart *kart, const ItemState *item)
 Receives notification if an item is collected.
 
virtual void endRaceEarly ()
 
virtual bool hasRaceEndedEarly () const
 
virtual bool haveBonusBoxes ()
 Called to determine whether this race mode uses bonus boxes.
 
virtual bool useFastMusicNearEnd () const
 Returns if this mode should use fast music (if available).
 
virtual void kartAdded (AbstractKart *kart, scene::ISceneNode *node)
 If you want to do something to karts or their graphics at the start of the race, override this.
 
virtual void newLap (unsigned int kart_index)
 Called whenever a kart starts a new lap.
 
virtual bool kartHit (int kart_id, int hitter=-1)
 Called when a kart was hit by a projectile.
 
virtual void onMouseClick (int x, int y)
 
HighscoresgetHighscores () const
 
HighscoresgetGPHighscores () const
 
void schedulePause (Phase phase)
 
void scheduleUnpause ()
 
void scheduleExitRace ()
 
void scheduleTutorial ()
 
void updateWorld (int ticks)
 This is the main interface to update the world.
 
void handleExplosion (const Vec3 &xyz, AbstractKart *kart_hit, PhysicalObject *object)
 
AbstractKartgetPlayerKart (unsigned int player) const
 Returns the n-th player kart.
 
AbstractKartgetLocalPlayerKart (unsigned int n) const
 Returns the nth local player kart, i.e.
 
virtual const btTransform & getStartTransform (int index)
 Returns the start coordinates for a kart with a given index.
 
void moveKartTo (AbstractKart *kart, const btTransform &t)
 Places the kart at a given position and rotation.
 
void updateTimeTargetSound ()
 
RaceGUIBasegetRaceGUI () const
 Returns a pointer to the race gui.
 
unsigned int getNumKarts () const
 Returns the number of karts in the race.
 
AbstractKartgetKart (int kartId) const
 Returns the kart with a given world id.
 
const KartList & getKarts () const
 Returns all karts.
 
unsigned int getCurrentNumKarts () const
 Returns the number of currently active (i.e.non-elikminated) karts.
 
unsigned int getCurrentNumPlayers () const
 Returns the number of currently active (i.e.
 
void resetElimination ()
 
virtual void addReservedKart (int kart_id)
 
virtual void saveCompleteState (BareNetworkString *bns, STKPeer *peer)
 
virtual void restoreCompleteState (const BareNetworkString &buffer)
 
virtual bool shouldDrawTimer () const
 The code that draws the timer should call this first to know whether the game mode wants a timer drawn.
 
bool useHighScores () const
 
virtual void onFirePressed (Controller *who)
 Override if you want to know when a kart presses fire.
 
virtual bool useChecklineRequirements () const
 Whether to compute checkline requirements for each world on the quadgraph.
 
virtual void escapePressed ()
 
virtual void loadCustomModels ()
 
void eliminateKart (int kart_number, bool notify_of_elimination=true)
 Remove (eliminate) a kart from the race.
 
void setUnfairTeam (bool val)
 
virtual bool hasTeam () const
 
KartTeam getKartTeam (unsigned int kart_id) const
 Get the team of kart in world (including AIs)
 
int getTeamNum (KartTeam team) const
 
void setNetworkWorld (bool is_networked)
 Set the network mode (true if networked)
 
bool isNetworkWorld () const
 
void initTeamArrows (AbstractKart *k)
 Set the team arrow on karts if necessary.
 
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress () const
 Used by server to get the current started game progress in either or both remaining time or progress in percent.
 
virtual bool isGoalPhase () const
 
- Public Member Functions inherited from WorldStatus
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.
 

Static Public Member Functions

static WorldgetWorld ()
 Returns a pointer to the (singleton) world object.
 
static void deleteWorld ()
 Delete the )singleton) world object, if it exists, and sets the singleton pointer to NULL.
 
static void setWorld (World *world)
 Sets the pointer to the world object.
 
static void clear ()
 

Protected Member Functions

void updateHighscores (int *best_highscore_rank)
 Called at the end of a race.
 
void resetAllKarts ()
 Waits till each kart is resting on the ground.
 
ControllerloadAIController (AbstractKart *kart)
 Creates an AI controller for the kart.
 
virtual std::shared_ptr< AbstractKartcreateKart (const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, HandicapLevel handicap)
 Creates a kart, having a certain position, starting location, and local and global player id (if applicable).
 
virtual void onGo () OVERRIDE
 Called when 'go' is being displayed for the first time.
 
virtual bool isRaceOver ()=0
 Returns true if the race is over.
 
virtual void update (int ticks) OVERRIDE
 Updates the physics, all karts, the track, and projectile manager.
 
virtual void createRaceGUI ()
 
void updateTrack (int ticks)
 Only updates the track.
 
virtual float estimateFinishTimeForKart (AbstractKart *kart)
 Used for AI karts that are still racing when all player kart finished.
 
void updateAchievementDataEndRace ()
 
void updateAchievementModeCounters (bool start)
 

Protected Attributes

int m_red_ai
 
int m_blue_ai
 
std::map< int, KartTeam > m_kart_team_map
 
std::map< int, unsigned int > m_kart_position_map
 
KartList m_karts
 The list of all karts.
 
RandomGenerator m_random
 
AbstractKartm_fastest_kart
 
int m_eliminated_karts
 Number of eliminated karts.
 
int m_eliminated_players
 Number of eliminated players.
 
int m_num_players
 OVerall number of players.
 
bool m_faster_music_active
 
bool m_stop_music_when_dialog_open
 
bool m_unfair_team
 
bool m_use_highscores
 Whether highscores should be used for this kind of race.
 
RaceGUIBasem_race_gui
 Pointer to the race GUI.
 
RaceGUIBasem_saved_race_gui
 The actual race gui needs to be saved when the race result gui is displayed since it is still needed in case of a restart, and it can't simply be created again (since it assumes that it can render to texture without having any scene nodes, but in case of a restart there are scene nodes).
 
bool m_schedule_pause
 Pausing/unpausing are not done immediately, but at next udpdate.
 
bool m_schedule_unpause
 Pausing/unpausing are not done immediately, but at next udpdate.
 
bool m_schedule_exit_race
 
bool m_schedule_tutorial
 
Phase m_scheduled_pause_phase
 
bool m_self_destruct
 Set when the world needs to be deleted but you can't do it immediately because you are e.g.
 
bool m_is_network_world
 Set when the world is online and counts network players.
 
bool m_ended_early
 
- Protected Attributes inherited from WorldStatus
double m_time
 Elasped/remaining time in seconds.
 
int m_time_ticks
 Time in number of ticks (in terms of physics time steps).
 
bool m_play_racestart_sounds
 If the start race should be played, disabled in cutscenes.
 
const ProcessType m_process_type
 Process type of this world (main or child).
 
bool m_play_track_intro_sound
 
bool m_play_ready_set_go_sounds
 
std::atomic< Phase > m_phase
 

Private Member Functions

void setAITeam ()
 
std::shared_ptr< AbstractKartcreateKartWithTeam (const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, HandicapLevel handicap)
 

Static Private Attributes

static Worldm_world [PT_COUNT]
 A pointer to the global world object for a race.
 

Detailed Description

base class for all game modes This class is responsible for running the actual race.

A world is created by the race manager on the start of each race (so a new world is created for each race of a Grand Prix). It creates the physics, loads the track, creates all karts, and initialises the race specific managers (ItemManager, ProjectilManager, highscores, ...). It uses the information from the race manager to get information like what and how many karts, track to load etc. This class does not really know about Grand Prixs, a GP is created It maintains the race clock, and updates all karts, herings etc. during the race. Special game modes (e.g. follow the leader) are currently integrated in this world, see e.g. updateRaceStatus where the world clock behaviour is handled differently to create the count down.

Constructor & Destructor Documentation

◆ World()

World::World ( )

The main world class is used to handle the track and the karts.

The end of the race is detected in two phases: first the (abstract) function isRaceOver, which must be implemented by all game modes, must return true. In which case enterRaceOverState is called. At this time a winning (or losing) animation can be played. The WorldStatus class will in its enterRaceOverState switch to DELAY_FINISH_PHASE, but the remaining AI kart will keep on racing during that time. After a time period specified in stk_config.xml WorldStatus will switch to FINISH_PHASE and call terminateRace. Now the finishing status of all karts is set (i.e. in a normal race the arrival time for karts will be estimated), highscore is updated, and the race result gui is being displayed. Rescuing is handled via the three functions: getNumberOfRescuePositions() - which returns the number of rescue positions defined. getRescuePositionIndex(AbstractKart *kart) - which determines the index of the rescue position to be used for the given kart. getRescueTransform(unsigned int index) - which returns the transform (i.e. position and rotation) for the specified rescue position. This allows the world class to do some tests to make sure all rescue positions are valid (when started with –track-debug). It tries to place all karts on all rescue positions. If there are any problems (e.g. a rescue position not over terrain (perhaps because it is too low); or the rescue position is on a texture which will immediately trigger another rescue), a warning message will be printed. Constructor. Note that in the constructor it is not possible to call any functions that use World::getWorld(), since this is only defined after the constructor. Those functions must be called in the init() function, which is called immediately after the constructor.

Member Function Documentation

◆ collectedItem()

virtual void World::collectedItem ( const AbstractKart kart,
const ItemState item 
)
inlinevirtual

Receives notification if an item is collected.

Used for easter eggs.

Reimplemented in EasterEggHunt.

◆ createKart()

std::shared_ptr< AbstractKart > World::createKart ( const std::string &  kart_ident,
int  index,
int  local_player_id,
int  global_player_id,
RaceManager::KartType  kart_type,
HandicapLevel  handicap 
)
protectedvirtual

Creates a kart, having a certain position, starting location, and local and global player id (if applicable).

Parameters
kart_identIdentifier of the kart to create.
indexIndex of the kart.
local_player_idIf the kart is a player kart this is the index of this player on the local machine.
global_player_idIf the kart is a player kart this is the index of this player globally (i.e. including network players).

Reimplemented in ProfileWorld.

◆ createRaceGUI()

void World::createRaceGUI ( )
protectedvirtual

Reimplemented in OverWorld.

◆ deleteWorld()

static void World::deleteWorld ( )
inlinestatic

Delete the )singleton) world object, if it exists, and sets the singleton pointer to NULL.

It's harmless to call this if the world has been deleted already.

◆ endRaceEarly()

virtual void World::endRaceEarly ( )
inlinevirtual

Reimplemented in StandardRace.

◆ estimateFinishTimeForKart()

virtual float World::estimateFinishTimeForKart ( AbstractKart kart)
inlineprotectedvirtual

Used for AI karts that are still racing when all player kart finished.

Generally it should estimate the arrival time for those karts, but as a default (useful for battle mode and ftl races) we just use the current time for this (since this is a good value for karts still around at the end of a race, and other criteria (number of lives, race position) will be used to determine the final order.

Reimplemented in EasterEggHunt, and LinearWorld.

◆ getCurrentNumPlayers()

unsigned int World::getCurrentNumPlayers ( ) const
inline

Returns the number of currently active (i.e.

non-eliminated) players.

◆ getDefaultCollectibles()

void World::getDefaultCollectibles ( int *  collectible_type,
int *  amount 
)
virtual

Called to determine the default collectibles to give each player at the start for this kind of race.

Both parameters are of 'out' type.

Parameters
collectible_typeThe type of collectible each kart.
amountThe number of collectibles.

Reimplemented in StandardRace.

◆ getFinishedLapsOfKart()

virtual int World::getFinishedLapsOfKart ( unsigned int  kart_index) const
inlinevirtual

Returns the number of laps for a given kart.

Only valid when raceHasLaps() - otherwise STK will abort.

Reimplemented in LinearWorld.

◆ getGameStartedProgress()

virtual std::pair< uint32_t, uint32_t > World::getGameStartedProgress ( ) const
inlinevirtual

Used by server to get the current started game progress in either or both remaining time or progress in percent.

uint32_t max for either or both if not available.

Reimplemented in CaptureTheFlag, FreeForAll, LinearWorld, and SoccerWorld.

◆ getIdent()

virtual const std::string & World::getIdent ( ) const
pure virtual

Each game mode should have a unique identifier.

Override this method in child classes to provide it.

Implemented in CaptureTheFlag, CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, OverWorld, SoccerWorld, StandardRace, and ThreeStrikesBattle.

◆ getKartsDisplayInfo()

virtual void World::getKartsDisplayInfo ( std::vector< RaceGUIBase::KartIconDisplayInfo > *  info)
pure virtual

Called by the code that draws the list of karts on the race GUI to know what needs to be drawn in the current mode.

Implemented in LapTrial, CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LinearWorld, OverWorld, SoccerWorld, and ThreeStrikesBattle.

◆ getLocalPlayerKart()

AbstractKart * World::getLocalPlayerKart ( unsigned int  n) const

Returns the nth local player kart, i.e.

a kart that has a camera. Note that in profile mode this means a non player kart could be returned (since an AI kart will have the camera).

Parameters
nIndex of player kart to return.

◆ getNumberOfRescuePositions()

unsigned int World::getNumberOfRescuePositions ( ) const
virtual

Returns the number of rescue positions on a given track and game mode.

Uses the start position as rescue positions, override if necessary.

Reimplemented in CutsceneWorld, LinearWorld, and TutorialWorld.

◆ getPlayerKart()

AbstractKart * World::getPlayerKart ( unsigned int  n) const

Returns the n-th player kart.

Note that this function is O(N), not O(1), so it shouldn't be called inside of loops.

Parameters
nIndex of player kart to return.

◆ getRescuePositionIndex()

virtual unsigned int World::getRescuePositionIndex ( AbstractKart kart)
pure virtual

Determines the rescue position index of the specified kart.

Implemented in CaptureTheFlag, CutsceneWorld, LinearWorld, OverWorld, SoccerWorld, TutorialWorld, and WorldWithRank.

◆ getRescueTransform()

btTransform World::getRescueTransform ( unsigned int  rescue_pos) const
virtual

Returns the bullet transformation for the specified rescue index.

Returns the start transform with the give index.

Parameters
rescue_posIndex of the start position to be returned.
Returns
The transform of the corresponding start position.

Reimplemented in CutsceneWorld, LinearWorld, TutorialWorld, and SoccerWorld.

◆ getStartTransform()

const btTransform & World::getStartTransform ( int  index)
virtual

Returns the start coordinates for a kart with a given index.

Parameters
indexIndex of kart ranging from 0 to kart_num-1.

Reimplemented in FollowTheLeaderRace.

◆ haveBonusBoxes()

virtual bool World::haveBonusBoxes ( )
inlinevirtual

Called to determine whether this race mode uses bonus boxes.

Reimplemented in LinearWorld, and StandardRace.

◆ init()

void World::init ( )
virtual

This function is called after instanciating.

The code here can't be moved to the contructor as child classes must be instanciated, otherwise polymorphism will fail and the results will be incorrect . Also in init() functions can be called that use World::getWorld().

Reimplemented in CaptureTheFlag, CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LinearWorld, SoccerWorld, ThreeStrikesBattle, and WorldWithRank.

◆ isRaceOver()

virtual bool World::isRaceOver ( )
protectedpure virtual

Returns true if the race is over.

Must be defined by all modes.

Implemented in ProfileWorld, CaptureTheFlag, CutsceneWorld, DemoWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, OverWorld, SoccerWorld, StandardRace, and ThreeStrikesBattle.

◆ kartAdded()

virtual void World::kartAdded ( AbstractKart kart,
scene::ISceneNode *  node 
)
inlinevirtual

If you want to do something to karts or their graphics at the start of the race, override this.

Reimplemented in ThreeStrikesBattle.

◆ kartHit()

virtual bool World::kartHit ( int  kart_id,
int  hitter = -1 
)
inlinevirtual

Called when a kart was hit by a projectile.

Reimplemented in CaptureTheFlag, FreeForAll, and ThreeStrikesBattle.

◆ loadAIController()

Controller * World::loadAIController ( AbstractKart kart)
protected

Creates an AI controller for the kart.

Parameters
kartThe kart to be controlled by an AI.

◆ moveKartAfterRescue()

void World::moveKartAfterRescue ( AbstractKart kart)
virtual

Places a kart that is rescued.

It calls getRescuePositionIndex to find to which rescue position the kart should be moved, then getRescueTransform to get the position and rotation of this rescue position, and then moves the kart.

Parameters
kartThe kart that is rescued.

◆ moveKartTo()

void World::moveKartTo ( AbstractKart kart,
const btTransform &  transform 
)

Places the kart at a given position and rotation.

Parameters
kartThe kart to be moved.
transform

◆ newLap()

virtual void World::newLap ( unsigned int  kart_index)
inlinevirtual

Called whenever a kart starts a new lap.

Meaningless (and won't be called) in non-laped races.

Reimplemented in LinearWorld.

◆ onFirePressed()

virtual void World::onFirePressed ( Controller who)
inlinevirtual

Override if you want to know when a kart presses fire.

Reimplemented in CutsceneWorld, and OverWorld.

◆ onGo()

void World::onGo ( )
protectedvirtual

Called when 'go' is being displayed for the first time.

Here the brakes of the karts are released.

Reimplemented from WorldStatus.

Reimplemented in SoccerWorld.

◆ onMouseClick()

virtual void World::onMouseClick ( int  x,
int  y 
)
inlinevirtual

Reimplemented in OverWorld.

◆ pause()

void World::pause ( Phase  phase)
virtual

Pauses the music (and then pauses WorldStatus).

Reimplemented from WorldStatus.

◆ raceHasLaps()

virtual bool World::raceHasLaps ( )
pure virtual

Called when it is needed to know whether this kind of race involves counting laps.

Implemented in CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LinearWorld, OverWorld, SoccerWorld, and ThreeStrikesBattle.

◆ reset()

void World::reset ( bool  restart = false)
virtual

This function is called before a race is started (i.e.

either after calling init() when starting a race for the first time, or after restarting a race, in which case no init() is called.

Reimplemented from WorldStatus.

Reimplemented in CaptureTheFlag, CutsceneWorld, EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, LinearWorld, SoccerWorld, ThreeStrikesBattle, and WorldWithRank.

◆ resetAllKarts()

void World::resetAllKarts ( )
protected

Waits till each kart is resting on the ground.

Does simulation steps still all karts reach the ground, i.e. are not moving anymore

◆ setWorld()

static void World::setWorld ( World world)
inlinestatic

Sets the pointer to the world object.

This is only used by the race_manager.

◆ shouldDrawTimer()

virtual bool World::shouldDrawTimer ( ) const
inlinevirtual

The code that draws the timer should call this first to know whether the game mode wants a timer drawn.

Reimplemented in OverWorld, SoccerWorld, and TutorialWorld.

◆ showLapsTarget()

virtual bool World::showLapsTarget ( )
inlinevirtual

If true lap counter shows lap count in format: 4/20 or if false then in format: 4.

Reimplemented in LapTrial, and LinearWorld.

◆ terminateRace()

void World::terminateRace ( )
virtual

Called at the end of a race.

Updates highscores, pauses the game, and informs the unlock manager about the finished race. This function must be called after all other stats were updated from the different game modes.

Only update high scores when these conditions are met:

  • The race is not over a network
  • There is at least 1 real kart in play
  • The number of laps is at least 1
  • The command line parameter –no-high-scores has not been passed

If they are met, retrieve the best highscore if relevant to show it in the GUI

Reimplemented from WorldStatus.

Reimplemented in EasterEggHunt, FollowTheLeaderRace, FreeForAll, LapTrial, SoccerWorld, and ThreeStrikesBattle.

◆ unpause()

void World::unpause ( )
virtual

Switches back from a pause state to the previous state.

Reimplemented from WorldStatus.

◆ update()

void World::update ( int  ticks)
protectedvirtual

Updates the physics, all karts, the track, and projectile manager.

Parameters
ticksNumber of physics time steps - should be 1.

Reimplemented from WorldStatus.

Reimplemented in ProfileWorld, CaptureTheFlag, CutsceneWorld, DemoWorld, EasterEggHunt, FreeForAll, LapTrial, LinearWorld, OverWorld, SoccerWorld, and ThreeStrikesBattle.

◆ updateGraphics()

void World::updateGraphics ( float  dt)
virtual

This updates all only graphical elements.

It is only called once per rendered frame, not once per time step. float dt Time since last frame.

Reimplemented in CaptureTheFlag, and LinearWorld.

◆ updateHighscores()

void World::updateHighscores ( int *  best_highscore_rank)
protected

Called at the end of a race.

Checks if the current times are worth a new score, if so it notifies the HighscoreManager so the new score is added and saved.

◆ updateTrack()

void World::updateTrack ( int  ticks)
protected

Only updates the track.

The order in which the various parts of STK are updated is quite important (i.e. the track can't be updated as part of the standard update call): the track must be updated after updating the karts (otherwise the checklines would be using the previous kart positions to determine new laps, but linear world which determines distance along track would be using the new kart positions --> the lap counting line will be triggered one frame too late, potentially causing strange behaviour of the icons. Similarly linear world must update the position of all karts after all karts have been updated (i.e. World::update() must be called before updating the position of the karts). The check manager (which is called from Track::update()) needs the updated distance along track, so track update has to be called after updating the race position in linear world. That's why there is a separate call for trackUpdate here.

◆ updateWorld()

void World::updateWorld ( int  ticks)

This is the main interface to update the world.

This function calls update(), and checks then for the end of the race. Note that race over handling can not necessarily be done in update(), since not all data structures might have been updated (e.g.LinearWorld must call World::update() first, to get updated kart positions. If race over would be handled in World::update, LinearWorld had no opportunity to update its data structures before the race is finished).

Parameters
ticksNumber of physics time steps - should be 1.

◆ useChecklineRequirements()

virtual bool World::useChecklineRequirements ( ) const
inlinevirtual

Whether to compute checkline requirements for each world on the quadgraph.

Override to change value.

Reimplemented in LinearWorld, and OverWorld.

◆ useFastMusicNearEnd()

virtual bool World::useFastMusicNearEnd ( ) const
inlinevirtual

Returns if this mode should use fast music (if available).

Reimplemented in FollowTheLeaderRace, and SoccerWorld.

◆ useHighScores()

bool World::useHighScores ( ) const
inline
Returns
whether this world can generate/have highscores

Member Data Documentation

◆ m_race_gui

RaceGUIBase* World::m_race_gui
protected

Pointer to the race GUI.

The race GUI is handled by world.

◆ m_schedule_pause

bool World::m_schedule_pause
protected

Pausing/unpausing are not done immediately, but at next udpdate.

The use of this is when switching between screens : if we leave a screen that paused the game, only to go to another screen that pauses back the game, this mechanism prevents the game from moving on between the switch.

◆ m_schedule_unpause

bool World::m_schedule_unpause
protected

Pausing/unpausing are not done immediately, but at next udpdate.

The use of this is when switching between screens : if we leave a screen that paused the game, only to go to another screen that pauses back the game, this mechanism prevents the game from moving on between the switch.

◆ m_self_destruct

bool World::m_self_destruct
protected

Set when the world needs to be deleted but you can't do it immediately because you are e.g.

within World::update()

◆ m_use_highscores

bool World::m_use_highscores
protected

Whether highscores should be used for this kind of race.

True by default, change to false in a child class to disable.


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