feat: defined state and state machine concepts

This commit is contained in:
Sara 2025-07-19 20:06:42 +02:00
parent 7c0b338f68
commit 7c4c75d193
5 changed files with 124 additions and 0 deletions

View 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