SuperTuxKart
cutscene_world.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2004-2015 SuperTuxKart-Team
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef CUTSCENE_WORLD_HPP
20 #define CUTSCENE_WORLD_HPP
21 
22 #include "modes/world_with_rank.hpp"
23 #include "states_screens/race_gui_base.hpp"
24 
25 #include <IMesh.h>
26 
27 #include <string>
28 #include <ICameraSceneNode.h>
29 
30 
31 class TrackObject;
32 
37 class CutsceneWorld : public World
38 {
39  scene::ICameraSceneNode* m_camera;
40 
41  std::map<float, std::vector<TrackObject*> > m_sounds_to_trigger;
42  std::map<float, std::vector<TrackObject*> > m_sounds_to_stop;
43  std::map<float, std::vector<TrackObject*> > m_particles_to_trigger;
44 
45  double m_duration;
46  bool m_aborted;
47 
48  float m_fade_duration;
49 
50  // TODO find a better way than static
51  static bool s_use_duration;
52 
57  double m_time_at_second_reset;
58 
59  std::vector<std::string> m_parts;
60 
61 public:
62 
63  CutsceneWorld();
64  virtual ~CutsceneWorld();
65 
66  virtual void init() OVERRIDE;
67 
68  virtual void reset(bool restart=false) OVERRIDE;
69 
70  // clock events
71  virtual bool isRaceOver() OVERRIDE;
72 
73  virtual const std::string& getIdent() const OVERRIDE;
74 
75  virtual void update(int ticks) OVERRIDE;
76 
77  virtual void createRaceGUI() OVERRIDE;
78 
79  virtual void enterRaceOverState() OVERRIDE;
80 
81  // ------------------------------------------------------------------------
82  virtual bool raceHasLaps() OVERRIDE { return false; }
83  // ------------------------------------------------------------------------
84  virtual unsigned int getNumberOfRescuePositions() const OVERRIDE
85  {
86  return 0;
87  } // getNumberOfRescuePositions
88  // ------------------------------------------------------------------------
89  virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE
90  {
91  return 0;
92  } // getRescuePositionIndex
93  // ------------------------------------------------------------------------
94  virtual btTransform getRescueTransform(unsigned int index) const OVERRIDE
95  {
96  return btTransform();
97  } // getRescueTransform
98  // ------------------------------------------------------------------------
99  virtual void onFirePressed(Controller* who) OVERRIDE { abortCutscene(); }
100  // ------------------------------------------------------------------------
101  void setParts(std::vector<std::string> parts) { m_parts = parts; }
102  // ------------------------------------------------------------------------
105  virtual void getKartsDisplayInfo(
106  std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE
107  {
108  };
109  // ------------------------------------------------------------------------
110  virtual void escapePressed() OVERRIDE { abortCutscene(); }
111  // ------------------------------------------------------------------------
112  static void setUseDuration(bool use_duration) { s_use_duration = use_duration; }
113  // ------------------------------------------------------------------------
114  void abortCutscene()
115  {
116  if (m_time < m_duration - m_fade_duration) m_duration = m_time + m_fade_duration;
117  m_aborted = true;
118  }
119 
120 }; // CutsceneWorld
121 
122 
123 #endif
double m_time
Elasped/remaining time in seconds.
Definition: world_status.hpp:93
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:45
CutsceneWorld()
Constructor.
Definition: cutscene_world.cpp:58
virtual void init() OVERRIDE
Initialises the three strikes battle.
Definition: cutscene_world.cpp:75
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: cutscene_world.cpp:190
base class for all game modes This class is responsible for running the actual race.
Definition: world.hpp:85
virtual void enterRaceOverState() OVERRIDE
Called when the race is finished, but it still leaves some time for an end of race animation,...
Definition: cutscene_world.cpp:405
An implementation of World, to provide animated 3D cutscenes.
Definition: cutscene_world.hpp:37
virtual btTransform getRescueTransform(unsigned int index) const OVERRIDE
Returns the bullet transformation for the specified rescue index.
Definition: cutscene_world.hpp:94
virtual void update(int ticks) OVERRIDE
Update the world and the track.
Definition: cutscene_world.cpp:199
virtual ~CutsceneWorld()
Destructor.
Definition: cutscene_world.cpp:177
virtual void onFirePressed(Controller *who) OVERRIDE
Override if you want to know when a kart presses fire.
Definition: cutscene_world.hpp:99
virtual unsigned int getNumberOfRescuePositions() const OVERRIDE
Returns the number of rescue positions on a given track and game mode.
Definition: cutscene_world.hpp:84
bool m_second_reset
monkey tricks to get the animations in sync with irrlicht.
Definition: cutscene_world.hpp:56
virtual void reset(bool restart=false) OVERRIDE
This function is called before a race is started (i.e.
Definition: cutscene_world.cpp:182
virtual bool raceHasLaps() OVERRIDE
Called when it is needed to know whether this kind of race involves counting laps.
Definition: cutscene_world.hpp:82
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
This is a base object for any separate object on the track, which might also have a skeletal animatio...
Definition: track_object.hpp:46
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Returns the data to display in the race gui.
Definition: cutscene_world.hpp:105
virtual bool isRaceOver() OVERRIDE
The battle is over if only one kart is left, or no player kart.
Definition: cutscene_world.cpp:610
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE
Determines the rescue position index of the specified kart.
Definition: cutscene_world.hpp:89