2022-04-13 00:59:23 -04:00
|
|
|
#include "state_machine/State.h"
|
2022-04-11 13:30:51 -04:00
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::_register_methods()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-08-31 00:36:01 -04:00
|
|
|
godot::register_method("set_parent", &State::set_parent);
|
|
|
|
godot::register_method("get_parent", &State::get_parent);
|
|
|
|
godot::register_method("set_state_machine", &State::set_state_machine);
|
|
|
|
godot::register_method("_state_enter", &State::_state_enter);
|
|
|
|
godot::register_method("_state_exit", &State::_state_exit);
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
alai::State::State()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
alai::State::~State()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::_init()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::_state_enter(const godot::String state, const godot::Array args)
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-04-16 15:54:05 -04:00
|
|
|
WARN_PRINT("State " + get_state_machine()->get_current_state() + " is missing its _state_enter method!");
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::_state_exit(const godot::String state, const godot::Array args)
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-04-16 15:54:05 -04:00
|
|
|
WARN_PRINT("State " + get_state_machine()->get_current_state() + " is missing its _state_exit method!");
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::set_parent(Node *parent)
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-04-12 11:33:22 -04:00
|
|
|
this->parent = parent;
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
godot::Node *alai::State::get_parent()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
void alai::State::set_state_machine(alai::StateMachine *state_machine)
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-04-12 11:33:22 -04:00
|
|
|
this->state_machine = state_machine;
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:57 -04:00
|
|
|
alai::StateMachine *alai::State::get_state_machine()
|
2022-04-11 13:30:51 -04:00
|
|
|
{
|
2022-04-12 11:33:22 -04:00
|
|
|
return this->state_machine;
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|