Fix BTState virtuals not being called

This commit is contained in:
Serhii Snitsaruk 2024-01-13 19:08:34 +01:00
parent f546e285b7
commit c875f9d5d6
2 changed files with 11 additions and 5 deletions

View File

@ -41,7 +41,7 @@ LimboState *LimboState::named(String p_name) {
void LimboState::_do_enter() { void LimboState::_do_enter() {
active = true; active = true;
VCALL(_enter); VCALL_OR_NATIVE(_enter);
emit_signal(LimboStringNames::get_singleton()->entered); emit_signal(LimboStringNames::get_singleton()->entered);
}; };
@ -49,13 +49,13 @@ void LimboState::_do_exit() {
if (!active) { if (!active) {
return; return;
} }
VCALL(_exit); VCALL_OR_NATIVE(_exit);
emit_signal(LimboStringNames::get_singleton()->exited); emit_signal(LimboStringNames::get_singleton()->exited);
active = false; active = false;
}; };
void LimboState::_do_update(double p_delta) { void LimboState::_do_update(double p_delta) {
VCALL_ARGS(_update, p_delta); VCALL_OR_NATIVE_ARGS(_update, p_delta);
emit_signal(LimboStringNames::get_singleton()->updated, p_delta); emit_signal(LimboStringNames::get_singleton()->updated, p_delta);
}; };
@ -71,7 +71,7 @@ void LimboState::_initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard)
} }
} }
VCALL(_setup); VCALL_OR_NATIVE(_setup);
emit_signal(LimboStringNames::get_singleton()->setup); emit_signal(LimboStringNames::get_singleton()->setup);
} }

View File

@ -60,7 +60,12 @@
#define VCALL(m_name, ...) (GDVIRTUAL_CALL(m_name, __VA_ARGS__)) #define VCALL(m_name, ...) (GDVIRTUAL_CALL(m_name, __VA_ARGS__))
#define VCALL_ARGS(method, ...) (call(LW_NAME(method), __VA_ARGS__)) #define VCALL_ARGS(method, ...) (call(LW_NAME(method), __VA_ARGS__))
#define VCALL_V(m_name, r_ret) (GDVIRTUAL_CALL(m_name, r_ret)) #define VCALL_V(m_name, r_ret) (GDVIRTUAL_CALL(m_name, r_ret))
#define VCALL_OR_NATIVE(m_name, ...) \ #define VCALL_OR_NATIVE(m_name) \
if (!GDVIRTUAL_CALL(m_name)) { \
m_name(); \
}
#define VCALL_OR_NATIVE_ARGS(m_name, ...) \
if (!GDVIRTUAL_CALL(m_name, __VA_ARGS__)) { \ if (!GDVIRTUAL_CALL(m_name, __VA_ARGS__)) { \
m_name(__VA_ARGS__); \ m_name(__VA_ARGS__); \
} }
@ -124,6 +129,7 @@ using namespace godot;
#define VCALL_ARGS(m_name, ...) (call(LW_NAME(m_name), __VA_ARGS__)) #define VCALL_ARGS(m_name, ...) (call(LW_NAME(m_name), __VA_ARGS__))
#define VCALL_V(m_name, r_ret) (r_ret = call(LW_NAME(m_name))) #define VCALL_V(m_name, r_ret) (r_ret = call(LW_NAME(m_name)))
#define VCALL_OR_NATIVE(m_name) (call(LW_NAME(m_name))) #define VCALL_OR_NATIVE(m_name) (call(LW_NAME(m_name)))
#define VCALL_OR_NATIVE_ARGS(m_name, ...) (call(LW_NAME(m_name), __VA_ARGS__))
// * Enum // * Enum