Add mostly minimal changes in order to compile and run with godot 4

This commit is contained in:
Serhii Snitsaruk 2022-12-15 08:26:52 +01:00
parent 71201a7389
commit dbc9a7ad31
135 changed files with 702 additions and 633 deletions

24
SCsub
View File

@ -1,12 +1,16 @@
# SCsub #!/usr/bin/env python
Import('env') Import("env")
Import("env_modules")
env.add_source_files(env.modules_sources, "*.cpp") module_env = env.Clone()
env.add_source_files(env.modules_sources, "bt/*.cpp")
env.add_source_files(env.modules_sources, "bt/composites/*.cpp") module_env.add_source_files(env.modules_sources, "*.cpp")
env.add_source_files(env.modules_sources, "bt/actions/*.cpp") module_env.add_source_files(env.modules_sources, "bt/*.cpp")
env.add_source_files(env.modules_sources, "bt/decorators/*.cpp") module_env.add_source_files(env.modules_sources, "bt/composites/*.cpp")
env.add_source_files(env.modules_sources, "bt/conditions/*.cpp") module_env.add_source_files(env.modules_sources, "bt/actions/*.cpp")
env.add_source_files(env.modules_sources, "editor/*.cpp") module_env.add_source_files(env.modules_sources, "bt/decorators/*.cpp")
env.add_source_files(env.modules_sources, "bb_param/*.cpp") module_env.add_source_files(env.modules_sources, "bt/conditions/*.cpp")
module_env.add_source_files(env.modules_sources, "bb_param/*.cpp")
if env.editor_build:
module_env.add_source_files(env.modules_sources, "editor/*.cpp")

View File

@ -4,13 +4,13 @@
#define BB_AABB_H #define BB_AABB_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBAabb : public BBParam { class BBAabb : public BBParam {
GDCLASS(BBAabb, BBParam); GDCLASS(BBAabb, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::AABB; } virtual Variant::Type get_type() const override { return Variant::AABB; }
}; };
#endif // BB_AABB_H #endif // BB_AABB_H

View File

@ -4,13 +4,13 @@
#define BB_ARRAY_H #define BB_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBArray : public BBParam { class BBArray : public BBParam {
GDCLASS(BBArray, BBParam); GDCLASS(BBArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::ARRAY; } virtual Variant::Type get_type() const override { return Variant::ARRAY; }
}; };
#endif // BB_ARRAY_H #endif // BB_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_BASIS_H #define BB_BASIS_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBBasis : public BBParam { class BBBasis : public BBParam {
GDCLASS(BBBasis, BBParam); GDCLASS(BBBasis, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::BASIS; } virtual Variant::Type get_type() const override { return Variant::BASIS; }
}; };
#endif // BB_BASIS_H #endif // BB_BASIS_H

View File

@ -4,13 +4,13 @@
#define BB_BOOL_H #define BB_BOOL_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBBool : public BBParam { class BBBool : public BBParam {
GDCLASS(BBBool, BBParam); GDCLASS(BBBool, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::BOOL; } virtual Variant::Type get_type() const override { return Variant::BOOL; }
}; };
#endif // BB_BOOL_H #endif // BB_BOOL_H

View File

@ -4,13 +4,13 @@
#define BB_BYTE_ARRAY_H #define BB_BYTE_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBByteArray : public BBParam { class BBByteArray : public BBParam {
GDCLASS(BBByteArray, BBParam); GDCLASS(BBByteArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_BYTE_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_BYTE_ARRAY; }
}; };
#endif // BB_BYTE_ARRAY_H #endif // BB_BYTE_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_COLOR_H #define BB_COLOR_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBColor : public BBParam { class BBColor : public BBParam {
GDCLASS(BBColor, BBParam); GDCLASS(BBColor, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::COLOR; } virtual Variant::Type get_type() const override { return Variant::COLOR; }
}; };
#endif // BB_COLOR_H #endif // BB_COLOR_H

View File

@ -4,13 +4,13 @@
#define BB_COLOR_ARRAY_H #define BB_COLOR_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBColorArray : public BBParam { class BBColorArray : public BBParam {
GDCLASS(BBColorArray, BBParam); GDCLASS(BBColorArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_COLOR_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_COLOR_ARRAY; }
}; };
#endif // BB_COLOR_ARRAY_H #endif // BB_COLOR_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_DICTIONARY_H #define BB_DICTIONARY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBDictionary : public BBParam { class BBDictionary : public BBParam {
GDCLASS(BBDictionary, BBParam); GDCLASS(BBDictionary, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::DICTIONARY; } virtual Variant::Type get_type() const override { return Variant::DICTIONARY; }
}; };
#endif // BB_DICTIONARY_H #endif // BB_DICTIONARY_H

View File

@ -4,13 +4,13 @@
#define BB_FLOAT_H #define BB_FLOAT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBFloat : public BBParam { class BBFloat : public BBParam {
GDCLASS(BBFloat, BBParam); GDCLASS(BBFloat, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::REAL; } virtual Variant::Type get_type() const override { return Variant::FLOAT; }
}; };
#endif // BB_FLOAT_H #endif // BB_FLOAT_H

View File

@ -4,13 +4,13 @@
#define BB_INT_H #define BB_INT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBInt : public BBParam { class BBInt : public BBParam {
GDCLASS(BBInt, BBParam); GDCLASS(BBInt, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::INT; } virtual Variant::Type get_type() const override { return Variant::INT; }
}; };
#endif // BB_INT_H #endif // BB_INT_H

View File

@ -4,13 +4,13 @@
#define BB_INT_ARRAY_H #define BB_INT_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBIntArray : public BBParam { class BBIntArray : public BBParam {
GDCLASS(BBIntArray, BBParam); GDCLASS(BBIntArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_INT_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_INT64_ARRAY; }
}; };
#endif // BB_INT_ARRAY_H #endif // BB_INT_ARRAY_H

View File

@ -1,8 +1,8 @@
/* bb_node.cpp */ /* bb_node.cpp */
#include "bb_node.h" #include "bb_node.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "scene/main/node.h" #include "scene/main/node.h"
Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) { Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) {
@ -21,7 +21,7 @@ Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard,
ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node."); ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node.");
return agent->get_node(val); return agent->get_node(val);
} else { } else {
Node *node = val; Node *node = Object::cast_to<Node>(val);
if (unlikely(node == nullptr && val.get_type() != Variant::NIL)) { if (unlikely(node == nullptr && val.get_type() != Variant::NIL)) {
WARN_PRINT("BBNode: Unexpected variant type of a blackboard variable."); WARN_PRINT("BBNode: Unexpected variant type of a blackboard variable.");
return p_default; return p_default;

View File

@ -4,16 +4,16 @@
#define BB_NODE_H #define BB_NODE_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBNode : public BBParam { class BBNode : public BBParam {
GDCLASS(BBNode, BBParam); GDCLASS(BBNode, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::NODE_PATH; } virtual Variant::Type get_type() const override { return Variant::NODE_PATH; }
public: public:
virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant()); virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant()) override;
}; };
#endif // BB_NODE_H #endif // BB_NODE_H

View File

@ -1,25 +1,26 @@
/* bb_param.cpp */ /* bb_param.cpp */
#include "bb_param.h" #include "bb_param.h"
#include "core/class_db.h" #include "core/core_bind.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/object.h" #include "core/object/class_db.h"
#include "core/variant.h" #include "core/object/object.h"
#include "core/variant/variant.h"
#include "modules/limboai/limbo_utility.h" #include "modules/limboai/limbo_utility.h"
VARIANT_ENUM_CAST(BBParam::ValueSource); VARIANT_ENUM_CAST(BBParam::ValueSource);
void BBParam::set_value_source(ValueSource p_value) { void BBParam::set_value_source(ValueSource p_value) {
value_source = p_value; value_source = p_value;
property_list_changed_notify(); notify_property_list_changed();
_update_name(); _update_name();
emit_changed(); emit_changed();
} }
Variant BBParam::get_saved_value() { Variant BBParam::get_saved_value() {
if (saved_value.get_type() != get_type()) { if (saved_value.get_type() != get_type()) {
Variant::CallError err; Callable::CallError err;
saved_value = Variant::construct(get_type(), nullptr, 0, err); Variant::construct(get_type(), saved_value, nullptr, 0, err);
} }
return saved_value; return saved_value;
} }

View File

@ -3,10 +3,10 @@
#ifndef BB_PARAM_H #ifndef BB_PARAM_H
#define BB_PARAM_H #define BB_PARAM_H
#include "core/object.h" #include "core/io/resource.h"
#include "core/resource.h" #include "core/object/object.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "modules/limboai/limbo_utility.h" #include "modules/limboai/limbo_utility.h"
@ -45,7 +45,7 @@ public:
void set_variable(const String &p_value); void set_variable(const String &p_value);
String get_variable() const { return variable; } String get_variable() const { return variable; }
virtual String to_string(); virtual String to_string() override;
virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant()); virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant());

View File

@ -4,13 +4,13 @@
#define BB_PLANE_H #define BB_PLANE_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBPlane : public BBParam { class BBPlane : public BBParam {
GDCLASS(BBPlane, BBParam); GDCLASS(BBPlane, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::PLANE; } virtual Variant::Type get_type() const override { return Variant::PLANE; }
}; };
#endif // BB_PLANE_H #endif // BB_PLANE_H

View File

@ -4,13 +4,13 @@
#define BB_QUAT_H #define BB_QUAT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBQuat : public BBParam { class BBQuat : public BBParam {
GDCLASS(BBQuat, BBParam); GDCLASS(BBQuat, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::QUAT; } virtual Variant::Type get_type() const override { return Variant::QUATERNION; }
}; };
#endif // BB_QUAT_H #endif // BB_QUAT_H

View File

@ -4,13 +4,13 @@
#define BB_REAL_ARRAY_H #define BB_REAL_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBRealArray : public BBParam { class BBRealArray : public BBParam {
GDCLASS(BBRealArray, BBParam); GDCLASS(BBRealArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_REAL_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_FLOAT64_ARRAY; }
}; };
#endif // BB_REAL_ARRAY_H #endif // BB_REAL_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_RECT2_H #define BB_RECT2_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBRect2 : public BBParam { class BBRect2 : public BBParam {
GDCLASS(BBRect2, BBParam); GDCLASS(BBRect2, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::RECT2; } virtual Variant::Type get_type() const override { return Variant::RECT2; }
}; };
#endif // BB_RECT2_H #endif // BB_RECT2_H

View File

@ -4,13 +4,13 @@
#define BB_STRING_H #define BB_STRING_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBString : public BBParam { class BBString : public BBParam {
GDCLASS(BBString, BBParam); GDCLASS(BBString, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::STRING; } virtual Variant::Type get_type() const override { return Variant::STRING; }
}; };
#endif // BB_STRING_H #endif // BB_STRING_H

View File

@ -4,13 +4,13 @@
#define BB_STRING_ARRAY_H #define BB_STRING_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBStringArray : public BBParam { class BBStringArray : public BBParam {
GDCLASS(BBStringArray, BBParam); GDCLASS(BBStringArray, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_STRING_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_STRING_ARRAY; }
}; };
#endif // BB_STRING_ARRAY_H #endif // BB_STRING_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_TRANSFORM_H #define BB_TRANSFORM_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBTransform : public BBParam { class BBTransform : public BBParam {
GDCLASS(BBTransform, BBParam); GDCLASS(BBTransform, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::TRANSFORM; } virtual Variant::Type get_type() const override { return Variant::TRANSFORM3D; }
}; };
#endif // BB_TRANSFORM_H #endif // BB_TRANSFORM_H

View File

@ -4,13 +4,13 @@
#define BB_TRANSFORM2D_H #define BB_TRANSFORM2D_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBTransform2D : public BBParam { class BBTransform2D : public BBParam {
GDCLASS(BBTransform2D, BBParam); GDCLASS(BBTransform2D, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::TRANSFORM2D; } virtual Variant::Type get_type() const override { return Variant::TRANSFORM2D; }
}; };
#endif // BB_TRANSFORM2D_H #endif // BB_TRANSFORM2D_H

View File

@ -1,12 +1,12 @@
/* bb_variant.cpp */ /* bb_variant.cpp */
#include "bb_variant.h" #include "bb_variant.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
void BBVariant::set_type(Variant::Type p_type) { void BBVariant::set_type(Variant::Type p_type) {
type = p_type; type = p_type;
property_list_changed_notify(); notify_property_list_changed();
emit_changed(); emit_changed();
} }

View File

@ -4,8 +4,8 @@
#define BB_VARIANT_H #define BB_VARIANT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
class BBVariant : public BBParam { class BBVariant : public BBParam {
GDCLASS(BBVariant, BBParam); GDCLASS(BBVariant, BBParam);
@ -16,7 +16,7 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual Variant::Type get_type() const { return type; } virtual Variant::Type get_type() const override { return type; }
void set_type(Variant::Type p_type); void set_type(Variant::Type p_type);
public: public:

View File

@ -4,13 +4,13 @@
#define BB_VECTOR2_H #define BB_VECTOR2_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBVector2 : public BBParam { class BBVector2 : public BBParam {
GDCLASS(BBVector2, BBParam); GDCLASS(BBVector2, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::VECTOR2; } virtual Variant::Type get_type() const override { return Variant::VECTOR2; }
}; };
#endif // BB_VECTOR2_H #endif // BB_VECTOR2_H

View File

@ -4,13 +4,13 @@
#define BB_VECTOR2_ARRAY_H #define BB_VECTOR2_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBVector2Array : public BBParam { class BBVector2Array : public BBParam {
GDCLASS(BBVector2Array, BBParam); GDCLASS(BBVector2Array, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_VECTOR2_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_VECTOR2_ARRAY; }
}; };
#endif // BB_VECTOR2_ARRAY_H #endif // BB_VECTOR2_ARRAY_H

View File

@ -4,13 +4,13 @@
#define BB_VECTOR3_H #define BB_VECTOR3_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBVector3 : public BBParam { class BBVector3 : public BBParam {
GDCLASS(BBVector3, BBParam); GDCLASS(BBVector3, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::VECTOR3; } virtual Variant::Type get_type() const override { return Variant::VECTOR3; }
}; };
#endif // BB_VECTOR3_H #endif // BB_VECTOR3_H

View File

@ -4,13 +4,13 @@
#define BB_VECTOR3_ARRAY_H #define BB_VECTOR3_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object.h" #include "core/object/object.h"
class BBVector3Array : public BBParam { class BBVector3Array : public BBParam {
GDCLASS(BBVector3Array, BBParam); GDCLASS(BBVector3Array, BBParam);
protected: protected:
virtual Variant::Type get_type() const { return Variant::POOL_VECTOR3_ARRAY; } virtual Variant::Type get_type() const override { return Variant::PACKED_VECTOR3_ARRAY; }
}; };
#endif // BB_VECTOR3_ARRAY_H #endif // BB_VECTOR3_ARRAY_H

View File

