feat: state machine exposes switch_to_state
This commit is contained in:
parent
7d7c61e8f7
commit
ca49ee81d7
1 changed files with 3 additions and 3 deletions
|
|
@ -2,7 +2,9 @@
|
|||
#include "core/config/engine.h"
|
||||
#include "state.h"
|
||||
|
||||
void StateMachine::_bind_methods() {}
|
||||
void StateMachine::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("switch_to_state", "state"), &self_type::switch_to_state);
|
||||
}
|
||||
|
||||
void StateMachine::switch_to_state(State *state) {
|
||||
if (this->current_state != nullptr) {
|
||||
|
|
@ -13,8 +15,6 @@ void StateMachine::switch_to_state(State *state) {
|
|||
if (this->current_state != nullptr) {
|
||||
this->current_state_is_active = true;
|
||||
this->current_state->enter_state();
|
||||
} else {
|
||||
print_error("StateMachine::switch_to_state: New state is nullptr, StateMachine will now stop working");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue