Refactor and clean up the code

This commit is contained in:
Serhii Snitsaruk 2024-01-13 17:10:42 +01:00
parent eec085278a
commit f546e285b7
91 changed files with 223 additions and 328 deletions

View File

@ -15,6 +15,7 @@
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/node.hpp> #include <godot_cpp/classes/node.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -11,9 +11,9 @@
#include "bb_param.h" #include "bb_param.h"
#ifdef LIMBOAI_MODULE #include "../../util/limbo_utility.h"
#include "modules/limboai/util/limbo_utility.h"
#ifdef LIMBOAI_MODULE
#include "core/core_bind.h" #include "core/core_bind.h"
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
@ -23,8 +23,6 @@
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include "util/limbo_utility.h"
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
@ -59,9 +57,9 @@ void BBParam::set_variable(const String &p_value) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
String BBParam::to_string() { String BBParam::to_string() {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
String BBParam::_to_string() { String BBParam::_to_string() {
#endif // LIMBOAI_MODULE #endif
if (value_source == SAVED_VALUE) { if (value_source == SAVED_VALUE) {
String s = saved_value.stringify(); String s = saved_value.stringify();
switch (get_type()) { switch (get_type()) {

View File

@ -27,7 +27,7 @@
#include <godot_cpp/classes/resource.hpp> #include <godot_cpp/classes/resource.hpp>
#include <godot_cpp/core/type_info.hpp> #include <godot_cpp/core/type_info.hpp>
#include <godot_cpp/variant/variant.hpp> #include <godot_cpp/variant/variant.hpp>
#endif #endif // LIMBOAI_GDEXTENSION
class BBParam : public Resource { class BBParam : public Resource {
GDCLASS(BBParam, Resource); GDCLASS(BBParam, Resource);
@ -54,8 +54,7 @@ protected:
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
Callable::CallError err; Callable::CallError err;
Variant::construct(get_type(), saved_value, nullptr, 0, err); Variant::construct(get_type(), saved_value, nullptr, 0, err);
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
saved_value.clear(); saved_value.clear();
#endif #endif
} }
@ -76,7 +75,7 @@ public:
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
virtual String to_string() override; virtual String to_string() override;
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
virtual String _to_string(); virtual String _to_string();
#endif #endif

View File

@ -68,7 +68,7 @@ void Blackboard::prefetch_nodepath_vars(Node *p_node) {
} }
} }
} }
}; }
void Blackboard::_bind_methods() { void Blackboard::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_data"), &Blackboard::get_data); ClassDB::bind_method(D_METHOD("get_data"), &Blackboard::get_data);

View File

@ -21,15 +21,12 @@
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/node.hpp> #include <godot_cpp/classes/node.hpp>
#include <godot_cpp/classes/ref.hpp> #include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/classes/ref_counted.hpp> #include <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/core/object.hpp> #include <godot_cpp/core/object.hpp>
#include <godot_cpp/variant/dictionary.hpp> #include <godot_cpp/variant/dictionary.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class Blackboard : public RefCounted { class Blackboard : public RefCounted {

View File

@ -16,7 +16,6 @@
#include "../util/limbo_string_names.h" #include "../util/limbo_string_names.h"
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "core/config/engine.h" #include "core/config/engine.h"
#include "core/debugger/engine_debugger.h" #include "core/debugger/engine_debugger.h"
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
@ -30,10 +29,9 @@
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active()) #define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
#define GET_TICKS_USEC() (OS::get_singleton()->get_ticks_usec()) #define GET_TICKS_USEC() (OS::get_singleton()->get_ticks_usec())
#endif // LIMBO_MODULE #endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/engine_debugger.hpp> #include <godot_cpp/classes/engine_debugger.hpp>
#include <godot_cpp/classes/performance.hpp> #include <godot_cpp/classes/performance.hpp>
#include <godot_cpp/classes/time.hpp> #include <godot_cpp/classes/time.hpp>
@ -41,7 +39,7 @@
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::get_singleton()->is_active()) #define IS_DEBUGGER_ACTIVE() (EngineDebugger::get_singleton()->is_active())
#define GET_TICKS_USEC() (Time::get_singleton()->get_ticks_usec()) #define GET_TICKS_USEC() (Time::get_singleton()->get_ticks_usec())
#endif // LIMBOAI_GDEXTENSION #endif // ! LIMBOAI_GDEXTENSION
VARIANT_ENUM_CAST(BTPlayer::UpdateMode); VARIANT_ENUM_CAST(BTPlayer::UpdateMode);
@ -148,7 +146,7 @@ double BTPlayer::_get_mean_update_time_msec() {
return 0.0; return 0.0;
} }
#endif // DEBUG_ENABLED #endif // ! DEBUG_ENABLED
void BTPlayer::_notification(int p_notification) { void BTPlayer::_notification(int p_notification) {
switch (p_notification) { switch (p_notification) {
@ -182,7 +180,7 @@ void BTPlayer::_notification(int p_notification) {
LimboDebugger::get_singleton()->unregister_bt_instance(tree_instance, get_path()); LimboDebugger::get_singleton()->unregister_bt_instance(tree_instance, get_path());
} }
} break; } break;
#endif #endif // DEBUG_ENABLED
} }
} }
@ -223,7 +221,6 @@ void BTPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_monitor_performance", "p_value"), &BTPlayer::_set_monitor_performance); ClassDB::bind_method(D_METHOD("_set_monitor_performance", "p_value"), &BTPlayer::_set_monitor_performance);
ClassDB::bind_method(D_METHOD("_get_monitor_performance"), &BTPlayer::_get_monitor_performance); ClassDB::bind_method(D_METHOD("_get_monitor_performance"), &BTPlayer::_get_monitor_performance);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitor_performance"), "_set_monitor_performance", "_get_monitor_performance"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitor_performance"), "_set_monitor_performance", "_get_monitor_performance");
// ADD_PROPERTY_DEFAULT("monitor_performance", false);
#endif // DEBUG_ENABLED #endif // DEBUG_ENABLED
} }

View File

@ -12,6 +12,10 @@
#ifndef BT_PLAYER_H #ifndef BT_PLAYER_H
#define BT_PLAYER_H #define BT_PLAYER_H
#include "../blackboard/blackboard.h"
#include "behavior_tree.h"
#include "tasks/bt_task.h"
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "scene/main/node.h" #include "scene/main/node.h"
#endif #endif
@ -20,17 +24,13 @@
#include <godot_cpp/classes/node.hpp> #include <godot_cpp/classes/node.hpp>
#endif #endif
#include "../blackboard/blackboard.h"
#include "behavior_tree.h"
#include "tasks/bt_task.h"
class BTPlayer : public Node { class BTPlayer : public Node {
GDCLASS(BTPlayer, Node); GDCLASS(BTPlayer, Node);
public: public:
enum UpdateMode : unsigned int { enum UpdateMode : unsigned int {
IDLE, // automatically call update() during NOTIFICATION_PROCESS IDLE, // automatically call update() during NOTIFICATION_PROCESS
PHYSICS, //# automatically call update() during NOTIFICATION_PHYSICS PHYSICS, // automatically call update() during NOTIFICATION_PHYSICS
MANUAL, // manually update state machine, user must call update(delta) MANUAL, // manually update state machine, user must call update(delta)
}; };
@ -77,8 +77,8 @@ public:
BTPlayer(); BTPlayer();
~BTPlayer(); ~BTPlayer();
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED // Performance monitoring
// Performace monitoring.
private: private:
bool monitor_performance = false; bool monitor_performance = false;
StringName monitor_id; StringName monitor_id;

View File

@ -30,7 +30,6 @@ protected:
static void _bind_methods(); static void _bind_methods();
virtual void _setup() override; virtual void _setup() override;
// virtual void _enter() override {}
virtual void _exit() override; virtual void _exit() override;
virtual void _update(double p_delta) override; virtual void _update(double p_delta) override;

View File

@ -23,4 +23,4 @@ public:
virtual PackedStringArray get_configuration_warnings() override; virtual PackedStringArray get_configuration_warnings() override;
}; };
#endif // BT_COMMENT #endif // BT_COMMENT_H

View File