@ -1,10 +1,9 @@
/* blackboard.cpp */ /* blackboard.cpp */
#include "blackboard.h" #include "blackboard.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include <cstddef>
Ref<Blackboard> Blackboard::top() const { Ref<Blackboard> Blackboard::top() const {
Ref<Blackboard> bb(this); Ref<Blackboard> bb(this);

View File

@ -3,13 +3,14 @@
#ifndef BLACKBOARD_H #ifndef BLACKBOARD_H
#define BLACKBOARD_H #define BLACKBOARD_H
#include "core/dictionary.h" #include "core/object/object.h"
#include "core/object.h" #include "core/object/ref_counted.h"
#include "core/reference.h" #include "core/variant/dictionary.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "scene/main/node.h"
class Blackboard : public Reference { class Blackboard : public RefCounted {
GDCLASS(Blackboard, Reference); GDCLASS(Blackboard, RefCounted);
private: private:
Dictionary data; Dictionary data;

View File

@ -4,7 +4,7 @@
String BTAction::get_configuration_warning() const { String BTAction::get_configuration_warning() const {
String warning = BTTask::get_configuration_warning(); String warning = BTTask::get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (get_child_count() != 0) { if (get_child_count() != 0) {

View File

@ -4,13 +4,13 @@
#define BT_ACTION_H #define BT_ACTION_H
#include "../bt_task.h" #include "../bt_task.h"
#include "core/object.h" #include "core/object/object.h"
class BTAction : public BTTask { class BTAction : public BTTask {
GDCLASS(BTAction, BTTask); GDCLASS(BTAction, BTTask);
public: public:
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_ACTION_H #endif // BT_ACTION_H

View File

@ -1,8 +1,8 @@
/* bt_console_print.cpp */ /* bt_console_print.cpp */
#include "bt_console_print.h" #include "bt_console_print.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/print_string.h" #include "core/string/print_string.h"
#include "modules/limboai/bt/actions/bt_action.h" #include "modules/limboai/bt/actions/bt_action.h"
String BTConsolePrint::_generate_name() const { String BTConsolePrint::_generate_name() const {
@ -54,7 +54,7 @@ int BTConsolePrint::_tick(float p_delta) {
String BTConsolePrint::get_configuration_warning() const { String BTConsolePrint::get_configuration_warning() const {
String warning = BTAction::get_configuration_warning(); String warning = BTAction::get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (format_var_args.size() > 5) { if (format_var_args.size() > 5) {
@ -70,5 +70,5 @@ void BTConsolePrint::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_format_var_args"), &BTConsolePrint::get_format_var_args); ClassDB::bind_method(D_METHOD("get_format_var_args"), &BTConsolePrint::get_format_var_args);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text");
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "format_var_args"), "set_format_var_args", "get_format_var_args"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "format_var_args"), "set_format_var_args", "get_format_var_args");
} }

View File

@ -4,21 +4,21 @@
#define BT_CONSOLE_PRINT_H #define BT_CONSOLE_PRINT_H
#include "bt_action.h" #include "bt_action.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
class BTConsolePrint : public BTAction { class BTConsolePrint : public BTAction {
GDCLASS(BTConsolePrint, BTAction); GDCLASS(BTConsolePrint, BTAction);
private: private:
String text; String text;
PoolStringArray format_var_args; PackedStringArray format_var_args;
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_text(String p_value) { void set_text(String p_value) {
@ -27,13 +27,13 @@ public:
} }
String get_text() const { return text; } String get_text() const { return text; }
void set_format_var_args(const PoolStringArray &p_value) { void set_format_var_args(const PackedStringArray &p_value) {
format_var_args = p_value; format_var_args = p_value;
emit_changed(); emit_changed();
} }
PoolStringArray get_format_var_args() const { return format_var_args; } PackedStringArray get_format_var_args() const { return format_var_args; }
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_CONSOLE_PRINT_H #endif // BT_CONSOLE_PRINT_H

View File

@ -4,13 +4,13 @@
#define BT_FAIL_H #define BT_FAIL_H
#include "bt_action.h" #include "bt_action.h"
#include "core/object.h" #include "core/object/object.h"
class BTFail : public BTAction { class BTFail : public BTAction {
GDCLASS(BTFail, BTAction); GDCLASS(BTFail, BTAction);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_FAIL_H #endif // BT_FAIL_H

View File

@ -4,7 +4,7 @@
#define BT_RANDOM_WAIT_H #define BT_RANDOM_WAIT_H
#include "bt_action.h" #include "bt_action.h"
#include "core/object.h" #include "core/object/object.h"
class BTRandomWait : public BTAction { class BTRandomWait : public BTAction {
GDCLASS(BTRandomWait, BTAction); GDCLASS(BTRandomWait, BTAction);
@ -18,9 +18,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_duration_min_max(Vector2 p_value) { void set_duration_min_max(Vector2 p_value) {

View File

@ -1,9 +1,9 @@
/* bt_wait.cpp */ /* bt_wait.cpp */
#include "bt_wait.h" #include "bt_wait.h"
#include "core/class_db.h" #include "core/object/class_db.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
String BTWait::_generate_name() const { String BTWait::_generate_name() const {
return vformat("Wait %ss", duration); return vformat("Wait %ss", duration);
@ -26,5 +26,5 @@ void BTWait::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_duration", "p_value"), &BTWait::set_duration); ClassDB::bind_method(D_METHOD("set_duration", "p_value"), &BTWait::set_duration);
ClassDB::bind_method(D_METHOD("get_duration"), &BTWait::get_duration); ClassDB::bind_method(D_METHOD("get_duration"), &BTWait::get_duration);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "duration"), "set_duration", "get_duration"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "duration"), "set_duration", "get_duration");
} }

View File

@ -4,7 +4,7 @@
#define BT_WAIT_H #define BT_WAIT_H
#include "bt_action.h" #include "bt_action.h"
#include "core/object.h" #include "core/object/object.h"
class BTWait : public BTAction { class BTWait : public BTAction {
GDCLASS(BTWait, BTAction); GDCLASS(BTWait, BTAction);
@ -17,9 +17,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_duration(float p_value) { void set_duration(float p_value) {

View File

@ -1,9 +1,9 @@
/* bt_wait_ticks.cpp */ /* bt_wait_ticks.cpp */
#include "bt_wait_ticks.h" #include "bt_wait_ticks.h"
#include "core/class_db.h" #include "core/object/class_db.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
String BTWaitTicks::_generate_name() const { String BTWaitTicks::_generate_name() const {
return vformat("WaitTicks x%d", num_ticks); return vformat("WaitTicks x%d", num_ticks);

View File

@ -4,7 +4,7 @@
#define BT_WAIT_TICKS_H #define BT_WAIT_TICKS_H
#include "bt_action.h" #include "bt_action.h"
#include "core/object.h" #include "core/object/object.h"
class BTWaitTicks : public BTAction { class BTWaitTicks : public BTAction {
GDCLASS(BTWaitTicks, BTAction); GDCLASS(BTWaitTicks, BTAction);
@ -17,9 +17,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_num_ticks(int p_value) { void set_num_ticks(int p_value) {

View File

@ -1,12 +1,11 @@
/* behavior_tree.cpp */ /* behavior_tree.cpp */
#include "behavior_tree.h" #include "behavior_tree.h"
#include "core/class_db.h" #include "core/error/error_macros.h"
#include "core/error_macros.h" #include "core/object/class_db.h"
#include "core/list.h" #include "core/object/object.h"
#include "core/object.h" #include "core/templates/list.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include <cstddef>
void BehaviorTree::init() { void BehaviorTree::init() {
List<BTTask *> stack; List<BTTask *> stack;
@ -17,7 +16,7 @@ void BehaviorTree::init() {
stack.push_back(task->get_child(i).ptr()); stack.push_back(task->get_child(i).ptr());
} }
task = nullptr; task = nullptr;
if (!stack.empty()) { if (!stack.is_empty()) {
task = stack.front()->get(); task = stack.front()->get();
stack.pop_front(); stack.pop_front();
} }

View File

@ -4,8 +4,8 @@
#define BEHAVIOR_TREE_H #define BEHAVIOR_TREE_H
#include "bt_task.h" #include "bt_task.h"
#include "core/object.h" #include "core/io/resource.h"
#include "core/resource.h" #include "core/object/object.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
class BehaviorTree : public Resource { class BehaviorTree : public Resource {

View File

@ -4,14 +4,13 @@
#include "../limbo_string_names.h" #include "../limbo_string_names.h"
#include "bt_task.h" #include "bt_task.h"
#include "core/class_db.h" #include "core/config/engine.h"
#include "core/engine.h"
#include "core/io/resource_loader.h" #include "core/io/resource_loader.h"
#include "core/object.h" #include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include <cstddef>
VARIANT_ENUM_CAST(BTPlayer::UpdateMode); VARIANT_ENUM_CAST(BTPlayer::UpdateMode);

View File

@ -5,7 +5,7 @@
#include "behavior_tree.h" #include "behavior_tree.h"
#include "bt_task.h" #include "bt_task.h"
#include "core/object.h" #include "core/object/object.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "scene/main/node.h" #include "scene/main/node.h"

View File

@ -1,8 +1,8 @@
/* bt_state.cpp */ /* bt_state.cpp */
#include "bt_state.h" #include "bt_state.h"
#include "core/class_db.h" #include "core/object/class_db.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "modules/limboai/bt/bt_task.h" #include "modules/limboai/bt/bt_task.h"
#include "modules/limboai/limbo_state.h" #include "modules/limboai/limbo_state.h"

View File

@ -3,7 +3,7 @@
#ifndef BT_STATE_H #ifndef BT_STATE_H
#define BT_STATE_H #define BT_STATE_H
#include "core/object.h" #include "core/object/object.h"
#include "modules/limboai/bt/behavior_tree.h" #include "modules/limboai/bt/behavior_tree.h"
#include "modules/limboai/bt/bt_task.h" #include "modules/limboai/bt/bt_task.h"
#include "modules/limboai/limbo_state.h" #include "modules/limboai/limbo_state.h"
@ -20,10 +20,10 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual void _setup(); virtual void _setup() override;
virtual void _enter() {} virtual void _enter() override {}
virtual void _exit(); virtual void _exit() override;
virtual void _update(float p_delta); virtual void _update(float p_delta) override;
public: public:
void set_behavior_tree(const Ref<BehaviorTree> &p_value) { behavior_tree = p_value; } void set_behavior_tree(const Ref<BehaviorTree> &p_value) { behavior_tree = p_value; }

View File

@ -2,16 +2,18 @@
#include "bt_task.h" #include "bt_task.h"
#include "core/class_db.h" #include "core/error/error_macros.h"
#include "core/error_macros.h" #include "core/io/resource.h"
#include "core/object.h" #include "core/object/class_db.h"
#include "core/script_language.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/object/ref_counted.h"
#include "editor/editor_node.h" #include "core/object/script_language.h"
#include "core/string/ustring.h"
#include "core/templates/hash_map.h"
#include "core/variant/variant.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "modules/limboai/limbo_string_names.h" #include "modules/limboai/limbo_string_names.h"
#include "modules/limboai/limbo_utility.h" #include "modules/limboai/limbo_utility.h"
#include <cstddef>
String BTTask::_generate_name() const { String BTTask::_generate_name() const {
if (get_script_instance()) { if (get_script_instance()) {
@ -20,7 +22,7 @@ String BTTask::_generate_name() const {
return get_script_instance()->call(LimboStringNames::get_singleton()->_generate_name); return get_script_instance()->call(LimboStringNames::get_singleton()->_generate_name);
} }
String name = get_script_instance()->get_script()->get_path(); String name = get_script_instance()->get_script()->get_path();
if (!name.empty()) { if (!name.is_empty()) {
// Generate name based on script file // Generate name based on script file
name = name.get_basename().get_file().trim_prefix("BT"); name = name.get_basename().get_file().trim_prefix("BT");
return name; return name;
@ -53,7 +55,7 @@ void BTTask::_set_children(Array p_children) {
} }
String BTTask::get_task_name() const { String BTTask::get_task_name() const {
if (custom_name.empty()) { if (custom_name.is_empty()) {
return _generate_name(); return _generate_name();
} }
return custom_name; return custom_name;
@ -82,12 +84,16 @@ void BTTask::initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard) {
for (int i = 0; i < children.size(); i++) { for (int i = 0; i < children.size(); i++) {
get_child(i)->initialize(p_agent, p_blackboard); get_child(i)->initialize(p_agent, p_blackboard);
} }
if (get_script_instance() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_setup)) { if (!GDVIRTUAL_CALL(_setup)) {
get_script_instance()->call(LimboStringNames::get_singleton()->_setup);
} else {
_setup(); _setup();
} }
// if (get_script_instance() &&
// get_script_instance()->has_method(LimboStringNames::get_singleton()->_setup)) {
// get_script_instance()->call(LimboStringNames::get_singleton()->_setup);
// } else {
// _setup();
// }
} }
Ref<BTTask> BTTask::clone() const { Ref<BTTask> BTTask::clone() const {
@ -104,7 +110,7 @@ Ref<BTTask> BTTask::clone() const {
// Make BBParam properties unique. // Make BBParam properties unique.
List<PropertyInfo> props; List<PropertyInfo> props;
inst->get_property_list(&props); inst->get_property_list(&props);
Map<RES, RES> duplicates; HashMap<Ref<Resource>, Ref<Resource>> duplicates;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue; continue;
@ -112,10 +118,10 @@ Ref<BTTask> BTTask::clone() const {
Variant v = inst->get(E->get().name); Variant v = inst->get(E->get().name);
if (v.is_ref()) { if (v.is_ref_counted()) {
REF ref = v; Ref<RefCounted> ref = v;
if (ref.is_valid()) { if (ref.is_valid()) {
RES res = ref; Ref<Resource> res = ref;
if (res.is_valid() && res->is_class("BBParam")) { if (res.is_valid() && res->is_class("BBParam")) {
if (!duplicates.has(res)) { if (!duplicates.has(res)) {
duplicates[res] = res->duplicate(); duplicates[res] = res->duplicate();
@ -132,31 +138,40 @@ Ref<BTTask> BTTask::clone() const {
int BTTask::execute(float p_delta) { int BTTask::execute(float p_delta) {
if (status != RUNNING) { if (status != RUNNING) {
if (get_script_instance() && if (!GDVIRTUAL_CALL(_enter)) {
// get_script_instance()->get_script()->is_valid() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_enter)) {
get_script_instance()->call(LimboStringNames::get_singleton()->_enter);
} else {
_enter(); _enter();
} }
// if (get_script_instance() &&
// // get_script_instance()->get_script()->is_valid() &&
// get_script_instance()->has_method(LimboStringNames::get_singleton()->_enter)) {
// get_script_instance()->call(LimboStringNames::get_singleton()->_enter);
// } else {
// _enter();
// }
} }
if (get_script_instance() && if (!GDVIRTUAL_CALL(_tick, p_delta, status)) {
// get_script_instance()->get_script()->is_valid() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_tick)) {
status = get_script_instance()->call(LimboStringNames::get_singleton()->_tick, Variant(p_delta));
} else {
status = _tick(p_delta); status = _tick(p_delta);
} }
// if (get_script_instance() &&
// // get_script_instance()->get_script()->is_valid() &&
// get_script_instance()->has_method(LimboStringNames::get_singleton()->_tick)) {
// status = get_script_instance()->call(LimboStringNames::get_singleton()->_tick, Variant(p_delta));
// } else {
// status = _tick(p_delta);
// }
if (status != RUNNING) { if (status != RUNNING) {
if (get_script_instance() && if (!GDVIRTUAL_CALL(_exit)) {
// get_script_instance()->get_script()->is_valid() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_exit)) {
get_script_instance()->call(LimboStringNames::get_singleton()->_exit);
} else {
_exit(); _exit();
} }
// if (get_script_instance() &&
// // get_script_instance()->get_script()->is_valid() &&
// get_script_instance()->has_method(LimboStringNames::get_singleton()->_exit)) {
// get_script_instance()->call(LimboStringNames::get_singleton()->_exit);
// } else {
// _exit();
// }
} }
return status; return status;
} }
@ -166,13 +181,16 @@ void BTTask::cancel() {
get_child(i)->cancel(); get_child(i)->cancel();
} }
if (status == RUNNING) { if (status == RUNNING) {
if (get_script_instance() && if (!GDVIRTUAL_CALL(_exit)) {
// get_script_instance()->get_script()->is_valid() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_exit)) {
get_script_instance()->call(LimboStringNames::get_singleton()->_exit);
} else {
_exit(); _exit();
} }
// if (get_script_instance() &&
// // get_script_instance()->get_script()->is_valid() &&
// get_script_instance()->has_method(LimboStringNames::get_singleton()->_exit)) {
// get_script_instance()->call(LimboStringNames::get_singleton()->_exit);
// } else {
// _exit();
// }
} }
status = FRESH; status = FRESH;
} }
@ -208,7 +226,7 @@ void BTTask::remove_child(Ref<BTTask> p_child) {
if (idx == -1) { if (idx == -1) {
ERR_FAIL_MSG("p_child not found!"); ERR_FAIL_MSG("p_child not found!");
} else { } else {
children.remove(idx); children.remove_at(idx);
p_child->parent = nullptr; p_child->parent = nullptr;
emit_changed(); emit_changed();
} }
@ -216,7 +234,7 @@ void BTTask::remove_child(Ref<BTTask> p_child) {
void BTTask::remove_child_at_index(int p_idx) { void BTTask::remove_child_at_index(int p_idx) {
ERR_FAIL_INDEX(p_idx, get_child_count()); ERR_FAIL_INDEX(p_idx, get_child_count());
children.remove(p_idx); children.remove_at(p_idx);
} }
bool BTTask::has_child(const Ref<BTTask> &p_child) const { bool BTTask::has_child(const Ref<BTTask> &p_child) const {
@ -250,10 +268,13 @@ Ref<BTTask> BTTask::next_sibling() const {
String BTTask::get_configuration_warning() const { String BTTask::get_configuration_warning() const {
String warning = ""; String warning = "";
if (get_script_instance() &&
get_script_instance()->has_method(LimboStringNames::get_singleton()->_get_configuration_warning)) { GDVIRTUAL_CALL(_get_configuration_warning, warning);
warning = get_script_instance()->call(LimboStringNames::get_singleton()->_get_configuration_warning); // if (get_script_instance() &&
} // get_script_instance()->has_method(LimboStringNames::get_singleton()->_get_configuration_warning)) {
// warning = get_script_instance()->call(LimboStringNames::get_singleton()->_get_configuration_warning);
// }
return warning; return warning;
} }
@ -287,22 +308,24 @@ void BTTask::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Object", 0), "set_agent", "get_agent"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Object", 0), "set_agent", "get_agent");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", 0), "", "get_blackboard"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", 0), "", "get_blackboard");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "parent", PROPERTY_HINT_RESOURCE_TYPE, "BTTask", 0), "", "get_parent"); 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_NOEDITOR | 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, "", 0), "", "get_status"); ADD_PROPERTY(PropertyInfo(Variant::INT, "status", PROPERTY_HINT_NONE, "", 0), "", "get_status");
// Virtual methods. // Virtual methods.
// TODO: Remove if unneeded.
ClassDB::bind_method(D_METHOD("_setup"), &BTTask::_setup); ClassDB::bind_method(D_METHOD("_setup"), &BTTask::_setup);
BIND_VMETHOD(MethodInfo("_setup"));
ClassDB::bind_method(D_METHOD("_enter"), &BTTask::_enter); ClassDB::bind_method(D_METHOD("_enter"), &BTTask::_enter);
BIND_VMETHOD(MethodInfo("_enter"))
ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit); ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit);
BIND_VMETHOD(MethodInfo("_exit"));
ClassDB::bind_method(D_METHOD("_tick", "p_delta"), &BTTask::_tick); ClassDB::bind_method(D_METHOD("_tick", "p_delta"), &BTTask::_tick);
BIND_VMETHOD(MethodInfo(Variant::INT, "_tick", PropertyInfo(Variant::REAL, "p_delta")));
ClassDB::bind_method(D_METHOD("_generate_name"), &BTTask::_generate_name); ClassDB::bind_method(D_METHOD("_generate_name"), &BTTask::_generate_name);
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, ""), "_generate_name"));
ClassDB::bind_method(D_METHOD("_get_configuration_warning"), &BTTask::get_configuration_warning); ClassDB::bind_method(D_METHOD("_get_configuration_warning"), &BTTask::get_configuration_warning);
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, ""), "_get_configuration_warning"));
GDVIRTUAL_BIND(_setup);
GDVIRTUAL_BIND(_enter);
GDVIRTUAL_BIND(_exit);
GDVIRTUAL_BIND(_tick, "p_delta");
GDVIRTUAL_BIND(_generate_name);
GDVIRTUAL_BIND(_get_configuration_warning);
// Public Methods. // Public Methods.
ClassDB::bind_method(D_METHOD("is_root"), &BTTask::is_root); ClassDB::bind_method(D_METHOD("is_root"), &BTTask::is_root);

View File

@ -3,13 +3,13 @@
#ifndef BTTASK_H #ifndef BTTASK_H
#define BTTASK_H #define BTTASK_H
#include "core/array.h" #include "core/io/resource.h"
#include "core/dictionary.h" #include "core/object/object.h"
#include "core/object.h" #include "core/object/ref_counted.h"
#include "core/reference.h" #include "core/string/ustring.h"
#include "core/resource.h" #include "core/templates/vector.h"
#include "core/ustring.h" #include "core/variant/array.h"
#include "core/vector.h" #include "core/variant/dictionary.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "scene/resources/texture.h" #include "scene/resources/texture.h"
@ -46,6 +46,13 @@ protected:
virtual void _exit() {} virtual void _exit() {}
virtual int _tick(float p_delta) { return FAILURE; } virtual int _tick(float p_delta) { return FAILURE; }
GDVIRTUAL0RC(String, _generate_name);
GDVIRTUAL0(_setup);
GDVIRTUAL0(_enter);
GDVIRTUAL0(_exit);
GDVIRTUAL1R(int, _tick, float);
GDVIRTUAL0RC(String, _get_configuration_warning);
public: public:
Object *get_agent() const { return agent; } Object *get_agent() const { return agent; }
void set_agent(Object *p_agent) { agent = p_agent; } void set_agent(Object *p_agent) { agent = p_agent; }
@ -60,6 +67,7 @@ public:
virtual Ref<BTTask> clone() const; virtual Ref<BTTask> clone() const;
virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard); virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard);
int execute(float p_delta); int execute(float p_delta);
void cancel(); void cancel();
Ref<BTTask> get_child(int p_idx) const; Ref<BTTask> get_child(int p_idx) const;

View File

@ -4,7 +4,7 @@
String BTComposite::get_configuration_warning() const { String BTComposite::get_configuration_warning() const {
String warning = BTTask::get_configuration_warning(); String warning = BTTask::get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (get_child_count() < 1) { if (get_child_count() < 1) {

View File

@ -4,13 +4,13 @@
#define BT_COMPOSITE_H #define BT_COMPOSITE_H
#include "../bt_task.h" #include "../bt_task.h"
#include "core/object.h" #include "core/object/object.h"
class BTComposite : public BTTask { class BTComposite : public BTTask {
GDCLASS(BTComposite, BTTask); GDCLASS(BTComposite, BTTask);
public: public:
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_COMPOSITE_H #endif // BT_COMPOSITE_H

View File

@ -4,7 +4,7 @@
#define BT_DYNAMIC_SELECTOR_H #define BT_DYNAMIC_SELECTOR_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/object.h" #include "core/object/object.h"
class BTDynamicSelector : public BTComposite { class BTDynamicSelector : public BTComposite {
GDCLASS(BTDynamicSelector, BTComposite); GDCLASS(BTDynamicSelector, BTComposite);
@ -13,8 +13,8 @@ private:
int last_running_idx = 0; int last_running_idx = 0;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_DYNAMIC_SELECTOR_H #endif // BT_DYNAMIC_SELECTOR_H

View File

@ -4,7 +4,7 @@
#define BT_DYNAMIC_SEQUENCE_H #define BT_DYNAMIC_SEQUENCE_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/object.h" #include "core/object/object.h"
class BTDynamicSequence : public BTComposite { class BTDynamicSequence : public BTComposite {
GDCLASS(BTDynamicSequence, BTComposite); GDCLASS(BTDynamicSequence, BTComposite);
@ -13,8 +13,8 @@ private:
int last_running_idx = 0; int last_running_idx = 0;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_DYNAMIC_SEQUENCE_H #endif // BT_DYNAMIC_SEQUENCE_H

View File

@ -1,7 +1,7 @@
/* bt_parallel.cpp */ /* bt_parallel.cpp */
#include "bt_parallel.h" #include "bt_parallel.h"
#include "core/class_db.h" #include "core/object/class_db.h"
void BTParallel::_enter() { void BTParallel::_enter() {
for (int i = 0; i < get_child_count(); i++) { for (int i = 0; i < get_child_count(); i++) {

View File

@ -4,7 +4,7 @@
#define BT_PARALLEL_H #define BT_PARALLEL_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/object.h" #include "core/object/object.h"
class BTParallel : public BTComposite { class BTParallel : public BTComposite {
GDCLASS(BTParallel, BTComposite); GDCLASS(BTParallel, BTComposite);
@ -17,8 +17,8 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
int get_num_successes_required() const { return num_successes_required; } int get_num_successes_required() const { return num_successes_required; }

View File

@ -4,7 +4,7 @@
#define BT_RANDOM_SELECTOR_H #define BT_RANDOM_SELECTOR_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/vector.h" #include "core/templates/vector.h"
class BTRandomSelector : public BTComposite { class BTRandomSelector : public BTComposite {
GDCLASS(BTRandomSelector, BTComposite); GDCLASS(BTRandomSelector, BTComposite);
@ -14,7 +14,7 @@ private:
Array _indicies; Array _indicies;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_RANDOM_SELECTOR_H #endif // BT_RANDOM_SELECTOR_H

View File

@ -4,7 +4,7 @@
#define BT_RANDOM_SEQUENCE_H #define BT_RANDOM_SEQUENCE_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/vector.h" #include "core/templates/vector.h"
class BTRandomSequence : public BTComposite { class BTRandomSequence : public BTComposite {
GDCLASS(BTRandomSequence, BTComposite); GDCLASS(BTRandomSequence, BTComposite);
@ -14,7 +14,7 @@ private:
Array _indicies; Array _indicies;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_RANDOM_SEQUENCE_H #endif // BT_RANDOM_SEQUENCE_H

View File

@ -12,7 +12,7 @@ private:
int last_running_idx = 0; int last_running_idx = 0;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_SELECTOR_H #endif // BT_SELECTOR_H

View File

@ -4,7 +4,7 @@
#define BT_SEQUENCE_H #define BT_SEQUENCE_H
#include "bt_composite.h" #include "bt_composite.h"
#include "core/object.h" #include "core/object/object.h"
class BTSequence : public BTComposite { class BTSequence : public BTComposite {
GDCLASS(BTSequence, BTComposite); GDCLASS(BTSequence, BTComposite);
@ -13,8 +13,8 @@ private:
int last_running_idx = 0; int last_running_idx = 0;
protected: protected:
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_SEQUENCE_H #endif // BT_SEQUENCE_H

View File

@ -4,7 +4,7 @@
String BTCondition::get_configuration_warning() const { String BTCondition::get_configuration_warning() const {
String warning = BTTask::get_configuration_warning(); String warning = BTTask::get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (get_child_count() != 0) { if (get_child_count() != 0) {

View File

@ -4,13 +4,13 @@
#define BT_CONDITION_H #define BT_CONDITION_H
#include "../bt_task.h" #include "../bt_task.h"
#include "core/object.h" #include "core/object/object.h"
class BTCondition : public BTTask { class BTCondition : public BTTask {
GDCLASS(BTCondition, BTTask); GDCLASS(BTCondition, BTTask);
public: public:
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_CONDITION_H #endif // BT_CONDITION_H

View File

@ -4,13 +4,13 @@
#define BT_ALWAYS_FAIL_H #define BT_ALWAYS_FAIL_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTAlwaysFail : public BTDecorator { class BTAlwaysFail : public BTDecorator {
GDCLASS(BTAlwaysFail, BTDecorator); GDCLASS(BTAlwaysFail, BTDecorator);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_ALWAYS_FAIL_H #endif // BT_ALWAYS_FAIL_H

View File

@ -4,13 +4,13 @@
#define BT_ALWAYS_SUCCEED_H #define BT_ALWAYS_SUCCEED_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTAlwaysSucceed : public BTDecorator { class BTAlwaysSucceed : public BTDecorator {
GDCLASS(BTAlwaysSucceed, BTDecorator); GDCLASS(BTAlwaysSucceed, BTDecorator);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_ALWAYS_SUCCEED_H #endif // BT_ALWAYS_SUCCEED_H

View File

@ -1,8 +1,8 @@
/* bt_cooldown.cpp */ /* bt_cooldown.cpp */
#include "bt_cooldown.h" #include "bt_cooldown.h"
#include "core/array.h" #include "core/object/class_db.h"
#include "core/class_db.h" #include "core/variant/array.h"
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
String BTCooldown::_generate_name() const { String BTCooldown::_generate_name() const {
@ -10,7 +10,7 @@ String BTCooldown::_generate_name() const {
} }
void BTCooldown::_setup() { void BTCooldown::_setup() {
if (cooldown_state_var.empty()) { if (cooldown_state_var.is_empty()) {
cooldown_state_var = vformat("cooldown_%d", rand()); cooldown_state_var = vformat("cooldown_%d", rand());
} }
get_blackboard()->set_var(cooldown_state_var, false); get_blackboard()->set_var(cooldown_state_var, false);
@ -37,7 +37,7 @@ void BTCooldown::_chill() {
_timer->set_time_left(duration); _timer->set_time_left(duration);
} else { } else {
_timer = SceneTree::get_singleton()->create_timer(duration, process_pause); _timer = SceneTree::get_singleton()->create_timer(duration, process_pause);
_timer->connect("timeout", this, "_on_timeout", Vector<Variant>(), CONNECT_ONESHOT); _timer->connect("timeout", callable_mp(this, &BTCooldown::_on_timeout), CONNECT_ONE_SHOT);
} }
} }
@ -59,7 +59,7 @@ void BTCooldown::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cooldown_state_var"), &BTCooldown::get_cooldown_state_var); ClassDB::bind_method(D_METHOD("get_cooldown_state_var"), &BTCooldown::get_cooldown_state_var);
ClassDB::bind_method(D_METHOD("_on_timeout"), &BTCooldown::_on_timeout); ClassDB::bind_method(D_METHOD("_on_timeout"), &BTCooldown::_on_timeout);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "duration"), "set_duration", "get_duration"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "duration"), "set_duration", "get_duration");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "process_pause"), "set_process_pause", "get_process_pause"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "process_pause"), "set_process_pause", "get_process_pause");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "start_cooled"), "set_start_cooled", "get_start_cooled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "start_cooled"), "set_start_cooled", "get_start_cooled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger_on_failure"), "set_trigger_on_failure", "get_trigger_on_failure"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger_on_failure"), "set_trigger_on_failure", "get_trigger_on_failure");

View File

@ -4,7 +4,7 @@
#define BT_COOLDOWN_H #define BT_COOLDOWN_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
class BTCooldown : public BTDecorator { class BTCooldown : public BTDecorator {
@ -25,9 +25,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _setup(); virtual void _setup() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_duration(float p_value) { void set_duration(float p_value) {

View File

@ -4,7 +4,7 @@
String BTDecorator::get_configuration_warning() const { String BTDecorator::get_configuration_warning() const {
String warning = BTTask::get_configuration_warning(); String warning = BTTask::get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (get_child_count() != 1) { if (get_child_count() != 1) {

View File

@ -4,13 +4,13 @@
#define BT_DECORATOR_H #define BT_DECORATOR_H
#include "../bt_task.h" #include "../bt_task.h"
#include "core/object.h" #include "core/object/object.h"
class BTDecorator : public BTTask { class BTDecorator : public BTTask {
GDCLASS(BTDecorator, BTTask) GDCLASS(BTDecorator, BTTask)
public: public:
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_DECORATOR_H #endif // BT_DECORATOR_H

View File

@ -1,11 +1,11 @@
/* bt_delay.cpp */ /* bt_delay.cpp */
#include "bt_delay.h" #include "bt_delay.h"
#include "core/array.h" #include "core/error/error_macros.h"
#include "core/class_db.h" #include "core/object/class_db.h"
#include "core/error_macros.h" #include "core/object/object.h"
#include "core/object.h" #include "core/variant/array.h"
#include "core/variant.h" #include "core/variant/variant.h"
String BTDelay::_generate_name() const { String BTDelay::_generate_name() const {
return vformat("Delay %ss", seconds); return vformat("Delay %ss", seconds);
@ -27,5 +27,5 @@ int BTDelay::_tick(float p_delta) {
void BTDelay::_bind_methods() { void BTDelay::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seconds", "p_value"), &BTDelay::set_seconds); ClassDB::bind_method(D_METHOD("set_seconds", "p_value"), &BTDelay::set_seconds);
ClassDB::bind_method(D_METHOD("get_seconds"), &BTDelay::get_seconds); ClassDB::bind_method(D_METHOD("get_seconds"), &BTDelay::get_seconds);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "seconds"), "set_seconds", "get_seconds"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "seconds"), "set_seconds", "get_seconds");
} }

View File

@ -4,7 +4,7 @@
#define BT_DELAY_H #define BT_DELAY_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTDelay : public BTDecorator { class BTDelay : public BTDecorator {
GDCLASS(BTDelay, BTDecorator); GDCLASS(BTDelay, BTDecorator);
@ -16,9 +16,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_seconds(float p_value) { void set_seconds(float p_value) {

View File

@ -1,9 +1,9 @@
/* bt_for_each.cpp */ /* bt_for_each.cpp */
#include "bt_for_each.h" #include "bt_for_each.h"
#include "core/error_list.h" #include "core/error/error_list.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "modules/limboai/limbo_utility.h" #include "modules/limboai/limbo_utility.h"
@ -19,8 +19,8 @@ void BTForEach::_enter() {
int BTForEach::_tick(float p_delta) { int BTForEach::_tick(float p_delta) {
ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "ForEach decorator has no child."); ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "ForEach decorator has no child.");
ERR_FAIL_COND_V_MSG(save_var.empty(), FAILURE, "ForEach save variable is not set."); ERR_FAIL_COND_V_MSG(save_var.is_empty(), FAILURE, "ForEach save variable is not set.");
ERR_FAIL_COND_V_MSG(array_var.empty(), FAILURE, "ForEach array variable is not set."); ERR_FAIL_COND_V_MSG(array_var.is_empty(), FAILURE, "ForEach array variable is not set.");
Array arr = get_blackboard()->get_var(array_var, Variant()); Array arr = get_blackboard()->get_var(array_var, Variant());
if (arr.size() == 0) { if (arr.size() == 0) {

View File

@ -4,7 +4,7 @@
#define BT_FOR_EACH_H #define BT_FOR_EACH_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTForEach : public BTDecorator { class BTForEach : public BTDecorator {
GDCLASS(BTForEach, BTDecorator); GDCLASS(BTForEach, BTDecorator);
@ -18,9 +18,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_array_var(String p_value) { void set_array_var(String p_value) {

View File

@ -4,13 +4,13 @@
#define BT_INVERT_H #define BT_INVERT_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTInvert : public BTDecorator { class BTInvert : public BTDecorator {
GDCLASS(BTInvert, BTDecorator); GDCLASS(BTInvert, BTDecorator);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_INVERT_H #endif // BT_INVERT_H

View File

@ -1,9 +1,9 @@
/* bt_new_scope.cpp */ /* bt_new_scope.cpp */
#include "bt_new_scope.h" #include "bt_new_scope.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/ustring.h" #include "core/string/ustring.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
void BTNewScope::initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard) { void BTNewScope::initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard) {

View File

@ -4,7 +4,7 @@
#define BT_NEW_SCOPE_H #define BT_NEW_SCOPE_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
#include "bt_decorator.h" #include "bt_decorator.h"
class BTNewScope : public BTDecorator { class BTNewScope : public BTDecorator {
@ -19,10 +19,10 @@ protected:
void _set_blackboard_data(const Dictionary &p_value) { blackboard_data = p_value; } void _set_blackboard_data(const Dictionary &p_value) { blackboard_data = p_value; }
Dictionary _get_blackboard_data() const { return blackboard_data; } Dictionary _get_blackboard_data() const { return blackboard_data; }
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard); virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard) override;
}; };
#endif // BT_NEW_SCOPE_H #endif // BT_NEW_SCOPE_H

View File

@ -1,7 +1,7 @@
/* bt_probability.cpp */ /* bt_probability.cpp */
#include "bt_probability.h" #include "bt_probability.h"
#include "core/object.h" #include "core/object/object.h"
String BTProbability::_generate_name() const { String BTProbability::_generate_name() const {
return vformat("Probability %.1f%%", run_chance); return vformat("Probability %.1f%%", run_chance);
@ -18,5 +18,5 @@ int BTProbability::_tick(float p_delta) {
void BTProbability::_bind_methods() { void BTProbability::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_run_chance", "p_value"), &BTProbability::set_run_chance); ClassDB::bind_method(D_METHOD("set_run_chance", "p_value"), &BTProbability::set_run_chance);
ClassDB::bind_method(D_METHOD("get_run_chance"), &BTProbability::get_run_chance); ClassDB::bind_method(D_METHOD("get_run_chance"), &BTProbability::get_run_chance);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "run_chance", PROPERTY_HINT_RANGE, "0.0,1.0"), "set_run_chance", "get_run_chance"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "run_chance", PROPERTY_HINT_RANGE, "0.0,1.0"), "set_run_chance", "get_run_chance");
} }

View File

@ -4,7 +4,7 @@
#define BT_PROBABILITY_H #define BT_PROBABILITY_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTProbability : public BTDecorator { class BTProbability : public BTDecorator {
GDCLASS(BTProbability, BTDecorator); GDCLASS(BTProbability, BTDecorator);
@ -15,8 +15,8 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_run_chance(float p_value) { void set_run_chance(float p_value) {

View File

@ -1,8 +1,8 @@
/* bt_repeat.cpp */ /* bt_repeat.cpp */
#include "bt_repeat.h" #include "bt_repeat.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/variant.h" #include "core/variant/variant.h"
String BTRepeat::_generate_name() const { String BTRepeat::_generate_name() const {
return vformat("Repeat x%s", times); return vformat("Repeat x%s", times);

View File

@ -4,7 +4,7 @@
#define BT_REPEAT_H #define BT_REPEAT_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTRepeat : public BTDecorator { class BTRepeat : public BTDecorator {
GDCLASS(BTRepeat, BTDecorator); GDCLASS(BTRepeat, BTDecorator);
@ -17,9 +17,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_times(int p_value) { void set_times(int p_value) {

View File

@ -4,13 +4,13 @@
#define BT_REPEAT_UNTIL_FAILURE_H #define BT_REPEAT_UNTIL_FAILURE_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTRepeatUntilFailure : public BTDecorator { class BTRepeatUntilFailure : public BTDecorator {
GDCLASS(BTRepeatUntilFailure, BTDecorator); GDCLASS(BTRepeatUntilFailure, BTDecorator);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_REPEAT_UNTIL_FAILURE_H #endif // BT_REPEAT_UNTIL_FAILURE_H

View File

@ -4,13 +4,13 @@
#define BT_REPEAT_UNTIL_SUCCESS_H #define BT_REPEAT_UNTIL_SUCCESS_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTRepeatUntilSuccess : public BTDecorator { class BTRepeatUntilSuccess : public BTDecorator {
GDCLASS(BTRepeatUntilSuccess, BTDecorator); GDCLASS(BTRepeatUntilSuccess, BTDecorator);
protected: protected:
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
}; };
#endif // BT_REPEAT_UNTIL_SUCCESS_H #endif // BT_REPEAT_UNTIL_SUCCESS_H

View File

@ -4,7 +4,7 @@
#define BT_RUN_LIMIT_H #define BT_RUN_LIMIT_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTRunLimit : public BTDecorator { class BTRunLimit : public BTDecorator {
GDCLASS(BTRunLimit, BTDecorator); GDCLASS(BTRunLimit, BTDecorator);
@ -16,8 +16,8 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_run_limit(int p_value) { void set_run_limit(int p_value) {

View File

@ -1,11 +1,11 @@
/* bt_subtree.cpp */ /* bt_subtree.cpp */
#include "bt_subtree.h" #include "bt_subtree.h"
#include "core/engine.h" #include "core/config/engine.h"
#include "core/error_macros.h" #include "core/error/error_macros.h"
#include "core/object.h" #include "core/object/object.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/variant.h" #include "core/variant/variant.h"
#include "modules/limboai/blackboard.h" #include "modules/limboai/blackboard.h"
#include "modules/limboai/bt/actions/bt_action.h" #include "modules/limboai/bt/actions/bt_action.h"
#include "modules/limboai/bt/actions/bt_fail.h" #include "modules/limboai/bt/actions/bt_fail.h"
@ -17,7 +17,7 @@ String BTSubtree::_generate_name() const {
String s; String s;
if (subtree.is_null()) { if (subtree.is_null()) {
s = "(unassigned)"; s = "(unassigned)";
} else if (subtree->get_path().empty()) { } else if (subtree->get_path().is_empty()) {
s = "(unsaved)"; s = "(unsaved)";
} else { } else {
s = vformat("\"%s\"", subtree->get_path()); s = vformat("\"%s\"", subtree->get_path());
@ -46,7 +46,7 @@ int BTSubtree::_tick(float p_delta) {
String BTSubtree::get_configuration_warning() const { String BTSubtree::get_configuration_warning() const {
String warning = BTTask::get_configuration_warning(); // BTDecorator skipped intentionally String warning = BTTask::get_configuration_warning(); // BTDecorator skipped intentionally
if (!warning.empty()) { if (!warning.is_empty()) {
warning += "\n"; warning += "\n";
} }
if (subtree.is_null()) { if (subtree.is_null()) {

View File

@ -4,7 +4,7 @@
#define BT_SUBTREE_H #define BT_SUBTREE_H
#include "bt_new_scope.h" #include "bt_new_scope.h"
#include "core/object.h" #include "core/object/object.h"
#include "modules/limboai/bt/behavior_tree.h" #include "modules/limboai/bt/behavior_tree.h"
class BTSubtree : public BTNewScope { class BTSubtree : public BTNewScope {
@ -16,8 +16,8 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_subtree(const Ref<BehaviorTree> &p_value) { void set_subtree(const Ref<BehaviorTree> &p_value) {
@ -26,8 +26,8 @@ public:
} }
Ref<BehaviorTree> get_subtree() const { return subtree; } Ref<BehaviorTree> get_subtree() const { return subtree; }
virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard); virtual void initialize(Object *p_agent, const Ref<Blackboard> &p_blackboard) override;
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const override;
}; };
#endif // BT_SUBTREE_H #endif // BT_SUBTREE_H

View File

@ -24,5 +24,5 @@ int BTTimeLimit::_tick(float p_delta) {
void BTTimeLimit::_bind_methods() { void BTTimeLimit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_time_limit", "p_value"), &BTTimeLimit::set_time_limit); ClassDB::bind_method(D_METHOD("set_time_limit", "p_value"), &BTTimeLimit::set_time_limit);
ClassDB::bind_method(D_METHOD("get_time_limit"), &BTTimeLimit::get_time_limit); ClassDB::bind_method(D_METHOD("get_time_limit"), &BTTimeLimit::get_time_limit);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_limit"), "set_time_limit", "get_time_limit"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_limit"), "set_time_limit", "get_time_limit");
} }

View File

@ -4,7 +4,7 @@
#define BT_TIME_LIMIT_H #define BT_TIME_LIMIT_H
#include "bt_decorator.h" #include "bt_decorator.h"
#include "core/object.h" #include "core/object/object.h"
class BTTimeLimit : public BTDecorator { class BTTimeLimit : public BTDecorator {
GDCLASS(BTTimeLimit, BTDecorator); GDCLASS(BTTimeLimit, BTDecorator);
@ -16,9 +16,9 @@ private:
protected: protected:
static void _bind_methods(); static void _bind_methods();
virtual String _generate_name() const; virtual String _generate_name() const override;
virtual void _enter(); virtual void _enter() override;
virtual int _tick(float p_delta); virtual int _tick(float p_delta) override;
public: public:
void set_time_limit(float p_value) { void set_time_limit(float p_value) {

View File

@ -13,6 +13,10 @@ def get_doc_path():
return "doc_classes" return "doc_classes"
# def get_icons_path():
# return "icons"
def get_doc_classes(): def get_doc_classes():
return [ return [
"BBAabb", "BBAabb",

View File

@ -4,35 +4,40 @@
#include "limbo_ai_editor_plugin.h" #include "limbo_ai_editor_plugin.h"
#include "core/array.h" #include "core/config/project_settings.h"
#include "core/class_db.h" #include "core/error/error_list.h"
#include "core/dictionary.h" #include "core/error/error_macros.h"
#include "core/error_list.h"
#include "core/error_macros.h"
#include "core/io/config_file.h" #include "core/io/config_file.h"
#include "core/io/dir_access.h"
#include "core/io/image_loader.h" #include "core/io/image_loader.h"
#include "core/io/resource.h"
#include "core/io/resource_loader.h" #include "core/io/resource_loader.h"
#include "core/io/resource_saver.h" #include "core/io/resource_saver.h"
#include "core/list.h"
#include "core/math/math_defs.h" #include "core/math/math_defs.h"
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/object.h" #include "core/object/callable_method_pointer.h"
#include "core/os/dir_access.h" #include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/object/script_language.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/print_string.h" #include "core/string/print_string.h"
#include "core/project_settings.h" #include "core/string/string_name.h"
#include "core/resource.h" #include "core/string/ustring.h"
#include "core/script_language.h" #include "core/templates/list.h"
#include "core/string_name.h" #include "core/templates/vector.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/ustring.h" #include "core/variant/array.h"
#include "core/variant.h" #include "core/variant/dictionary.h"
#include "core/vector.h" #include "core/variant/variant.h"
#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h" #include "editor/editor_inspector.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/script_editor_plugin.h"
#include "modules/limboai/bt/actions/bt_action.h" #include "modules/limboai/bt/actions/bt_action.h"
#include "modules/limboai/bt/behavior_tree.h" #include "modules/limboai/bt/behavior_tree.h"
#include "modules/limboai/bt/bt_task.h" #include "modules/limboai/bt/bt_task.h"
@ -51,7 +56,7 @@
#include "scene/gui/separator.h" #include "scene/gui/separator.h"
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
#include "scene/gui/tree.h" #include "scene/gui/tree.h"
#include <cstddef> #include "servers/display_server.h"
////////////////////////////// TaskTree ////////////////////////////////////// ////////////////////////////// TaskTree //////////////////////////////////////
@ -72,7 +77,7 @@ void TaskTree::_update_item(TreeItem *p_item) {
Ref<BTTask> task = p_item->get_metadata(0); Ref<BTTask> task = p_item->get_metadata(0);
ERR_FAIL_COND_MSG(!task.is_valid(), "Invalid task reference in metadata."); ERR_FAIL_COND_MSG(!task.is_valid(), "Invalid task reference in metadata.");
p_item->set_text(0, task->get_task_name()); p_item->set_text(0, task->get_task_name());
if (task->get_script_instance() && !task->get_script_instance()->get_script()->get_path().empty()) { if (task->get_script_instance() && !task->get_script_instance()->get_script()->get_path().is_empty()) {
p_item->set_icon(0, LimboAIEditor::get_task_icon(task->get_script_instance()->get_script()->get_path())); p_item->set_icon(0, LimboAIEditor::get_task_icon(task->get_script_instance()->get_script()->get_path()));
} else { } else {
p_item->set_icon(0, LimboAIEditor::get_task_icon(task->get_class())); p_item->set_icon(0, LimboAIEditor::get_task_icon(task->get_class()));
@ -83,8 +88,8 @@ void TaskTree::_update_item(TreeItem *p_item) {
p_item->erase_button(0, i); p_item->erase_button(0, i);
} }
String warning = task->get_configuration_warning(); String warning = task->get_configuration_warning();
if (!warning.empty()) { if (!warning.is_empty()) {
p_item->add_button(0, get_icon("NodeWarning", "EditorIcons"), 0, false, warning); p_item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), 0, false, warning);
} }
// TODO: Update probabilities. // TODO: Update probabilities.
@ -114,11 +119,11 @@ TreeItem *TaskTree::_find_item(const Ref<BTTask> &p_task) const {
TreeItem *item = tree->get_root(); TreeItem *item = tree->get_root();
List<TreeItem *> stack; List<TreeItem *> stack;
while (item && item->get_metadata(0) != p_task) { while (item && item->get_metadata(0) != p_task) {
if (item->get_children()) { if (item->get_child_count() > 0) {
stack.push_back(item->get_children()); stack.push_back(item->get_first_child());
} }
item = item->get_next(); item = item->get_next();
if (item == nullptr && !stack.empty()) { if (item == nullptr && !stack.is_empty()) {
item = stack.front()->get(); item = stack.front()->get();
stack.pop_front(); stack.pop_front();
} }
@ -126,19 +131,21 @@ TreeItem *TaskTree::_find_item(const Ref<BTTask> &p_task) const {
return item; return item;
} }
void TaskTree::_on_item_rmb_selected(const Vector2 &p_pos) { void TaskTree::_on_item_mouse_selected(const Vector2 &p_pos, int p_button_index) {
if (p_button_index == 2) {
emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos)); emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos));
} }
}
void TaskTree::_on_item_selected() { void TaskTree::_on_item_selected() {
if (last_selected.is_valid()) { if (last_selected.is_valid()) {
update_task(last_selected); update_task(last_selected);
if (last_selected->is_connected("changed", this, "_on_task_changed")) { if (last_selected->is_connected("changed", callable_mp(this, &TaskTree::_on_task_changed))) {
last_selected->disconnect("changed", this, "_on_task_changed"); last_selected->disconnect("changed", callable_mp(this, &TaskTree::_on_task_changed));
} }
} }
last_selected = get_selected(); last_selected = get_selected();
last_selected->connect("changed", this, "_on_task_changed"); last_selected->connect("changed", callable_mp(this, &TaskTree::_on_task_changed));
emit_signal("task_selected", last_selected); emit_signal("task_selected", last_selected);
} }
@ -153,8 +160,8 @@ void TaskTree::_on_task_changed() {
void TaskTree::load_bt(const Ref<BehaviorTree> &p_behavior_tree) { void TaskTree::load_bt(const Ref<BehaviorTree> &p_behavior_tree) {
ERR_FAIL_COND_MSG(p_behavior_tree.is_null(), "Tried to load a null tree."); ERR_FAIL_COND_MSG(p_behavior_tree.is_null(), "Tried to load a null tree.");
if (last_selected.is_valid() and last_selected->is_connected("changed", this, "_on_task_changed")) { if (last_selected.is_valid() and last_selected->is_connected("changed", callable_mp(this, &TaskTree::_on_task_changed))) {
last_selected->disconnect("changed", this, "_on_task_changed"); last_selected->disconnect("changed", callable_mp(this, &TaskTree::_on_task_changed));
} }
bt = p_behavior_tree; bt = p_behavior_tree;
@ -186,7 +193,7 @@ void TaskTree::deselect() {
} }
} }
Variant TaskTree::get_drag_data_fw(const Point2 &p_point, Control *p_from) { Variant TaskTree::_get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (editable && tree->get_item_at_position(p_point)) { if (editable && tree->get_item_at_position(p_point)) {
Dictionary drag_data; Dictionary drag_data;
drag_data["type"] = "task"; drag_data["type"] = "task";
@ -197,7 +204,7 @@ Variant TaskTree::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
return Variant(); return Variant();
} }
bool TaskTree::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { bool TaskTree::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
if (!editable) { if (!editable) {
return false; return false;
} }
@ -224,7 +231,7 @@ bool TaskTree::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
return false; return false;
} }
void TaskTree::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { void TaskTree::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data; Dictionary d = p_data;
TreeItem *item = tree->get_item_at_position(p_point); TreeItem *item = tree->get_item_at_position(p_point);
if (item && d.has("task")) { if (item && d.has("task")) {
@ -234,7 +241,7 @@ void TaskTree::drop_data_fw(const Point2 &p_point, const Variant &p_data, Contro
} }
void TaskTree::_bind_methods() { void TaskTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_on_item_rmb_selected"), &TaskTree::_on_item_rmb_selected); ClassDB::bind_method(D_METHOD("_on_item_mouse_selected"), &TaskTree::_on_item_mouse_selected);
ClassDB::bind_method(D_METHOD("_on_item_selected"), &TaskTree::_on_item_selected); ClassDB::bind_method(D_METHOD("_on_item_selected"), &TaskTree::_on_item_selected);
ClassDB::bind_method(D_METHOD("_on_item_double_clicked"), &TaskTree::_on_item_double_clicked); ClassDB::bind_method(D_METHOD("_on_item_double_clicked"), &TaskTree::_on_item_double_clicked);
ClassDB::bind_method(D_METHOD("_on_task_changed"), &TaskTree::_on_task_changed); ClassDB::bind_method(D_METHOD("_on_task_changed"), &TaskTree::_on_task_changed);
@ -245,9 +252,9 @@ void TaskTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_selected"), &TaskTree::get_selected); ClassDB::bind_method(D_METHOD("get_selected"), &TaskTree::get_selected);
ClassDB::bind_method(D_METHOD("deselect"), &TaskTree::deselect); ClassDB::bind_method(D_METHOD("deselect"), &TaskTree::deselect);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &TaskTree::get_drag_data_fw); ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &TaskTree::_get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &TaskTree::can_drop_data_fw); ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &TaskTree::_can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &TaskTree::drop_data_fw); ClassDB::bind_method(D_METHOD("_drop_data_fw"), &TaskTree::_drop_data_fw);
ADD_SIGNAL(MethodInfo("rmb_pressed")); ADD_SIGNAL(MethodInfo("rmb_pressed"));
ADD_SIGNAL(MethodInfo("task_selected")); ADD_SIGNAL(MethodInfo("task_selected"));
@ -266,19 +273,20 @@ TaskTree::TaskTree() {
tree->set_columns(2); tree->set_columns(2);
tree->set_column_expand(0, true); tree->set_column_expand(0, true);
tree->set_column_expand(1, false); tree->set_column_expand(1, false);
tree->set_column_min_width(1, 64); tree->set_column_custom_minimum_width(1, 64);
tree->set_anchor(MARGIN_RIGHT, ANCHOR_END); tree->set_anchor(SIDE_RIGHT, ANCHOR_END);
tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); tree->set_anchor(SIDE_BOTTOM, ANCHOR_END);
tree->set_allow_rmb_select(true); tree->set_allow_rmb_select(true);
tree->connect("item_rmb_selected", this, "_on_item_rmb_selected"); tree->connect("item_mouse_selected", callable_mp(this, &TaskTree::_on_item_mouse_selected));
tree->connect("item_selected", this, "_on_item_selected"); tree->connect("item_selected", callable_mp(this, &TaskTree::_on_item_selected));
tree->connect("item_activated", this, "_on_item_double_clicked"); tree->connect("item_activated", callable_mp(this, &TaskTree::_on_item_double_clicked));
tree->set_drag_forwarding(this); tree->set_drag_forwarding(this);
} }
TaskTree::~TaskTree() { TaskTree::~TaskTree() {
if (last_selected.is_valid() and last_selected->is_connected("changed", this, "_on_task_changed")) { if (last_selected.is_valid() and last_selected->is_connected("changed", callable_mp(this, &TaskTree::_on_task_changed))) {
last_selected->disconnect("changed", this, "_on_task_changed"); last_selected->disconnect("changed", callable_mp(this, &TaskTree::_on_task_changed));
} }
} }
@ -292,12 +300,12 @@ void TaskSection::_on_task_button_pressed(const StringName &p_task) {
void TaskSection::_on_header_pressed() { void TaskSection::_on_header_pressed() {
tasks_container->set_visible(!tasks_container->is_visible()); tasks_container->set_visible(!tasks_container->is_visible());
section_header->set_icon(tasks_container->is_visible() ? get_icon("GuiTreeArrowDown", "EditorIcons") : get_icon("GuiTreeArrowRight", "EditorIcons")); section_header->set_icon(tasks_container->is_visible() ? get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")) : get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")));
} }
void TaskSection::set_filter(String p_filter_text) { void TaskSection::set_filter(String p_filter_text) {
int num_hidden = 0; int num_hidden = 0;
if (p_filter_text.empty()) { if (p_filter_text.is_empty()) {
for (int i = 0; i < tasks_container->get_child_count(); i++) { for (int i = 0; i < tasks_container->get_child_count(); i++) {
Object::cast_to<Button>(tasks_container->get_child(i))->show(); Object::cast_to<Button>(tasks_container->get_child(i))->show();
} }
@ -316,13 +324,13 @@ void TaskSection::add_task_button(String p_name, const Ref<Texture> &icon, Varia
Button *btn = memnew(Button); Button *btn = memnew(Button);
btn->set_text(p_name); btn->set_text(p_name);
btn->set_icon(icon); btn->set_icon(icon);
btn->connect("pressed", this, "_on_task_button_pressed", varray(p_meta)); btn->connect("pressed", callable_mp(this, &TaskSection::_on_task_button_pressed).bind(p_meta));
tasks_container->add_child(btn); tasks_container->add_child(btn);
} }
void TaskSection::set_collapsed(bool p_collapsed) { void TaskSection::set_collapsed(bool p_collapsed) {
tasks_container->set_visible(!p_collapsed); tasks_container->set_visible(!p_collapsed);
section_header->set_icon(p_collapsed ? get_icon("GuiTreeArrowRight", "EditorIcons") : get_icon("GuiTreeArrowDown", "EditorIcons")); section_header->set_icon(p_collapsed ? get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")) : get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
} }
bool TaskSection::is_collapsed() const { bool TaskSection::is_collapsed() const {
@ -336,13 +344,13 @@ void TaskSection::_bind_methods() {
ADD_SIGNAL(MethodInfo("task_button_pressed")); ADD_SIGNAL(MethodInfo("task_button_pressed"));
} }
TaskSection::TaskSection(String p_category_name, EditorNode *p_editor) { TaskSection::TaskSection(String p_category_name) {
section_header = memnew(Button); section_header = memnew(Button);
add_child(section_header); add_child(section_header);
section_header->set_text(p_category_name); section_header->set_text(p_category_name);
section_header->set_icon(p_editor->get_gui_base()->get_icon("GuiTreeArrowDown", "EditorIcons")); section_header->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
section_header->set_focus_mode(FOCUS_NONE); section_header->set_focus_mode(FOCUS_NONE);
section_header->connect("pressed", this, "_on_header_pressed"); section_header->connect("pressed", callable_mp(this, &TaskSection::_on_header_pressed));
tasks_container = memnew(HFlowContainer); tasks_container = memnew(HFlowContainer);
add_child(tasks_container); add_child(tasks_container);
@ -367,13 +375,13 @@ void TaskPanel::_on_filter_text_changed(String p_text) {
} }
void TaskPanel::refresh() { void TaskPanel::refresh() {
filter_edit->set_right_icon(get_icon("Search", "EditorIcons")); filter_edit->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
Set<String> collapsed_sections; HashSet<String> collapsed_sections;
if (sections->get_child_count() == 0) { if (sections->get_child_count() == 0) {
// Restore collapsed state from config. // Restore collapsed state from config.
ConfigFile conf; ConfigFile conf;
String conf_path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("limbo_ai.cfg"); String conf_path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("limbo_ai.cfg");
if (conf.load(conf_path) == OK) { if (conf.load(conf_path) == OK) {
Variant value = conf.get_value("bt_editor", "collapsed_sections", Array()); Variant value = conf.get_value("bt_editor", "collapsed_sections", Array());
if (value.is_array()) { if (value.is_array()) {
@ -391,7 +399,7 @@ void TaskPanel::refresh() {
if (sec->is_collapsed()) { if (sec->is_collapsed()) {
collapsed_sections.insert(sec->get_category_name()); collapsed_sections.insert(sec->get_category_name());
} }
sections->get_child(i)->queue_delete(); sections->get_child(i)->queue_free();
} }
} }
@ -421,7 +429,9 @@ void TaskPanel::refresh() {
_populate_from_user_dir(dir3, &categories); _populate_from_user_dir(dir3, &categories);
List<String> keys; List<String> keys;
categories.get_key_list(&keys); for (const KeyValue<String, List<String>> &K : categories) {
keys.push_back(K.key);
}
keys.sort(); keys.sort();
for (List<String>::Element *E = keys.front(); E; E = E->next()) { for (List<String>::Element *E = keys.front(); E; E = E->next()) {
String cat = E->get(); String cat = E->get();
@ -431,7 +441,7 @@ void TaskPanel::refresh() {
continue; continue;
} }
TaskSection *sec = memnew(TaskSection(cat, editor)); TaskSection *sec = memnew(TaskSection(cat));
for (List<String>::Element *E = task_list.front(); E; E = E->next()) { for (List<String>::Element *E = task_list.front(); E; E = E->next()) {
String meta = E->get(); String meta = E->get();
String tname; String tname;
@ -441,7 +451,7 @@ void TaskPanel::refresh() {
sec->add_task_button(tname, icon, meta); sec->add_task_button(tname, icon, meta);
} }
sec->set_filter(""); sec->set_filter("");
sec->connect("task_button_pressed", this, "_on_task_button_pressed"); sec->connect("task_button_pressed", callable_mp(this, &TaskPanel::_on_task_button_pressed));
sections->add_child(sec); sections->add_child(sec);
sec->set_collapsed(collapsed_sections.has(cat)); sec->set_collapsed(collapsed_sections.has(cat));
} }
@ -457,14 +467,14 @@ void TaskPanel::_populate_core_tasks_from_class(const StringName &p_base_class,
} }
void TaskPanel::_populate_from_user_dir(String p_path, HashMap<String, List<String>> *p_categories) { void TaskPanel::_populate_from_user_dir(String p_path, HashMap<String, List<String>> *p_categories) {
if (p_path.empty()) { if (p_path.is_empty()) {
return; return;
} }
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (dir->change_dir(p_path) == OK) { if (dir->change_dir(p_path) == OK) {
dir->list_dir_begin(); dir->list_dir_begin();
String fn = dir->get_next(); String fn = dir->get_next();
while (!fn.empty()) { while (!fn.is_empty()) {
if (dir->current_is_dir() && fn != "..") { if (dir->current_is_dir() && fn != "..") {
String full_path; String full_path;
String category; String category;
@ -472,12 +482,12 @@ void TaskPanel::_populate_from_user_dir(String p_path, HashMap<String, List<Stri
full_path = p_path; full_path = p_path;
category = "User"; category = "User";
} else { } else {
full_path = p_path.plus_file(fn); full_path = p_path.path_join(fn);
category = fn.capitalize(); category = fn.capitalize();
} }
if (!p_categories->has(category)) { if (!p_categories->has(category)) {
p_categories->set(category, List<String>()); p_categories->insert(category, List<String>());
} }
_populate_scripted_tasks_from_dir(full_path, &p_categories->get(category)); _populate_scripted_tasks_from_dir(full_path, &p_categories->get(category));
@ -488,20 +498,19 @@ void TaskPanel::_populate_from_user_dir(String p_path, HashMap<String, List<Stri
} else { } else {
ERR_FAIL_MSG(vformat("Failed to list \"%s\" directory.", p_path)); ERR_FAIL_MSG(vformat("Failed to list \"%s\" directory.", p_path));
} }
memdelete(dir);
} }
void TaskPanel::_populate_scripted_tasks_from_dir(String p_path, List<String> *p_task_classes) { void TaskPanel::_populate_scripted_tasks_from_dir(String p_path, List<String> *p_task_classes) {
if (p_path.empty()) { if (p_path.is_empty()) {
return; return;
} }
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (dir->change_dir(p_path) == OK) { if (dir->change_dir(p_path) == OK) {
dir->list_dir_begin(); dir->list_dir_begin();
String fn = dir->get_next(); String fn = dir->get_next();
while (!fn.empty()) { while (!fn.is_empty()) {
if (fn.ends_with(".gd")) { if (fn.ends_with(".gd")) {
String full_path = p_path.plus_file(fn); String full_path = p_path.path_join(fn);
p_task_classes->push_back(full_path); p_task_classes->push_back(full_path);
} }
fn = dir->get_next(); fn = dir->get_next();
@ -510,7 +519,6 @@ void TaskPanel::_populate_scripted_tasks_from_dir(String p_path, List<String> *p
} else { } else {
ERR_FAIL_MSG(vformat("Failed to list \"%s\" directory.", p_path)); ERR_FAIL_MSG(vformat("Failed to list \"%s\" directory.", p_path));
} }
memdelete(dir);
} }
void TaskPanel::_notification(int p_what) { void TaskPanel::_notification(int p_what) {
@ -526,7 +534,7 @@ void TaskPanel::_notification(int p_what) {
} }
} }
ConfigFile conf; ConfigFile conf;
String conf_path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("limbo_ai.cfg"); String conf_path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("limbo_ai.cfg");
conf.load(conf_path); conf.load(conf_path);
conf.set_value("bt_editor", "collapsed_sections", collapsed_sections); conf.set_value("bt_editor", "collapsed_sections", collapsed_sections);
conf.save(conf_path); conf.save(conf_path);
@ -541,16 +549,14 @@ void TaskPanel::_bind_methods() {
ADD_SIGNAL(MethodInfo("task_selected")); ADD_SIGNAL(MethodInfo("task_selected"));
} }
TaskPanel::TaskPanel(EditorNode *p_editor) { TaskPanel::TaskPanel() {
editor = p_editor;
VBoxContainer *vb = memnew(VBoxContainer); VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb); add_child(vb);
filter_edit = memnew(LineEdit); filter_edit = memnew(LineEdit);
vb->add_child(filter_edit); vb->add_child(filter_edit);
filter_edit->set_clear_button_enabled(true); filter_edit->set_clear_button_enabled(true);
filter_edit->connect("text_changed", this, "_on_filter_text_changed"); filter_edit->connect("text_changed", callable_mp(this, &TaskPanel::_on_filter_text_changed));
ScrollContainer *sc = memnew(ScrollContainer); ScrollContainer *sc = memnew(ScrollContainer);
vb->add_child(sc); vb->add_child(sc);
@ -588,14 +594,14 @@ void LimboAIEditor::_add_task(const Ref<BTTask> &p_task) {
void LimboAIEditor::_update_header() const { void LimboAIEditor::_update_header() const {
String text = task_tree->get_bt()->get_path(); String text = task_tree->get_bt()->get_path();
if (text.empty()) { if (text.is_empty()) {
text = TTR("New Behavior Tree"); text = TTR("New Behavior Tree");
} else if (dirty.has(task_tree->get_bt())) { } else if (dirty.has(task_tree->get_bt())) {
text += "(*)"; text += "(*)";
} }
header->set_text(text); header->set_text(text);
header->set_icon(editor->get_object_icon(task_tree->get_bt().ptr(), "BehaviorTree")); header->set_icon(EditorNode::get_singleton()->get_object_icon(task_tree->get_bt().ptr(), "BehaviorTree"));
} }
void LimboAIEditor::_update_history_buttons() { void LimboAIEditor::_update_history_buttons() {
@ -606,20 +612,20 @@ void LimboAIEditor::_update_history_buttons() {
void LimboAIEditor::_new_bt() { void LimboAIEditor::_new_bt() {
BehaviorTree *bt = memnew(BehaviorTree); BehaviorTree *bt = memnew(BehaviorTree);
bt->set_root_task(memnew(BTSelector)); bt->set_root_task(memnew(BTSelector));
editor->edit_resource(bt); EditorNode::get_singleton()->edit_resource(bt);
} }
void LimboAIEditor::_save_bt(String p_path) { void LimboAIEditor::_save_bt(String p_path) {
ERR_FAIL_COND_MSG(p_path.empty(), "Empty p_path"); ERR_FAIL_COND_MSG(p_path.is_empty(), "Empty 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.");
task_tree->get_bt()->set_path(p_path, true); task_tree->get_bt()->set_path(p_path, true);
ResourceSaver::save(p_path, task_tree->get_bt(), ResourceSaver::FLAG_CHANGE_PATH); ResourceSaver::save(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH);
_update_header(); _update_header();
_mark_as_dirty(false); _mark_as_dirty(false);
} }
void LimboAIEditor::_load_bt(String p_path) { void LimboAIEditor::_load_bt(String p_path) {
ERR_FAIL_COND_MSG(p_path.empty(), "Empty p_path"); ERR_FAIL_COND_MSG(p_path.is_empty(), "Empty p_path");
Ref<BehaviorTree> bt = ResourceLoader::load(p_path, "BehaviorTree"); Ref<BehaviorTree> bt = ResourceLoader::load(p_path, "BehaviorTree");
if (history.find(bt) != -1) { if (history.find(bt) != -1) {
@ -627,7 +633,7 @@ void LimboAIEditor::_load_bt(String p_path) {
history.push_back(bt); history.push_back(bt);
} }
editor->edit_resource(bt); EditorNode::get_singleton()->edit_resource(bt);
} }
void LimboAIEditor::edit_bt(Ref<BehaviorTree> p_behavior_tree, bool p_force_refresh) { void LimboAIEditor::edit_bt(Ref<BehaviorTree> p_behavior_tree, bool p_force_refresh) {
@ -671,12 +677,12 @@ void LimboAIEditor::_on_tree_rmb(const Vector2 &p_menu_pos) {
menu->set_position(p_menu_pos); menu->set_position(p_menu_pos);
menu->clear(); menu->clear();
menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Remove"), ACTION_REMOVE); menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove"), ACTION_REMOVE);
menu->add_separator(); menu->add_separator();
menu->add_icon_item(get_icon("MoveUp", "EditorIcons"), TTR("Move Up"), ACTION_MOVE_UP); menu->add_icon_item(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), TTR("Move Up"), ACTION_MOVE_UP);
menu->add_icon_item(get_icon("MoveDown", "EditorIcons"), TTR("Move Down"), ACTION_MOVE_DOWN); menu->add_icon_item(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), TTR("Move Down"), ACTION_MOVE_DOWN);
menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate"), ACTION_DUPLICATE); menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate"), ACTION_DUPLICATE);
menu->add_icon_item(get_icon("NewRoot", "EditorIcons"), TTR("Make Root"), ACTION_MAKE_ROOT); menu->add_icon_item(get_theme_icon(SNAME("NewRoot"), SNAME("EditorIcons")), TTR("Make Root"), ACTION_MAKE_ROOT);
menu->popup(); menu->popup();
} }
@ -692,7 +698,7 @@ void LimboAIEditor::_on_action_selected(int p_id) {
sel->get_parent()->remove_child(sel); sel->get_parent()->remove_child(sel);
} }
task_tree->update_tree(); task_tree->update_tree();
editor->edit_node(nullptr); EditorNode::get_singleton()->edit_node(nullptr);
_mark_as_dirty(true); _mark_as_dirty(true);
} }
} break; } break;
@ -750,8 +756,8 @@ void LimboAIEditor::_on_action_selected(int p_id) {
} }
} }
void LimboAIEditor::_on_tree_task_selected(const Ref<BTTask> &p_task) const { void LimboAIEditor::_on_tree_task_selected(const Ref<BTTask> &p_task) {
editor->edit_resource(p_task); EditorNode::get_singleton()->edit_resource(p_task);
} }
void LimboAIEditor::_on_tree_task_double_clicked() { void LimboAIEditor::_on_tree_task_double_clicked() {
@ -769,11 +775,11 @@ void LimboAIEditor::_on_panel_task_selected(String p_task) {
if (p_task.begins_with("res:")) { if (p_task.begins_with("res:")) {
Ref<Script> script = ResourceLoader::load(p_task, "Script"); Ref<Script> script = ResourceLoader::load(p_task, "Script");
ERR_FAIL_COND_MSG(script.is_null() || !script->is_valid(), vformat("LimboAI: Failed to instance task. Bad script: %s", p_task)); ERR_FAIL_COND_MSG(script.is_null() || !script->is_valid(), vformat("LimboAI: Failed to instance task. Bad script: %s", p_task));
Variant inst = ClassDB::instance(script->get_instance_base_type()); Variant inst = ClassDB::instantiate(script->get_instance_base_type());
ERR_FAIL_COND_MSG(inst.is_zero(), vformat("LimboAI: Failed to instance base type \"%s\".", script->get_instance_base_type())); ERR_FAIL_COND_MSG(inst.is_zero(), vformat("LimboAI: Failed to instance base type \"%s\".", script->get_instance_base_type()));
if (unlikely(!((Object *)inst)->is_class("BTTask"))) { if (unlikely(!((Object *)inst)->is_class("BTTask"))) {
if (!inst.is_ref()) { if (!inst.is_ref_counted()) {
memdelete((Object *)inst); memdelete((Object *)inst);
} }
ERR_PRINT(vformat("LimboAI: Failed to instance task. Script is not a BTTask: %s", p_task)); ERR_PRINT(vformat("LimboAI: Failed to instance task. Script is not a BTTask: %s", p_task));
@ -781,31 +787,31 @@ void LimboAIEditor::_on_panel_task_selected(String p_task) {
} }
if (inst && script.is_valid()) { if (inst && script.is_valid()) {
((Object *)inst)->set_script(script.get_ref_ptr()); ((Object *)inst)->set_script(script);
_add_task(Variant(inst)); _add_task(Variant(inst));
} }
} else { } else {
_add_task(Ref<BTTask>(ClassDB::instance(p_task))); _add_task(Ref<BTTask>(ClassDB::instantiate(p_task)));
} }
} }
void LimboAIEditor::_on_visibility_changed() const { void LimboAIEditor::_on_visibility_changed() {
if (is_visible()) { if (task_tree->is_visible()) {
Ref<BTTask> sel = task_tree->get_selected(); Ref<BTTask> sel = task_tree->get_selected();
if (sel.is_valid()) { if (sel.is_valid()) {
editor->edit_resource(sel); EditorNode::get_singleton()->edit_resource(sel);
} else if (task_tree->get_bt().is_valid() && editor->get_inspector()->get_edited_object() != task_tree->get_bt().ptr()) { } else if (task_tree->get_bt().is_valid() && InspectorDock::get_inspector_singleton()->get_edited_object() != task_tree->get_bt().ptr()) {
editor->edit_resource(task_tree->get_bt()); EditorNode::get_singleton()->edit_resource(task_tree->get_bt());
} }
task_panel->refresh(); task_panel->refresh();
} }
} }
void LimboAIEditor::_on_header_pressed() const { void LimboAIEditor::_on_header_pressed() {
_update_header(); _update_header();
task_tree->deselect(); task_tree->deselect();
editor->edit_resource(task_tree->get_bt()); EditorNode::get_singleton()->edit_resource(task_tree->get_bt());
} }
void LimboAIEditor::_on_save_pressed() { void LimboAIEditor::_on_save_pressed() {
@ -813,7 +819,7 @@ void LimboAIEditor::_on_save_pressed() {
return; return;
} }
String path = task_tree->get_bt()->get_path(); String path = task_tree->get_bt()->get_path();
if (path.empty()) { if (path.is_empty()) {
save_dialog->popup_centered_ratio(); save_dialog->popup_centered_ratio();
} else { } else {
_save_bt(path); _save_bt(path);
@ -822,12 +828,12 @@ void LimboAIEditor::_on_save_pressed() {
void LimboAIEditor::_on_history_back() { void LimboAIEditor::_on_history_back() {
idx_history = MAX(idx_history - 1, 0); idx_history = MAX(idx_history - 1, 0);
editor->edit_resource(history[idx_history]); EditorNode::get_singleton()->edit_resource(history[idx_history]);
} }
void LimboAIEditor::_on_history_forward() { void LimboAIEditor::_on_history_forward() {
idx_history = MIN(idx_history + 1, history.size() - 1); idx_history = MIN(idx_history + 1, history.size() - 1);
editor->edit_resource(history[idx_history]); EditorNode::get_singleton()->edit_resource(history[idx_history]);
} }
void LimboAIEditor::_on_task_dragged(Ref<BTTask> p_task, Ref<BTTask> p_to_task, int p_type) { void LimboAIEditor::_on_task_dragged(Ref<BTTask> p_task, Ref<BTTask> p_to_task, int p_type) {
@ -872,10 +878,9 @@ void LimboAIEditor::_on_resources_reload(const Vector<String> &p_resources) {
disk_changed_list->clear(); disk_changed_list->clear();
disk_changed_list->set_hide_root(true); disk_changed_list->set_hide_root(true);
disk_changed_list->create_item(); disk_changed_list->create_item();
for (Set<String>::Element *E = disk_changed_files.front(); E; E = E->next()) { for (const String &fn : disk_changed_files) {
// for (int i = 0; i < disk_changed_files.size(); i++) {
TreeItem *ti = disk_changed_list->create_item(); TreeItem *ti = disk_changed_list->create_item();
ti->set_text(0, E->get()); ti->set_text(0, fn);
} }
if (!is_visible()) { if (!is_visible()) {
@ -886,9 +891,9 @@ void LimboAIEditor::_on_resources_reload(const Vector<String> &p_resources) {
} }
void LimboAIEditor::_reload_modified() { void LimboAIEditor::_reload_modified() {
for (Set<String>::Element *E = disk_changed_files.front(); E; E = E->next()) { for (const String &fn : disk_changed_files) {
for (int j = 0; j < history.size(); j++) { for (int j = 0; j < history.size(); j++) {
if (history.get(j)->get_path() == E->get()) { if (history.get(j)->get_path() == fn) {
dirty.erase(history.get(j)); dirty.erase(history.get(j));
history.get(j)->get_root_task()->clear_internal_resource_paths(); history.get(j)->get_root_task()->clear_internal_resource_paths();
history.get(j)->reload_from_file(); history.get(j)->reload_from_file();
@ -902,10 +907,10 @@ void LimboAIEditor::_reload_modified() {
} }
void LimboAIEditor::_resave_modified(String _str) { void LimboAIEditor::_resave_modified(String _str) {
for (Set<String>::Element *E = disk_changed_files.front(); E; E = E->next()) { for (const String &fn : disk_changed_files) {
for (int j = 0; j < history.size(); j++) { for (int j = 0; j < history.size(); j++) {
if (history.get(j)->get_path() == E->get()) { if (history.get(j)->get_path() == fn) {
ResourceSaver::save(history.get(j)->get_path(), history.get(j)); ResourceSaver::save(history.get(j), history.get(j)->get_path());
} }
} }
} }
@ -917,7 +922,7 @@ void LimboAIEditor::_rename_task(String _str) {
ERR_FAIL_COND(!task_tree->get_selected().is_valid()); ERR_FAIL_COND(!task_tree->get_selected().is_valid());
task_tree->get_selected()->set_custom_name(rename_edit->get_text()); task_tree->get_selected()->set_custom_name(rename_edit->get_text());
rename_dialog->hide(); rename_dialog->hide();
editor->edit_resource(task_tree->get_selected()); EditorNode::get_singleton()->edit_resource(task_tree->get_selected());
} }
void LimboAIEditor::apply_changes() { void LimboAIEditor::apply_changes() {
@ -925,7 +930,7 @@ void LimboAIEditor::apply_changes() {
Ref<BehaviorTree> bt = history.get(i); Ref<BehaviorTree> bt = history.get(i);
String path = bt->get_path(); String path = bt->get_path();
if (ResourceLoader::exists(path)) { if (ResourceLoader::exists(path)) {
ResourceSaver::save(path, bt); ResourceSaver::save(bt, path);
} }
dirty.clear(); dirty.clear();
_update_header(); _update_header();
@ -941,7 +946,7 @@ Ref<Texture> LimboAIEditor::get_task_icon(String p_script_path_or_class) {
while (base_script.is_valid()) { while (base_script.is_valid()) {
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name); String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
if (!icon_path.empty()) { if (!icon_path.is_empty()) {
Ref<Image> img = memnew(Image); Ref<Image> img = memnew(Image);
Error err = ImageLoader::load_image(icon_path, img); Error err = ImageLoader::load_image(icon_path, img);
if (err == OK) { if (err == OK) {
@ -964,14 +969,14 @@ void LimboAIEditor::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
ConfigFile conf; ConfigFile conf;
String conf_path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("limbo_ai.cfg"); String conf_path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("limbo_ai.cfg");
if (conf.load(conf_path) == OK) { if (conf.load(conf_path) == OK) {
hsc->set_split_offset(conf.get_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset())); hsc->set_split_offset(conf.get_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset()));
} }
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
ConfigFile conf; ConfigFile conf;
String conf_path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("limbo_ai.cfg"); String conf_path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("limbo_ai.cfg");
conf.load(conf_path); conf.load(conf_path);
conf.set_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset()); conf.set_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset());
conf.save(conf_path); conf.save(conf_path);
@ -1003,28 +1008,28 @@ void LimboAIEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_rename_task"), &LimboAIEditor::_rename_task, String()); ClassDB::bind_method(D_METHOD("_rename_task"), &LimboAIEditor::_rename_task, String());
} }
LimboAIEditor::LimboAIEditor(EditorNode *p_editor) { LimboAIEditor::LimboAIEditor() {
editor = p_editor; idx_history = 0;
save_dialog = memnew(FileDialog); save_dialog = memnew(FileDialog);
add_child(save_dialog); add_child(save_dialog);
save_dialog->set_mode(FileDialog::MODE_SAVE_FILE); save_dialog->set_file_mode(FileDialog::FILE_MODE_SAVE_FILE);
save_dialog->set_title("Save Behavior Tree"); save_dialog->set_title("Save Behavior Tree");
save_dialog->add_filter("*.tres"); save_dialog->add_filter("*.tres");
save_dialog->connect("file_selected", this, "_save_bt"); save_dialog->connect("file_selected", callable_mp(this, &LimboAIEditor::_save_bt));
save_dialog->hide(); save_dialog->hide();
load_dialog = memnew(FileDialog); load_dialog = memnew(FileDialog);
add_child(load_dialog); add_child(load_dialog);
load_dialog->set_mode(FileDialog::MODE_OPEN_FILE); load_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
load_dialog->set_title("Load Behavior Tree"); load_dialog->set_title("Load Behavior Tree");
load_dialog->add_filter("*.tres"); load_dialog->add_filter("*.tres");
load_dialog->connect("file_selected", this, "_load_bt"); load_dialog->connect("file_selected", callable_mp(this, &LimboAIEditor::_load_bt));
load_dialog->hide(); load_dialog->hide();
VBoxContainer *vb = memnew(VBoxContainer); VBoxContainer *vb = memnew(VBoxContainer);
vb->set_anchor(MARGIN_RIGHT, ANCHOR_END); vb->set_anchor(SIDE_RIGHT, ANCHOR_END);
vb->set_anchor(MARGIN_BOTTOM, ANCHOR_END); vb->set_anchor(SIDE_BOTTOM, ANCHOR_END);
add_child(vb); add_child(vb);
HBoxContainer *panel = memnew(HBoxContainer); HBoxContainer *panel = memnew(HBoxContainer);
@ -1032,29 +1037,29 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
Button *selector_btn = memnew(Button); Button *selector_btn = memnew(Button);
selector_btn->set_text(TTR("Selector")); selector_btn->set_text(TTR("Selector"));
selector_btn->set_tooltip(TTR("Add Selector task.")); selector_btn->set_tooltip_text(TTR("Add Selector task."));
selector_btn->set_icon(editor->get_class_icon("BTSelector")); selector_btn->set_icon(EditorNode::get_singleton()->get_class_icon("BTSelector"));
selector_btn->set_flat(true); selector_btn->set_flat(true);
selector_btn->set_focus_mode(Control::FOCUS_NONE); selector_btn->set_focus_mode(Control::FOCUS_NONE);
selector_btn->connect("pressed", this, "_add_task_with_prototype", varray(Ref<BTTask>(memnew(BTSelector)))); selector_btn->connect("pressed", callable_mp(this, &LimboAIEditor::_add_task_with_prototype).bind(Ref<BTTask>(memnew(BTSelector))));
panel->add_child(selector_btn); panel->add_child(selector_btn);
Button *sequence_btn = memnew(Button); Button *sequence_btn = memnew(Button);
sequence_btn->set_text(TTR("Sequence")); sequence_btn->set_text(TTR("Sequence"));
sequence_btn->set_tooltip(TTR("Add Sequence task.")); sequence_btn->set_tooltip_text(TTR("Add Sequence task."));
sequence_btn->set_icon(editor->get_class_icon("BTSequence")); sequence_btn->set_icon(EditorNode::get_singleton()->get_class_icon("BTSequence"));
sequence_btn->set_flat(true); sequence_btn->set_flat(true);
sequence_btn->set_focus_mode(Control::FOCUS_NONE); sequence_btn->set_focus_mode(Control::FOCUS_NONE);
sequence_btn->connect("pressed", this, "_add_task_with_prototype", varray(Ref<BTTask>(memnew(BTSequence)))); sequence_btn->connect("pressed", callable_mp(this, &LimboAIEditor::_add_task_with_prototype).bind(Ref<BTTask>(memnew(BTSequence))));
panel->add_child(sequence_btn); panel->add_child(sequence_btn);
Button *parallel_btn = memnew(Button); Button *parallel_btn = memnew(Button);
parallel_btn->set_text(TTR("Parallel")); parallel_btn->set_text(TTR("Parallel"));
parallel_btn->set_tooltip(TTR("Add Parallel task.")); parallel_btn->set_tooltip_text(TTR("Add Parallel task."));
parallel_btn->set_icon(editor->get_class_icon("BTParallel")); parallel_btn->set_icon(EditorNode::get_singleton()->get_class_icon("BTParallel"));
parallel_btn->set_flat(true); parallel_btn->set_flat(true);
parallel_btn->set_focus_mode(Control::FOCUS_NONE); parallel_btn->set_focus_mode(Control::FOCUS_NONE);
parallel_btn->connect("pressed", this, "_add_task_with_prototype", varray(Ref<BTTask>(memnew(BTParallel)))); parallel_btn->connect("pressed", callable_mp(this, &LimboAIEditor::_add_task_with_prototype).bind(Ref<BTTask>(memnew(BTParallel))));
panel->add_child(parallel_btn); panel->add_child(parallel_btn);
panel->add_child(memnew(VSeparator)); panel->add_child(memnew(VSeparator));
@ -1062,37 +1067,37 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
Button *new_btn = memnew(Button); Button *new_btn = memnew(Button);
panel->add_child(new_btn); panel->add_child(new_btn);
new_btn->set_text(TTR("New")); new_btn->set_text(TTR("New"));
new_btn->set_tooltip(TTR("Create new behavior tree.")); new_btn->set_tooltip_text(TTR("Create new behavior tree."));
new_btn->set_icon(editor->get_gui_base()->get_icon("New", "EditorIcons")); new_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("New"), SNAME("EditorIcons")));
new_btn->set_flat(true); new_btn->set_flat(true);
new_btn->set_focus_mode(Control::FOCUS_NONE); new_btn->set_focus_mode(Control::FOCUS_NONE);
new_btn->connect("pressed", this, "_new_bt"); new_btn->connect("pressed", callable_mp(this, &LimboAIEditor::_new_bt));
Button *load_btn = memnew(Button); Button *load_btn = memnew(Button);
panel->add_child(load_btn); panel->add_child(load_btn);
load_btn->set_text(TTR("Load")); load_btn->set_text(TTR("Load"));
load_btn->set_tooltip(TTR("Load behavior tree.")); load_btn->set_tooltip_text(TTR("Load behavior tree."));
load_btn->set_icon(editor->get_gui_base()->get_icon("Load", "EditorIcons")); load_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Load"), SNAME("EditorIcons")));
load_btn->set_flat(true); load_btn->set_flat(true);
load_btn->set_focus_mode(Control::FOCUS_NONE); load_btn->set_focus_mode(Control::FOCUS_NONE);
load_btn->connect("pressed", load_dialog, "popup_centered_ratio"); load_btn->connect("pressed", callable_mp(load_dialog, &FileDialog::popup_file_dialog));
Button *save_btn = memnew(Button); Button *save_btn = memnew(Button);
panel->add_child(save_btn); panel->add_child(save_btn);
save_btn->set_text(TTR("Save")); save_btn->set_text(TTR("Save"));
save_btn->set_tooltip(TTR("Save current behavior tree.")); save_btn->set_tooltip_text(TTR("Save current behavior tree."));
save_btn->set_icon(editor->get_gui_base()->get_icon("Save", "EditorIcons")); save_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
save_btn->set_flat(true); save_btn->set_flat(true);
save_btn->set_focus_mode(Control::FOCUS_NONE); save_btn->set_focus_mode(Control::FOCUS_NONE);
save_btn->connect("pressed", this, "_on_save_pressed"); save_btn->connect("pressed", callable_mp(this, &LimboAIEditor::_on_save_pressed));
panel->add_child(memnew(VSeparator)); panel->add_child(memnew(VSeparator));
Button *new_script_btn = memnew(Button); Button *new_script_btn = memnew(Button);
panel->add_child(new_script_btn); panel->add_child(new_script_btn);
new_script_btn->set_text(TTR("New Task")); new_script_btn->set_text(TTR("New Task"));
new_script_btn->set_tooltip(TTR("Create new task script and edit it.")); new_script_btn->set_tooltip_text(TTR("Create new task script and edit it."));
new_script_btn->set_icon(editor->get_gui_base()->get_icon("ScriptCreate", "EditorIcons")); new_script_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")));
new_script_btn->set_flat(true); new_script_btn->set_flat(true);
new_script_btn->set_focus_mode(Control::FOCUS_NONE); new_script_btn->set_focus_mode(Control::FOCUS_NONE);
@ -1101,24 +1106,24 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
nav->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END); nav->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
history_back = memnew(Button); history_back = memnew(Button);
history_back->set_icon(editor->get_gui_base()->get_icon("Back", "EditorIcons")); history_back->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
history_back->set_flat(true); history_back->set_flat(true);
history_back->set_focus_mode(FOCUS_NONE); history_back->set_focus_mode(FOCUS_NONE);
history_back->connect("pressed", this, "_on_history_back"); history_back->connect("pressed", callable_mp(this, &LimboAIEditor::_on_history_back));
nav->add_child(history_back); nav->add_child(history_back);
history_forward = memnew(Button); history_forward = memnew(Button);
history_forward->set_icon(editor->get_gui_base()->get_icon("Forward", "EditorIcons")); history_forward->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
history_forward->set_flat(true); history_forward->set_flat(true);
history_forward->set_focus_mode(FOCUS_NONE); history_forward->set_focus_mode(FOCUS_NONE);
history_forward->connect("pressed", this, "_on_history_forward"); history_forward->connect("pressed", callable_mp(this, &LimboAIEditor::_on_history_forward));
nav->add_child(history_forward); nav->add_child(history_forward);
header = memnew(Button); header = memnew(Button);
vb->add_child(header); vb->add_child(header);
header->set_text_align(Button::ALIGN_LEFT); header->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
header->add_constant_override("hseparation", 8); header->add_theme_constant_override("hseparation", 8);
header->connect("pressed", this, "_on_header_pressed"); header->connect("pressed", callable_mp(this, &LimboAIEditor::_on_header_pressed));
hsc = memnew(HSplitContainer); hsc = memnew(HSplitContainer);
vb->add_child(hsc); vb->add_child(hsc);
@ -1129,11 +1134,11 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
hsc->add_child(task_tree); hsc->add_child(task_tree);
task_tree->set_v_size_flags(SIZE_EXPAND_FILL); task_tree->set_v_size_flags(SIZE_EXPAND_FILL);
task_tree->set_h_size_flags(SIZE_EXPAND_FILL); task_tree->set_h_size_flags(SIZE_EXPAND_FILL);
task_tree->connect("rmb_pressed", this, "_on_tree_rmb"); task_tree->connect("rmb_pressed", callable_mp(this, &LimboAIEditor::_on_tree_rmb));
task_tree->connect("task_selected", this, "_on_tree_task_selected"); task_tree->connect("task_selected", callable_mp(this, &LimboAIEditor::_on_tree_task_selected));
task_tree->connect("visibility_changed", this, "_on_visibility_changed"); task_tree->connect("visibility_changed", callable_mp(this, &LimboAIEditor::_on_visibility_changed));
task_tree->connect("task_dragged", this, "_on_task_dragged"); task_tree->connect("task_dragged", callable_mp(this, &LimboAIEditor::_on_task_dragged));
task_tree->connect("task_double_clicked", this, "_on_tree_task_double_clicked"); task_tree->connect("task_double_clicked", callable_mp(this, &LimboAIEditor::_on_tree_task_double_clicked));
task_tree->hide(); task_tree->hide();
usage_hint = memnew(Panel); usage_hint = memnew(Panel);
@ -1141,23 +1146,23 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
usage_hint->set_h_size_flags(SIZE_EXPAND_FILL); usage_hint->set_h_size_flags(SIZE_EXPAND_FILL);
hsc->add_child(usage_hint); hsc->add_child(usage_hint);
Label *usage_label = memnew(Label); Label *usage_label = memnew(Label);
usage_label->set_anchor(MARGIN_RIGHT, 1); usage_label->set_anchor(SIDE_RIGHT, 1);
usage_label->set_anchor(MARGIN_BOTTOM, 1); usage_label->set_anchor(SIDE_BOTTOM, 1);
usage_label->set_align(Label::ALIGN_CENTER); usage_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
usage_label->set_valign(Label::VALIGN_CENTER); usage_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
usage_label->set_text(TTR("Create a new or load an existing behavior tree.")); usage_label->set_text(TTR("Create a new or load an existing behavior tree."));
usage_hint->add_child(usage_label); usage_hint->add_child(usage_label);
task_panel = memnew(TaskPanel(p_editor)); task_panel = memnew(TaskPanel());
hsc->add_child(task_panel); hsc->add_child(task_panel);
hsc->set_split_offset(-300); hsc->set_split_offset(-300);
task_panel->connect("task_selected", this, "_on_panel_task_selected"); task_panel->connect("task_selected", callable_mp(this, &LimboAIEditor::_on_panel_task_selected));
task_panel->hide(); task_panel->hide();
menu = memnew(PopupMenu); menu = memnew(PopupMenu);
add_child(menu); add_child(menu);
menu->connect("id_pressed", this, "_on_action_selected"); menu->connect("id_pressed", callable_mp(this, &LimboAIEditor::_on_action_selected));
menu->set_hide_on_window_lose_focus(true); // menu->set_hide_on_window_lose_focus(true);
rename_dialog = memnew(ConfirmationDialog); rename_dialog = memnew(ConfirmationDialog);
{ {
@ -1171,10 +1176,10 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
rename_edit->set_placeholder("Custom Name"); rename_edit->set_placeholder("Custom Name");
rename_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); rename_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rename_edit->set_custom_minimum_size(Size2(350.0, 0.0)); rename_edit->set_custom_minimum_size(Size2(350.0, 0.0));
rename_edit->connect("text_entered", this, "_rename_task"); rename_edit->connect("text_changed", callable_mp(this, &LimboAIEditor::_rename_task));
rename_dialog->get_ok()->set_text(TTR("Rename")); rename_dialog->get_ok_button()->set_text(TTR("Rename"));
rename_dialog->connect("confirmed", this, "_rename_task"); rename_dialog->connect("confirmed", callable_mp(this, &LimboAIEditor::_rename_task));
} }
add_child(rename_dialog); add_child(rename_dialog);
@ -1191,13 +1196,13 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
vbc->add_child(disk_changed_list); vbc->add_child(disk_changed_list);
disk_changed_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); disk_changed_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
disk_changed->get_ok()->set_text(TTR("Reload")); disk_changed->get_ok_button()->set_text(TTR("Reload"));
disk_changed->connect("confirmed", this, "_reload_modified"); disk_changed->connect("confirmed", callable_mp(this, &LimboAIEditor::_reload_modified));
disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave"); disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->connect("custom_action", this, "_resave_modified"); disk_changed->connect("custom_action", callable_mp(this, &LimboAIEditor::_resave_modified));
} }
editor->get_gui_base()->add_child(disk_changed); EditorNode::get_singleton()->get_gui_base()->add_child(disk_changed);
GLOBAL_DEF("limbo_ai/behavior_tree/behavior_tree_default_dir", "res://ai/trees"); GLOBAL_DEF("limbo_ai/behavior_tree/behavior_tree_default_dir", "res://ai/trees");
ProjectSettings::get_singleton()->set_custom_property_info("limbo_ai/behavior_tree/behavior_tree_default_dir", ProjectSettings::get_singleton()->set_custom_property_info("limbo_ai/behavior_tree/behavior_tree_default_dir",
@ -1214,10 +1219,9 @@ LimboAIEditor::LimboAIEditor(EditorNode *p_editor) {
save_dialog->set_current_dir(GLOBAL_GET("limbo_ai/behavior_tree/behavior_tree_default_dir")); save_dialog->set_current_dir(GLOBAL_GET("limbo_ai/behavior_tree/behavior_tree_default_dir"));
load_dialog->set_current_dir(GLOBAL_GET("limbo_ai/behavior_tree/behavior_tree_default_dir")); load_dialog->set_current_dir(GLOBAL_GET("limbo_ai/behavior_tree/behavior_tree_default_dir"));
new_script_btn->connect("pressed", ScriptEditor::get_singleton(), "open_script_create_dialog", new_script_btn->connect("pressed", callable_mp(ScriptEditor::get_singleton(), &ScriptEditor::open_script_create_dialog).bind("BTAction", String(GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_1")).path_join("new_task")));
varray("BTAction", String(GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_1")).plus_file("new_task")));
EditorFileSystem::get_singleton()->connect("resources_reload", this, "_on_resources_reload"); EditorFileSystem::get_singleton()->connect("resources_reload", callable_mp(this, &LimboAIEditor::_on_resources_reload));
} }
LimboAIEditor::~LimboAIEditor() { LimboAIEditor::~LimboAIEditor() {
@ -1227,8 +1231,8 @@ LimboAIEditor::~LimboAIEditor() {
///////////////////////// LimboAIEditorPlugin //////////////////////////////// ///////////////////////// LimboAIEditorPlugin ////////////////////////////////
const Ref<Texture> LimboAIEditorPlugin::get_icon() const { const Ref<Texture2D> LimboAIEditorPlugin::get_icon() const {
return editor->get_gui_base()->get_icon("LimboAIEditor", "EditorIcons"); return EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("LimboAIEditor"), SNAME("EditorIcons"));
} }
void LimboAIEditorPlugin::apply_changes() { void LimboAIEditorPlugin::apply_changes() {
@ -1253,11 +1257,10 @@ bool LimboAIEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("BehaviorTree"); return p_object->is_class("BehaviorTree");
} }
LimboAIEditorPlugin::LimboAIEditorPlugin(EditorNode *p_editor) { LimboAIEditorPlugin::LimboAIEditorPlugin() {
editor = p_editor; limbo_ai_editor = memnew(LimboAIEditor());
limbo_ai_editor = memnew(LimboAIEditor(p_editor));
limbo_ai_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); limbo_ai_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->get_viewport()->add_child(limbo_ai_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(limbo_ai_editor);
limbo_ai_editor->hide(); limbo_ai_editor->hide();
} }

View File

@ -4,15 +4,19 @@
#ifndef LIMBO_AI_EDITOR_PLUGIN_H #ifndef LIMBO_AI_EDITOR_PLUGIN_H
#define LIMBO_AI_EDITOR_PLUGIN_H #define LIMBO_AI_EDITOR_PLUGIN_H
#include "core/object.h" #include "core/object/class_db.h"
#include "core/object/object.h"
#include "core/templates/hash_set.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "modules/limboai/bt/behavior_tree.h" #include "modules/limboai/bt/behavior_tree.h"
#include "modules/limboai/bt/bt_task.h" #include "modules/limboai/bt/bt_task.h"
#include "scene/gui/box_container.h" #include "scene/gui/box_container.h"
#include "scene/gui/control.h"
#include "scene/gui/file_dialog.h" #include "scene/gui/file_dialog.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_menu.h" #include "scene/gui/popup_menu.h"
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
#include "scene/gui/tree.h" #include "scene/gui/tree.h"
@ -34,12 +38,12 @@ private:
void _on_item_selected(); void _on_item_selected();
void _on_item_double_clicked(); void _on_item_double_clicked();
void _on_item_rmb_selected(const Vector2 &p_pos); void _on_item_mouse_selected(const Vector2 &p_pos, int p_button_index);
void _on_task_changed(); void _on_task_changed();
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); Variant _get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected: protected:
static void _bind_methods(); static void _bind_methods();
@ -80,7 +84,7 @@ public:
String get_category_name() const { return section_header->get_text(); } String get_category_name() const { return section_header->get_text(); }
TaskSection(String p_category_name, EditorNode *p_editor); TaskSection(String p_category_name);
~TaskSection(); ~TaskSection();
}; };
@ -88,7 +92,6 @@ class TaskPanel : public PanelContainer {
GDCLASS(TaskPanel, PanelContainer) GDCLASS(TaskPanel, PanelContainer)
private: private:
EditorNode *editor;
LineEdit *filter_edit; LineEdit *filter_edit;
VBoxContainer *sections; VBoxContainer *sections;
@ -106,7 +109,7 @@ protected:
public: public:
void refresh(); void refresh();
TaskPanel(EditorNode *p_editor); TaskPanel();
~TaskPanel(); ~TaskPanel();
}; };
@ -122,10 +125,9 @@ private:
ACTION_MAKE_ROOT, ACTION_MAKE_ROOT,
}; };
EditorNode *editor;
Vector<Ref<BehaviorTree>> history; Vector<Ref<BehaviorTree>> history;
int idx_history; int idx_history;
Set<Ref<BehaviorTree>> dirty; HashSet<Ref<BehaviorTree>> dirty;
Button *header; Button *header;
HSplitContainer *hsc; HSplitContainer *hsc;
@ -143,7 +145,7 @@ private:
ConfirmationDialog *disk_changed; ConfirmationDialog *disk_changed;
Tree *disk_changed_list; Tree *disk_changed_list;
Set<String> disk_changed_files; HashSet<String> disk_changed_files;
void _add_task(const Ref<BTTask> &p_task); void _add_task(const Ref<BTTask> &p_task);
_FORCE_INLINE_ void _add_task_with_prototype(const Ref<BTTask> &p_prototype) { _add_task(p_prototype->clone()); } _FORCE_INLINE_ void _add_task_with_prototype(const Ref<BTTask> &p_prototype) { _add_task(p_prototype->clone()); }
@ -161,10 +163,10 @@ private:
void _on_tree_rmb(const Vector2 &p_menu_pos); void _on_tree_rmb(const Vector2 &p_menu_pos);
void _on_action_selected(int p_id); void _on_action_selected(int p_id);
void _on_tree_task_selected(const Ref<BTTask> &p_task) const; void _on_tree_task_selected(const Ref<BTTask> &p_task);
void _on_tree_task_double_clicked(); void _on_tree_task_double_clicked();
void _on_visibility_changed() const; void _on_visibility_changed();
void _on_header_pressed() const; void _on_header_pressed();
void _on_save_pressed(); void _on_save_pressed();
void _on_panel_task_selected(String p_task); void _on_panel_task_selected(String p_task);
void _on_history_back(); void _on_history_back();
@ -184,7 +186,7 @@ public:
void apply_changes(); void apply_changes();
LimboAIEditor(EditorNode *p_editor); LimboAIEditor();
~LimboAIEditor(); ~LimboAIEditor();
}; };
@ -192,22 +194,21 @@ class LimboAIEditorPlugin : public EditorPlugin {
GDCLASS(LimboAIEditorPlugin, EditorPlugin); GDCLASS(LimboAIEditorPlugin, EditorPlugin);
private: private:
EditorNode *editor;
LimboAIEditor *limbo_ai_editor; LimboAIEditor *limbo_ai_editor;
protected: protected:
void _notification(int p_notification); void _notification(int p_notification);
public: public:
virtual String get_name() const { return "LimboAI"; } virtual String get_name() const override { return "LimboAI"; }
virtual const Ref<Texture> get_icon() const; virtual const Ref<Texture2D> get_icon() const override;
bool has_main_screen() const { return true; } bool has_main_screen() const override { return true; }
virtual void make_visible(bool p_visible); virtual void make_visible(bool p_visible) override;
virtual void apply_changes(); virtual void apply_changes() override;
virtual void edit(Object *p_object); virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const; virtual bool handles(Object *p_object) const override;
LimboAIEditorPlugin(EditorNode *p_editor); LimboAIEditorPlugin();
~LimboAIEditorPlugin(); ~LimboAIEditorPlugin();
}; };

View File

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

View File

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 242 B

View File

Before

Width:  |  Height:  |  Size: 265 B

After

Width:  |  Height:  |  Size: 265 B

View File

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 487 B

View File

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 600 B

View File

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 421 B

View File

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 268 B

View File

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 421 B

View File

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 661 B

View File

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 296 B

View File

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 242 B

Some files were not shown because too many files have changed in this diff Show More