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 "scene/main/node.h"
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/node.hpp>
#endif // LIMBOAI_GDEXTENSION

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@
#include "../util/limbo_string_names.h"
#ifdef LIMBOAI_MODULE
#include "core/config/engine.h"
#include "core/debugger/engine_debugger.h"
#include "core/error/error_macros.h"
@ -30,10 +29,9 @@
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
#define GET_TICKS_USEC() (OS::get_singleton()->get_ticks_usec())
#endif // LIMBO_MODULE
#endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/engine_debugger.hpp>
#include <godot_cpp/classes/performance.hpp>
#include <godot_cpp/classes/time.hpp>
@ -41,7 +39,7 @@
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::get_singleton()->is_active())
#define GET_TICKS_USEC() (Time::get_singleton()->get_ticks_usec())
#endif // LIMBOAI_GDEXTENSION
#endif // ! LIMBOAI_GDEXTENSION
VARIANT_ENUM_CAST(BTPlayer::UpdateMode);
@ -148,7 +146,7 @@ double BTPlayer::_get_mean_update_time_msec() {
return 0.0;
}
#endif // DEBUG_ENABLED
#endif // ! DEBUG_ENABLED
void BTPlayer::_notification(int 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());
}
} 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("_get_monitor_performance"), &BTPlayer::_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
}

View File

@ -12,6 +12,10 @@
#ifndef BT_PLAYER_H
#define BT_PLAYER_H
#include "../blackboard/blackboard.h"
#include "behavior_tree.h"
#include "tasks/bt_task.h"
#ifdef LIMBOAI_MODULE
#include "scene/main/node.h"
#endif
@ -20,17 +24,13 @@
#include <godot_cpp/classes/node.hpp>
#endif
#include "../blackboard/blackboard.h"
#include "behavior_tree.h"
#include "tasks/bt_task.h"
class BTPlayer : public Node {
GDCLASS(BTPlayer, Node);
public:
enum UpdateMode : unsigned int {
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)
};
@ -77,8 +77,8 @@ public:
BTPlayer();
~BTPlayer();
#ifdef DEBUG_ENABLED
// Performace monitoring.
#ifdef DEBUG_ENABLED // Performance monitoring
private:
bool monitor_performance = false;
StringName monitor_id;

View File

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

View File

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

View File