@ -11,12 +11,12 @@
#include "bt_task.h" #include "bt_task.h"
#ifdef LIMBOAI_MODULE #include "../../blackboard/blackboard.h"
#include "../../util/limbo_string_names.h"
#include "../../util/limbo_utility.h"
#include "bt_comment.h" #include "bt_comment.h"
#include "modules/limboai/blackboard/blackboard.h"
#include "modules/limboai/util/limbo_string_names.h"
#include "modules/limboai/util/limbo_utility.h"
#ifdef LIMBOAI_MODULE
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/io/resource.h" #include "core/io/resource.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
@ -29,10 +29,6 @@
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include "blackboard/blackboard.h"
#include "bt/tasks/bt_comment.h"
#include "util/limbo_string_names.h"
#include "godot_cpp/classes/global_constants.hpp" #include "godot_cpp/classes/global_constants.hpp"
#include "godot_cpp/core/class_db.hpp" #include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/variant/dictionary.hpp" #include "godot_cpp/variant/dictionary.hpp"
@ -41,6 +37,7 @@
#include "godot_cpp/variant/utility_functions.hpp" #include "godot_cpp/variant/utility_functions.hpp"
#include "godot_cpp/variant/variant.hpp" #include "godot_cpp/variant/variant.hpp"
#include <godot_cpp/classes/ref.hpp> #include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/classes/script.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
void BT::_bind_methods() { void BT::_bind_methods() {
@ -102,7 +99,7 @@ String BTTask::get_task_name() {
} }
} }
return _generate_name(); return _generate_name();
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
return call(LimboStringNames::get_singleton()->_generate_name); return call(LimboStringNames::get_singleton()->_generate_name);
#endif #endif
} }
@ -133,15 +130,7 @@ void BTTask::initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) {
get_child(i)->initialize(p_agent, p_blackboard); get_child(i)->initialize(p_agent, p_blackboard);
} }
#ifdef LIMBOAI_MODULE VCALL_OR_NATIVE(_setup);
if (!GDVIRTUAL_CALL(_setup)) {
_setup();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_setup);
#endif
} }
Ref<BTTask> BTTask::clone() const { Ref<BTTask> BTTask::clone() const {
@ -191,9 +180,7 @@ Ref<BTTask> BTTask::clone() const {
} }
} }
} }
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
// Make BBParam properties unique. // Make BBParam properties unique.
TypedArray<Dictionary> props = inst->get_property_list(); TypedArray<Dictionary> props = inst->get_property_list();
HashMap<Ref<Resource>, Ref<Resource>> duplicates; HashMap<Ref<Resource>, Ref<Resource>> duplicates;
@ -220,8 +207,7 @@ Ref<BTTask> BTTask::clone() const {
} }
} }
} }
#endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
#endif // LIMBOAI_GDEXTENSION
return inst; return inst;
} }
@ -235,15 +221,7 @@ BT::Status BTTask::execute(double p_delta) {
} }
} }
#ifdef LIMBOAI_MODULE VCALL_OR_NATIVE(_enter);
if (!GDVIRTUAL_CALL(_enter)) {
_enter();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_enter);
#endif
} else { } else {
data.elapsed += p_delta; data.elapsed += p_delta;
} }
@ -252,20 +230,12 @@ BT::Status BTTask::execute(double p_delta) {
if (!GDVIRTUAL_CALL(_tick, p_delta, data.status)) { if (!GDVIRTUAL_CALL(_tick, p_delta, data.status)) {
data.status = _tick(p_delta); data.status = _tick(p_delta);
} }
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
data.status = (Status)(int)call(LimboStringNames::get_singleton()->_tick, p_delta); data.status = (Status)(int)call(LimboStringNames::get_singleton()->_tick, p_delta);
#endif #endif
if (data.status != RUNNING) { if (data.status != RUNNING) {
#ifdef LIMBOAI_MODULE VCALL_OR_NATIVE(_exit);
if (!GDVIRTUAL_CALL(_exit)) {
_exit();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_exit);
#endif
data.elapsed = 0.0; data.elapsed = 0.0;
} }
return data.status; return data.status;
@ -276,14 +246,7 @@ void BTTask::abort() {
get_child(i)->abort(); get_child(i)->abort();
} }
if (data.status == RUNNING) { if (data.status == RUNNING) {
#ifdef LIMBOAI_MODULE VCALL_OR_NATIVE(_exit);
if (!GDVIRTUAL_CALL(_exit)) {
_exit();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_exit);
#endif
} }
data.status = FRESH; data.status = FRESH;
data.elapsed = 0.0; data.elapsed = 0.0;
@ -364,19 +327,16 @@ Ref<BTTask> BTTask::next_sibling() const {
return Ref<BTTask>(); return Ref<BTTask>();
} }
PackedStringArray BTTask::_get_configuration_warnings() {
return PackedStringArray();
}
PackedStringArray BTTask::get_configuration_warnings() { PackedStringArray BTTask::get_configuration_warnings() {
PackedStringArray ret; PackedStringArray ret;
PackedStringArray warnings; PackedStringArray warnings;
#ifdef LIMBOAI_MODULE VCALL_V(_get_configuration_warnings, warnings); // Get script warnings.
if (GDVIRTUAL_CALL(_get_configuration_warning, warnings)) {
ret.append_array(warnings);
}
#endif
#ifdef LIMBOAI_GDEXTENSION
warnings = call(LimboStringNames::get_singleton()->_get_configuration_warning);
ret.append_array(warnings); ret.append_array(warnings);
#endif
return ret; return ret;
} }
@ -431,7 +391,6 @@ void BTTask::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "custom_name"), "set_custom_name", "get_custom_name"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "custom_name"), "set_custom_name", "get_custom_name");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_agent", "get_agent"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_agent", "get_agent");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", PROPERTY_USAGE_NONE), "", "get_blackboard"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", PROPERTY_USAGE_NONE), "", "get_blackboard");
// ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "parent", PROPERTY_HINT_RESOURCE_TYPE, "BTTask", 0), "", "get_parent");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "children", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_children", "_get_children"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "children", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_children", "_get_children");
ADD_PROPERTY(PropertyInfo(Variant::INT, "status", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_status"); ADD_PROPERTY(PropertyInfo(Variant::INT, "status", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_status");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "elapsed_time", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_elapsed_time"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "elapsed_time", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_elapsed_time");
@ -442,22 +401,15 @@ void BTTask::_bind_methods() {
GDVIRTUAL_BIND(_exit); GDVIRTUAL_BIND(_exit);
GDVIRTUAL_BIND(_tick, "p_delta"); GDVIRTUAL_BIND(_tick, "p_delta");
GDVIRTUAL_BIND(_generate_name); GDVIRTUAL_BIND(_generate_name);
GDVIRTUAL_BIND(_get_configuration_warning); GDVIRTUAL_BIND(_get_configuration_warnings);
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
// TODO: Until virtual functions are implemented in godot-cpp, we do this. Replace this code when possible. // TODO: Until virtual functions are implemented in godot-cpp, we do this. Replace this code when possible.
ClassDB::bind_method(D_METHOD("_setup"), &BTTask::_setup); ClassDB::bind_method(D_METHOD("_setup"), &BTTask::_setup);
ClassDB::bind_method(D_METHOD("_enter"), &BTTask::_enter); ClassDB::bind_method(D_METHOD("_enter"), &BTTask::_enter);
ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit); ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit);
ClassDB::bind_method(D_METHOD("_tick", "p_delta"), &BTTask::_tick); ClassDB::bind_method(D_METHOD("_tick", "p_delta"), &BTTask::_tick);
ClassDB::bind_method(D_METHOD("_generate_name"), &BTTask::_generate_name); ClassDB::bind_method(D_METHOD("_generate_name"), &BTTask::_generate_name);
ClassDB::bind_method(D_METHOD("_get_configuration_warnings"), &BTTask::get_configuration_warnings); ClassDB::bind_method(D_METHOD("_get_configuration_warnings"), &BTTask::_get_configuration_warnings);
// BIND_VIRTUAL_METHOD(BTTask, _setup);
// BIND_VIRTUAL_METHOD(BTTask, _enter);
// BIND_VIRTUAL_METHOD(BTTask, _exit);
// BIND_VIRTUAL_METHOD(BTTask, _tick);
// BIND_VIRTUAL_METHOD(BTTask, _generate_name);
// BIND_VIRTUAL_METHOD(BTTask, get_configuration_warnings);
#endif #endif
} }

View File

