19 #ifndef HEADER_WORLD_HPP 20 #define HEADER_WORLD_HPP 35 #include "graphics/weather.hpp" 36 #include "modes/world_status.hpp" 37 #include "race/highscores.hpp" 38 #include "states_screens/race_gui_base.hpp" 39 #include "states_screens/state_manager.hpp" 40 #include "utils/random_generator.hpp" 41 #include "utils/stk_process.hpp" 43 #include "LinearMath/btTransform.h" 60 namespace scene {
class ISceneNode; }
90 typedef std::vector<std::shared_ptr<AbstractKart> > KartList;
93 static World *m_world[PT_COUNT];
97 std::shared_ptr<AbstractKart> createKartWithTeam
98 (
const std::string &kart_ident,
int index,
int local_player_id,
105 unsigned int m_magic_number;
111 std::map<int, KartTeam> m_kart_team_map;
112 std::map<int, unsigned int> m_kart_position_map;
126 bool m_faster_music_active;
128 bool m_stop_music_when_dialog_open;
137 void updateHighscores (
int* best_highscore_rank);
138 void resetAllKarts ();
142 virtual std::shared_ptr<AbstractKart> createKart
143 (
const std::string &kart_ident,
int index,
int local_player_id,
171 bool m_schedule_exit_race;
173 bool m_schedule_tutorial;
175 Phase m_scheduled_pause_phase;
187 virtual void onGo() OVERRIDE;
189 virtual
bool isRaceOver() = 0;
190 virtual
void update(
int ticks) OVERRIDE;
191 virtual
void createRaceGUI();
192 void updateTrack(
int ticks);
203 void updateAchievementDataEndRace();
204 void updateAchievementModeCounters(
bool start);
215 ProcessType type = STKProcess::getType();
216 return m_world[type];
224 ProcessType type = STKProcess::getType();
225 delete m_world[type];
226 m_world[type] = NULL;
233 ProcessType type = STKProcess::getType();
234 m_world[type] = world;
237 static void clear() { memset(m_world, 0,
sizeof(m_world)); }
245 virtual const std::string& getIdent()
const = 0;
249 virtual unsigned int getNumberOfRescuePositions()
const;
252 virtual unsigned int getRescuePositionIndex(
AbstractKart *kart) = 0;
255 virtual btTransform getRescueTransform(
unsigned int index)
const;
261 virtual bool raceHasLaps() = 0;
270 assert(
false);
return -1;
275 virtual void getKartsDisplayInfo(
276 std::vector<RaceGUIBase::KartIconDisplayInfo> *info)= 0;
282 virtual void updateGraphics(
float dt);
283 virtual void terminateRace() OVERRIDE;
284 virtual void reset(
bool restart=
false) OVERRIDE;
285 virtual void pause(Phase phase) OVERRIDE;
286 virtual void unpause() OVERRIDE;
287 virtual void getDefaultCollectibles(
int *collectible_type,
294 virtual void endRaceEarly() {
return; }
296 virtual bool hasRaceEndedEarly()
const {
return m_ended_early; }
311 virtual void newLap(
unsigned int kart_index) {}
314 virtual bool kartHit(
int kart_id,
int hitter = -1) {
return false; }
316 virtual void onMouseClick(
int x,
int y) {};
322 void schedulePause(Phase phase);
323 void scheduleUnpause();
324 void scheduleExitRace() { m_schedule_exit_race =
true; }
325 void scheduleTutorial();
326 void updateWorld(
int ticks);
331 virtual const btTransform &getStartTransform(
int index);
332 void moveKartTo(
AbstractKart* kart,
const btTransform &t);
333 void updateTimeTargetSound();
339 unsigned int getNumKarts()
const {
return (
unsigned int) m_karts.size(); }
343 assert(kartId >= 0 && kartId <
int(m_karts.size()));
344 return m_karts[kartId].get(); }
347 const KartList &
getKarts()
const {
return m_karts; }
351 m_eliminated_karts; }
355 m_eliminated_players;}
357 void resetElimination()
359 m_eliminated_karts = 0;
360 m_eliminated_players = 0;
363 virtual void addReservedKart(
int kart_id)
365 if (m_eliminated_karts > 0)
366 m_eliminated_karts--;
376 {
return isActiveRacePhase() && getClockMode() != CLOCK_NONE; }
388 virtual void escapePressed();
390 virtual void loadCustomModels() {}
392 void eliminateKart(
int kart_number,
bool notify_of_elimination =
true);
394 void setUnfairTeam(
bool val) { m_unfair_team = val; }
396 virtual bool hasTeam()
const {
return false; }
399 KartTeam getKartTeam(
unsigned int kart_id)
const;
401 int getTeamNum(KartTeam team)
const;
406 bool isNetworkWorld()
const {
return m_is_network_world; }
416 return std::make_pair(std::numeric_limits<uint32_t>::max(),
417 std::numeric_limits<uint32_t>::max());
420 virtual bool isGoalPhase()
const {
return false; }
A random number generator.
Definition: random_generator.hpp:33
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:39
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:45
virtual int getFinishedLapsOfKart(unsigned int kart_index) const
Returns the number of laps for a given kart.
Definition: world.hpp:268
static World * getWorld()
Returns a pointer to the (singleton) world object.
Definition: world.hpp:213
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:49
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
bool m_use_highscores
Whether highscores should be used for this kind of race.
Definition: world.hpp:135
virtual void onFirePressed(Controller *who)
Override if you want to know when a kart presses fire.
Definition: world.hpp:382
base class for all game modes This class is responsible for running the actual race.
Definition: world.hpp:87
RaceGUIBase * getRaceGUI() const
Returns a pointer to the race gui.
Definition: world.hpp:336
RaceGUIBase * m_race_gui
Pointer to the race GUI.
Definition: world.hpp:148
virtual void collectedItem(const AbstractKart *kart, const ItemState *item)
Receives notification if an item is collected.
Definition: world.hpp:291
KartType
Different kart types: A local player, a player connected via network, an AI kart, the leader kart (cu...
Definition: race_manager.hpp:241
unsigned int getCurrentNumPlayers() const
Returns the number of currently active (i.e.
Definition: world.hpp:354
KartList m_karts
The list of all karts.
Definition: world.hpp:115
Definition: three_d_animation.hpp:32
virtual bool useChecklineRequirements() const
Whether to compute checkline requirements for each world on the quadgraph.
Definition: world.hpp:386
virtual bool shouldDrawTimer() const
The code that draws the timer should call this first to know whether the game mode wants a timer draw...
Definition: world.hpp:375
bool m_self_destruct
Set when the world needs to be deleted but you can't do it immediately because you are e...
Definition: world.hpp:180
static void deleteWorld()
Delete the )singleton) world object, if it exists, and sets the singleton pointer to NULL...
Definition: world.hpp:222
Definition: physical_object.hpp:38
virtual bool kartHit(int kart_id, int hitter=-1)
Called when a kart was hit by a projectile.
Definition: world.hpp:314
bool m_schedule_pause
Pausing/unpausing are not done immediately, but at next udpdate.
Definition: world.hpp:162
unsigned int getNumKarts() const
Returns the number of karts in the race.
Definition: world.hpp:339
bool m_schedule_unpause
Pausing/unpausing are not done immediately, but at next udpdate.
Definition: world.hpp:169
int m_eliminated_players
Number of eliminated players.
Definition: world.hpp:122
int m_eliminated_karts
Number of eliminated karts.
Definition: world.hpp:120
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...
Definition: world.hpp:306
int m_num_players
OVerall number of players.
Definition: world.hpp:124
A class that manages the clock (countdown, chrono, etc.) Also manages stuff like the 'ready/set/go' t...
Definition: world_status.hpp:32
Represents one highscore entry, i.e.
Definition: highscores.hpp:40
virtual void newLap(unsigned int kart_index)
Called whenever a kart starts a new lap.
Definition: world.hpp:311
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
bool useHighScores() const
Definition: world.hpp:379
void setNetworkWorld(bool is_networked)
Set the network mode (true if networked)
Definition: world.hpp:404
virtual bool useFastMusicNearEnd() const
Returns if this mode should use fast music (if available).
Definition: world.hpp:302
unsigned int getCurrentNumKarts() const
Returns the number of currently active (i.e.non-elikminated) karts.
Definition: world.hpp:350
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:75
bool m_is_network_world
Set when the world is online and counts network players.
Definition: world.hpp:183
AbstractKart * getKart(int kartId) const
Returns the kart with a given world id.
Definition: world.hpp:342
Contains the state information of an item, i.e.
Definition: item.hpp:52
RaceGUIBase * m_saved_race_gui
The actual race gui needs to be saved when the race result gui is displayed since it is still needed ...
Definition: world.hpp:155
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
static void setWorld(World *world)
Sets the pointer to the world object.
Definition: world.hpp:231
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 ...
Definition: world.hpp:414
const KartList & getKarts() const
Returns all karts.
Definition: world.hpp:347
virtual bool showLapsTarget()
If true lap counter shows lap count in format: 4/20 or if false then in format: 4.
Definition: world.hpp:264
virtual bool haveBonusBoxes()
Called to determine whether this race mode uses bonus boxes.
Definition: world.hpp:299