Add Dynamic versions of Selector and Sequence, plus icons
|
@ -0,0 +1,25 @@
|
||||||
|
/* bt_dynamic_selector.cpp */
|
||||||
|
|
||||||
|
#include "bt_dynamic_selector.h"
|
||||||
|
|
||||||
|
void BTDynamicSelector::_enter() {
|
||||||
|
last_running_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BTDynamicSelector::_tick(float p_delta) {
|
||||||
|
int status = SUCCESS;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < get_child_count(); i++) {
|
||||||
|
status = get_child(i)->execute(p_delta);
|
||||||
|
if (status != FAILURE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the last node ticked is earlier in the tree than the previous runner,
|
||||||
|
// cancel previous runner.
|
||||||
|
if (last_running_idx > i && get_child(last_running_idx)->get_status() == RUNNING) {
|
||||||
|
get_child(last_running_idx)->cancel();
|
||||||
|
}
|
||||||
|
last_running_idx = i;
|
||||||
|
return status;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* bt_dynamic_selector.h */
|
||||||
|
|
||||||
|
#ifndef BT_DYNAMIC_SELECTOR_H
|
||||||
|
#define BT_DYNAMIC_SELECTOR_H
|
||||||
|
|
||||||
|
#import "bt_composite.h"
|
||||||
|
#include "core/object.h"
|
||||||
|
|
||||||
|
class BTDynamicSelector : public BTComposite {
|
||||||
|
GDCLASS(BTDynamicSelector, BTComposite);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int last_running_idx = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void _enter();
|
||||||
|
virtual int _tick(float p_delta);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BT_DYNAMIC_SELECTOR_H
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* bt_dynamic_sequence.cpp */
|
||||||
|
|
||||||
|
#include "bt_dynamic_sequence.h"
|
||||||
|
|
||||||
|
void BTDynamicSequence::_enter() {
|
||||||
|
last_running_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BTDynamicSequence::_tick(float p_delta) {
|
||||||
|
int status = SUCCESS;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < get_child_count(); i++) {
|
||||||
|
status = get_child(i)->execute(p_delta);
|
||||||
|
if (status != SUCCESS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the last node ticked is earlier in the tree than the previous runner,
|
||||||
|
// cancel previous runner.
|
||||||
|
if (last_running_idx > i && get_child(last_running_idx)->get_status() == RUNNING) {
|
||||||
|
get_child(last_running_idx)->cancel();
|
||||||
|
}
|
||||||
|
last_running_idx = i;
|
||||||
|
return status;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* bt_dynamic_sequence.h */
|
||||||
|
|
||||||
|
#ifndef BT_DYNAMIC_SEQUENCE_H
|
||||||
|
#define BT_DYNAMIC_SEQUENCE_H
|
||||||
|
|
||||||
|
#import "bt_composite.h"
|
||||||
|
#include "core/object.h"
|
||||||
|
|
||||||
|
class BTDynamicSequence : public BTComposite {
|
||||||
|
GDCLASS(BTDynamicSequence, BTComposite);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int last_running_idx = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void _enter();
|
||||||
|
virtual int _tick(float p_delta);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BT_DYNAMIC_SEQUENCE_H
|
|
@ -7,7 +7,7 @@ void BTSelector::_enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int BTSelector::_tick(float p_delta) {
|
int BTSelector::_tick(float p_delta) {
|
||||||
int status = FRESH;
|
int status = FAILURE;
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
status = get_child(i)->execute(p_delta);
|
status = get_child(i)->execute(p_delta);
|
||||||
if (status != FAILURE) {
|
if (status != FAILURE) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ void BTSequence::_enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int BTSequence::_tick(float p_delta) {
|
int BTSequence::_tick(float p_delta) {
|
||||||
int status = FRESH;
|
int status = SUCCESS;
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
status = get_child(i)->execute(p_delta);
|
status = get_child(i)->execute(p_delta);
|
||||||
if (status != SUCCESS) {
|
if (status != SUCCESS) {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m4.5 1 2.47 10h2.31l2.22-10z"/><path d="m8 12a1.5 1.5 0 1 0 1.5 1.49 1.49 1.49 0 0 0 -1.5-1.49z"/></g></svg>
|
After Width: | Height: | Size: 195 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#ffca5f"><path d="m7.66 12a1.5 1.5 0 1 0 1.51 1.49 1.49 1.49 0 0 0 -1.51-1.49z"/><path d="m13 5.33c0-2.51-2.14-4.33-5.08-4.33-2.67 0-4.59 1.48-4.92 3.77v.32h2.56l.05-.24a2.28 2.28 0 0 1 2.39-1.73 2.25 2.25 0 0 1 2.47 2.21c0 1.24-1.76 2.59-3.35 2.59h-2l1.52 3.08h2l.07-1.45v-.19h.2c2.54-.36 4.09-1.89 4.09-4.03z"/></g></svg>
|
After Width: | Height: | Size: 392 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m8 2.3a5.7 5.7 0 1 1 -5.7 5.7 5.71 5.71 0 0 1 5.7-5.7m0-1.3a7 7 0 1 0 7 7 7 7 0 0 0 -7-7z" fill="#c38ef1"/></svg>
|
After Width: | Height: | Size: 182 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m3.75 9a1 1 0 1 0 1 1 1 1 0 0 0 -1-1z"/><path d="m8.34 3.61c0-2.09-1.78-3.61-4.24-3.61-2.23 0-3.82 1.23-4.1 3.14v.27h2.14v-.2a1.91 1.91 0 0 1 2-1.44 1.88 1.88 0 0 1 2.09 1.84c0 1-1.46 2.16-2.8 2.16h-1.67l1.24 2.57h1.7l.06-1.21v-.13h.24c2.05-.33 3.34-1.61 3.34-3.39z"/><path d="m16 12.5a21 21 0 0 1 -6-3.5l.9 2.62h-10.9v1.76h10.92l-.92 2.62a21 21 0 0 1 6-3.5z"/><path d="m12.62 5 3.38 3v-6z"/><path d="m11 2h1.62v6h-1.62z"/></g></svg>
|
After Width: | Height: | Size: 520 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m16 11.5a21 21 0 0 1 -6-3.5l.9 2.62h-10.9v1.76h10.92l-.92 2.62a21 21 0 0 1 6-3.5z"/><path d="m12.62 4 3.38 3v-6z"/><path d="m11 1h1.62v6h-1.62z"/></g></svg>
|
After Width: | Height: | Size: 243 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m12 6a13.69 13.69 0 0 1 4-2.5 13.69 13.69 0 0 1 -4-2.5l.64 2h-12.64v1h12.64z"/><path d="m12 16a13.69 13.69 0 0 1 4-2.5 13.69 13.69 0 0 1 -4-2.5l.64 2h-12.64v1h12.64z"/><path d="m12 11a13.69 13.69 0 0 1 4-2.5 13.69 13.69 0 0 1 -4-2.5l.64 2h-12.64v1h12.64z"/></g></svg>
|
After Width: | Height: | Size: 354 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m16 12a24.07 24.07 0 0 1 -6.84-4l1 3h-10.16v2h10.19l-1 3a24.07 24.07 0 0 1 6.81-4z"/><path d="m4 2a2 2 0 1 0 -2 2 2 2 0 0 0 2-2zm-2 1.5a1.5 1.5 0 1 1 1.5-1.5 1.5 1.5 0 0 1 -1.5 1.5z"/><path d="m8.24 6.23a2 2 0 1 0 -2 2 2 2 0 0 0 2-2zm-2 1.51a1.5 1.5 0 1 1 1.5-1.51 1.5 1.5 0 0 1 -1.49 1.51z"/><path d="m-.88 3.62h10v1h-10z" transform="matrix(.70710678 -.70710678 .70710678 .70710678 -1.71 4.12)"/></g></svg>
|
After Width: | Height: | Size: 494 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m3.75 9a1 1 0 1 0 1 1 1 1 0 0 0 -1-1z"/><path d="m8.34 3.61c0-2.09-1.78-3.61-4.24-3.61-2.23 0-3.82 1.23-4.1 3.14v.27h2.14v-.2a1.91 1.91 0 0 1 2-1.44 1.88 1.88 0 0 1 2.09 1.84c0 1-1.46 2.16-2.8 2.16h-1.67l1.24 2.57h1.7l.06-1.21v-.13h.24c2.05-.33 3.34-1.61 3.34-3.39z"/><path d="m16 12.5a21 21 0 0 1 -6-3.5l.9 2.62h-10.9v1.76h10.92l-.92 2.62a21 21 0 0 1 6-3.5z"/><path d="m16 5.34c0 2.59-2 3.51-3.16 2.73l-1.11-.82c-.67-.48-1.23.33-1.23 1.09h-1.5c0-2.56 2-3.44 3.16-2.66l1.11.82c.73.5 1.23-.38 1.23-1.16z"/></g></svg>
|
After Width: | Height: | Size: 602 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m16 12a24.07 24.07 0 0 1 -6.84-4l1 3h-10.16v2h10.19l-1 3a24.07 24.07 0 0 1 6.81-4z"/><path d="m10 3.33c0 3.45-2.84 4.67-4.51 3.67l-1.59-1.12c-.9-.65-1.75.44-1.75 1.45h-2.15c0-3.42 2.87-4.59 4.51-3.56l1.59 1.1c1 .64 1.75-.51 1.75-1.54z"/></g></svg>
|
After Width: | Height: | Size: 334 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3"><path d="m5.19 0c-2.53 0-4.34 1.41-4.62 3.6l-.07.54h2.74l.07-.39a1.86 1.86 0 0 1 1.95-1.39 1.83 1.83 0 0 1 2 1.78c0 1-1.5 2.14-2.81 2.14h-2.15l1.6 3.22h2.17l.08-1.5c2.35-.33 3.85-1.8 3.85-3.86 0-2.4-2-4.14-4.81-4.14z"/><path d="m16 12a24.07 24.07 0 0 1 -6.84-4l1 3h-10.16v2h10.19l-1 3a24.07 24.07 0 0 1 6.81-4z"/></g></svg>
|
After Width: | Height: | Size: 401 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m16 8a24.07 24.07 0 0 1 -6.84-4l1 3h-10.16v2h10.19l-1 3a24.07 24.07 0 0 1 6.81-4z" fill="#8da5f3"/></svg>
|
After Width: | Height: | Size: 174 B |
|
@ -12,6 +12,8 @@
|
||||||
#include "bt/bt_cooldown.h"
|
#include "bt/bt_cooldown.h"
|
||||||
#include "bt/bt_decorator.h"
|
#include "bt/bt_decorator.h"
|
||||||
#include "bt/bt_delay.h"
|
#include "bt/bt_delay.h"
|
||||||
|
#include "bt/bt_dynamic_selector.h"
|
||||||
|
#include "bt/bt_dynamic_sequence.h"
|
||||||
#include "bt/bt_invert.h"
|
#include "bt/bt_invert.h"
|
||||||
#include "bt/bt_parallel.h"
|
#include "bt/bt_parallel.h"
|
||||||
#include "bt/bt_probability.h"
|
#include "bt/bt_probability.h"
|
||||||
|
@ -35,8 +37,11 @@ void register_limboai_types() {
|
||||||
ClassDB::register_class<BTCondition>();
|
ClassDB::register_class<BTCondition>();
|
||||||
|
|
||||||
ClassDB::register_class<BTSequence>();
|
ClassDB::register_class<BTSequence>();
|
||||||
|
ClassDB::register_class<BTDynamicSequence>();
|
||||||
|
ClassDB::register_class<BTDynamicSelector>();
|
||||||
ClassDB::register_class<BTSelector>();
|
ClassDB::register_class<BTSelector>();
|
||||||
ClassDB::register_class<BTParallel>();
|
ClassDB::register_class<BTParallel>();
|
||||||
|
|
||||||
ClassDB::register_class<BTInvert>();
|
ClassDB::register_class<BTInvert>();
|
||||||
ClassDB::register_class<BTAlwaysFail>();
|
ClassDB::register_class<BTAlwaysFail>();
|
||||||
ClassDB::register_class<BTAlwaysSucceed>();
|
ClassDB::register_class<BTAlwaysSucceed>();
|
||||||
|
@ -48,6 +53,7 @@ void register_limboai_types() {
|
||||||
ClassDB::register_class<BTTimeLimit>();
|
ClassDB::register_class<BTTimeLimit>();
|
||||||
ClassDB::register_class<BTCooldown>();
|
ClassDB::register_class<BTCooldown>();
|
||||||
ClassDB::register_class<BTProbability>();
|
ClassDB::register_class<BTProbability>();
|
||||||
|
|
||||||
LimboStringNames::create();
|
LimboStringNames::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|