@ -9,8 +9,8 @@
* ============================================================================= * =============================================================================
*/ */
#ifndef BTTASK_H #ifndef BT_TASK_H
#define BTTASK_H #define BT_TASK_H
#include "../../blackboard/blackboard.h" #include "../../blackboard/blackboard.h"
#include "../../util/limbo_compat.h" #include "../../util/limbo_compat.h"
@ -32,16 +32,15 @@
#include "core/variant/binder_common.h" #include "core/variant/binder_common.h"
#include "core/variant/dictionary.h" #include "core/variant/dictionary.h"
#include "scene/resources/texture.h" #include "scene/resources/texture.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/engine.hpp> #include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/resource.hpp> #include <godot_cpp/classes/resource.hpp>
#include <godot_cpp/core/object.hpp> #include <godot_cpp/core/object.hpp>
#include <godot_cpp/templates/vector.hpp> #include <godot_cpp/templates/vector.hpp>
using namespace godot; using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
/** /**
* Base class for BTTask. * Base class for BTTask.
@ -71,7 +70,7 @@ class BTTask : public BT {
private: private:
friend class BehaviorTree; friend class BehaviorTree;
// Avoid namespace pollution in derived classes. // Avoid namespace pollution in the derived classes.
struct Data { struct Data {
int index = -1; int index = -1;
String custom_name; String custom_name;
@ -86,6 +85,8 @@ private:
Array _get_children() const; Array _get_children() const;
void _set_children(Array children); void _set_children(Array children);
PackedStringArray _get_configuration_warnings(); // ! Scripts only.
protected: protected:
static void _bind_methods(); static void _bind_methods();
@ -101,7 +102,7 @@ protected:
GDVIRTUAL0(_enter); GDVIRTUAL0(_enter);
GDVIRTUAL0(_exit); GDVIRTUAL0(_exit);
GDVIRTUAL1R(Status, _tick, double); GDVIRTUAL1R(Status, _tick, double);
GDVIRTUAL0RC(PackedStringArray, _get_configuration_warning); GDVIRTUAL0RC(PackedStringArray, _get_configuration_warnings);
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
public: public:
@ -122,7 +123,7 @@ public:
virtual Ref<BTTask> clone() const; virtual Ref<BTTask> clone() const;
virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard); virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard);
virtual PackedStringArray get_configuration_warnings(); virtual PackedStringArray get_configuration_warnings(); // ! Native version.
Status execute(double p_delta); Status execute(double p_delta);
void abort(); void abort();
@ -158,4 +159,4 @@ public:
~BTTask(); ~BTTask();
}; };
#endif // BTTASK_H #endif // BT_TASK_H

View File

@ -20,6 +20,7 @@
#include "core/core_string_names.h" #include "core/core_string_names.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/templates/hash_set.hpp> #include <godot_cpp/templates/hash_set.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -26,4 +26,5 @@ protected:
virtual void _enter() override; virtual void _enter() override;
virtual Status _tick(double p_delta) override; virtual Status _tick(double p_delta) override;
}; };
#endif // BT_RANDOM_SELECTOR_H #endif // BT_RANDOM_SELECTOR_H

View File

@ -26,4 +26,5 @@ protected:
virtual void _enter() override; virtual void _enter() override;
virtual Status _tick(double p_delta) override; virtual Status _tick(double p_delta) override;
}; };
#endif // BT_RANDOM_SEQUENCE_H #endif // BT_RANDOM_SEQUENCE_H

View File

@ -14,6 +14,7 @@
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
#endif #endif
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/scene_tree.hpp> #include <godot_cpp/classes/scene_tree.hpp>
#endif #endif
@ -78,13 +79,8 @@ void BTCooldown::_chill() {
if (timer.is_valid()) { if (timer.is_valid()) {
timer->set_time_left(duration); timer->set_time_left(duration);
} else { } else {
#ifdef LIMBOAI_MODULE timer = SCENE_TREE()->create_timer(duration, process_pause);
timer = SceneTree::get_singleton()->create_timer(duration, process_pause); ERR_FAIL_NULL(timer);
#endif
#ifdef LIMBOAI_GDEXTENSION
SceneTree *st = (SceneTree *)Engine::get_singleton()->get_main_loop();
timer = st->create_timer(duration, process_pause);
#endif
timer->connect(LW_NAME(timeout), callable_mp(this, &BTCooldown::_on_timeout), CONNECT_ONE_SHOT); timer->connect(LW_NAME(timeout), callable_mp(this, &BTCooldown::_on_timeout), CONNECT_ONE_SHOT);
} }
} }

View File

@ -17,6 +17,7 @@
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
#endif #endif
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/scene_tree_timer.hpp> #include <godot_cpp/classes/scene_tree_timer.hpp>
#endif #endif

View File

@ -11,8 +11,6 @@
#include "bt_repeat.h" #include "bt_repeat.h"
#include "../../../util/limbo_string_names.h"
String BTRepeat::_generate_name() { String BTRepeat::_generate_name() {
if (forever) { if (forever) {
return LW_NAME(repeat_forever); return LW_NAME(repeat_forever);

View File

@ -56,4 +56,4 @@ public:
virtual PackedStringArray get_configuration_warnings() override; virtual PackedStringArray get_configuration_warnings() override;
}; };
#endif // BT_AWAIT_ANIMATION #endif // BT_AWAIT_ANIMATION_H

View File

@ -58,8 +58,7 @@ BT::Status BTCheckAgentProperty::_tick(double p_delta) {
bool r_valid; bool r_valid;
Variant left_value = get_agent()->get(property, &r_valid); Variant left_value = get_agent()->get(property, &r_valid);
ERR_FAIL_COND_V_MSG(r_valid == false, FAILURE, vformat("BTCheckAgentProperty: Agent has no property named \"%s\"", property)); ERR_FAIL_COND_V_MSG(r_valid == false, FAILURE, vformat("BTCheckAgentProperty: Agent has no property named \"%s\"", property));
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
Variant left_value = get_agent()->get(property); Variant left_value = get_agent()->get(property);
#endif #endif

View File

@ -45,4 +45,4 @@ public:
virtual PackedStringArray get_configuration_warnings() override; virtual PackedStringArray get_configuration_warnings() override;
}; };
#endif // BT_CHECK_AGENT_PROPERTY #endif // BT_CHECK_AGENT_PROPERTY_H

View File

@ -69,4 +69,4 @@ public:
virtual PackedStringArray get_configuration_warnings() override; virtual PackedStringArray get_configuration_warnings() override;
}; };
#endif // BT_PLAY_ANIMATION #endif // BT_PLAY_ANIMATION_H

View File

@ -64,8 +64,7 @@ BT::Status BTSetAgentProperty::_tick(double p_delta) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
Variant left_value = get_agent()->get(property, &r_valid); Variant left_value = get_agent()->get(property, &r_valid);
ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Failed to get agent's \"%s\" property. Returning FAILURE.", property)); ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Failed to get agent's \"%s\" property. Returning FAILURE.", property));
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
Variant left_value = get_agent()->get(property); Variant left_value = get_agent()->get(property);
#endif #endif
result = LimboUtility::get_singleton()->perform_operation(operation, left_value, right_value); result = LimboUtility::get_singleton()->perform_operation(operation, left_value, right_value);
@ -75,8 +74,7 @@ BT::Status BTSetAgentProperty::_tick(double p_delta) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
get_agent()->set(property, result, &r_valid); get_agent()->set(property, result, &r_valid);
ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Couldn't set property \"%s\" with value \"%s\"", property, result)); ERR_FAIL_COND_V_MSG(!r_valid, FAILURE, vformat("BTSetAgentProperty: Couldn't set property \"%s\" with value \"%s\"", property, result));
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
get_agent()->set(property, result); get_agent()->set(property, result);
#endif #endif
return SUCCESS; return SUCCESS;

View File

@ -45,4 +45,4 @@ public:
LimboUtility::Operation get_operation() const { return operation; } LimboUtility::Operation get_operation() const { return operation; }
}; };
#endif // BT_SET_AGENT_PROPERTY #endif // BT_SET_AGENT_PROPERTY_H

View File

@ -56,4 +56,4 @@ public:
virtual PackedStringArray get_configuration_warnings() override; virtual PackedStringArray get_configuration_warnings() override;
}; };
#endif // BT_STOP_ANIMATION #endif // BT_STOP_ANIMATION_H

View File

@ -95,8 +95,7 @@ BT::Status BTCallMethod::_tick(double p_delta) {
if (ce.error != Callable::CallError::CALL_OK) { if (ce.error != Callable::CallError::CALL_OK) {
ERR_FAIL_V_MSG(FAILURE, "BTCallMethod: Error calling method: " + Variant::get_call_error_text(obj, method, argptrs, argument_count, ce) + "."); ERR_FAIL_V_MSG(FAILURE, "BTCallMethod: Error calling method: " + Variant::get_call_error_text(obj, method, argptrs, argument_count, ce) + ".");
} }
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
Array call_args; Array call_args;
if (include_delta) { if (include_delta) {
call_args.push_back(Variant(p_delta)); call_args.push_back(Variant(p_delta));
@ -107,7 +106,7 @@ BT::Status BTCallMethod::_tick(double p_delta) {
// TODO: Unsure how to detect call error, so we return SUCCESS for now... // TODO: Unsure how to detect call error, so we return SUCCESS for now...
obj->callv(method, call_args); obj->callv(method, call_args);
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
return SUCCESS; return SUCCESS;
} }

View File

@ -50,4 +50,4 @@ public:
BTCallMethod(); BTCallMethod();
}; };
#endif // BT_CALL_METHOD #endif // BT_CALL_METHOD_H

View File

@ -22,7 +22,7 @@
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/button.hpp>
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
void ActionBanner::set_text(const String &p_text) { void ActionBanner::set_text(const String &p_text) {
message->set_text(p_text); message->set_text(p_text);
@ -48,11 +48,9 @@ void ActionBanner::_execute_action(const Callable &p_action, bool p_auto_close)
Callable::CallError ce; Callable::CallError ce;
Variant ret; Variant ret;
p_action.callp(nullptr, 0, ret, ce); p_action.callp(nullptr, 0, ret, ce);
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
p_action.call(); p_action.call();
#endif // LIMBOAI_GDEXTENSION #endif
if (p_auto_close) { if (p_auto_close) {
queue_free(); queue_free();
@ -96,4 +94,4 @@ ActionBanner::ActionBanner() {
hbox->add_child(spacer); hbox->add_child(spacer);
} }
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED

View File

@ -20,16 +20,15 @@
#include "scene/gui/label.h" #include "scene/gui/label.h"
#include "scene/gui/margin_container.h" #include "scene/gui/margin_container.h"
#include "scene/gui/texture_rect.h" #include "scene/gui/texture_rect.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/h_box_container.hpp> #include <godot_cpp/classes/h_box_container.hpp>
#include <godot_cpp/classes/label.hpp> #include <godot_cpp/classes/label.hpp>
#include <godot_cpp/classes/margin_container.hpp> #include <godot_cpp/classes/margin_container.hpp>
#include <godot_cpp/classes/texture_rect.hpp> #include <godot_cpp/classes/texture_rect.hpp>
using namespace godot; using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class ActionBanner : public MarginContainer { class ActionBanner : public MarginContainer {
GDCLASS(ActionBanner, MarginContainer); GDCLASS(ActionBanner, MarginContainer);
@ -57,6 +56,6 @@ public:
ActionBanner(); ActionBanner();
}; };
#endif // ! ACTION_BANNER #endif // ACTION_BANNER_H
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED

View File

@ -15,7 +15,7 @@
#include "core/templates/list.h" #include "core/templates/list.h"
#endif #endif
//// BehaviorTreeData //**** BehaviorTreeData
void BehaviorTreeData::serialize(Array &p_arr) { void BehaviorTreeData::serialize(Array &p_arr) {
p_arr.push_back(bt_player_path); p_arr.push_back(bt_player_path);

View File

@ -51,4 +51,4 @@ public:
BehaviorTreeData() {} BehaviorTreeData() {}
}; };
#endif // BEHAVIOR_TREE_DATA #endif // BEHAVIOR_TREE_DATA_H

View File

@ -30,7 +30,6 @@
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/editor_interface.hpp> #include <godot_cpp/classes/editor_interface.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
void BehaviorTreeView::_draw_running_status(Object *p_obj, Rect2 p_rect) { void BehaviorTreeView::_draw_running_status(Object *p_obj, Rect2 p_rect) {
@ -203,4 +202,4 @@ BehaviorTreeView::BehaviorTreeView() {
tree->set_anchor(SIDE_BOTTOM, ANCHOR_END); tree->set_anchor(SIDE_BOTTOM, ANCHOR_END);
} }
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED

View File

@ -28,7 +28,7 @@
#include <godot_cpp/classes/font.hpp> #include <godot_cpp/classes/font.hpp>
#include <godot_cpp/classes/style_box_flat.hpp> #include <godot_cpp/classes/style_box_flat.hpp>
#include <godot_cpp/classes/tree.hpp> #include <godot_cpp/classes/tree.hpp>
#endif #endif // LIMBOAI_GDEXTENSION
class BehaviorTreeView : public Control { class BehaviorTreeView : public Control {
GDCLASS(BehaviorTreeView, Control); GDCLASS(BehaviorTreeView, Control);

View File

@ -30,7 +30,7 @@
#include <godot_cpp/classes/window.hpp> #include <godot_cpp/classes/window.hpp>
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
//// LimboDebugger //**** LimboDebugger
LimboDebugger *LimboDebugger::singleton = nullptr; LimboDebugger *LimboDebugger::singleton = nullptr;
LimboDebugger *LimboDebugger::get_singleton() { LimboDebugger *LimboDebugger::get_singleton() {
@ -41,8 +41,7 @@ LimboDebugger::LimboDebugger() {
singleton = this; singleton = this;
#if defined(DEBUG_ENABLED) && defined(LIMBOAI_MODULE) #if defined(DEBUG_ENABLED) && defined(LIMBOAI_MODULE)
EngineDebugger::register_message_capture("limboai", EngineDebugger::Capture(nullptr, LimboDebugger::parse_message)); EngineDebugger::register_message_capture("limboai", EngineDebugger::Capture(nullptr, LimboDebugger::parse_message));
#endif #elif defined(DEBUG_ENABLED) && defined(LIMBOAI_GDEXTENSION)
#if defined(DEBUG_ENABLED) && defined(LIMBOAI_GDEXTENSION)
EngineDebugger::get_singleton()->register_message_capture("limboai", callable_mp(this, &LimboDebugger::parse_message_gdext)); EngineDebugger::get_singleton()->register_message_capture("limboai", callable_mp(this, &LimboDebugger::parse_message_gdext));
#endif #endif
} }
@ -98,7 +97,7 @@ bool LimboDebugger::parse_message_gdext(const String &p_msg, const Array &p_args
LimboDebugger::parse_message(nullptr, p_msg, p_args, r_captured); LimboDebugger::parse_message(nullptr, p_msg, p_args, r_captured);
return r_captured; return r_captured;
} }
#endif // LIMBOAI_MODULE #endif // LIMBOAI_GDEXTENSION
void LimboDebugger::register_bt_instance(Ref<BTTask> p_instance, NodePath p_player_path) { void LimboDebugger::register_bt_instance(Ref<BTTask> p_instance, NodePath p_player_path) {
ERR_FAIL_COND(p_instance.is_null()); ERR_FAIL_COND(p_instance.is_null());

View File

@ -69,4 +69,4 @@ public:
#endif // ! DEBUG_ENABLED #endif // ! DEBUG_ENABLED
}; };
#endif // ! LIMBO_DEBUGGER_H #endif // LIMBO_DEBUGGER_H

View File

@ -40,15 +40,14 @@
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h" #include "scene/gui/tab_container.h"
#include "scene/gui/texture_rect.h" #include "scene/gui/texture_rect.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/editor_interface.hpp> #include <godot_cpp/classes/editor_interface.hpp>
#include <godot_cpp/classes/file_system_dock.hpp> #include <godot_cpp/classes/file_system_dock.hpp>
#include <godot_cpp/classes/resource_loader.hpp> #include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/tab_container.hpp> #include <godot_cpp/classes/tab_container.hpp>
#endif // LIMBOAI_GDEXTENSION
#endif // ! LIMBOAI_GDEXTENSION
//**** LimboDebuggerTab //**** LimboDebuggerTab
@ -279,7 +278,7 @@ void LimboDebuggerPlugin::_window_visibility_changed(bool p_visible) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
void LimboDebuggerPlugin::setup_session(int p_idx) { void LimboDebuggerPlugin::setup_session(int p_idx) {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
void LimboDebuggerPlugin::_setup_session(int32_t p_idx) { void LimboDebuggerPlugin::_setup_session(int32_t p_idx) {
#endif #endif
Ref<EditorDebuggerSession> session = get_session(p_idx); Ref<EditorDebuggerSession> session = get_session(p_idx);
@ -309,7 +308,7 @@ void LimboDebuggerPlugin::_setup_session(int32_t p_idx) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
bool LimboDebuggerPlugin::capture(const String &p_message, const Array &p_data, int p_session) { bool LimboDebuggerPlugin::capture(const String &p_message, const Array &p_data, int p_session) {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
bool LimboDebuggerPlugin::_capture(const String &p_message, const Array &p_data, int32_t p_session) { bool LimboDebuggerPlugin::_capture(const String &p_message, const Array &p_data, int32_t p_session) {
#endif #endif
bool captured = true; bool captured = true;
@ -329,7 +328,7 @@ bool LimboDebuggerPlugin::_capture(const String &p_message, const Array &p_data,
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
bool LimboDebuggerPlugin::has_capture(const String &p_capture) const { bool LimboDebuggerPlugin::has_capture(const String &p_capture) const {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
bool LimboDebuggerPlugin::_has_capture(const String &p_capture) const { bool LimboDebuggerPlugin::_has_capture(const String &p_capture) const {
#endif #endif
return p_capture == "limboai"; return p_capture == "limboai";

View File

@ -29,10 +29,9 @@
#include "scene/gui/panel_container.h" #include "scene/gui/panel_container.h"
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
#include "scene/gui/texture_rect.h" #include "scene/gui/texture_rect.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/editor_debugger_plugin.hpp> #include <godot_cpp/classes/editor_debugger_plugin.hpp>
#include <godot_cpp/classes/editor_debugger_session.hpp> #include <godot_cpp/classes/editor_debugger_session.hpp>
@ -44,8 +43,7 @@
#include <godot_cpp/classes/panel_container.hpp> #include <godot_cpp/classes/panel_container.hpp>
#include <godot_cpp/classes/texture_rect.hpp> #include <godot_cpp/classes/texture_rect.hpp>
#include <godot_cpp/classes/v_box_container.hpp> #include <godot_cpp/classes/v_box_container.hpp>
#endif // LIMBOAI_GDEXTENSION
#endif // ! LIMBOAI_GDEXTENSION
class LimboDebuggerTab : public PanelContainer { class LimboDebuggerTab : public PanelContainer {
GDCLASS(LimboDebuggerTab, PanelContainer); GDCLASS(LimboDebuggerTab, PanelContainer);
@ -114,13 +112,11 @@ public:
void setup_session(int p_idx) override; void setup_session(int p_idx) override;
bool has_capture(const String &p_capture) const override; bool has_capture(const String &p_capture) const override;
bool capture(const String &p_message, const Array &p_data, int p_session) override; bool capture(const String &p_message, const Array &p_data, int p_session) override;
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
void _setup_session(int32_t p_idx) override; void _setup_session(int32_t p_idx) override;
bool _has_capture(const String &p_capture) const override; bool _has_capture(const String &p_capture) const override;
bool _capture(const String &p_message, const Array &p_data, int32_t p_session) override; bool _capture(const String &p_message, const Array &p_data, int32_t p_session) override;
#endif // LIMBOAI_GDEXTENSION #endif
CompatWindowWrapper *get_session_tab() const; CompatWindowWrapper *get_session_tab() const;
int get_session_tab_index() const; int get_session_tab_index() const;
@ -129,6 +125,6 @@ public:
~LimboDebuggerPlugin(); ~LimboDebuggerPlugin();
}; };
#endif // ! LIMBO_DEBUGGER_PLUGIN_H #endif // LIMBO_DEBUGGER_PLUGIN_H
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -41,7 +41,7 @@
#include "editor/project_settings_editor.h" #include "editor/project_settings_editor.h"
#include "scene/gui/panel_container.h" #include "scene/gui/panel_container.h"
#include "scene/gui/separator.h" #include "scene/gui/separator.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button_group.hpp> #include <godot_cpp/classes/button_group.hpp>
@ -66,7 +66,7 @@
#include <godot_cpp/classes/script_editor_base.hpp> #include <godot_cpp/classes/script_editor_base.hpp>
#include <godot_cpp/classes/v_separator.hpp> #include <godot_cpp/classes/v_separator.hpp>
#include <godot_cpp/core/error_macros.hpp> #include <godot_cpp/core/error_macros.hpp>
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
//**** LimboAIEditor //**** LimboAIEditor
@ -193,9 +193,9 @@ void LimboAIEditor::_save_bt(String p_path) {
ERR_FAIL_COND_MSG(task_tree->get_bt().is_null(), "Behavior Tree is null."); ERR_FAIL_COND_MSG(task_tree->get_bt().is_null(), "Behavior Tree is null.");
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
task_tree->get_bt()->set_path(p_path, true); task_tree->get_bt()->set_path(p_path, true);
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
task_tree->get_bt()->take_over_path(p_path); task_tree->get_bt()->take_over_path(p_path);
#endif // LIMBOAI_MODULE #endif
RESOURCE_SAVE(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH); RESOURCE_SAVE(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH);
_update_header(); _update_header();
_mark_as_dirty(false); _mark_as_dirty(false);
@ -259,7 +259,7 @@ void LimboAIEditor::_create_user_task_dir() {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
EditorFileSystem::get_singleton()->scan_changes(); EditorFileSystem::get_singleton()->scan_changes();
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
EditorInterface::get_singleton()->get_resource_filesystem()->scan_sources(); EditorInterface::get_singleton()->get_resource_filesystem()->scan_sources();
#endif #endif
_update_banners(); _update_banners();
@ -270,7 +270,7 @@ void LimboAIEditor::_edit_project_settings() {
ProjectSettingsEditor::get_singleton()->set_general_page("limbo_ai/behavior_tree"); ProjectSettingsEditor::get_singleton()->set_general_page("limbo_ai/behavior_tree");
ProjectSettingsEditor::get_singleton()->popup_project_settings(); ProjectSettingsEditor::get_singleton()->popup_project_settings();
ProjectSettingsEditor::get_singleton()->connect(LW_NAME(visibility_changed), callable_mp(this, &LimboAIEditor::_update_banners), CONNECT_ONE_SHOT); ProjectSettingsEditor::get_singleton()->connect(LW_NAME(visibility_changed), callable_mp(this, &LimboAIEditor::_update_banners), CONNECT_ONE_SHOT);
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
// TODO: Find a way to show project setting in GDExtension. // TODO: Find a way to show project setting in GDExtension.
// TODO: Maybe show a popup dialog instead. // TODO: Maybe show a popup dialog instead.
ERR_PRINT("Can't do in GDExtension. To edit project settings, navigate to \"Project->Project Settings\", enable \"Advanced settings\", and scroll down to the \"LimboAI\" section."); ERR_PRINT("Can't do in GDExtension. To edit project settings, navigate to \"Project->Project Settings\", enable \"Advanced settings\", and scroll down to the \"LimboAI\" section.");
@ -601,9 +601,9 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorDebuggerNode::get_singleton()); EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorDebuggerNode::get_singleton());
EditorDebuggerNode::get_singleton()->get_default_debugger()->switch_to_debugger( EditorDebuggerNode::get_singleton()->get_default_debugger()->switch_to_debugger(
LimboDebuggerPlugin::get_singleton()->get_session_tab_index()); LimboDebuggerPlugin::get_singleton()->get_session_tab_index());
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
// TODO: Unsure how to switch to debugger pane with GDExtension. // TODO: Unsure how to switch to debugger pane with GDExtension.
#endif // LIMBOAI_MODULE #endif
} }
} break; } break;
case MISC_PROJECT_SETTINGS: { case MISC_PROJECT_SETTINGS: {
@ -787,9 +787,9 @@ void LimboAIEditor::_on_resources_reload(const PackedStringArray &p_resources) {
} }
disk_changed->call_deferred("popup_centered_ratio", 0.5); disk_changed->call_deferred("popup_centered_ratio", 0.5);
} }
#else //LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
task_tree->update_tree(); task_tree->update_tree();
#endif // LIMBOAI_MODULE #endif
} }
void LimboAIEditor::_task_type_selected(const String &p_class_or_path) { void LimboAIEditor::_task_type_selected(const String &p_class_or_path) {
@ -942,7 +942,7 @@ void LimboAIEditor::_update_misc_menu() {
misc_menu->add_separator(); misc_menu->add_separator();
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
// * Not sure how to switch to debugger pane with GDExtension. // * Disabled in GDExtension: Not sure how to switch to debugger pane.
misc_menu->add_icon_shortcut(theme_cache.open_debugger_icon, LW_GET_SHORTCUT("limbo_ai/open_debugger"), MISC_OPEN_DEBUGGER); misc_menu->add_icon_shortcut(theme_cache.open_debugger_icon, LW_GET_SHORTCUT("limbo_ai/open_debugger"), MISC_OPEN_DEBUGGER);
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
misc_menu->add_item(TTR("Project Settings..."), MISC_PROJECT_SETTINGS); misc_menu->add_item(TTR("Project Settings..."), MISC_PROJECT_SETTINGS);
@ -1355,7 +1355,7 @@ LimboAIEditor::~LimboAIEditor() {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::apply_changes() { void LimboAIEditorPlugin::apply_changes() {
#else // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_apply_changes() { void LimboAIEditorPlugin::_apply_changes() {
#endif #endif
limbo_ai_editor->apply_changes(); limbo_ai_editor->apply_changes();
@ -1382,7 +1382,7 @@ void LimboAIEditorPlugin::_notification(int p_notification) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::make_visible(bool p_visible) { void LimboAIEditorPlugin::make_visible(bool p_visible) {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_make_visible(bool p_visible) { void LimboAIEditorPlugin::_make_visible(bool p_visible) {
#endif #endif
limbo_ai_editor->set_visible(p_visible); limbo_ai_editor->set_visible(p_visible);
@ -1390,7 +1390,7 @@ void LimboAIEditorPlugin::_make_visible(bool p_visible) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::edit(Object *p_object) { void LimboAIEditorPlugin::edit(Object *p_object) {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_edit(Object *p_object) { void LimboAIEditorPlugin::_edit(Object *p_object) {
#endif #endif
if (Object::cast_to<BehaviorTree>(p_object)) { if (Object::cast_to<BehaviorTree>(p_object)) {
@ -1400,7 +1400,7 @@ void LimboAIEditorPlugin::_edit(Object *p_object) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
bool LimboAIEditorPlugin::handles(Object *p_object) const { bool LimboAIEditorPlugin::handles(Object *p_object) const {
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
bool LimboAIEditorPlugin::_handles(Object *p_object) const { bool LimboAIEditorPlugin::_handles(Object *p_object) const {
#endif #endif
if (Object::cast_to<BehaviorTree>(p_object)) { if (Object::cast_to<BehaviorTree>(p_object)) {

View File

@ -41,7 +41,7 @@
#define GET_UNDO_REDO() EditorUndoRedoManager::get_singleton() #define GET_UNDO_REDO() EditorUndoRedoManager::get_singleton()
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/control.hpp> #include <godot_cpp/classes/control.hpp>
@ -62,7 +62,7 @@ using namespace godot;
#define GET_UNDO_REDO() plugin->get_undo_redo() #define GET_UNDO_REDO() plugin->get_undo_redo()
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class LimboAIEditor : public Control { class LimboAIEditor : public Control {
GDCLASS(LimboAIEditor, Control); GDCLASS(LimboAIEditor, Control);
@ -208,7 +208,7 @@ public:
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
virtual void _shortcut_input(const Ref<InputEvent> &p_event) override { _process_shortcut_input(p_event); } virtual void _shortcut_input(const Ref<InputEvent> &p_event) override { _process_shortcut_input(p_event); }
#endif // LIMBOAI_GDEXTENSION #endif
LimboAIEditor(); LimboAIEditor();
~LimboAIEditor(); ~LimboAIEditor();
@ -233,9 +233,8 @@ public:
virtual void apply_changes() override; virtual void apply_changes() override;
virtual void edit(Object *p_object) override; virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override; virtual bool handles(Object *p_object) const override;
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
bool _has_main_screen() const override { return true; } bool _has_main_screen() const override { return true; }
virtual String _get_plugin_name() const override { return "LimboAI"; } virtual String _get_plugin_name() const override { return "LimboAI"; }
@ -244,12 +243,12 @@ public:
virtual void _edit(Object *p_object) override; virtual void _edit(Object *p_object) override;
virtual bool _handles(Object *p_object) const override; virtual bool _handles(Object *p_object) const override;
virtual Ref<Texture2D> _get_plugin_icon() const override; virtual Ref<Texture2D> _get_plugin_icon() const override;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
LimboAIEditorPlugin(); LimboAIEditorPlugin();
~LimboAIEditorPlugin(); ~LimboAIEditorPlugin();
}; };
#endif // ! LIMBO_AI_EDITOR_PLUGIN_H #endif // LIMBO_AI_EDITOR_PLUGIN_H
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -20,18 +20,14 @@
#include "core/typedefs.h" #include "core/typedefs.h"
#include "scene/gui/button.h" #include "scene/gui/button.h"
#include "scene/resources/texture.h" #include "scene/resources/texture.h"
#endif // LIMBOAI_MODULE
#define SET_ICON(m_tex) set_icon(m_tex)
#endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/texture2d.hpp> #include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/templates/vector.hpp> #include <godot_cpp/templates/vector.hpp>
using namespace godot; using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class ModeSwitchButton : public Button { class ModeSwitchButton : public Button {
GDCLASS(ModeSwitchButton, Button); GDCLASS(ModeSwitchButton, Button);
@ -69,6 +65,6 @@ public:
ModeSwitchButton(); ModeSwitchButton();
}; };
#endif // ! MODE_SWITCH_BUTTON_H #endif // MODE_SWITCH_BUTTON_H
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -27,7 +27,6 @@
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h"
#include "scene/gui/check_box.h" #include "scene/gui/check_box.h"
#endif // LIMBO_MODULE #endif // LIMBO_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
@ -50,7 +49,6 @@
#include <godot_cpp/classes/script_editor_base.hpp> #include <godot_cpp/classes/script_editor_base.hpp>
#include <godot_cpp/classes/style_box.hpp> #include <godot_cpp/classes/style_box.hpp>
#include <godot_cpp/core/error_macros.hpp> #include <godot_cpp/core/error_macros.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -15,15 +15,14 @@
#define TASK_PALETTE_H #define TASK_PALETTE_H
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "scene/gui/panel_container.h"
#include "scene/gui/box_container.h" #include "scene/gui/box_container.h"
#include "scene/gui/button.h" #include "scene/gui/button.h"
#include "scene/gui/check_box.h" #include "scene/gui/check_box.h"
#include "scene/gui/flow_container.h" #include "scene/gui/flow_container.h"
#include "scene/gui/line_edit.h" #include "scene/gui/line_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/popup.h" #include "scene/gui/popup.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/button.hpp>
@ -36,9 +35,8 @@
#include <godot_cpp/classes/texture2d.hpp> #include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/classes/v_box_container.hpp> #include <godot_cpp/classes/v_box_container.hpp>
#include <godot_cpp/templates/hash_set.hpp> #include <godot_cpp/templates/hash_set.hpp>
using namespace godot; using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class TaskButton : public Button { class TaskButton : public Button {
GDCLASS(TaskButton, Button); GDCLASS(TaskButton, Button);
@ -52,10 +50,9 @@ protected:
public: public:
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
virtual Control *make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); } virtual Control *make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); }
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
virtual Object *_make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); } virtual Object *_make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); }
#endif // LIMBOAI_GDEXTENSION #endif
TaskButton(); TaskButton();
}; };
@ -192,6 +189,6 @@ public:
~TaskPalette(); ~TaskPalette();
}; };
#endif // ! TASK_PALETTE_H #endif // TASK_PALETTE_H
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -26,7 +26,6 @@
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/editor_interface.hpp> #include <godot_cpp/classes/editor_interface.hpp>
#include <godot_cpp/classes/script.hpp> #include <godot_cpp/classes/script.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -98,7 +98,6 @@ void LimboHSM::update(double p_delta) {
} }
void LimboHSM::add_transition(Node *p_from_state, Node *p_to_state, const String &p_event) { void LimboHSM::add_transition(Node *p_from_state, Node *p_to_state, const String &p_event) {
// ERR_FAIL_COND(p_from_state == nullptr);
ERR_FAIL_COND(p_from_state != nullptr && p_from_state->get_parent() != this); ERR_FAIL_COND(p_from_state != nullptr && p_from_state->get_parent() != this);
ERR_FAIL_COND(p_from_state != nullptr && !p_from_state->is_class("LimboState")); ERR_FAIL_COND(p_from_state != nullptr && !p_from_state->is_class("LimboState"));
ERR_FAIL_COND(p_to_state == nullptr); ERR_FAIL_COND(p_to_state == nullptr);
@ -164,11 +163,9 @@ bool LimboHSM::dispatch(const String &p_event, const Variant &p_cargo) {
if (unlikely(ce.error != Callable::CallError::CALL_OK)) { if (unlikely(ce.error != Callable::CallError::CALL_OK)) {
ERR_PRINT_ONCE("LimboHSM: Error calling substate's guard callable: " + Variant::get_callable_error_text(to_state->guard_callable, nullptr, 0, ce)); ERR_PRINT_ONCE("LimboHSM: Error calling substate's guard callable: " + Variant::get_callable_error_text(to_state->guard_callable, nullptr, 0, ce));
} }
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
ret = to_state->guard_callable.call(); ret = to_state->guard_callable.call();
#endif // LIMBOAI_GDEXTENSION #endif
if (unlikely(ret.get_type() != Variant::BOOL)) { if (unlikely(ret.get_type() != Variant::BOOL)) {
ERR_PRINT_ONCE(vformat("State guard callable %s returned non-boolean value (%s).", to_state->guard_callable, to_state)); ERR_PRINT_ONCE(vformat("State guard callable %s returned non-boolean value (%s).", to_state->guard_callable, to_state));

View File

@ -100,9 +100,8 @@ bool LimboState::dispatch(const String &p_event, const Variant &p_cargo) {
ERR_PRINT("Error calling event handler " + Variant::get_callable_error_text(handlers[p_event], argptrs, 1, ce)); ERR_PRINT("Error calling event handler " + Variant::get_callable_error_text(handlers[p_event], argptrs, 1, ce));
} }
} }
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
if (p_cargo.get_type() == Variant::NIL) { if (p_cargo.get_type() == Variant::NIL) {
ret = handlers[p_event].call(); ret = handlers[p_event].call();
} else { } else {
@ -189,8 +188,7 @@ void LimboState::_bind_methods() {
GDVIRTUAL_BIND(_enter); GDVIRTUAL_BIND(_enter);
GDVIRTUAL_BIND(_exit); GDVIRTUAL_BIND(_exit);
GDVIRTUAL_BIND(_update, "p_delta"); GDVIRTUAL_BIND(_update, "p_delta");
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
ClassDB::bind_method(D_METHOD("_setup"), &LimboState::_setup); ClassDB::bind_method(D_METHOD("_setup"), &LimboState::_setup);
ClassDB::bind_method(D_METHOD("_enter"), &LimboState::_enter); ClassDB::bind_method(D_METHOD("_enter"), &LimboState::_enter);
ClassDB::bind_method(D_METHOD("_exit"), &LimboState::_exit); ClassDB::bind_method(D_METHOD("_exit"), &LimboState::_exit);

View File

@ -104,25 +104,20 @@
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor/debugger/behavior_tree_view.h" #include "editor/debugger/behavior_tree_view.h"
#include "editor/limbo_ai_editor_plugin.h" #include "editor/limbo_ai_editor_plugin.h"
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
#endif // LIMBOAI_MODULE
#endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/engine.hpp> #include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/memory.hpp> #include <godot_cpp/core/memory.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION
#endif // ! LIMBOAI_GDEXTENSION
static LimboUtility *_limbo_utility = nullptr; static LimboUtility *_limbo_utility = nullptr;
@ -228,7 +223,7 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
Engine::get_singleton()->add_singleton(Engine::Singleton("LimboUtility", LimboUtility::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("LimboUtility", LimboUtility::get_singleton()));
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
Engine::get_singleton()->register_singleton("LimboUtility", LimboUtility::get_singleton()); Engine::get_singleton()->register_singleton("LimboUtility", LimboUtility::get_singleton());
#endif #endif
@ -252,7 +247,7 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(LimboDebuggerPlugin); GDREGISTER_CLASS(LimboDebuggerPlugin);
GDREGISTER_CLASS(LimboAIEditor); GDREGISTER_CLASS(LimboAIEditor);
GDREGISTER_CLASS(LimboAIEditorPlugin); GDREGISTER_CLASS(LimboAIEditorPlugin);
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
EditorPlugins::add_by_type<LimboAIEditorPlugin>(); EditorPlugins::add_by_type<LimboAIEditorPlugin>();
} }
@ -280,4 +275,4 @@ GDExtensionBool GDE_EXPORT limboai_init(GDExtensionInterfaceGetProcAddress p_get
return init_obj.init(); return init_obj.init();
} }
} }
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -13,17 +13,12 @@
#define LIMBOAI_REGISTER_TYPES_H #define LIMBOAI_REGISTER_TYPES_H
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "modules/register_module_types.h" #include "modules/register_module_types.h"
#endif // LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
void initialize_limboai_module(ModuleInitializationLevel p_level); void initialize_limboai_module(ModuleInitializationLevel p_level);

View File

@ -52,9 +52,6 @@
#include <godot_cpp/classes/window.hpp> #include <godot_cpp/classes/window.hpp>
using namespace godot; using namespace godot;
// #include "editor/editor_node.h"
// #include "editor/editor_scale.h"
// #include "editor/progress_dialog.h"
// WindowWrapper // WindowWrapper

View File

@ -40,12 +40,9 @@
#define CompatShortcutBin ShortcutBin #define CompatShortcutBin ShortcutBin
#define CompatScreenSelect ScreenSelect #define CompatScreenSelect ScreenSelect
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
// TODO: Need to compile this as module too!!!
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/h_box_container.hpp> #include <godot_cpp/classes/h_box_container.hpp>
#include <godot_cpp/classes/input_event.hpp> #include <godot_cpp/classes/input_event.hpp>
#include <godot_cpp/classes/label.hpp> #include <godot_cpp/classes/label.hpp>
@ -144,4 +141,4 @@ public:
#endif // ! LIMBOAI_GDEXTENSION #endif // ! LIMBOAI_GDEXTENSION
#endif // ! COMPAT_WINDOW_WRAPPER_H #endif // COMPAT_WINDOW_WRAPPER_H

View File

@ -17,7 +17,7 @@
#include "core/io/resource.h" #include "core/io/resource.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h"
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED
#endif // ! LIMBOAI_MODULE #endif // ! LIMBOAI_MODULE
@ -91,13 +91,13 @@ void SHOW_DOC(const String &p_topic) {
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
ScriptEditor::get_singleton()->goto_help(p_topic); ScriptEditor::get_singleton()->goto_help(p_topic);
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors(); TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors();
ERR_FAIL_COND_MSG(open_editors.size() == 0, "Can't open help page. Need at least one script open in the script editor."); ERR_FAIL_COND_MSG(open_editors.size() == 0, "Can't open help page. Need at least one script open in the script editor.");
ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(open_editors.front()); ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(open_editors.front());
ERR_FAIL_NULL(seb); ERR_FAIL_NULL(seb);
seb->emit_signal("go_to_help", p_topic); seb->emit_signal("go_to_help", p_topic);
#endif // ! LIMBOAI_GDEXTENSION #endif
} }
void EDIT_SCRIPT(const String &p_path) { void EDIT_SCRIPT(const String &p_path) {
@ -105,14 +105,12 @@ void EDIT_SCRIPT(const String &p_path) {
Ref<Resource> res = ScriptEditor::get_singleton()->open_file(p_path); Ref<Resource> res = ScriptEditor::get_singleton()->open_file(p_path);
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path); ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
EditorNode::get_singleton()->edit_resource(res); EditorNode::get_singleton()->edit_resource(res);
#endif // LIMBOAI_MODULE #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
Ref<Script> res = RESOURCE_LOAD(p_path, "Script"); Ref<Script> res = RESOURCE_LOAD(p_path, "Script");
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path); ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
EditorInterface::get_singleton()->edit_script(res); EditorInterface::get_singleton()->edit_script(res);
EditorInterface::get_singleton()->set_main_screen_editor("Script"); EditorInterface::get_singleton()->set_main_screen_editor("Script");
#endif // LIMBOAI_GDEXTENSION #endif
} }
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -22,7 +22,7 @@
#include "core/object/ref_counted.h" #include "core/object/ref_counted.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
// * API abstractions: Module edition // *** API abstractions: Module edition
#define SCRIPT_EDITOR() (ScriptEditor::get_singleton()) #define SCRIPT_EDITOR() (ScriptEditor::get_singleton())
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton()) #define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
@ -37,8 +37,6 @@
#define IS_CLASS(m_obj, m_class) (m_obj->is_class_ptr(m_class::get_class_ptr_static())) #define IS_CLASS(m_obj, m_class) (m_obj->is_class_ptr(m_class::get_class_ptr_static()))
#define RAND_RANGE(m_from, m_to) (Math::random(m_from, m_to)) #define RAND_RANGE(m_from, m_to) (Math::random(m_from, m_to))
#define RANDF() (Math::randf()) #define RANDF() (Math::randf())
#define VCALL(m_name, ...) (GDVIRTUAL_CALL(m_name, __VA_ARGS__))
#define VCALL_ARGS(method, ...) (call(LW_NAME(method), __VA_ARGS__))
#define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_icon(m_icon) #define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_icon(m_icon)
#define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::load(m_path, m_hint) #define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::load(m_path, m_hint)
#define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::load(m_path, m_hint, ResourceFormatLoader::CACHE_MODE_IGNORE) #define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::load(m_path, m_hint, ResourceFormatLoader::CACHE_MODE_IGNORE)
@ -57,6 +55,16 @@
#define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) r_ret = Variant::evaluate(m_op, m_lvalue, m_rvalue) #define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) r_ret = Variant::evaluate(m_op, m_lvalue, m_rvalue)
// * Virtual calls
#define VCALL(m_name, ...) (GDVIRTUAL_CALL(m_name, __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_OR_NATIVE(m_name, ...) \
if (!GDVIRTUAL_CALL(m_name, __VA_ARGS__)) { \
m_name(__VA_ARGS__); \
}
// * Enum // * Enum
#define LW_KEY(key) (Key::key) #define LW_KEY(key) (Key::key)
@ -73,7 +81,7 @@
using namespace godot; using namespace godot;
// * API abstractions: GDExtension edition // *** API abstractions: GDExtension edition
#define SCRIPT_EDITOR() (EditorInterface::get_singleton()->get_script_editor()) #define SCRIPT_EDITOR() (EditorInterface::get_singleton()->get_script_editor())
#define EDITOR_FILE_SYSTEM() (EditorInterface::get_singleton()->get_resource_filesystem()) #define EDITOR_FILE_SYSTEM() (EditorInterface::get_singleton()->get_resource_filesystem())
@ -90,8 +98,6 @@ using namespace godot;
#define IS_CLASS(m_obj, m_class) (m_obj->is_class(#m_class)) #define IS_CLASS(m_obj, m_class) (m_obj->is_class(#m_class))
#define RAND_RANGE(m_from, m_to) (UtilityFunctions::randf_range(m_from, m_to)) #define RAND_RANGE(m_from, m_to) (UtilityFunctions::randf_range(m_from, m_to))
#define RANDF() (UtilityFunctions::randf()) #define RANDF() (UtilityFunctions::randf())
#define VCALL(m_name) (call(LW_NAME(m_name)))
#define VCALL_ARGS(m_name, ...) (call(LW_NAME(m_name), __VA_ARGS__))
#define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_button_icon(m_icon) #define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_button_icon(m_icon)
#define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::get_singleton()->load(m_path, m_hint) #define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::get_singleton()->load(m_path, m_hint)
#define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::get_singleton()->load(m_path, m_hint, ResourceLoader::CACHE_MODE_IGNORE) #define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::get_singleton()->load(m_path, m_hint, ResourceLoader::CACHE_MODE_IGNORE)
@ -114,7 +120,12 @@ using namespace godot;
Variant::evaluate(m_op, m_lvalue, m_rvalue, r_ret, r_valid); \ Variant::evaluate(m_op, m_lvalue, m_rvalue, r_ret, r_valid); \
} }
// * Enums #define VCALL(m_name) (call(LW_NAME(m_name)))
#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_OR_NATIVE(m_name) (call(LW_NAME(m_name)))
// * Enum
#define LW_KEY(key) (Key::KEY_##key) #define LW_KEY(key) (Key::KEY_##key)
#define LW_KEY_MASK(mask) (KeyModifierMask::KEY_MASK_##mask) #define LW_KEY_MASK(mask) (KeyModifierMask::KEY_MASK_##mask)
@ -137,7 +148,7 @@ String TTR(const String &p_text, const String &p_context = "");
#endif // ! LIMBOAI_GDEXTENSION #endif // ! LIMBOAI_GDEXTENSION
// * Shared defines // *** API abstractions: Shared
#define VARIANT_IS_ARRAY(m_variant) (m_variant.get_type() >= Variant::ARRAY) #define VARIANT_IS_ARRAY(m_variant) (m_variant.get_type() >= Variant::ARRAY)
#define VARIANT_IS_NUM(m_variant) (m_variant.get_type() == Variant::INT || m_variant.get_type() == Variant::FLOAT) #define VARIANT_IS_NUM(m_variant) (m_variant.get_type() == Variant::INT || m_variant.get_type() == Variant::FLOAT)
@ -159,6 +170,6 @@ inline void VARIANT_DELETE_IF_OBJECT(Variant m_variant) {
void SHOW_DOC(const String &p_topic); void SHOW_DOC(const String &p_topic);
void EDIT_SCRIPT(const String &p_path); void EDIT_SCRIPT(const String &p_path);
#endif // ! TOOLS_ENABLED #endif // TOOLS_ENABLED
#endif // LIMBO_COMPAT_H #endif // LIMBO_COMPAT_H

View File

@ -34,7 +34,7 @@ LimboStringNames::LimboStringNames() {
_enter = SN("_enter"); _enter = SN("_enter");
_exit = SN("_exit"); _exit = SN("_exit");
_generate_name = SN("_generate_name"); _generate_name = SN("_generate_name");
_get_configuration_warning = SN("_get_configuration_warning"); _get_configuration_warnings = SN("_get_configuration_warnings");
_replace_task = SN("_replace_task"); _replace_task = SN("_replace_task");
_setup = SN("_setup"); _setup = SN("_setup");
_tick = SN("_tick"); _tick = SN("_tick");

View File

@ -16,14 +16,13 @@
#include "core/string/string_name.h" #include "core/string/string_name.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "modules/register_module_types.h" #include "modules/register_module_types.h"
#endif // ! LIMBOAI_MODULE #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include "godot_cpp/variant/string.hpp" #include "godot_cpp/variant/string.hpp"
#include <godot_cpp/variant/string_name.hpp> #include <godot_cpp/variant/string_name.hpp>
using namespace godot; using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
class LimboStringNames { class LimboStringNames {
friend void initialize_limboai_module(ModuleInitializationLevel p_level); friend void initialize_limboai_module(ModuleInitializationLevel p_level);
@ -49,7 +48,7 @@ public:
StringName _enter; StringName _enter;
StringName _exit; StringName _exit;
StringName _generate_name; StringName _generate_name;
StringName _get_configuration_warning; StringName _get_configuration_warnings;
StringName _replace_task; StringName _replace_task;
StringName _setup; StringName _setup;
StringName _tick; StringName _tick;

View File

@ -21,7 +21,6 @@
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/dir_access.hpp> #include <godot_cpp/classes/dir_access.hpp>
#include <godot_cpp/classes/project_settings.hpp> #include <godot_cpp/classes/project_settings.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION

View File

@ -16,7 +16,7 @@
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/templates/hash_map.h" #include "core/templates/hash_map.h"
#include "core/templates/list.h" #include "core/templates/list.h"
#endif #endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
@ -24,7 +24,7 @@
#include <godot_cpp/templates/list.hpp> #include <godot_cpp/templates/list.hpp>
#include <godot_cpp/variant/string.hpp> #include <godot_cpp/variant/string.hpp>
using namespace godot; using namespace godot;
#endif #endif // LIMBOAI_GDEXTENSION
class LimboTaskDB { class LimboTaskDB {
private: private:
@ -69,9 +69,7 @@ public:
if (m_class::_class_is_enabled) { \ if (m_class::_class_is_enabled) { \
::LimboTaskDB::register_task<m_class>(); \ ::LimboTaskDB::register_task<m_class>(); \
} }
#endif #elif LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_GDEXTENSION
#define LIMBO_REGISTER_TASK(m_class) LimboTaskDB::register_task<m_class>(); #define LIMBO_REGISTER_TASK(m_class) LimboTaskDB::register_task<m_class>();
#endif #endif

View File

@ -11,10 +11,9 @@
#include "limbo_utility.h" #include "limbo_utility.h"
#include "../bt/tasks/bt_task.h"
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "modules/limboai/bt/tasks/bt_task.h"
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/object/script_language.h" #include "core/object/script_language.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
@ -24,11 +23,9 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
#endif // LIMBOAI_MODULE #endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include "bt/tasks/bt_task.h"
#include "godot_cpp/classes/input_event_key.hpp" #include "godot_cpp/classes/input_event_key.hpp"
#include "godot_cpp/classes/project_settings.hpp" #include "godot_cpp/classes/project_settings.hpp"
#include "godot_cpp/variant/dictionary.hpp" #include "godot_cpp/variant/dictionary.hpp"
@ -38,8 +35,7 @@
#include <godot_cpp/classes/texture2d.hpp> #include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/classes/theme.hpp> #include <godot_cpp/classes/theme.hpp>
#include <godot_cpp/core/error_macros.hpp> #include <godot_cpp/core/error_macros.hpp>
#endif // ! LIMBOAI_GDEXTENSION
#endif // LIMBOAI_GDEXTENSION
LimboUtility *LimboUtility::singleton = nullptr; LimboUtility *LimboUtility::singleton = nullptr;
@ -265,10 +261,10 @@ Variant LimboUtility::perform_operation(Operation p_operation, const Variant &le
// TODO: Fix when godot-cpp https://github.com/godotengine/godot-cpp/issues/1348 is resolved. // TODO: Fix when godot-cpp https://github.com/godotengine/godot-cpp/issues/1348 is resolved.
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
VARIANT_EVALUATE(Variant::OP_POWER, left_value, right_value, ret); VARIANT_EVALUATE(Variant::OP_POWER, left_value, right_value, ret);
#else // LIMBOAI_GDEXTENSION #elif LIMBOAI_GDEXTENSION
ERR_PRINT("LimboUtility: Operation POWER is not available due to https://github.com/godotengine/godot-cpp/issues/1348"); ERR_PRINT("LimboUtility: Operation POWER is not available due to https://github.com/godotengine/godot-cpp/issues/1348");
ret = left_value; ret = left_value;
#endif // LIMBOAI_MODULE #endif
} break; } break;
case OPERATION_BIT_SHIFT_LEFT: { case OPERATION_BIT_SHIFT_LEFT: {
VARIANT_EVALUATE(Variant::OP_SHIFT_LEFT, left_value, right_value, ret); VARIANT_EVALUATE(Variant::OP_SHIFT_LEFT, left_value, right_value, ret);

View File

@ -26,13 +26,11 @@
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/object.hpp> #include <godot_cpp/classes/object.hpp>
#include <godot_cpp/classes/shortcut.hpp> #include <godot_cpp/classes/shortcut.hpp>
#include <godot_cpp/classes/texture2d.hpp> #include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/core/binder_common.hpp> #include <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/templates/hash_map.hpp> #include <godot_cpp/templates/hash_map.hpp>
using namespace godot; using namespace godot;
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION