Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
state.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 
7 class Transition;
8 
14 class State {
15 public:
16  State(State* parent = nullptr);
17  State(const std::string& name, State* parent = nullptr);
18  virtual ~State();
19 
20  const std::string& name() const;
21  void setName(const std::string& name);
22 
23  State* parentState();
24  const State* parentState() const;
25 
26  State* initialSubState();
27  const State* initialSubState() const;
28  void setInitialSubState(State* initialSubState);
29 
30  State* finalSubState();
31  const State* finalSubState() const;
32  void setFinalSubState(State* finalSubState);
33 
34  State* currentSubState();
35  const State* currentSubState() const;
36  void setCurrentSubState(State* substate);
37 
38  bool finished() const;
39 
40  std::list<State*>& substates();
41  const std::list<State*>& substates() const;
42  void addSubState(State* state);
43  void removeSubState(State* state);
44 
45  std::list<Transition*>& transitions();
46  const std::list<Transition*>& transitions() const;
47  void addTransition(Transition* transition);
48  void removeTransition(Transition* transition);
49 
54  virtual void update(float deltaSec);
55 
60  virtual void onEntered();
61 
66  virtual void onLeft();
67 
68 
69 protected:
70  std::string m_name;
71 
72  State* m_parentState;
73  std::list<State*> m_subStates;
74  std::list<Transition*> m_transitions;
75 
76  State* m_initialSubState;
77  State* m_finalSubState;
78  State* m_currentSubState;
79 
80 
86  State* pathToDescendant(State* descendant);
87 
92  void transit(State* target);
93 
94  void leave();
95 };
96 
Definition: state.h:14
virtual void onLeft()
Definition: state.cpp:209
virtual void update(float deltaSec)
Definition: state.cpp:144
void transit(State *target)
Definition: state.cpp:181
virtual void onEntered()
Definition: state.cpp:205
State * pathToDescendant(State *descendant)
Definition: state.cpp:166
Definition: transition.h:15