@ -11,12 +11,12 @@
#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 "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/io/resource.h"
#include "core/object/class_db.h"
@ -29,10 +29,6 @@
#endif // LIMBOAI_MODULE
#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/core/class_db.hpp"
#include "godot_cpp/variant/dictionary.hpp"
@ -41,6 +37,7 @@
#include "godot_cpp/variant/utility_functions.hpp"
#include "godot_cpp/variant/variant.hpp"
#include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/classes/script.hpp>
#endif // LIMBOAI_GDEXTENSION
void BT::_bind_methods() {
@ -102,7 +99,7 @@ String BTTask::get_task_name() {
}
}
return _generate_name();
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
return call(LimboStringNames::get_singleton()->_generate_name);
#endif
}
@ -133,15 +130,7 @@ void BTTask::initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) {
get_child(i)->initialize(p_agent, p_blackboard);
}
#ifdef LIMBOAI_MODULE
if (!GDVIRTUAL_CALL(_setup)) {
_setup();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_setup);
#endif
VCALL_OR_NATIVE(_setup);
}
Ref<BTTask> BTTask::clone() const {
@ -191,9 +180,7 @@ Ref<BTTask> BTTask::clone() const {
}
}
}
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
// Make BBParam properties unique.
TypedArray<Dictionary> props = inst->get_property_list();
HashMap<Ref<Resource>, Ref<Resource>> duplicates;
@ -220,8 +207,7 @@ Ref<BTTask> BTTask::clone() const {
}
}
}
#endif // LIMBOAI_GDEXTENSION
#endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
return inst;
}
@ -235,15 +221,7 @@ BT::Status BTTask::execute(double p_delta) {
}
}
#ifdef LIMBOAI_MODULE
if (!GDVIRTUAL_CALL(_enter)) {
_enter();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_enter);
#endif
VCALL_OR_NATIVE(_enter);
} else {
data.elapsed += p_delta;
}
@ -252,20 +230,12 @@ BT::Status BTTask::execute(double p_delta) {
if (!GDVIRTUAL_CALL(_tick, p_delta, data.status)) {
data.status = _tick(p_delta);
}
#endif
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
data.status = (Status)(int)call(LimboStringNames::get_singleton()->_tick, p_delta);
#endif
if (data.status != RUNNING) {
#ifdef LIMBOAI_MODULE
if (!GDVIRTUAL_CALL(_exit)) {
_exit();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_exit);
#endif
VCALL_OR_NATIVE(_exit);
data.elapsed = 0.0;
}
return data.status;
@ -276,14 +246,7 @@ void BTTask::abort() {
get_child(i)->abort();
}
if (data.status == RUNNING) {
#ifdef LIMBOAI_MODULE
if (!GDVIRTUAL_CALL(_exit)) {
_exit();
}
#endif
#ifdef LIMBOAI_GDEXTENSION
call(LimboStringNames::get_singleton()->_exit);
#endif
VCALL_OR_NATIVE(_exit);
}
data.status = FRESH;
data.elapsed = 0.0;
@ -364,19 +327,16 @@ Ref<BTTask> BTTask::next_sibling() const {
return Ref<BTTask>();
}
PackedStringArray BTTask::_get_configuration_warnings() {
return PackedStringArray();
}
PackedStringArray BTTask::get_configuration_warnings() {
PackedStringArray ret;
PackedStringArray warnings;
#ifdef LIMBOAI_MODULE
if (GDVIRTUAL_CALL(_get_configuration_warning, warnings)) {
ret.append_array(warnings);
}
#endif
#ifdef LIMBOAI_GDEXTENSION
warnings = call(LimboStringNames::get_singleton()->_get_configuration_warning);
VCALL_V(_get_configuration_warnings, warnings); // Get script warnings.
ret.append_array(warnings);
#endif
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::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, "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::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");
@ -442,22 +401,15 @@ void BTTask::_bind_methods() {
GDVIRTUAL_BIND(_exit);
GDVIRTUAL_BIND(_tick, "p_delta");
GDVIRTUAL_BIND(_generate_name);
GDVIRTUAL_BIND(_get_configuration_warning);
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
GDVIRTUAL_BIND(_get_configuration_warnings);
#elif LIMBOAI_GDEXTENSION
// 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("_enter"), &BTTask::_enter);
ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit);
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("_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);
ClassDB::bind_method(D_METHOD("_get_configuration_warnings"), &BTTask::_get_configuration_warnings);
#endif
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -56,4 +56,4 @@ public:
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;
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));
#endif
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
Variant left_value = get_agent()->get(property);
#endif

View File

@ -45,4 +45,4 @@ public:
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;
};
#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
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));
#endif
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
Variant left_value = get_agent()->get(property);
#endif
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
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));
#endif
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
get_agent()->set(property, result);
#endif
return SUCCESS;

View File

@ -45,4 +45,4 @@ public:
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;
};
#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) {
ERR_FAIL_V_MSG(FAILURE, "BTCallMethod: Error calling method: " + Variant::get_call_error_text(obj, method, argptrs, argument_count, ce) + ".");
}
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
Array call_args;
if (include_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...
obj->callv(method, call_args);
#endif // LIMBOAI_GDEXTENSION
#endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
return SUCCESS;
}

View File

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

View File

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

View File

