feat: defined state and state machine concepts
This commit is contained in:
parent
7c0b338f68
commit
7c4c75d193
5 changed files with 124 additions and 0 deletions
23
modules/wave_survival/state_machine.h
Normal file
23
modules/wave_survival/state_machine.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef STATE_MACHINE_H
|
||||
#define STATE_MACHINE_H
|
||||
|
||||
#include "scene/main/node.h"
|
||||
class State;
|
||||
|
||||
class StateMachine : public Node {
|
||||
GDCLASS(StateMachine, Node);
|
||||
static void _bind_methods();
|
||||
void add_state(State *state);
|
||||
void switch_to_state(State *state);
|
||||
void ready();
|
||||
void process(double delta);
|
||||
|
||||
protected:
|
||||
void _notification(int what);
|
||||
|
||||
private:
|
||||
State *current_state{ nullptr };
|
||||
HashMap<StringName, State *> states{};
|
||||
};
|
||||
|
||||
#endif // !STATE_MACHINE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue