Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Online/state_machine.h')
-rw-r--r--Source/Online/state_machine.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/Online/state_machine.h b/Source/Online/state_machine.h
index 2dd0ef34..abf23a49 100644
--- a/Source/Online/state_machine.h
+++ b/Source/Online/state_machine.h
@@ -24,33 +24,33 @@
template <class T>
class BaseState {
-protected:
+ protected:
T* actor;
-public:
+ public:
void SetActor(T* actor) {
this->actor = actor;
}
- virtual void OnEnter() {};
+ virtual void OnEnter(){};
virtual BaseState<T>* OnUpdate() = 0;
- virtual void OnExit() {};
+ virtual void OnExit(){};
virtual ~BaseState() {}
};
template <class T>
class StateMachine {
-private:
+ private:
BaseState<T>* current_state = nullptr;
BaseState<T>* start_state = nullptr;
-public:
+ public:
T actor;
-private:
+ private:
void SwitchToState(BaseState<T>* new_state) {
- if(current_state != new_state) {
+ if (current_state != new_state) {
ExitState();
current_state = new_state;
@@ -69,12 +69,12 @@ private:
}
}
-public:
+ public:
void Update() {
if (current_state != nullptr) {
BaseState<T>* new_state = current_state->OnUpdate();
- if(current_state != new_state) {
+ if (current_state != new_state) {
SwitchToState(new_state);
}
} else {
@@ -87,7 +87,6 @@ public:
}
StateMachine() {
-
}
StateMachine(BaseState<T>* initial_state, T actor) : actor(actor) {