@ -20,16 +20,15 @@
#include "scene/gui/label.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/texture_rect.h"
#endif // ! LIMBOAI_MODULE
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/h_box_container.hpp>
#include <godot_cpp/classes/label.hpp>
#include <godot_cpp/classes/margin_container.hpp>
#include <godot_cpp/classes/texture_rect.hpp>
using namespace godot;
#endif // ! LIMBOAI_GDEXTENSION
#endif // LIMBOAI_GDEXTENSION
class ActionBanner : public MarginContainer {
GDCLASS(ActionBanner, MarginContainer);
@ -57,6 +56,6 @@ public:
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"
#endif
//// BehaviorTreeData
//**** BehaviorTreeData
void BehaviorTreeData::serialize(Array &p_arr) {
p_arr.push_back(bt_player_path);

View File

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

View File

@ -30,7 +30,6 @@
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/editor_interface.hpp>
#endif // LIMBOAI_GDEXTENSION
void BehaviorTreeView::_draw_running_status(Object *p_obj, Rect2 p_rect) {
@ -203,4 +202,4 @@ BehaviorTreeView::BehaviorTreeView() {
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/style_box_flat.hpp>
#include <godot_cpp/classes/tree.hpp>
#endif
#endif // LIMBOAI_GDEXTENSION
class BehaviorTreeView : public Control {
GDCLASS(BehaviorTreeView, Control);

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@
#include "editor/project_settings_editor.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/separator.h"
#endif // ! LIMBOAI_MODULE
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button_group.hpp>
@ -66,7 +66,7 @@
#include <godot_cpp/classes/script_editor_base.hpp>
#include <godot_cpp/classes/v_separator.hpp>
#include <godot_cpp/core/error_macros.hpp>
#endif // ! LIMBOAI_GDEXTENSION
#endif // LIMBOAI_GDEXTENSION
//**** 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.");
#ifdef LIMBOAI_MODULE
task_tree->get_bt()->set_path(p_path, true);
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
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);
_update_header();
_mark_as_dirty(false);
@ -259,7 +259,7 @@ void LimboAIEditor::_create_user_task_dir() {
#ifdef LIMBOAI_MODULE
EditorFileSystem::get_singleton()->scan_changes();
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
EditorInterface::get_singleton()->get_resource_filesystem()->scan_sources();
#endif
_update_banners();
@ -270,7 +270,7 @@ void LimboAIEditor::_edit_project_settings() {
ProjectSettingsEditor::get_singleton()->set_general_page("limbo_ai/behavior_tree");
ProjectSettingsEditor::get_singleton()->popup_project_settings();
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: 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.");
@ -601,9 +601,9 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorDebuggerNode::get_singleton());
EditorDebuggerNode::get_singleton()->get_default_debugger()->switch_to_debugger(
LimboDebuggerPlugin::get_singleton()->get_session_tab_index());
#else // LIMBOAI_GDEXTENSION
// TODO: Unsure how to switch to debugger pane with GDExtension.
#endif // LIMBOAI_MODULE
#elif LIMBOAI_GDEXTENSION
// TODO: Unsure how to switch to debugger pane with GDExtension.
#endif
}
} break;
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);
}
#else //LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
task_tree->update_tree();
#endif // LIMBOAI_MODULE
#endif
}
void LimboAIEditor::_task_type_selected(const String &p_class_or_path) {
@ -942,7 +942,7 @@ void LimboAIEditor::_update_misc_menu() {
misc_menu->add_separator();
#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);
#endif // LIMBOAI_MODULE
misc_menu->add_item(TTR("Project Settings..."), MISC_PROJECT_SETTINGS);
@ -1355,7 +1355,7 @@ LimboAIEditor::~LimboAIEditor() {
#ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::apply_changes() {
#else // LIMBOAI_MODULE
#elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_apply_changes() {
#endif
limbo_ai_editor->apply_changes();
@ -1382,7 +1382,7 @@ void LimboAIEditorPlugin::_notification(int p_notification) {
#ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::make_visible(bool p_visible) {
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_make_visible(bool p_visible) {
#endif
limbo_ai_editor->set_visible(p_visible);
@ -1390,7 +1390,7 @@ void LimboAIEditorPlugin::_make_visible(bool p_visible) {
#ifdef LIMBOAI_MODULE
void LimboAIEditorPlugin::edit(Object *p_object) {
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
void LimboAIEditorPlugin::_edit(Object *p_object) {
#endif
if (Object::cast_to<BehaviorTree>(p_object)) {
@ -1400,7 +1400,7 @@ void LimboAIEditorPlugin::_edit(Object *p_object) {
#ifdef LIMBOAI_MODULE
bool LimboAIEditorPlugin::handles(Object *p_object) const {
#else // LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
bool LimboAIEditorPlugin::_handles(Object *p_object) const {
#endif
if (Object::cast_to<BehaviorTree>(p_object)) {

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,6 @@
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/editor_interface.hpp>
#include <godot_cpp/classes/script.hpp>
using namespace godot;
#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) {
// 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->is_class("LimboState"));
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)) {
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
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
ret = to_state->guard_callable.call();
#endif // LIMBOAI_GDEXTENSION
#endif
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));

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));
}
}
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
if (p_cargo.get_type() == Variant::NIL) {
ret = handlers[p_event].call();
} else {
@ -189,8 +188,7 @@ void LimboState::_bind_methods() {
GDVIRTUAL_BIND(_enter);
GDVIRTUAL_BIND(_exit);
GDVIRTUAL_BIND(_update, "p_delta");
#endif
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
ClassDB::bind_method(D_METHOD("_setup"), &LimboState::_setup);
ClassDB::bind_method(D_METHOD("_enter"), &LimboState::_enter);
ClassDB::bind_method(D_METHOD("_exit"), &LimboState::_exit);

View File

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

View File

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

View File

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

View File

@ -40,12 +40,9 @@
#define CompatShortcutBin ShortcutBin
#define CompatScreenSelect ScreenSelect
#endif // ! LIMBOAI_MODULE
// TODO: Need to compile this as module too!!!
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/h_box_container.hpp>
#include <godot_cpp/classes/input_event.hpp>
#include <godot_cpp/classes/label.hpp>
@ -144,4 +141,4 @@ public:
#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 "editor/editor_node.h"
#include "editor/plugins/script_editor_plugin.h"
#endif // ! TOOLS_ENABLED
#endif // TOOLS_ENABLED
#endif // ! LIMBOAI_MODULE
@ -91,13 +91,13 @@ void SHOW_DOC(const String &p_topic) {
#ifdef LIMBOAI_MODULE
ScriptEditor::get_singleton()->goto_help(p_topic);
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();
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());
ERR_FAIL_NULL(seb);
seb->emit_signal("go_to_help", p_topic);
#endif // ! LIMBOAI_GDEXTENSION
#endif
}
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);
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
EditorNode::get_singleton()->edit_resource(res);
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#elif LIMBOAI_GDEXTENSION
Ref<Script> res = RESOURCE_LOAD(p_path, "Script");
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
EditorInterface::get_singleton()->edit_script(res);
EditorInterface::get_singleton()->set_main_screen_editor("Script");
#endif // LIMBOAI_GDEXTENSION
#endif
}
#endif // ! TOOLS_ENABLED

View File

@ -22,7 +22,7 @@
#include "core/object/ref_counted.h"
#include "core/string/print_string.h"
// * API abstractions: Module edition
// *** API abstractions: Module edition
#define SCRIPT_EDITOR() (ScriptEditor::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 RAND_RANGE(m_from, m_to) (Math::random(m_from, m_to))
#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 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)
@ -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)
// * 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
#define LW_KEY(key) (Key::key)
@ -73,7 +81,7 @@
using namespace godot;
// * API abstractions: GDExtension edition
// *** API abstractions: GDExtension edition
#define SCRIPT_EDITOR() (EditorInterface::get_singleton()->get_script_editor())
#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 RAND_RANGE(m_from, m_to) (UtilityFunctions::randf_range(m_from, m_to))
#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 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)
@ -114,7 +120,12 @@ using namespace godot;
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_MASK(mask) (KeyModifierMask::KEY_MASK_##mask)
@ -137,7 +148,7 @@ String TTR(const String &p_text, const String &p_context = "");
#endif // ! LIMBOAI_GDEXTENSION
// * Shared defines
// *** API abstractions: Shared
#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)
@ -159,6 +170,6 @@ inline void VARIANT_DELETE_IF_OBJECT(Variant m_variant) {
void SHOW_DOC(const String &p_topic);
void EDIT_SCRIPT(const String &p_path);
#endif // ! TOOLS_ENABLED
#endif // TOOLS_ENABLED
#endif // LIMBO_COMPAT_H

View File

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

View File

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

View File

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

View File

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

View File

@ -11,10 +11,9 @@
#include "limbo_utility.h"
#include "../bt/tasks/bt_task.h"
#ifdef LIMBOAI_MODULE
#include "modules/limboai/bt/tasks/bt_task.h"
#include "core/error/error_macros.h"
#include "core/object/script_language.h"
#include "core/variant/variant.h"
@ -24,11 +23,9 @@
#include "editor/editor_node.h"
#endif // TOOLS_ENABLED
#endif // LIMBOAI_MODULE
#endif // ! LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include "bt/tasks/bt_task.h"
#include "godot_cpp/classes/input_event_key.hpp"
#include "godot_cpp/classes/project_settings.hpp"
#include "godot_cpp/variant/dictionary.hpp"
@ -38,8 +35,7 @@
#include <godot_cpp/classes/texture2d.hpp>
#include <godot_cpp/classes/theme.hpp>
#include <godot_cpp/core/error_macros.hpp>
#endif // LIMBOAI_GDEXTENSION
#endif // ! LIMBOAI_GDEXTENSION
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.
#ifdef LIMBOAI_MODULE
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");
ret = left_value;
#endif // LIMBOAI_MODULE
#endif
} break;
case OPERATION_BIT_SHIFT_LEFT: {
VARIANT_EVALUATE(Variant::OP_SHIFT_LEFT, left_value, right_value, ret);

View File

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