2022-04-13 00:59:23 -04:00
|
|
|
#include "state_machine/State.h"
|
2022-04-11 13:30:51 -04:00
|
|
|
|
|
|
|
using namespace godot;
|
|
|
|
|
|
|
|
void State::_register_methods()
|
|
|
|
{
|
|
|
|
register_method("set_parent", &State::set_parent);
|
|
|
|
register_method("get_parent", &State::get_parent);
|
|
|
|
register_method("set_state_machine", &State::set_state_machine);
|
|
|
|
register_method("_state_enter", &State::_state_enter);
|
|
|
|
register_method("_state_exit", &State::_state_exit);
|
|
|
|
}
|
|
|
|
|
|
|
|
State::State()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
State::~State()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void State::_init()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void State::_state_enter(const String state, const Array args)
|
|
|
|
{
|
|
|
|
WARN_PRINT("State " + state + " is missing its _state_enter method!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void State::_state_exit(const String state, const Array args)
|
|
|
|
{
|
|
|
|
WARN_PRINT("State " + state + " is missing its _state_exit method!");
|
|
|
|
}
|
|
|
|
|
2022-04-12 11:33:22 -04:00
|
|
|
void 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
|
|
|
}
|
|
|
|
|
|
|
|
Node *State::get_parent()
|
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2022-04-12 11:33:22 -04:00
|
|
|
void State::set_state_machine(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
|
|
|
}
|
|
|
|
|
|
|
|
StateMachine *State::get_state_machine()
|
|
|
|
{
|
2022-04-12 11:33:22 -04:00
|
|
|
return this->state_machine;
|
2022-04-11 13:30:51 -04:00
|
|
|
}
|