Compare commits

..

4 Commits

Author SHA1 Message Date
Legendsmith 1b9a81ad0c
Merge bbdafa9033 into 6de8b9e4c4 2024-11-01 14:19:26 +01:00
Serhii Snitsaruk 6de8b9e4c4
Merge pull request #227 from limbonaut/fix-bttask-setup-overriding
Call both native and script `_setup/_enter/_exit` in BTTask
2024-11-01 06:19:13 -07:00
Serhii Snitsaruk 7feff38d6b
Call both native and script _enter/_exit in BTTask 2024-11-01 13:50:08 +01:00
Serhii Snitsaruk 632e26c922
Call both native and script's `_setup()` in BTTask
Current behavior is overriding, which is not correct as it's an initializer function.
2024-11-01 13:42:49 +01:00
1 changed files with 11 additions and 12 deletions

View File

@ -172,9 +172,8 @@ void BTTask::initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard, Node
get_child(i)->initialize(p_agent, p_blackboard, p_scene_root); get_child(i)->initialize(p_agent, p_blackboard, p_scene_root);
} }
if (!GDVIRTUAL_CALL(_setup)) {
_setup(); _setup();
} GDVIRTUAL_CALL(_setup);
} }
Ref<BTTask> BTTask::clone() const { Ref<BTTask> BTTask::clone() const {
@ -235,9 +234,9 @@ BT::Status BTTask::execute(double p_delta) {
data.children.get(i)->abort(); data.children.get(i)->abort();
} }
} }
if (!GDVIRTUAL_CALL(_enter)) { // First native, then script.
_enter(); _enter();
} GDVIRTUAL_CALL(_enter);
} else { } else {
data.elapsed += p_delta; data.elapsed += p_delta;
} }
@ -247,9 +246,9 @@ BT::Status BTTask::execute(double p_delta) {
} }
if (data.status != RUNNING) { if (data.status != RUNNING) {
if (!GDVIRTUAL_CALL(_exit)) { // First script, then native.
GDVIRTUAL_CALL(_exit);
_exit(); _exit();
}
data.elapsed = 0.0; data.elapsed = 0.0;
} }
return data.status; return data.status;
@ -260,10 +259,10 @@ void BTTask::abort() {
get_child(i)->abort(); get_child(i)->abort();
} }
if (data.status == RUNNING) { if (data.status == RUNNING) {
if (!GDVIRTUAL_CALL(_exit)) { // First script, then native.
GDVIRTUAL_CALL(_exit);
_exit(); _exit();
} }
}
data.status = FRESH; data.status = FRESH;
data.elapsed = 0.0; data.elapsed = 0.0;
} }