SuperTuxKart
Loading...
Searching...
No Matches
race_event_manager.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2013-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 NETWORK_WORLD_HPP
20#define NETWORK_WORLD_HPP
21
22#include <memory>
23
24class Controller;
26class AbstractKart;
27class Item;
28
36{
37private:
38 bool m_running;
39
40 std::weak_ptr<GameEventsProtocol> m_game_events_protocol;
41
44
45public:
46 // ----------------------------------------------------------------------------------------
47 static RaceEventManager* get();
48 // ----------------------------------------------------------------------------------------
49 static void create();
50 // ----------------------------------------------------------------------------------------
51 static void destroy();
52 // ----------------------------------------------------------------------------------------
53 static void clear();
54 // ------------------------------------------------------------------------
55 void update(int ticks, bool fast_forward);
56 // ------------------------------------------------------------------------
57 void start(std::shared_ptr<GameEventsProtocol> gep)
58 {
59 m_game_events_protocol = gep;
60 m_running = true;
61 }
62 // ------------------------------------------------------------------------
63 void stop() { m_running = false; }
64 // ------------------------------------------------------------------------
66 bool isRunning() { return m_running; }
67 // ------------------------------------------------------------------------
68 std::shared_ptr<GameEventsProtocol> getProtocol() const
69 { return m_game_events_protocol.lock(); }
70 // ------------------------------------------------------------------------
71 bool protocolStopped() const { return m_game_events_protocol.expired(); }
72 // ------------------------------------------------------------------------
73 bool isRaceOver();
74 // ------------------------------------------------------------------------
75 void kartFinishedRace(AbstractKart *kart, float time);
76
77};
78
79#endif // NETWORK_WORLD_HPP
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:46
Definition: game_events_protocol.hpp:10
Definition: item.hpp:324
This is the interface between the main game and the online implementation.
Definition: race_event_manager.hpp:36
bool isRunning()
Returns if this instance is in running state or not.
Definition: race_event_manager.hpp:66
void update(int ticks, bool fast_forward)
In network games this update function is called instead of World::updateWorld().
Definition: race_event_manager.cpp:60