From 632e26c922b742dccbe99334013ff61e1386eb1b Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sun, 22 Sep 2024 14:49:46 +0200 Subject: [PATCH 1/2] Call both native and script's `_setup()` in BTTask Current behavior is overriding, which is not correct as it's an initializer function. --- bt/tasks/bt_task.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bt/tasks/bt_task.cpp b/bt/tasks/bt_task.cpp index c170778..c64b552 100644 --- a/bt/tasks/bt_task.cpp +++ b/bt/tasks/bt_task.cpp @@ -172,9 +172,8 @@ void BTTask::initialize(Node *p_agent, const Ref &p_blackboard, Node get_child(i)->initialize(p_agent, p_blackboard, p_scene_root); } - if (!GDVIRTUAL_CALL(_setup)) { - _setup(); - } + _setup(); + GDVIRTUAL_CALL(_setup); } Ref BTTask::clone() const { From 7feff38d6bded61d685ecfdb379a325d2178168f Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 1 Nov 2024 13:50:08 +0100 Subject: [PATCH 2/2] Call both native and script _enter/_exit in BTTask --- bt/tasks/bt_task.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bt/tasks/bt_task.cpp b/bt/tasks/bt_task.cpp index c64b552..11ae322 100644 --- a/bt/tasks/bt_task.cpp +++ b/bt/tasks/bt_task.cpp @@ -234,9 +234,9 @@ BT::Status BTTask::execute(double p_delta) { data.children.get(i)->abort(); } } - if (!GDVIRTUAL_CALL(_enter)) { - _enter(); - } + // First native, then script. + _enter(); + GDVIRTUAL_CALL(_enter); } else { data.elapsed += p_delta; } @@ -246,9 +246,9 @@ BT::Status BTTask::execute(double p_delta) { } if (data.status != RUNNING) { - if (!GDVIRTUAL_CALL(_exit)) { - _exit(); - } + // First script, then native. + GDVIRTUAL_CALL(_exit); + _exit(); data.elapsed = 0.0; } return data.status; @@ -259,9 +259,9 @@ void BTTask::abort() { get_child(i)->abort(); } if (data.status == RUNNING) { - if (!GDVIRTUAL_CALL(_exit)) { - _exit(); - } + // First script, then native. + GDVIRTUAL_CALL(_exit); + _exit(); } data.status = FRESH; data.elapsed = 0.0;