31 lines
747 B
C++
31 lines
747 B
C++
#ifndef STATE_MACHINE_HPP
|
|
#define STATE_MACHINE_HPP
|
|
|
|
#include <godot_cpp/variant/string_name.hpp>
|
|
#include <godot_cpp/classes/node.hpp>
|
|
#include <godot_cpp/templates/hash_map.hpp>
|
|
|
|
namespace godot {
|
|
class IState;
|
|
|
|
class StateMachine : public Node {
|
|
GDCLASS(StateMachine, Node);
|
|
static void _bind_methods();
|
|
public:
|
|
virtual void _enter_tree() override;
|
|
virtual void _exit_tree() override;
|
|
virtual void _process(double delta_time) override;
|
|
|
|
void override_state(StringName new_state_class);
|
|
|
|
void set_initial_state(StringName name);
|
|
StringName get_initial_state() const;
|
|
private:
|
|
String initial_state{};
|
|
IState *state{nullptr};
|
|
HashMap<StringName, IState*> available{};
|
|
};
|
|
}
|
|
|
|
#endif // !STATE_MACHINE_HPP
|