-
Notifications
You must be signed in to change notification settings - Fork 0
/
machine.hpp
103 lines (90 loc) · 2.45 KB
/
machine.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef INSULA_MACHINE_HPP_INCLUDED
#define INSULA_MACHINE_HPP_INCLUDED
#include "states/game_outer_fwd.hpp"
#include "input_delegator.hpp"
#include "console/object.hpp"
#include "graphics/camera/object.hpp"
#include "graphics/stats.hpp"
#include "music_controller.hpp"
#include "sound_controller.hpp"
#include <sge/systems/instance.hpp>
#include <sge/parse/json/object.hpp>
#include <fcppt/signal/scoped_connection.hpp>
#include <boost/statechart/state_machine.hpp>
namespace insula
{
/// The machine should contain all information which is needed by all
/// substates, so no ingame information and nothing concerning the
/// menu (if existant later).
///
/// The machine also sends out tick events, although the ticks
/// themselves come from outside. I don't want to have an "infinite"
/// loop inside the machine, blocking everything else.
///
/// The complete state layout looks like this:
///
/// machine
/// / |
/// menu game_outer
/// |
/// game_inner
/// / | | | | |
/// freelook camera_move pregame running finished gameover
class machine
:
public
boost::statechart::state_machine
<
machine,
states::game_outer
>
{
public:
explicit
machine(
sge::parse::json::object const &config_file);
// Sends events::tick, events::input and then events::render
void
tick(
sge::time::timer::frames_type);
graphics::camera::object &
camera();
sge::systems::instance const &
systems() const;
insula::console::object &
console();
sge::parse::json::object const &
config_file() const;
music_controller &
music();
sound_controller &
sounds();
insula::input_delegator &
input_delegator();
// This is checked for in the main program (which _might_ exit if
// it's false)
bool
running() const;
~machine();
private:
bool running_;
sge::parse::json::object config_file_;
sge::systems::instance systems_;
insula::console::object console_;
insula::input_delegator input_delegator_;
// This is a ptr because the cli_factory returns a ptr
graphics::camera::object camera_;
fcppt::signal::scoped_connection exit_callback_;
fcppt::signal::scoped_connection wireframe_callback_;
fcppt::signal::scoped_connection
key_callback_,
mouse_axis_callback_,
mouse_button_callback_;
graphics::stats stats_;
bool show_stats_;
fcppt::signal::scoped_connection stats_callback_;
music_controller music_;
sound_controller sounds_;
};
}
#endif